#include <bits/stdc++.h>
using namespace std;
const int INF = (1 << 31) - 1;
const long long LINF = (1ll << 63) - 1;
const double DINF = numeric_limits<double>::infinity();
const int MOD = 1e9 + 7;
const double EPS = 1e-7;
long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; }
mt19937 mmtw(MOD);
long long rnd(long long x, long long y) {
  static uniform_int_distribution<long long> d;
  return d(mmtw) % (y - x + 1) + x;
}
template <class T>
T binpow(T n, T k) {
  if (k == 1) return n;
  if (k & 1) return binpow(n, k - 1) * n;
  T a = binpow(n, k / 2);
  return a * a;
}
template <class T>
T fact(T n) {
  if (n == 1) return 1;
  return n * fact(n - 1);
}
int n;
unordered_map<string, vector<string>> m;
bool cmp(const string &a, const string &b) { return a.size() > b.size(); }
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> n;
  for (int i = 0; i < n; ++i) {
    string name, q;
    int cnt;
    cin >> name >> cnt;
    for (int i = 0; i < cnt; ++i) {
      cin >> q;
      m[name].push_back(q);
    }
  }
  for (auto it : m) {
    sort(m[it.first].begin(), m[it.first].end(), cmp);
  }
  cout << m.size() << endl;
  for (auto it : m) {
    string name = it.first;
    vector<string> list = it.second;
    vector<bool> use(list.size(), true);
    for (int i = 0; i < list.size(); ++i) {
      string b = list[i];
      for (int j = 0; j < i; ++j) {
        string a = list[j];
        if (a.substr(a.size() - b.size(), b.size()) == b) {
          use[i] = false;
          break;
        }
      }
    }
    int cnt = 0;
    for (auto it : use) {
      cnt += it;
    }
    cout << name << " " << cnt;
    for (int i = 0; i < list.size(); ++i) {
      if (use[i]) cout << " " << list[i];
    }
    cout << endl;
  }
}
