{$i exp.inc}

var
    n, i, j, k, z: int;
    ch: char;
    v: array[1 .. maxn] of int;

begin
    randseed := strtoint(paramstr(1));

    readln(n);
    writeln(n);
    for i := 1 to n do begin
        if seekeof then
            break;
        read(ch);
        read(z);
        if (z > 0) then begin
            read(v[1]);
            for j := 2 to z do begin
                k := random(j - 1) + 1;
                v[j] := v[k];
                read(v[k]);
            end;
        end;
        write(ch, ' ', z);
        for j := 1 to z do
            write(' ', v[j]);
        writeln;
    end;
end.