#include #include #include #include using namespace std; using i32 = int32_t; using u32 = uint32_t; using i64 = int64_t; using u64 = uint64_t; #define rep(i,n) for(int i=0; i<(n); i++) int main() { int N; cin >> N; u64 all_XOR_for_imput = 0; rep(i,N-1){ int u,v; u64 a; cin >> u >> v >> a; all_XOR_for_imput ^= u; all_XOR_for_imput ^= v; all_XOR_for_imput ^= a; } int Q; cin >> Q; rep(i,Q){ int t,x; cin >> t >> x; all_XOR_for_imput ^= t; all_XOR_for_imput ^= x; } cout << all_XOR_for_imput << endl; return 0; } /* struct ios_do_not_sync{ ios_do_not_sync(){ ios::sync_with_stdio(false); cin.tie(nullptr); } } ios_do_not_sync_instance; */