#include <bits/stdc++.h>
#define mk make_pair
#define fs first
#define sc second
using namespace std;
typedef long long ll;
typedef long double ld;
// please, read the question correctly (do you need set or multiset)???
const int N=3010; //check the limits, dummy
ll a[N];
int n, m;
ll mod = 1e9+7;
int mem[N][N], mem1[N][N], lst[N][N];
ll dp(int x, int y){
	if(x==n)return 1;
	if(x>n)return 0;
	if(mem[x][y]!=-1)return mem[x][y];
	ll res = 0;
	int tmp = mem1[x][y];
	if(tmp==n){
		res = 1;
	}
	else{
		res = dp(tmp, y+1)+dp(tmp, y);
		res %= mod;
	}
	// cout<<x<<" "<<y<<" "<<tmp<<" "<<res<<endl;
	// for(int i=x; i<n; ++i){
	// 	tmp += a[i];
	// 	tmp %= y;
	// 	if(tmp==0){
	// 		res += dp(i+1, y+1)+dp(i+1, y);
	// 		res %= mod;
	// 		break;
	// 	}
	// }
	mem[x][y] = res; 
	return res;
}
int main(){
	scanf("%d",&n);
	for(int i=0; i<n; ++i){
		scanf("%lld",a+i);
	}
	for(int i=1; i<=n; ++i){
		for(int j=0; j<n; ++j){
			lst[i][j] = n+1;
		}
		lst[i][0] = n;
	}
	ll sm = 0;
	for(int i=n-1; i>=0; --i){
		sm += a[i];
		for(int j=1; j<=n; ++j){
			mem1[i][j] = lst[j][(sm%j)];
		}
		for(int j=1; j<=n; ++j){
			lst[j][sm%j] = i;
		}
	}
	memset(mem, -1, sizeof mem);
	ll ans = dp(0,1);
	cout<<ans<<endl;
}
#include <bits/stdc++.h>
using namespace std;
//#define FOR_CODEFORCES
//#define MOD 998244353LL

#if 1 //テンプレ折り畳み//テンプレ折り畳み//テンプレ折り畳み

#ifdef _DEBUG
#define debug() if(true)
#define dout cout
#define dvout(v) __vout(v)
#define dvvout(v) __vvout(v)
#else
#define debug() if (false)
#define dout if (false)cout
#define dvout(v) if(false)__vout(v)
#define dvvout(v) if(false)__vvout(v)
#endif

typedef long long ll;
typedef unsigned long long ull;

#define rep(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)//rep
#define repll(i, n) for(ll i=0, i##_len=(n); i<i##_len; ++i)//rep
#define repi(i, n1, n) for(int i=n1, i##_len=(n); i<i##_len; ++i)//rep
#define reps(i, n) for(int i=1, i##_len=(n); i<=i##_len; ++i)//自然数rep
#define rrep(i, n) for(int i=((int)(n)-1); i>=0; --i)
#define rreps(i, n) for(int i=((int)(n)); i>0; --i)

#define _Yes {cout<<"Yes"<<endl; return;}//出力
#define _No {cout<<"No"<<endl;return;}
#define _ans {cout<<ans<<endl;return;}
#define _endout(s) {cout<<(s)<<endl;return;}

#define vec(v, n) vector<int> v(n, 0);//配列
#define vecll(v, n) vector<ll> v(n, 0);
#define vecvec(v, n, m) vector<vector<int>> v(n, vector<int>(m));
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
#define vin(v) for (auto &i : (v)) cin >> i; //配列入力
#define vvin(v) for(auto&i:(v))for(auto&j:i)cin>>j;
#define __vout(v) for(auto&i:(v)){cout<<i<<' ';}cout<<"\n";
#define __vvout(v) for(auto&i:(v)){for(auto&j:i){cout<<j<<' ';}cout<<"\n";}cout<<"\n";

#ifndef MOD
#define MOD 1000000007LL//mod用定数 (ll)(1e9+7)
#endif
#define mod(n) ( ((ll)n) % MOD)
#define modp(n, p) ( ((ll)n) % (ll)(p))
#define modx(A,B) mod(mod(A)*mod(B))
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }

#define next asdnext
#define prev asdprev
#define y0 y3487465
#define y1 y8687969
#define j0 j1347829
#define j1 j234892
#define SZ(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define _n "\n"
#define _n2 "\n\n"
#define _t "\t"

void test();

#endif //テンプレ折り畳み

//	LLONG_MAX 9.2*1e18	9223372036854775807LL = (2^63)-1
//	INT_MAX 2.1*1e9 2147483647 = (2^31)-1
//	O(1e8) 1.2sec

struct ARROW{
	ll a=1,b=0,c=0,d=1,k1=0,k2=0;
};

void Main()
{
	int N;
	cin>>N;
	vll X(N);
	vll Y(N);

	rep(i,N){
		cin>>X[i]>>Y[i];
	}

	int M;
	cin>>M;
	vector<ARROW> ar(M+1);
	reps(i,M){
		int t;
		cin>>t;
		ll p;
		if(t==3 || t==4)cin>>p;

		switch (t)
		{
			case 1:
			ar[i].a=(ar[i-1].c);
			ar[i].b=(ar[i-1].d);
			ar[i].k1=(ar[i-1].k2);

			ar[i].c=-(ar[i-1].a);
			ar[i].d=-(ar[i-1].b);
			ar[i].k2=-(ar[i-1].k1);
			break;
			
			case 2:
			ar[i].a=-(ar[i-1].c);
			ar[i].b=-(ar[i-1].d);
			ar[i].k1=-(ar[i-1].k2);

			ar[i].c=(ar[i-1].a);
			ar[i].d=(ar[i-1].b);
			ar[i].k2=(ar[i-1].k1);
			break;
			
			case 3:
			ar[i].a=-(ar[i-1].a);
			ar[i].b=-(ar[i-1].b);
			ar[i].k1=p*2LL - (ar[i-1].k1);
			ar[i].c=(ar[i-1].c);
			ar[i].d=(ar[i-1].d);
			ar[i].k2=(ar[i-1].k2);
			break;
			
			case 4:
			ar[i].a=(ar[i-1].a);
			ar[i].b=(ar[i-1].b);
			ar[i].k1=(ar[i-1].k1);
			ar[i].c=-(ar[i-1].c);
			ar[i].d=-(ar[i-1].d);
			ar[i].k2=p*2LL - (ar[i-1].k2);
			break;
		}
	}

	int Q;

	cin>>Q;
	rep(i,Q){
		int A,B;
		cin>>A>>B;
		A;B--;
		ll x=(ar[A].a)*X[B] + (ar[A].b)*Y[B] + (ar[A].k1);
		ll y=(ar[A].c)*X[B] + (ar[A].d)*Y[B] + (ar[A].k2);

		dout<<"output  ";
		cout<<x<<" "<<y<<_n;
	}
}

void test(){
}
int main(){
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << std::fixed << std::setprecision(20);
#ifdef FOR_CODEFORCES
	int t = 0;
	cin >> t;
	rep(i, t) Main();
#else
	Main();
#endif
	return 0;
}
