#include using namespace std; const int N = 2e5 + 10; int n, w, h, a[N], b[N]; int main() { ios::sync_with_stdio(false); cin.tie(0); cin >> n; for(int i = 1; i <= n; i ++) { cin >> a[i]; } for(int i = 2; i <= n; i ++) { cin >> b[i]; } if(a[2] == b[2]) { for(w = 2; w < n && a[w] != a[w + 1]; w ++); for(h = 2; h < n && b[h] != b[h + 1]; h ++); } int q; cin >> q; for(int i = 1; i <= q; i ++) { long long t; int x, y; cin >> t >> x >> y; if(x == 1) cout << a[y] << "\n"; else if(y == 1) cout << b[x] << "\n"; else if(x <= h && y <= w && t >= max(x, y) - 1) cout << ((a[2] ^ (x + y - 3)) & 1) << "\n"; else cout << (t & 1) << "\n"; } }