import java.io.IOException; import java.io.PrintWriter; import java.util.Arrays; import java.util.Scanner; class Main { public static void main(String[] args) throws IOException { new Main().run(); } void run() { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int q = sc.nextInt(); Seg seg = new Seg(n); PrintWriter pw=new PrintWriter(System.out); for (int z = 0; z < q; ++z) { String s = sc.next(); int i = sc.nextInt(); if (s.equals("x")) { long x = sc.nextLong(); seg.setX(x, i); } else if (s.equals("y")) { long y = sc.nextLong(); seg.setY(y, i); } else if (s.equals("a")) { pw.println(seg.query(i)[0][0]); } } pw.close(); } final long MODULO = 1_000_000_000 + 7; class Seg { int n; long[][][] v; public Seg(int n_) { n = 1; while (n < n_) n *= 2; v = new long[2 * n - 1][][]; for (int i = 0; i < v.length; ++i) { v[i] = new long[][] { { 1, 0, 0, 0 }, { 0, 0, 0, 1 }, { 0, 0, 0, 1 }, { 0, 0, 0, 1 } }; } } void setX(long x, int k) { k += n - 1; v[k][0][2] = x; while (k > 0) { k = (k - 1) / 2; v[k] = mul(v[2 * k + 2], v[2 * k + 1]); } } void setY(long y, int k) { k += n - 1; v[k][1][1] = y; v[k][2][1] = 2 * y % MODULO; v[k][2][2] = y * y % MODULO; while (k > 0) { k = (k - 1) / 2; v[k] = mul(v[2 * k + 2], v[2 * k + 1]); } } long[][] query(int i) { long[][] a = query(0, i, 0, n, 0); long[][] f = { { 1 }, { 1 }, { 1 }, { 1 } }; return mul(a, f); } long[][] query(int a, int b, int l, int r, int k) { if (b <= l || r <= a) { return new long[][] { { 1, 0, 0, 0 }, { 0, 1, 0, 0 }, { 0, 0, 1, 0 }, { 0, 0, 0, 1 } }; } else if (a <= l && r <= b) { return v[k]; } else { long[][] vl = query(a, b, l, (l + r) / 2, 2 * k + 1); long[][] vr = query(a, b, (l + r) / 2, r, 2 * k + 2); return mul(vr, vl); } } } long[][] mul(long[][] a, long[][] b) { long[][] ret = new long[a.length][b[0].length]; for (int i = 0; i < a.length; ++i) { for (int k = 0; k < a[i].length; ++k) { for (int j = 0; j < b[k].length; ++j) { ret[i][j] = (ret[i][j] + a[i][k] * b[k][j] % MODULO) % MODULO; } } } return ret; } void tr(Object... objects) { System.out.println(Arrays.deepToString(objects)); } }