// Example 6-4: Using a local class.
#include <algorithm>
#include <iostream>
#include <iterator>
#include <sstream>
#include <string>
#include <vector>

// Take a string and break it up into tokens,
// storing the tokens in a vector.
void get_tokens(std::vector<std::string>& tokens,
                const std::string& str)
{
  class tokenizer {
  public:
    tokenizer(const std::string& str) : in_(str) {}
    bool next()
    {
      return in_ >> token_;
    }
    std::string token() const { return token_; }
  private:
    std::istringstream in_;
    std::string token_;
  };

  tokens.clear();
  tokenizer t(str);
  while (t.next())
    tokens.push_back(t.token());
}

int main()
{
  std::string line;

  while (std::getline(std::cin, line)) {
    std::vector<std::string> tokens;
    get_tokens(tokens, line);
    std::copy(tokens.begin(), tokens.end(),
              std::ostream_iterator<std::string>(std::cout, "\n"));
  }
}
