// -*- compile-command: "make -k readchords"; -*-

#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <iterator>

using namespace std;

// Function split adapted from Koenig and Moo's Accelerated C++
vector<string> split(const string& str, const char sep)
{
  typedef string::const_iterator iter;
  vector<string> ret;

  iter i = str.begin();
  while (i != str.end()) {
    // Ignore leading separators.
    i = find_if(i, str.end(), bind2nd(not_equal_to<char>(), sep));

    // Find end of next block.
    iter j = find_if(i, str.end(), bind2nd(equal_to<char>(), sep));

    // Copy the characters in [i, j)
    if (i != str.end())
      ret.push_back(string(i, j));
    i = j;
  }

  return ret;
}

void ParseChordsInBar(const string& bar)
{
  vector<string> chords = split(bar, ' ');

  cout << chords.size() << ' ';
  copy(chords.begin(), chords.end(), ostream_iterator<string>(cout, " "));
  cout << endl;
}

void ParseBarsOnLine(const string& line)
{
  vector<string> bars = split(line, '|');

  for_each(bars.begin(), bars.end(), ParseChordsInBar);
}

int main()
{
  string line;

  while (getline(cin, line))
    ParseBarsOnLine(line);

  return 0;
}