program voc_tl;

{$APPTYPE CONSOLE}

uses
  SysUtils;

const nmax=100*1000+5;

type tword = string[15];


var z,w:array [1..nmax] of tword;
    q,cnt_a,n,k,i,j:integer;
    r,x:array [1..nmax] of integer;
    s:tword;
begin
//  reset(input,'voc.in');
//  rewrite(output,'voc.out');
  
  readln(n);
  cnt_a:=0;
  for i:=1 to n do
  begin
    readln(w[i]);
    readln(k);
    for j:=1 to k do
    begin
      inc(cnt_a);
      readln(z[cnt_a]);
      x[cnt_a]:=i;
    end;
  end;

  for i:=1 to cnt_a-1 do
    for j:=i+1 to cnt_a do
      if (z[i]>z[j])or(z[i]=z[j])and(x[i]>x[j]) then
      begin
        s:=z[i];
        z[i]:=z[j];
        z[j]:=s;
        k:=x[i];
        x[i]:=x[j];
        x[j]:=k;
      end;
  k:=1;
  r[1]:=1;
  for i:=2 to cnt_a do
    if z[i]=z[i-1] then
      inc(r[k])
    else
    begin
      inc(k);
      r[k]:=1;
    end;
  q:=1;
  if k=1 then
  begin
    writeln(1);
    writeln(z[1]);
    writeln(1);
    writeln(w[1]);
    halt;
  end;
  writeln(k);
  for i:=1 to k do
  begin
    writeln(z[q]);
    writeln(r[i]);
    for j:=q to q+r[i]-1 do
      writeln(w[x[j]]);
    q:=q+r[i];
  end;
  close(input);
  close(output);
end.
