n = int(input()) q = int(input()) x = [0]*(n+1) y = [0]*(n+1) a = [1]*(n+1) b = [1]*(n+1) def refresh(flag=False): if flag: for i in range(1, n+1): b[i] = y[i-1]*b[i-1]+1 for i in range(1, n+1): a[i] = x[i-1]*b[i-1]**2 + a[i-1] flag = False for i in range(q): query = input().split() if query[0] == "a": refresh(flag) flag = False '''print(a) print(x) print(b) print(y)''' print(a[int(query[1])]%1000000007) elif query[0] == "x": x[int(query[1])] = int(query[2]) elif query[0] == "y": y[int(query[1])] = int(query[2]) flag = True