{ NOTE: it is recommended to use this even if you don't understand the following code }

const
    MAXN = 1000000;
    MAXM = 500001;

var
    M, N, T, i, test : LongInt;
    A, B, C          : Array[0..MAXN-1] of LongInt;
    R                : Array[0..MAXM-1] of LongInt;

begin
{
    uncomment the two following lines if you want to read/write from files
    assign(input,  'input.txt');  reset(input);
    assign(output, 'output.txt'); rewrite(output);
}

    ReadLn(T);
    for test:=1 to T do begin
        ReadLn();
        ReadLn(N);

        for i:=0 to N-1 do
            ReadLn(A[i], B[i], C[i]);

        M := 0;
        for i := 0 to MAXM-1 do R[i] := 0;

        { INSERT YOUR CODE HERE }


        WriteLn(M);
        for i:=0 to M-1 do
            Write(R[i], ' ');
        WriteLn();
    end;

end.
