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

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

// constraints
#define MAXSIZE 200000

// input data
int N, M, K, Q;
int PA[MAXSIZE], PB[MAXSIZE], X[MAXSIZE], Y[MAXSIZE], C[MAXSIZE], U[MAXSIZE], V[MAXSIZE];

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(int i = 0; i < N-1; i++){
        assert(1 == scanf("%d", &PA[i]));
    }
    assert(1 == scanf("%d", &M));
    for(int i = 0; i < M-1; i++){
        assert(1 == scanf("%d", &PB[i]));
    }
    assert(1 == scanf("%d", &K));
    for(int i = 0; i < K; i++){
        assert(3 == scanf("%d %d %d", &X[i], &Y[i], &C[i]));
    }
    assert(1 == scanf("%d", &Q));
    for(int i = 0; i < Q; i++){
        assert(2 == scanf("%d %d", &U[i], &V[i]));
    }

    // insert your code here
    
    printf("%d\n", 42); // print the result
    return 0;
}
