#include #define FOR(i,bg,ed) for(ll i=(bg);i<(ed);i++) #define REP(i,n) FOR(i,0,n) #define REP1(i,n) for(ll i=1;i<=(n);i++) #define MOD 1000000007 #define int long long #define all(c) (c).begin(), (c).end() #define uniq(c) c.erase(unique(all(c)), (c).end()) using namespace std; typedef long long ll; typedef pair P; typedef vector vec; typedef vector mat; const int INF = 1e9; //行列Aと行列Bの積を返す mat f(mat A, mat B) { mat C(A.size(), vec(B[0].size())); REP(i,A.size()) REP(j,B[0].size()) { REP(k,A[0].size()) { C[i][j] += (A[i][k] * B[k][j]) % MOD; C[i][j] %= MOD; } } return C; } mat defvalue(4, vec(4)), defvalue2(4, vec(4)); class SegTree { private: int n; vector val; public: SegTree(int size) { n = 1; while (n < size) n <<= 1; val = vector(2 * n, defvalue); } void update(int q, int i, int a) { i += n - 1; if (q == 0) { val[i][0][2] = a; } else { val[i][1][1] = a; val[i][2][1] = 2 * a; val[i][2][2] = a * a % MOD; } while (i > 0) { i = (i - 1) / 2; val[i] = f(val[i * 2 + 2],val[i * 2 + 1]); } } mat query(int a, int b, int k = 0, int l = 0, int r = - 1) { if (r == -1) r = n; if (r <= a || b <= l) return defvalue2; if (a <= l && r <= b) return val[k]; else return f(query(a, b, k * 2 + 2, (l + r) / 2, r), query(a, b, k * 2 + 1, l, (l + r) / 2)); } }; int n, q; signed main() { cin >> n >> q; defvalue[0][0] = defvalue[1][3] = defvalue[2][3] = defvalue[3][3] = 1; defvalue2[0][0] = defvalue2[1][1] = defvalue2[2][2] = defvalue2[3][3] = 1; SegTree st(n + 1); while (q--) { int a, b; char c; cin >> c; if (c == 'x') { cin >> a >> b; st.update(0, a, b); } else if (c == 'y') { cin >> a >> b; st.update(1, a, b); } else if (c == 'a') { cin >> a; mat t = st.query(0, a); cout << (t[0][0]+t[0][1]+t[0][2]+t[0][3]) % MOD << endl; } } }