#include using namespace std; #define rep(i,n) for(int i = 0; i < n; i++) #define all(x) x.begin(), x.end() #define Min(x) *min_element(all(x)) #define Max(x) *max_element(all(x)) template ostream &operator<<(ostream &o, const pair &v) { o << "(" << v.first << ", " << v.second << ")"; return o; } template ostream &operator<<(ostream &o, const vector &v) { if (!v.empty()) { o << '['; copy(v.begin(), v.end(), ostream_iterator(o, ", ")); o << "\b\b]"; } return o; } using ll = long long; using ld = long double; using vll = vector; using vi = vector; typedef pair P; static const double EPS = 1e-14; static const long long INF = 1e18; static const long long mo = 1e9+7; #define MAX_N 100005 int main(void) { ll n; cin >> n; ll q; cin >> q; vll x(n), y(n); vll a(n+1, 0), b(n+1, 0); a[0] = b[0] = 1; bool updated = 1; rep(i, q) { char query; cin >> query; if (query == 'a') { if (updated) { rep(j, n) { a[j+1] = (((x[j] * b[j]) % mo) * b[j] + a[j]) % mo; b[j+1] = (y[j] * b[j] + 1) % mo; } updated = 0; } ll i; cin >> i; cout << a[i] << endl; } else { ll i, v; cin >> i >> v; (query == 'x' ? x : y)[i] = v; updated = 1; } } return 0; }