#include #include #include using namespace std; using ulli = unsigned long long int; void update( vector & a, vector & b, vector & x, vector & y, int pos){ for(int i = 1; i <= pos; ++i){ a[i] = x[i - 1] * b[i - 1] * b[i - 1] + a[i - 1]; b[i] = y[i - 1] * b[i - 1] + 1; } } int main(void){ ulli n, q; cin >> n >> q; ++n; vector a(n), b(n), x(n), y(n); a[0] = b[0] = 1; for(int i = 0; i < n; ++i){ x[i] = y[i] = 0; } for(int i = 0; i < q; ++i){ char query; ulli pos; cin >> query; cin >> pos; if(query == 'a'){ update(a, b, x, y, pos); cout << a[pos] % (1000000000 + 7) << endl; } if(query == 'x') cin >> x[pos]; if(query == 'y') cin >> y[pos]; } return 0; }