#include "bits/stdc++.h" using namespace std; #define FOR(i,j,k) for(int (i)=(j);(i)<(int)(k);++(i)) #define rep(i,j) FOR(i,0,j) #define each(x,y) for(auto &(x):(y)) #define mp make_pair #define mt make_tuple #define all(x) (x).begin(),(x).end() #define debug(x) cout<<#x<<": "<<(x)< pii; typedef vector vi; typedef vector vll; const int MOD = (int)1e9 + 7; vector > mulMatMod(vector > A, vector > B) { auto n = A.size(), m = A[0].size(), p = B[0].size(); vector > res(n, vector(p)); for (int i = 0; i < n; ++i)for (int j = 0; j < p; ++j) for (int k = 0; k < m; ++k) res[i][j] = (int)((res[i][j] + (long long)A[i][k] * B[k][j]) % MOD); return res; } typedef vector mat; template class SegmentTree { int n; Value init; vector dat; Value cal(Value a, Value b) { return mulMatMod(b, a); } inline Value query(int a, int b, int k, int l, int r) { if (r <= a || b <= l) return init; if (a <= l&&r <= b) return dat[k]; else { Value vl, vr; vl = query(a, b, k << 1, l, (l + r) >> 1); vr = query(a, b, (k << 1) | 1, (l + r) >> 1, r); return cal(vl, vr); } } public: SegmentTree() {} SegmentTree(int n_, Value init_) :n(1), init(init_) { for (; n(n << 1, init); } void update(int k, Value a) { k += n; dat[k] = a; while (k>1) { k >>= 1; dat[k] = cal(dat[k << 1], dat[(k << 1) | 1]); } } Value query(int a, int b) { return query(a, b, 1, 0, n); } }; typedef SegmentTree SegTree; int n, q; mat A[100001]; int main(){ ios::sync_with_stdio(false); cin.tie(0); cin >> n >> q; mat E(4, vi(4)); rep(i, 4)E[i][i] = 1; SegTree st(n + 1, E); rep(i, n) { A[i] = mat(4, vi(4)); auto &B = A[i]; B[0][0] = B[1][3] = B[2][3] = B[3][3] = 1; st.update(i, B); } while (q--) { string c; cin >> c; int k; cin >> k; auto &B = A[k]; if (c == "x") { int v; cin >> v; B[0][2] = v; st.update(k, B); } else if (c == "y") { int v; cin >> v; B[1][1] = v; B[2][1] = v * 2; B[2][2] = (int)((ll)v*v % MOD); st.update(k, B); } else { auto C = st.query(0, k); ll ans = 0; rep(i, 4)ans += C[0][i]; cout << ans%MOD << endl; } } }