Problem: A rare article in the Internet is posted without a possibility to comment it. On a Polycarp's website each article has comments feed.

Each comment on Polycarp's website is a non-empty string consisting of uppercase and lowercase letters of English alphabet. Comments have tree-like structure, that means each comment except root comments (comments of the highest level) has exactly one parent comment.

When Polycarp wants to save comments to his hard drive he uses the following format. Each comment he writes in the following format: 

  * at first, the text of the comment is written; 
  * after that the number of comments is written, for which this comment is a parent comment (i. e. the number of the replies to this comments); 
  * after that the comments for which this comment is a parent comment are written (the writing of these comments uses the same algorithm). 

All elements in this format are separated by single comma. Similarly, the comments of the first level are separated by comma.

For example, if the comments look like:

<image>

then the first comment is written as "hello,2,ok,0,bye,0", the second is written as "test,0", the third comment is written as "one,1,two,2,a,0,b,0". The whole comments feed is written as: "hello,2,ok,0,bye,0,test,0,one,1,two,2,a,0,b,0". For a given comments feed in the format specified above print the comments in a different format: 

  * at first, print a integer d — the maximum depth of nesting comments; 
  * after that print d lines, the i-th of them corresponds to nesting level i; 
  * for the i-th row print comments of nesting level i in the order of their appearance in the Policarp's comments feed, separated by space. 

Input

The first line contains non-empty comments feed in the described format. It consists of uppercase and lowercase letters of English alphabet, digits and commas. 

It is guaranteed that each comment is a non-empty string consisting of uppercase and lowercase English characters. Each of the number of comments is integer (consisting of at least one digit), and either equals 0 or does not contain leading zeros.

The length of the whole string does not exceed 106. It is guaranteed that given structure of comments is valid. 

Output

Print comments in a format that is given in the statement. For each level of nesting, comments should be printed in the order they are given in the input.

Examples

Input

hello,2,ok,0,bye,0,test,0,one,1,two,2,a,0,b,0


Output

3
hello test one 
ok bye two 
a b 


Input

a,5,A,0,a,0,A,0,a,0,A,0


Output

2
a 
A a A a A 


Input

A,3,B,2,C,0,D,1,E,0,F,1,G,0,H,1,I,1,J,0,K,1,L,0,M,2,N,0,O,1,P,0


Output

4
A K M 
B F H L N O 
C D G I P 
E J 

Note

The first example is explained in the statements. 

Solution (in CPP):

