#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #define rep(X,Y) for (int (X) = 0;(X) < (Y);++(X)) #define reps(X,S,Y) for (int (X) = S;(X) < (Y);++(X)) #define rrep(X,Y) for (int (X) = (Y)-1;(X) >=0;--(X)) #define repe(X,Y) for ((X) = 0;(X) < (Y);++(X)) #define peat(X,Y) for (;(X) < (Y);++(X)) #define all(X) (X).begin(),(X).end() using namespace std; typedef long long ll; typedef pair pii; typedef pair pll; const int MAX_N = 100000, MAX_Q = 20000, MOD = 1e9 + 7; int main() { int n, q; static ll a[MAX_N+1], b[MAX_N+1]; static int x[MAX_N+1], y[MAX_N+1]; a[0] = 1; b[0] = 1; cin >> n >> q; static char query[MAX_Q]; static int i[MAX_Q], v[MAX_Q]; rep(s, q) { cin >> query[s]; if (query[s] == 'x') { cin >> i[s] >> v[s]; } else if (query[s] == 'y') { cin >> i[s] >> v[s]; } else { cin >> i[s]; } } rep(s, q) { if (query[s] == 'x') { x[i[s]] = v[s]; } else if (query[s] == 'y') { y[i[s]] = v[s]; } else { if (i[s] == 0) { cout << 1 << endl; } reps(j, 1, i[s]+1) { a[j] = (((x[j-1] * b[j-1]) % MOD) * b[j-1] + a[j-1]) % MOD; b[j] = (y[j-1] * b[j-1] + 1) % MOD; } cout << a[i[s]] << endl; } } return 0; }