#include <bits/stdc++.h>
using namespace std;
double pi = 2 * acos(0.0);
long long _sieve_size;
bitset<10000010> _bs;
vector<long long> _primes;
void sieve(long long upperbound) {
  _sieve_size = upperbound;
  _bs.set();
  _bs[0] = _bs[1] = 0;
  for (long long i = 2; i <= _sieve_size; i++)
    if (_bs[i]) {
      for (long long j = i * i; j <= _sieve_size; j += i) _bs[j] = 0;
      _primes.push_back(i);
    }
}
bool isPrime(long long N) {
  if (N <= _sieve_size) return _bs[N];
  for (int i = 0; i < _primes.size(); i++)
    if (N % _primes[i] == 0) return false;
  return true;
}
vector<long long> primeFactors(long long N) {
  vector<long long> factors;
  long long PF_idx = 0, PF = _primes[PF_idx];
  while (PF * PF <= N) {
    while (N % PF == 0) {
      N /= PF;
      factors.push_back(PF);
    }
    PF = _primes[++PF_idx];
  }
  if (N != 1) factors.push_back(N);
  return factors;
}
long long gcd(long long a, long long b) { return b == 0 ? a : gcd(b, a % b); }
long long lcm(long long a, long long b) { return a * (b / gcd(a, b)); }
long long FastPower(long long Num, long long Pow) {
  if (Pow == 0) return 1;
  if (Pow == 1) return Num;
  long long Result = FastPower(Num, Pow / 2);
  Result *= Result;
  if (Pow % 2 != 0) Result *= Num;
  return Result;
}
long long power(long long x, unsigned long long y, long long mod) {
  long long temp;
  if (y == 0) return 1;
  temp = power(x, y / 2, mod) % mod;
  if (y % 2 == 0)
    return (temp % mod * temp % mod) % mod;
  else
    return ((x % mod * temp) % mod * temp) % mod;
}
long long ncr(long long n, long long r) {
  r = min(r, n - r);
  long long ans = 1;
  for (int i = 1; i <= r; i++) {
    ans *= n - i + 1;
    ans /= i;
  }
  return ans;
}
bool isPowerOfTwo(int x) { return (x && !(x & (x - 1))); }
bool sortbysec(const string &a, const string &b) {
  return (a.size() < b.size());
}
double binet(unsigned int n) {
  static const double phi = (1 + sqrt(5)) * 0.5;
  double fib = (pow(phi, n) - pow(1 - phi, n)) / sqrt(5);
  return round(fib);
}
long largest_power_of_two(long N) {
  N = N | (N >> 1);
  N = N | (N >> 2);
  N = N | (N >> 4);
  N = N | (N >> 8);
  return (N + 1) >> 1;
}
int solve(string temp, string mobile) {
  long long cnt = 0;
  bool Flag = 0;
  if (temp.size() > mobile.size()) {
    for (int i = temp.size() - mobile.size(); i < temp.size(); i++) {
      if (temp[i] != mobile[cnt]) {
        Flag = 1;
        break;
      }
      cnt++;
    }
    if (Flag) return 0;
    return 1;
  } else {
    for (int i = mobile.size() - temp.size(); i < mobile.size(); i++) {
      if (temp[cnt] != mobile[i]) {
        Flag = 1;
        break;
      }
      cnt++;
    }
    if (Flag) return 0;
    return -1;
  }
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long n;
  cin >> n;
  map<string, set<string> > mp;
  while (n--) {
    string s;
    long long y;
    cin >> s >> y;
    while (y--) {
      string mobile;
      cin >> mobile;
      if (!mp[s].size()) {
        mp[s].insert(mobile);
        continue;
      }
      bool Flag = 0;
      vector<string> v;
      for (set<string>::iterator it = mp[s].begin(); it != mp[s].end(); it++) {
        string temp = *it;
        int x = solve(temp, mobile);
        if (temp == mobile || x == 1) {
          Flag = 1;
          break;
        } else if (x == -1)
          v.push_back(temp);
      }
      if (!Flag) mp[s].insert(mobile);
      for (int i = 0; i < v.size(); i++) mp[s].erase(v[i]);
    }
  }
  cout << mp.size() << '\n';
  for (map<string, set<string> >::iterator it = mp.begin(); it != mp.end();
       it++) {
    cout << it->first << ' ' << (it->second).size() << ' ';
    set<string> s = it->second;
    for (set<string>::iterator on = s.begin(); on != s.end(); on++)
      cout << *on << ' ';
    cout << '\n';
  }
  return 0;
}
