from collections import defaultdict
import sys, os, io
input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline
n = int(input())
d = defaultdict(lambda : set())
for _ in range(n):
x = list(input().rstrip().decode().split())
u = x[0]
for i in x[2:]:
d[u].add(i)
ans = []
for i in d.keys():
x = list(d[i])
y = []
for u in x:
c = 0
for v in x:
if len(u) > len(v):
continue
f = 1
for j in range(1, min(len(u), len(v)) + 1):
if not u[-j] == v[-j]:
f = 0
break
if f:
c += 1
if c == 1:
y.append("".join(u))
ans0 = [i, str(len(y))] + y
ans.append(" ".join(ans0))
m = len(ans)
print(m)
sys.stdout.write("\n".join(ans))
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=1e3+5;
ll trie[22][N][27],cnt[22],pos[22][N],k[22];
map<string,ll>mp;
map<ll,string>mpp;
string A[N][N];
vector<string>ans[N];
void insert(string s,ll id)
{
ll p=0;
ll len=s.length();
for(ll i=len-1;i>=0;i--)
{
pos[id][p]=2;
ll x=s[i]-'0';
if(trie[id][p][x]==0)trie[id][p][x]=++cnt[id];
p=trie[id][p][x];
// cout<<trie[id][1][2]<<" ";
}
if(pos[id][p]!=2)pos[id][p]=1;
}
void find(string s,ll id)
{
ll p=0;
ll len=s.length();
for(ll i=len-1;i>=0;i--)
{
ll x=s[i]-'0';
p=trie[id][p][x];
}
if(pos[id][p]!=2)
{
pos[id][p]=2;
ans[id].push_back(s);
}
}
int main()
{
ll tot=0;
ll n;
cin>>n;
for(ll i=1;i<=n;i++)
{
string s;
cin>>s;
if(mp[s]==0) mp[s]=++tot,mpp[tot]=s;
ll ss;
cin>>ss;
while(ss--)
{
string s1;
cin>>s1;
A[mp[s]][++k[mp[s]]]=s1;
ll dd=mp[s];
insert(s1,dd);
}
}
for(ll i=1;i<=tot;i++)
{
for(ll j=1;j<=k[i];j++)
{
find(A[i][j],i);
}
}
cout<<tot<<endl;
for(ll i=1;i<=tot;i++)
{
cout<<mpp[i]<<" "<<ans[i].size()<<" ";
for(auto ss: ans[i])
{
cout<<ss<<" ";
}
cout<<endl;
}
}
HILLSEQ Hill Sequence | MAXBRIDGE Maximise the bridges |
WLDRPL Wildcard Replacement | 1221. Split a String in Balanced Strings |
1002. Find Common Characters | 1602A - Two Subsequences |
1555A - PizzaForces | 1607B - Odd Grasshopper |
1084A - The Fair Nut and Elevator | 1440B - Sum of Medians |
1032A - Kitchen Utensils | 1501B - Napoleon Cake |
1584B - Coloring Rectangles | 1562B - Scenes From a Memory |
1521A - Nastia and Nearly Good Numbers | 208. Implement Trie |
1605B - Reverse Sort | 1607C - Minimum Extraction |
1604B - XOR Specia-LIS-t | 1606B - Update Files |
1598B - Groups | 1602B - Divine Array |
1594B - Special Numbers | 1614A - Divan and a Store |
2085. Count Common Words With One Occurrence | 2089. Find Target Indices After Sorting Array |
2090. K Radius Subarray Averages | 2091. Removing Minimum and Maximum From Array |
6. Zigzag Conversion | 1612B - Special Permutation |