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

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

// constraints
#define MAXN 1000

// input data
int N, M, i, j;
int V[MAXN];
int K[MAXN];
int L[MAXN];
int R[MAXN];
int E[MAXN][MAXN];
int C[MAXN][MAXN];
int T[MAXN][MAXN];


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

    assert(1 == scanf("%d", &N));
    for (i=0; i<N; i++) {
        assert(3 == scanf("%d %d %d", &V[i], &K[i], &L[i]));
        for (j=0; j<K[i]; ++j) assert(1 == scanf("%d", &E[i][j]));
        for (j=0; j<L[i]; ++j) assert(1 == scanf("%d", &C[i][j]));
        for (j=0; j<L[i]; ++j) assert(1 == scanf("%d", &T[i][j]));
    }

    // insert your code here
    M = 2;
    R[0] = 0;
    R[1] = N-1;
    
    // print the solution
    printf("%d\n", M);
    for (i=0; i<M; ++i)
        printf("%d ", R[i]);
    printf("\n");
    return 0;
}
