#include<cstdio>
#include<cstring>
#include<cmath>
#include<cassert>
#include<iostream>
#include<iomanip>
#include<map>
#include<unordered_map>
#include<set>
#include<unordered_set>
#include<vector>
#include<algorithm>
#include<string>
#include<queue>
using namespace std;
#define DEBUG(x) cout<<#x<<"="<<x<<endl
#define DEBUG2(x,y) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<endl
typedef long long ll;
const int MAXN=1;
const ll MOD=1;
ll _gcd(ll a,ll b){if(b==0)return a;return _gcd(b,a%b);}
ll gcd(ll a,ll b){a=abs(a),b=abs(b);if(a<b)swap(a,b);return _gcd(a,b);}
ll qpow(ll a,ll n){ll rt=1;while(n){if(n&1)rt=(rt*a)%MOD;a=a*a%MOD;n>>=1;}return rt;}
ll factor[MAXN];
ll inv[MAXN];
void cal_factor(){factor[0]=1;for(int u=1;u<MAXN;u++){factor[u]=(factor[u-1]*u)%MOD;}}
void cal_factor_inv(){inv[0]=1;inv[MAXN-1]=qpow(factor[MAXN-1],MOD-2);for(int u=MAXN-2;u>=1;u--){inv[u]=inv[u+1]*(u+1)%MOD;}}
void init_factor(){cal_factor();cal_factor_inv();}
ll C(ll n,ll k){if(n<k)return 0;return factor[n]*qpow(factor[n-k],MOD-2)%MOD*qpow(factor[k],MOD-2)%MOD;}
struct mat{
    ll m[3][3];
    mat(){
        memset(m,0,sizeof(m));
    }
    mat(ll a[3][3]){
        memcpy(m,a,sizeof(m));
    }
    mat operator * (const mat mt){
        //m (3,3)
        mat tmp;
        for(int u=0;u<3;u++){
            for(int v=0;v<3;v++){
                for(int k=0;k<3;k++){
                    tmp.m[u][v]+=m[u][k]*mt.m[k][v];
                }
            }
        }
        return tmp;
    }
    mat operator *=(const mat &mt){
        return *this=(*this)*mt;
    }
    friend ostream& operator<<(ostream &out,const mat &m){
        for(int u=0;u<3;u++){
            for(int v=0;v<3;v++){
                cout<<m.m[u][v]<<" ";
            }
            cout<<"\n";
        }
        return out;
    }
};
ll pat[][3][3]={
    {0,1,0,-1,0,0,0,0,1},
    {0,-1,0,1,0,0,0,0,1},
    {-1,0,0,0,1,0,0,0,1},
    {1,0,0,0,-1,0,0,0,1}
};
mat get_mat(int op,int p){
    if(op==1||op==2){
        return mat(pat[op-1]);
    }else if(op==3){
        pat[op-1][0][2]=2*p;
        return mat(pat[op-1]);
    }else if(op==4){
        pat[op-1][1][2]=2*p;
        return mat(pat[op-1]);
    }
}
pair<ll,ll> pt_trans(pair<ll,ll>pt,mat &m){
    ll x,y;
    x=m.m[0][0]*pt.first+m.m[0][1]*pt.second+m.m[0][2];
    y=m.m[1][0]*pt.first+m.m[1][1]*pt.second+m.m[1][2];
    return {x,y};
}
void solve(){
    // ll a1[3][3]={2,0,0,0,2,0,0,0,2},
    // a2[3][3]={1,2,3,4,5,6,7,8,9};
    // mat m1(a1),m2(a2);
    vector<mat>macc;
    vector<pair<ll,ll>>pts;
    int n;
    cin>>n;
    for(int u=0;u<n;u++){
        ll x,y;
        cin>>x>>y;
        pts.push_back({x,y});
    }
    int m;
    cin>>m;
    for(int t=0;t<m;t++){
        int op,p;
        cin>>op;
        if(op==3||op==4)cin>>p;
        if(t==0){
            macc.push_back(get_mat(op,p));
        }else {
            macc.push_back(get_mat(op,p)*macc.back());
        }
    }
    int q;
    cin>>q;
    while(q--){
        int a,b;
        cin>>a>>b;
        b--;
        if(a==0){
            cout<<pts[b].first<<" "<<pts[b].second<<"\n";
            continue;
        }
        a--;
        auto p=pt_trans(pts[b],macc[a]);
        cout<<p.first<<" "<<p.second<<"\n";
    }
}
// #define LOCAL
int main()
{
#ifdef LOCAL
    freopen("in.txt","r",stdin);
#endif
    ios::sync_with_stdio(false);
    cin.tie(0);
    solve();
}
#include<bits/stdc++.h>
using namespace std;
#ifndef ONLINE_JUDGE
#define dbg(x...) do { cout << "\033[32;1m " << #x << " -> "; err(x); } while (0)
void err() { cout << "\033[39;0m" << endl; }
template<template<typename...> class T, typename t, typename... A>
void err(T<t> a, A... x) { for (auto v: a) cout << v << ' '; err(x...); }
template<typename T, typename... A>
void err(T a, A... x) { cout << a << ' '; err(x...); }
#else
#define dbg(...)
#endif
typedef long long ll;
typedef pair<int,int> pi;
typedef vector<int> vi;
template<class T> using vc=vector<T>;
template<class T> using vvc=vc<vc<T>>;
template<class T> void mkuni(vector<T>&v)
{
    sort(v.begin(),v.end());
    v.erase(unique(v.begin(),v.end()),v.end());
}
ll rand_int(ll l, ll r) //[l, r]
{
    static mt19937_64 gen(chrono::steady_clock::now().time_since_epoch().count());
    return uniform_int_distribution<ll>(l, r)(gen);
}
template<class T>
void print(T x,int suc=1)
{
    cout<<x;
    if(suc==1) cout<<'\n';
    else cout<<' ';
}
template<class T>
void print(const vector<T>&v,int suc=1)
{
    for(int i=0;i<v.size();i++)
    print(v[i],i==(int)(v.size())-1?suc:2);
}
const int maxn=1e4+7;
const int mod=998244353;
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n;
    cin>>n;
    vi a(n);
    for(int i=0;i<n;i++) cin>>a[i];
    vc<vi> dp(n+1,vi(maxn));
    int sum=0;
    dp[0][0]=1;
    for(int i=1;i<=n;i++)
    {
        sum+=a[i-1];
        for(int j=n-1;j>=0;j--)
        {
            for(int k=a[i-1];k<maxn;k++)
                dp[j+1][k]=(dp[j+1][k]+dp[j][k-a[i-1]])%mod;
        }
    }
    if(sum%2!=0) print(0);
    else{
        ll ans=0;
        for(int i=0;i<=n;i++)
        {
            ll cur=dp[i][sum/2];
            //dbg(i,cur);
            for(int j=1;j<=i;j++) cur=cur*j%mod;
            for(int j=1;j<=n-i;j++) cur=cur*j%mod;
            ans=(ans+cur)%mod;
        }
        print(ans);
    }
}