#include using namespace std; using ll = long long; ll a[100001], b[100001], x[100001], y[100001]; int main(){ constexpr ll mod = 1e9 + 7; cin.tie(0); ios::sync_with_stdio(false); ll n, q, puni = 0; cin >> n >> q; a[0] = b[0] = 1; while(q--){ char c; cin >> c; if(c == 'x'){ ll i, v; cin >> i >> v; x[i] = v; puni = min(puni, i); } if(c == 'y'){ ll i, v; cin >> i >> v; y[i] = v; puni = min(puni, i); } if(c == 'a'){ ll i; cin >> i; if(puni != 10000000){ for(int j = puni; j < n; j++){ a[j + 1] = (x[j] * b[j] % mod * b[j] + a[j]) % mod; b[j + 1] = (y[j] * b[j] + 1) % mod; } puni = 10000000; } cout << a[i] << endl; } } }