Solution:
#include <bits/stdc++.h>
using namespace std;
const double eps = 1e-8;
const double pi = 4 * atan(1);
const int inf = 0x3f3f3f3f;
const long long INF = 0x3f3f3f3f3f3f3f3f;
const int MOD = 1e9 + 7;
int nCase = 0;
int dcmp(double x) {
  if (fabs(x) < eps) return 0;
  return x < 0 ? -1 : 1;
}
template <class T>
inline bool read(T &n) {
  T x = 0, tmp = 1;
  char c = getchar();
  while ((c < '0' || c > '9') && c != '-' && c != EOF) c = getchar();
  if (c == EOF) return false;
  if (c == '-') c = getchar(), tmp = -1;
  while (c >= '0' && c <= '9') x *= 10, x += (c - '0'), c = getchar();
  n = x * tmp;
  return true;
}
template <class T>
inline void write(T n) {
  if (n < 0) {
    putchar('-');
    n = -n;
  }
  int len = 0, data[20];
  while (n) {
    data[len++] = n % 10;
    n /= 10;
  }
  if (!len) data[len++] = 0;
  while (len--) putchar(data[len] + 48);
}
long long QMOD(long long x, long long k) {
  long long res = 1LL;
  while (k) {
    if (k & 1) res = res * x % MOD;
    k >>= 1;
    x = x * x % MOD;
  }
  return res;
}
class BigInteger {
 public:
  const static int maxn = 2005;
  int len, s[maxn];
  BigInteger();
  BigInteger(const char *);
  BigInteger(int);
  bool sign;
  string toStr() const;
  friend istream &operator>>(istream &, BigInteger &);
  friend ostream &operator<<(ostream &, BigInteger &);
  BigInteger operator=(const char *);
  BigInteger operator=(int);
  BigInteger operator=(const string);
  bool operator>(const BigInteger &) const;
  bool operator>=(const BigInteger &) const;
  bool operator<(const BigInteger &) const;
  bool operator<=(const BigInteger &) const;
  bool operator==(const BigInteger &) const;
  bool operator!=(const BigInteger &) const;
  BigInteger operator+(const BigInteger &) const;
  BigInteger operator++();
  BigInteger operator++(int);
  BigInteger operator+=(const BigInteger &);
  BigInteger operator-(const BigInteger &) const;
  BigInteger operator--();
  BigInteger operator--(int);
  BigInteger operator-=(const BigInteger &);
  BigInteger operator*(const BigInteger &) const;
  BigInteger operator*(const int num) const;
  BigInteger operator*=(const BigInteger &);
  BigInteger operator/(const BigInteger &) const;
  BigInteger operator/=(const BigInteger &);
  BigInteger operator%(const BigInteger &) const;
  BigInteger factorial() const;
  BigInteger Sqrt() const;
  BigInteger pow(const BigInteger &) const;
  void clean();
  ~BigInteger();
};
BigInteger::BigInteger() {
  memset(s, 0, sizeof(s));
  len = 1;
  sign = 1;
}
BigInteger::BigInteger(const char *num) { *this = num; }
BigInteger::BigInteger(int num) { *this = num; }
string BigInteger::toStr() const {
  string res;
  res = "";
  for (int i = 0; i < len; i++) res = (char)(s[i] + '0') + res;
  if (res == "") res = "0";
  if (!sign && res != "0") res = "-" + res;
  return res;
}
istream &operator>>(istream &in, BigInteger &num) {
  string str;
  in >> str;
  num = str;
  return in;
}
ostream &operator<<(ostream &out, BigInteger &num) {
  out << num.toStr();
  return out;
}
BigInteger BigInteger::operator=(const char *num) {
  memset(s, 0, sizeof(s));
  char a[maxn] = "";
  if (num[0] != '-')
    strcpy(a, num);
  else
    for (int i = 1; i < strlen(num); i++) a[i - 1] = num[i];
  sign = !(num[0] == '-');
  len = strlen(a);
  for (int i = 0; i < strlen(a); i++) s[i] = a[len - i - 1] - 48;
  return *this;
}
BigInteger BigInteger::operator=(int num) {
  if (num < 0)
    sign = 0, num = -num;
  else
    sign = 1;
  char temp[maxn];
  sprintf(temp, "%d", num);
  *this = temp;
  return *this;
}
BigInteger BigInteger::operator=(const string num) {
  const char *tmp;
  tmp = num.c_str();
  *this = tmp;
  return *this;
}
bool BigInteger::operator<(const BigInteger &num) const {
  if (sign ^ num.sign) return num.sign;
  if (len != num.len) return len < num.len;
  for (int i = len - 1; i >= 0; i--)
    if (s[i] != num.s[i])
      return sign ? (s[i] < num.s[i]) : (!(s[i] < num.s[i]));
  return !sign;
}
bool BigInteger::operator>(const BigInteger &num) const { return num < *this; }
bool BigInteger::operator<=(const BigInteger &num) const {
  return !(*this > num);
}
bool BigInteger::operator>=(const BigInteger &num) const {
  return !(*this < num);
}
bool BigInteger::operator!=(const BigInteger &num) const {
  return *this > num || *this < num;
}
bool BigInteger::operator==(const BigInteger &num) const {
  return !(num != *this);
}
BigInteger BigInteger::operator+(const BigInteger &num) const {
  if (sign ^ num.sign) {
    BigInteger tmp = sign ? num : *this;
    tmp.sign = 1;
    return sign ? *this - tmp : num - tmp;
  }
  BigInteger result;
  result.len = 0;
  int temp = 0;
  for (int i = 0; temp || i < (max(len, num.len)); i++) {
    int t = s[i] + num.s[i] + temp;
    result.s[result.len++] = t % 10;
    temp = t / 10;
  }
  result.sign = sign;
  return result;
}
BigInteger BigInteger::operator++() {
  *this = *this + 1;
  return *this;
}
BigInteger BigInteger::operator++(int) {
  BigInteger old = *this;
  ++(*this);
  return old;
}
BigInteger BigInteger::operator+=(const BigInteger &num) {
  *this = *this + num;
  return *this;
}
BigInteger BigInteger::operator-(const BigInteger &num) const {
  BigInteger b = num, a = *this;
  if (!num.sign && !sign) {
    b.sign = 1;
    a.sign = 1;
    return b - a;
  }
  if (!b.sign) {
    b.sign = 1;
    return a + b;
  }
  if (!a.sign) {
    a.sign = 1;
    b = BigInteger(0) - (a + b);
    return b;
  }
  if (a < b) {
    BigInteger c = (b - a);
    c.sign = false;
    return c;
  }
  BigInteger result;
  result.len = 0;
  for (int i = 0, g = 0; i < a.len; i++) {
    int x = a.s[i] - g;
    if (i < b.len) x -= b.s[i];
    if (x >= 0)
      g = 0;
    else {
      g = 1;
      x += 10;
    }
    result.s[result.len++] = x;
  }
  result.clean();
  return result;
}
BigInteger BigInteger::operator*(const BigInteger &num) const {
  BigInteger result;
  result.len = len + num.len;
  for (int i = 0; i < len; i++)
    for (int j = 0; j < num.len; j++) result.s[i + j] += s[i] * num.s[j];
  for (int i = 0; i < result.len; i++) {
    result.s[i + 1] += result.s[i] / 10;
    result.s[i] %= 10;
  }
  result.clean();
  result.sign = !(sign ^ num.sign);
  return result;
}
BigInteger BigInteger::operator*(const int num) const {
  BigInteger x = num;
  BigInteger z = *this;
  return x * z;
}
BigInteger BigInteger::operator*=(const BigInteger &num) {
  *this = *this * num;
  return *this;
}
BigInteger BigInteger::operator/(const BigInteger &num) const {
  BigInteger ans;
  ans.len = len - num.len + 1;
  if (ans.len < 0) {
    ans.len = 1;
    return ans;
  }
  BigInteger divisor = *this, divid = num;
  divisor.sign = divid.sign = 1;
  int k = ans.len - 1;
  int j = len - 1;
  while (k >= 0) {
    while (divisor.s[j] == 0) j--;
    if (k > j) k = j;
    char z[maxn];
    memset(z, 0, sizeof(z));
    for (int i = j; i >= k; i--) z[j - i] = divisor.s[i] + '0';
    BigInteger dividend = z;
    if (dividend < divid) {
      k--;
      continue;
    }
    int key = 0;
    while (divid * key <= dividend) key++;
    key--;
    ans.s[k] = key;
    BigInteger temp = divid * key;
    for (int i = 0; i < k; i++) temp = temp * 10;
    divisor = divisor - temp;
    k--;
  }
  ans.clean();
  ans.sign = !(sign ^ num.sign);
  return ans;
}
BigInteger BigInteger::operator/=(const BigInteger &num) {
  *this = *this / num;
  return *this;
}
BigInteger BigInteger::operator%(const BigInteger &num) const {
  BigInteger a = *this, b = num;
  a.sign = b.sign = 1;
  BigInteger result, temp = a / b * b;
  result = a - temp;
  result.sign = sign;
  return result;
}
BigInteger BigInteger::pow(const BigInteger &num) const {
  BigInteger result = 1;
  for (BigInteger i = 0; i < num; i++) result = result * (*this);
  return result;
}
BigInteger BigInteger::factorial() const {
  BigInteger result = 1;
  for (BigInteger i = 1; i <= *this; i++) result *= i;
  return result;
}
void BigInteger::clean() {
  if (len == 0) len++;
  while (len > 1 && s[len - 1] == '\0') len--;
}
BigInteger BigInteger::Sqrt() const {
  if (*this < 0) return -1;
  if (*this <= 1) return *this;
  BigInteger l = 0, r = *this, mid;
  while (r - l > 1) {
    mid = (l + r) / 2;
    if (mid * mid > *this)
      r = mid;
    else
      l = mid;
  }
  return l;
}
BigInteger::~BigInteger() {}
char s[1000010];
int top = 1;
vector<string> vec[1000010];
int MaxDepth;
void dfs(int depth) {
  string ss;
  MaxDepth = max(MaxDepth, depth);
  while (s[top] != ',') {
    ss += s[top];
    top++;
  }
  vec[depth].push_back(ss);
  int num = 0;
  top++;
  while ('0' <= s[top] && s[top] <= '9') {
    num = num * 10 + s[top] - '0';
    top++;
  }
  top++;
  while (num--) {
    dfs(depth + 1);
  }
}
int main(int argc, const char *argv[]) {
  scanf("%s", s + 1);
  int len = strlen(s + 1);
  while (top <= len) {
    dfs(1);
  }
  cout << MaxDepth << endl;
  for (int i = 1; i <= MaxDepth; ++i) {
    for (string &s : vec[i]) cout << s << ' ';
    cout << endl;
  }
  return 0;
}