#include
using namespace std;
typedef long long dint; #ifdef WIN32 #define lld “%I64d” #else #define lld “%lld” #endif #define _l (long long int)
struct seg { int m, a, c; seg *ch[2]; seg() { ch[0] = ch[1] = 0, m = a = c = 0; } };
#define sgtRoot 1, n + 1
#define mp ((pl+pr)»1)
#define lson pl, mp
#define rson mp, pr
#define checkNeg(x) {
if (x < 0)
x += mod;
}
#define mInc(x,y) {
x += y;
if (x >= mod)
x -= mod;
}
typedef map <dint, seg* > pmap; typedef pair <dint, seg* > ppr; typedef pmap :: iterator pmap_it;
const int maxn = 100007; const int mod = 1e9 + 7; const int bsz = 1000007;
int n, m, sm, sa, sc, lans; dint x[maxn], y[maxn], qv; pmap r[2];
inline seg* allocSeg() { static seg* sbuf; static int cnt(0); if (!cnt) sbuf = new seg[bsz], cnt = bsz - 1; return – cnt, sbuf ++; }
inline seg* sgtChg(seg* q, int po, int pl, int pr) { seg* p(q ? q : allocSeg()); mInc(p-> m, sm); mInc(p-> a, sa); mInc(p-> c, sc); if (pl + 1 < pr) { if (po < mp) p-> ch[0] = sgtChg(p-> ch[0], po, lson); else p-> ch[1] = sgtChg(p-> ch[1], po, rson); } return p; } void sgtQry(seg* p, int l, int r, int pl, int pr) { if (!p) return; else if (l == pl && r == pr) { mInc(sm, p-> m); mInc(sa, p-> a); mInc(sc, p-> c); } else if (r <= mp) sgtQry(p-> ch[0], l, r, lson); else if (l >= mp) sgtQry(p-> ch[1], l, r, rson); else sgtQry(p-> ch[0], l, mp, lson), sgtQry(p-> ch[1], mp, r, rson); }
inline int sqr(int x) { return _l x * x % mod; } inline void chgVal(int ri, int po, dint x, dint y, int sgn) { sm = y % mod; checkNeg(sm); sa = sqr(y % mod); sc = sgn; if (sgn == -1) { sm = (mod - sm) % mod; sa = (mod - sa) % mod; } r[ri][x] = sgtChg(r[ri][x], po, sgtRoot); } inline int qrySum(int ri, dint x, dint y, int le, int re) { sm = sa = sc = 0; sgtQry(r[ri][x], le, re + 1, sgtRoot); sm = -sm * 2 % mod; checkNeg(sm); int ret((_l sqr(y % mod) * sc + y % mod * sm + sa) % mod); checkNeg(ret); return ret; }
int main() { #ifndef ONLINE_JUDGE freopen(".in", “r”, stdin); #endif
scanf("%d%*s", &n);
for (int i = 1; i <= n; ++ i) {
scanf(lld lld, x + i, y + i);
chgVal(0, i, x[i], y[i], 1);
chgVal(1, i, y[i], x[i], 1);
}
scanf("%d", &m);
lans = 0;
while (m --) {
char opt[3];
scanf("%s", opt);
if (opt[0] == 'Q') {
int i, l, r;
scanf("%d%d%d", &i, &l, &r);
i ^= lans;
lans = (qrySum(0, x[i], y[i], l, r) + qrySum(1, y[i], x[i], l, r)) % mod;
printf("%d\n", lans);
}
else {
int i;
dint l;
scanf("%d" lld, &i, &l);
i ^= lans;
chgVal(0, i, x[i], y[i], -1);
chgVal(1, i, y[i], x[i], -1);
if (opt[0] == 'U')
y[i] += l;
else if (opt[0] == 'D')
y[i] -= l;
else if (opt[0] == 'L')
x[i] -= l;
else if (opt[0] == 'R')
x[i] += l;
chgVal(0, i, x[i], y[i], 1);
chgVal(1, i, y[i], x[i], 1);
}
}
}