#define _CRT_SECURE_NO_WARNINGS #include <stdio.h> #include <algorithm> #include <utility> #include <functional> #include <cstring> #include <queue> #include <stack> #include <math.h> #include <iterator> #include <vector> #include <string> #include <set> #include <math.h> #include <iostream> #include<map> #include <iomanip> #include <time.h> #include <stdlib.h> #include <list> #include <typeinfo> #include <list> #include <set> using namespace std; #define LONG_INF 10000000000000000 #define MAX_MOD 1000000007 #define REP(i,n) for(long long i = 0;i < n;++i) set<pair<long long, long long>> x; set<pair<long long, long long>> y; map<long long,long long> x_appear; map<long long,long long> y_appear; int main() { #define int long long long long n, query; cin >> n >> query; y.insert(make_pair(10000000, 0)); REP(test_case, query) { string s; cin >> s; if (s == "a") { long long a; cin >> a; auto xs = x.begin(); auto ys = y.begin(); long long ans = 1; long long back_b = 1; long long backed = 0; while (x.end() != xs&&y.end() != ys) { if (xs->first == ys->first) { if (xs->first <= a) { if (backed != ys->first - 1) { back_b = 1; } long long hoge = back_b*back_b; hoge %= MAX_MOD; hoge *= xs->second; hoge %= MAX_MOD; ans += hoge; ans %= MAX_MOD; backed = ys->first; back_b *= ys->second; back_b++; back_b %= MAX_MOD; xs++; ys++; } else break; } else if (xs->first < ys->first) { if (xs->first <= a) { back_b = 1; ans += xs->second; ans %= MAX_MOD; xs++; } else break; } else { if (ys->first <= a) { if (backed != ys->first - 1) { back_b = 1; } backed = ys->first; back_b *= ys->second; back_b++; back_b %= MAX_MOD; ys++; } else break; } } cout << ans%MAX_MOD << endl; } else if (s == "x") { int a, b; cin >> a >> b; if (x_appear[a] == 0) { x_appear[a] = 1; x.insert(make_pair(a+1, b)); } else { for (auto i = x.begin();i != x.end();++i) { int hoge = i -> first; if (hoge == a+1) { x.erase(i); x.insert(make_pair(a+1, b)); break; } } } } else { //s == "y" int a, b; cin >> a >> b; if (y_appear[a] == 0) { y_appear[a] = 1; y.insert(make_pair(a+1, b)); } else { for (auto i = y.begin();i != y.end();++i) { int hoge = i->first; if (hoge == a+1) { y.erase(i); y.insert(make_pair(a+1, b)); break; } } } } } }