def main(): MOD = 998244353 N, X = map(int, input().split()) R, B = 0, 0 rbrb, brbr = [1] + [0] * 4, [1] + [0] * 4 for i in range(X): c, v = input().split() v = int(v) if c == 'R': R += v rbrb[1] = (rbrb[1] + rbrb[0] * v) % MOD rbrb[3] = (rbrb[3] + rbrb[2] * v) % MOD brbr[2] = (brbr[2] + brbr[1] * v) % MOD brbr[4] = (brbr[4] + brbr[3] * v) % MOD else: B += v brbr[1] = (brbr[1] + brbr[0] * v) % MOD brbr[3] = (brbr[3] + brbr[2] * v) % MOD rbrb[2] = (rbrb[2] + rbrb[1] * v) % MOD rbrb[4] = (rbrb[4] + rbrb[3] * v) % MOD ans = 0 ans += rbrb[-1] * pow(R-1, -1, MOD) * pow(B-1, -1, MOD) % MOD ans += brbr[-1] * pow(R-1, -1, MOD) * pow(B-1, -1, MOD) % MOD ans += R * (R-2) * pow(24, -1, MOD) % MOD ans += B * (B-2) * pow(24, -1, MOD) % MOD print(ans % MOD) if __name__ == '__main__': main()