#include using namespace std; #define fst(t) std::get<0>(t) #define snd(t) std::get<1>(t) #define thd(t) std::get<2>(t) using ll = long long; using P = std::tuple; const int dx[8] = {-1, 1, 0, 0, -1, -1, 1, 1}, dy[8] = {0, 0, -1, 1, -1, 1, -1, 1}; const ll MOD = 1e9 + 7; template using Matrix = std::vector>; namespace tottori{ template Matrix mult(const Matrix& m2, const Matrix& m1){ assert(m1.size() > 0); assert(m2.size() > 0); assert(m1[0].size() == m2.size()); int n = m1.size(), m = m1[0].size(), l = m2[0].size(); Matrix res(n); for(int i=0;i using F2 = std::function; template > struct SegmentTree{ SegmentTree(T u, F f = F()){ size = 1; while(size < N){ size <<= 1; } unit = u; func = f; init(); } void init(){ for(int i=1;i<=2*size-1;++i){ data[i] = {{1, 0, 0, 0}, {0, 0, 0, 1}, {0, 0, 0, 1}, {0, 0, 0, 1}}; } } void update(int k, T v){ k += size; data[k] = v; while(k > 1){ k >>= 1; data[k] = func(data[k*2], data[k*2+1]); } } inline T query(int l, int r){ return _query(l, r, 1, 0, size); } T _query(int a, int b, int k, int l, int r){ if(b <= l || r <= a){return unit;} if(a <= l && r <= b){return data[k];} int mid = (l + r) >> 1; return func(_query(a, b, 2*k, l, mid), _query(a, b, 2*k+1, mid, r )); } T unit, data[N*4]; int size; F func; }; SegmentTree, 100100, F2>> segtree({{1, 0, 0, 0}, {0, 1, 0, 0}, {0, 0, 1, 0}, {0, 0, 0, 1}}, sandwich(tottori::mult)); ll xs[100100], ys[100100]; void update(int i){ Matrix mat = {{1, 0, xs[i], 0}, {0, ys[i], 0, 1}, {0, ys[i] * 2 % MOD, ys[i] * ys[i] % MOD, 1}, {0, 0, 0, 1}}; segtree.update(i, mat); } int main(){ std::cin.tie(nullptr); std::ios::sync_with_stdio(false); int N; std::cin >> N; int Q; std::cin >> Q; for(int i=0;i> c; if(c == 'x'){ int i, v; std::cin >> i >> v; xs[i] = v; update(i); }else if(c == 'y'){ int i, v; std::cin >> i >> v; ys[i] = v; update(i); }else{ int i; std::cin >> i; int ai = 0; if(i == 0){ ai = 1; }else{ Matrix coefficientMatrix = segtree.query(0, i); // auto f = [](const Matrix& mat){ // int n = mat.size(), m = mat[0].size(); // for(int i=0;i