import std.stdio, std.conv, std.math, std.string, std.range, std.array, std.algorithm; void main(){ auto buf = readln().strip().split().map!(to!int)().array; immutable N = buf[0]; immutable Q = buf[1]; immutable M = 2*N; auto map = new long[](M); foreach(immutable int t; 1 .. Q+1) { auto p = readln().strip().split(); immutable x = p[0].to!string(); immutable y = p[1].to!int(); immutable z = p[2].to!int(); if(x == "R") { map[(M-1-y+t) % M] += z; }else if(x == "L") { map[(y+t) % M] += z; }else if(x == "C") { long sum; foreach(immutable i; y+t .. z+t) sum += map[i%M]; foreach(immutable i; M-1-z+t+1 .. M-1-y+t+1) sum += map[i%M]; writeln(sum); } } }