#include #include #include #include #include const int mod = 1e9 + 7; struct modint { int n; modint(int n = 0) : n(n) {} }; modint operator+(modint a, modint b) { return modint((a.n += b.n) >= mod ? a.n - mod : a.n); } modint operator-(modint a, modint b) { return modint((a.n -= b.n) < 0 ? a.n + mod : a.n); } modint operator*(modint a, modint b) { return modint(1LL * a.n * b.n % mod); } modint &operator+=(modint &a, modint b) { return a = a + b; } modint &operator-=(modint &a, modint b) { return a = a - b; } modint &operator*=(modint &a, modint b) { return a = a * b; } using V = std::array; using M = std::array; M operator*(const M &a, const M &b) { long long c[4][4]; for (int i = 0; i < 3; i++) { for (int j = 1; j < 4; j++) { c[i][j] = 0; } } for (int i = 0; i < 3; i++) { for (int k = 0; k < 4; k++) { for (int j = 1; j < 4; j++) { c[i][j] += 1LL * a[i][k].n * b[k][j].n; } } } M ret = {}; for (int i = 0; i < 3; i++) { for (int j = 1; j < 4; j++) { ret[i][j] = c[i][j] % mod; } } ret[0][0] = 1; ret[3][3] = 1; return ret; } M getmat(modint x, modint y) { return M{ V{1, 0, x, 0}, V{0, y, 0, 1}, V{0, 2 * y, y * y, 1}, V{0, 0, 0, 1}, }; } int main() { int n, q; std::cin >> n >> q; std::vector xs(n); std::vector ys(n); int N = 1; while (N < n) { N *= 2; } std::vector seg(N * 2); for (int i = 0; i < N * 2; i++) { seg[i] = getmat(0, 0); } for (int i = N - 1; i >= 1; i--) { seg[i] = seg[i * 2 + 1] * seg[i * 2]; } auto setval = [&](int k, M v) { k += N; seg[k] = v; while (k > 1) { k /= 2; seg[k] = seg[k * 2 + 1] * seg[k * 2]; } }; auto getval = [&](int k) { if (k == N) { return seg[1]; } k += N; M ret = {}; for (int i = 0; i < 4; i++) { ret[i][i] = 1; } while (k > 1) { if (k & 1) { ret = ret * seg[--k]; } k /= k & -k; } return ret; }; while (q--) { char c; scanf(" %c", &c); if (c == 'x') { int i, v; scanf("%d %d", &i, &v); xs[i] = v; setval(i, getmat(xs[i], ys[i])); } else if (c == 'y') { int i, v; scanf("%d %d", &i, &v); ys[i] = v; setval(i, getmat(xs[i], ys[i])); } else { int i; scanf("%d", &i); auto m = getval(i); printf("%d\n", (m[0][0] + m[0][1] + m[0][2] + m[0][3]).n); } } }