#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #define popcount __builtin_popcount using namespace std; typedef long long int ll; typedef pair P; template struct ModInt{ int x; ModInt(): x(0){} ModInt(ll y): x(y>=0 ? y%MOD : (MOD-(-y)%MOD)%MOD){} ModInt &operator+=(const ModInt &p){ if((x+=p.x)>=MOD) x-=MOD; return *this; } ModInt &operator-=(const ModInt &p){ if((x+=MOD-p.x)>=MOD) x-=MOD; return *this; } ModInt &operator*=(const ModInt &p){ x=(int)(1ll*x*p.x%MOD); return *this; } ModInt &operator/=(const ModInt &p){ *this*=p.inv(); return *this; } ModInt operator-() const{ return ModInt(-x);} ModInt operator+(const ModInt &p) const{ return ModInt(*this)+=p;} ModInt operator-(const ModInt &p) const{ return ModInt(*this)-=p;} ModInt operator*(const ModInt &p) const{ return ModInt(*this)*=p;} ModInt operator/(const ModInt &p) const{ return ModInt(*this)/=p;} bool operator==(const ModInt &p) const{ return x==p.x;} bool operator!=(const ModInt &p) const{ return x!=p.x;} ModInt pow(ll n) const{ ModInt ret(1), p(x); while(n){ if(n&1) ret*=p; p*=p; n>>=1; } return ret; } ModInt inv() const{ return pow(MOD-2); } }; const int MOD=1e9+7; using mint=ModInt; template struct Matrix{ using arr=array; array a; Matrix(){} Matrix(array a):a(a){} inline const arr &operator[](size_t k) const{ return a[k]; } inline arr &operator[](size_t k){ return a[k]; } static Matrix I(){ Matrix mat; for(int i=0; i c; for(int i=0; i>=1; } return ret; } }; template struct SegmentTree{ using F=function; int sz; vector seg; const F f; const Monoid e; SegmentTree(int n, const F f, const Monoid &e): f(f), e(e){ sz=1; while(sz v): f(f), e(e){ sz=1; while(sz=1; i--){ seg[i]=f(seg[2*i], seg[2*i+1]); } } void update(int k, const Monoid &x){ k+=sz; seg[k]=x; while(k>1){ k>>=1; seg[k]=f(seg[2*k], seg[2*k+1]); } } Monoid query(int a, int b){ a+=sz, b+=sz; Monoid ret=e; for(;a>=1, b>>=1){ if(b&1) ret=f(seg[--b], ret); if(a&1) ret=f(ret, seg[a++]); } return ret; } Monoid operator[](const int &k) const{ return seg[k+sz]; } }; int main() { using Mat=Matrix; Mat id; id[0][0]=id[1][3]=id[2][3]=id[3][3]=1; int n; cin>>n; vector v(n, id); SegmentTree seg(n, [](Mat a, Mat b){ return b*a;}, Mat::I(), v); int q; cin>>q; for(int i=0; i>c; if(c=='x'){ int p; mint val; cin>>p>>val.x; v[p][0][1]=val; seg.update(p, v[p]); }else if(c=='y'){ int p; mint val; cin>>p>>val.x; v[p][1][1]=val*val, v[p][1][2]=val*mint(2), v[p][2][2]=val; seg.update(p, v[p]); }else{ int p; cin>>p; Mat mat=seg.query(0, p); cout<<(mat[0][0]+mat[0][1]+mat[0][2]+mat[0][3]).x<