/****************************************** * AUTHOR: BHUVNESH JAIN * * INSTITUITION: BITS PILANI, PILANI * ******************************************/ #include using namespace std; typedef long long LL; typedef long double LD; typedef pair pii; typedef pair pll; #define fi first #define sec second const int MAX = 1e5 + 5; const int MOD = 1e9 + 7; const int MINUS_ONE = MOD - 1; const int MINUS_TWO = MOD - 2; int add(int a, int b) { int c = a + b; return (c >= MOD ? c - MOD : c); } int sub(int a, int b) { int c = a - b; return (c < 0 ? c + MOD : c); } inline pii rotate(pii &point, pii &ref, int &angle) { pii ans; if (angle == 0) { ans.fi = point.fi; ans.sec = point.sec; } else if (angle == 90) { ans.fi = sub(add(ref.sec, ref.fi), point.sec); ans.sec = add(sub(ref.sec, ref.fi), point.fi); } else if (angle == 180) { ans.fi = sub(add(ref.fi, ref.fi), point.fi); ans.sec = sub(add(ref.sec, ref.sec), point.sec); } else { ans.fi = add(sub(ref.fi, ref.sec), point.sec); ans.sec = sub(add(ref.fi, ref.sec), point.fi); } return ans; } pii pt[MAX]; int ang[MAX]; pii pre[MAX]; pair coef[MAX]; //{-1/1, -1/1, swap} int st[MAX], en[MAX], blk[MAX]; map> mp; void init() { mp[{1, 2}] = {{1, 1}, 0}; mp[{MINUS_TWO, 1}] = {{1, -1}, 1}; mp[{MINUS_ONE, MINUS_TWO}] = {{-1, -1}, 0}; mp[{2, MINUS_ONE}] = {{-1, 1}, 1}; } inline void build_block(int l, int r, int ctr) { pre[ctr] = {0, 0}; pii ref = {0, 0}; pii to_rot = {1, 2}; for(int j = l; j <= r; ++j) { blk[j] = ctr; pre[ctr] = rotate(pre[ctr], pt[j], ang[j]); to_rot = rotate(to_rot, ref, ang[j]); } coef[ctr] = mp[to_rot]; } inline void get_blk(pii &point, int ctr) { if (coef[ctr].fi.fi == -1) { point.fi = sub(0, point.fi); } if (coef[ctr].fi.sec == -1) { point.sec = sub(0, point.sec); } if (coef[ctr].sec == 1) { point = {point.sec, point.fi}; } point.fi = add(point.fi, pre[ctr].fi); point.sec = add(point.sec, pre[ctr].sec); } int main() { init(); int n; scanf("%d", &n); for(int i = 1; i <= n; ++i) { scanf("%d %d %d", &pt[i].fi, &pt[i].sec, &ang[i]); } int ctr = 0; int cut = ceil(sqrt(n)); for(int i = 1; i <= n; i += cut) { int l = i, r = min(n, l + cut - 1); ctr += 1; st[ctr] = l; en[ctr] = r; build_block(l, r, ctr); } int q; scanf("%d", &q); while(q--) { int type; scanf("%d", &type); if (type == 1) { int l, r; pii point; scanf("%d %d %d %d", &point.fi, &point.sec, &l, &r); pii ans = point; if (blk[l] == blk[r]) { for(int i = l; i <= r; ++i) { ans = rotate(ans, pt[i], ang[i]); } } else { for(int i = l; i <= en[blk[l]]; ++i) { ans = rotate(ans, pt[i], ang[i]); } for(int i = blk[l]+1; i <= blk[r]-1; ++i) { get_blk(ans, i); } for(int i = st[blk[r]]; i <= r; ++i) { ans = rotate(ans, pt[i], ang[i]); } } printf("%d %d\n", ans.fi, ans.sec); } else { int u, x, y, a; scanf("%d %d %d %d", &u, &x, &y, &a); pt[u] = {x, y}; ang[u] = a; build_block(st[blk[u]], en[blk[u]], blk[u]); } } return 0; }