#!/usr/bin/ python3.8 import sys read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines MOD = 10 ** 9 + 7 class SegTree: """ segment tree with point modification and range product access. """ data_unit = (1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1) @classmethod def data_f(cls, A, B): C = [0] * 16 for i in range(4): for j in range(i, 4): for k in range(j, 4): C[4 * i + k] += B[4 * i + j] * A[4 * j + k] return tuple(x % MOD for x in C) def __init__(self, N): self.N = N self.data = [self.data_unit] * (N + N) def build(self, raw_data): data = self.data f = self.data_f N = self.N data[N:] = raw_data[:] for i in range(N - 1, 0, -1): data[i] = f(data[i << 1], data[i << 1 | 1]) def set_val(self, i, x): data = self.data f = self.data_f i += self.N data[i] = x while i > 1: i >>= 1 data[i] = f(data[i << 1], data[i << 1 | 1]) def fold(self, L, R): """ compute for [L, R) """ vL = vR = self.data_unit data = self.data f = self.data_f L += self.N R += self.N while L < R: if L & 1: vL = f(vL, data[L]) L += 1 if R & 1: R -= 1 vR = f(data[R], vR) L >>= 1 R >>= 1 return f(vL, vR) N = int(readline()) X = [0] * N Y = [0] * N Q = int(readline()) seg = SegTree(N) def mat(x, y): return (1, x, 0, 0, 0, y * y, 2 * y, 1, 0, 0, y, 1, 0, 0, 0, 1) for query in readlines()[:Q]: if query.startswith(b'a'): i = int(query[2:]) if i == 0: print(1) else: A = seg.fold(0, i) print(sum(A[:4]) % MOD) elif query.startswith(b'x'): i, v = map(int, query[2:].split()) X[i] = v seg.set_val(i, mat(v, Y[i])) elif query.startswith(b'y'): i, v = map(int, query[2:].split()) Y[i] = v seg.set_val(i, mat(X[i], v))