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

#include <assert.h>
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>

#define MAXN 1000000
#define MAXM 500001

int M, N, T, i, test;
int A[MAXN], B[MAXN], C[MAXN];
int R[MAXM];

int main() {
    // uncomment the two following lines if you want to read/write from files
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);

    assert(1 == scanf("%d", &T));
    for (test = 1; test <= T; ++test) {
        assert(1 == scanf("%d", &N));

        for (i = 0; i < N; ++i)
            assert(3 == scanf("%d%d%d", &A[i], &B[i], &C[i]));

        M = 0;


        // INSERT YOUR CODE HERE


        printf("%d\n", M);
        for (i = 0; i < M; ++i)
            printf("%d ", R[i]);
        printf("\n");
    }

    return 0;
}
