
#include <algorithm>
#include <iostream>
#include <vector>
#include <numeric>

struct AMat
{
public:
    AMat() : m{ 0, 0, 0, 0 }, v{ 0, 0 }
    {}
    AMat(int op, int p) : m { 0, 0, 0, 0 }, v{ 0, 0 }
    {
        if (op == 1) {
            m[0][0] = 0;
            m[0][1] = 1;
            m[1][0] = -1;
            m[1][1] = 0;
            v[0] = 0;
            v[1] = 0;
        }
        else if (op == 2) {
            m[0][0] = 0;
            m[0][1] = -1;
            m[1][0] = 1;
            m[1][1] = 0;
            v[0] = 0;
            v[1] = 0;
        }
        else if (op == 3) {
            m[0][0] = -1;
            m[0][1] = 0;
            m[1][0] = 0;
            m[1][1] = 1;
            v[0] = 2 * static_cast<int64_t>(p);
            v[1] = 0;
        }
        else if (op == 4) {
            m[0][0] = 1;
            m[0][1] = 0;
            m[1][0] = 0;
            m[1][1] = -1;
            v[0] = 0;
            v[1] = 2 * static_cast<int64_t>(p);
        }
    }
    ~AMat()
    {}

    std::int64_t m[2][2];
    std::int64_t v[2];
};

struct Vec2
{
    Vec2() : v{0, 0}
    {}
    ~Vec2()
    {}

    std::int64_t v[2];
};

AMat operator*(const AMat& lhs, const AMat& rhs)
{
    AMat r;
    for (int i = 0; i < 2; ++i) {
        for (int j = 0; j < 2; ++j) {
            for (int k = 0; k < 2; ++k) {
                r.m[i][j] += lhs.m[i][k] * rhs.m[k][j];
            }
        }
    }
    r.v[0] = lhs.m[0][0] * rhs.v[0] + lhs.m[0][1] * rhs.v[1] + lhs.v[0];
    r.v[1] = lhs.m[1][0] * rhs.v[0] + lhs.m[1][1] * rhs.v[1] + lhs.v[1];
    return r;
}

Vec2 operator*(const AMat& lhs, const Vec2& rhs)
{
    Vec2 r;
    r.v[0] = lhs.m[0][0] * rhs.v[0] + lhs.m[0][1] * rhs.v[1] + lhs.v[0];
    r.v[1] = lhs.m[1][0] * rhs.v[0] + lhs.m[1][1] * rhs.v[1] + lhs.v[1];
    return r;
}


int main()
{
    int N;
    std::cin >> N;
    std::vector<Vec2> X(N);
    for (int i = 0; i < N; ++i) {
        std::cin >> X[i].v[0] >> X[i].v[1];
    }

    int M;
    std::cin >> M;
    std::vector<int> OP(M);
    std::vector<int> P(M);
    for (int i = 0; i < M; ++i) {
        std::cin >> OP[i];
        if (OP[i] == 3) {
            std::cin >> P[i];
        }
        else if (OP[i] == 4) {
            std::cin >> P[i];
        }
    }

    int Q;
    std::cin >> Q;
    std::vector<int> A(Q), B(Q);
    for (int i = 0; i < Q; ++i) {
        std::cin >> A[i] >> B[i];
    }

    std::vector<AMat> mats(M);
    for (int i = 0; i < M; ++i) {
        AMat m(OP[i], P[i]);
        if (i == 0) {
            mats[i] = m;
        }
        else {
            mats[i] = m * mats[i - 1];
        }
    }

    for (int i = 0; i < Q; ++i) {
        int p = B[i] - 1;
        if (A[i] == 0) {
            std::cout << X[p].v[0] << " " << X[p].v[1] << std::endl;
        }
        else {
            Vec2 r = mats[A[i] - 1] * X[p];
            std::cout << r.v[0] << " " << r.v[1] << std::endl;
        }
    }
}

#include<iostream>
#include<bits/stdc++.h>
#define int long long int
#define vi vector<int>
#define fo(i,n) for(int i=1;i<=n;i++)
#define foo(i,n) for(int i=0;i<n;i++)
#define sort(v) sort(v.begin(), v.end())
#define rev(v) reverse(v.begin(), v.end())
#define uniq(v) sort(v); v.resize(unique(v.begin(), v.end())-v.begin());
#define ff first
#define ss second
#define pb push_back
#define pii pair<int,int>
#define ok ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
using namespace std;
#define vp vector<pair<int,int>>
#define mod 1000000007
const int huge = 1e17;
               
                
int max(int a,int b){ if(a>b) return a; return b; }
int min(int a,int b){ if(a<b) return a; return b; }
int abbs(int a,int b){   if(a-b < 0) return b-a; return a-b; }
 
 
int lowerB(vi &v, int val){
int ind=v.size(),l=0,r=v.size(),mid;while(l<=r){mid=(l+r)/2;if(v[mid]>=val){ind=mid;r=mid-1;}else l=mid+1;}return ind;
}
 
 
void solve(){
    int n; cin>>n; vi v(n); foo(i,n) cin>>v[i];
    vi pre(n); int x = 0;
    foo(i,n) x+=v[i], pre[i] = x;

    vector<vector<int>> dp(n+500,vector<int>(n+500,0));
    dp[1][0] = 1;
    int ans = 0;
    for(int i=0; i<n; i++) {
        for(int j=n; j>=1; j--) {
           dp[j+1][pre[i]%(j+1)] += dp[j][pre[i]%j];
           dp[j+1][pre[i]%(j+1)]%=mod;
           if(i==n-1) {
            ans+=dp[j][pre[i]%j];
            ans%=mod;
           }
        }
    }
   
    cout<<ans;
} 
      
      
signed main(){
   ok
   int t;
   t = 1;
   //cin>>t;
     while(t--){
      solve();
    }
}