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

#include <iostream>
#include <vector>

using namespace std;

// input data
int N;
vector<int> V, K, L, R;
vector<vector<int>> E, C, T;


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

    cin >> N;
    V.resize(N);
    K.resize(N);
    L.resize(N);
    E.resize(N);
    C.resize(N);
    T.resize(N);
    for (int i=0; i<N; i++) {
        cin >> V[i] >> K[i] >> L[i];
        E[i].resize(K[i]);
        C[i].resize(L[i]);
        T[i].resize(L[i]);
        for (int j=0; j<K[i]; ++j) cin >> E[i][j];
        for (int j=0; j<L[i]; ++j) cin >> C[i][j];
        for (int j=0; j<L[i]; ++j) cin >> T[i][j];
    }

    // insert your code here
    R.resize(2);
    R[0] = 0;
    R[1] = N-1;
    
    // print the solution
    cout << R.size() << endl;
    for (int i=0; i<(int)R.size(); ++i)
        cout << R[i] << " ";
    cout << endl;
    return 0;
}
