import java.util.Scanner; public class SegmentFishing { /** * @param args */ public static void main(String[] args) throws Exception{ int N = NI(); int Q = NI(); long[][] seg = new long[N][2]; StringBuilder sb=new StringBuilder(); while(Q-->0){ char c = NC(); int y = NI(); int z = NI(); if(c=='L'){ seg[y][1]+=z; } else if(c=='R'){ seg[y][0]+=z; } else { long sum =0; for (int i = y; i < z; i++) { sum += seg[i][0]+seg[i][1]; } /* for (int i = 0; i < 2; i++) { for (int j = 0; j < seg.length; j++) { System.out.print(seg[j][i]+" "); } System.out.println(); } System.out.println(sum); */ sb.append(sum); sb.append('\n'); } move(seg); } System.out.print(sb); } static void move(long[][] seg){ long right = seg[seg.length-1][0]; long left = seg[0][1]; // right for (int i = seg.length-2; i >= 0; i--) { seg[i+1][0] = seg[i][0]; } // left for (int i = 1;i