using System; namespace yukicoder { class Program { static void Main(string[] args) { int n = int.Parse(Console.ReadLine()); int q = int.Parse(Console.ReadLine()); long[] x = new long[n + 1]; long[] y = new long[n + 1]; long[] a = new long[n + 1]; long[] b = new long[n + 1]; a[0] = b[0] = 1; int s = 0; string[] query = new string[3]; for (int i = 0; i < q; i++) { query = Console.ReadLine().Split(' '); if (query[0] == "x") { x[int.Parse(query[1])] = int.Parse(query[2]); s = Math.Min(s, int.Parse(query[1])); } else if (query[0] == "y") { y[int.Parse(query[1])] = int.Parse(query[2]); s = Math.Min(s, int.Parse(query[1])); } else { int l = int.Parse(query[1]); for (int j = 0; j < l; j++) { if (s - 1 <= j) { a[j + 1] = (x[j] * b[j] % 1000000007L * b[j] + a[j]) % 1000000007L; b[j + 1] = (y[j] * b[j] + 1) % 1000000007L; s++; } } Console.WriteLine(a[l]); } } } } }