description: Kawasiro Nitori is excellent in engineering. Thus she has been appointed to help maintain trains.
  
  There are n models of trains, and Nitori's department will only have at most one train of each model at any moment. In the beginning, there are no trains, at each of the following m days, one train will be added, or one train will be removed. When a train of model i is added at day t, it works for x_i days (day t inclusive), then it is in maintenance for y_i days, then in work for x_i days again, and so on until it is removed.
  
  In order to make management easier, Nitori wants you to help her calculate how many trains are in maintenance in each day.
  
  On a day a train is removed, it is not counted as in maintenance.
  
  Input
  
  The first line contains two integers n, m (1 ≤ n,m ≤ 2 ⋅ 10^5).
  
  The i-th of the next n lines contains two integers x_i,y_i (1 ≤ x_i,y_i ≤ 10^9).
  
  Each of the next m lines contains two integers op, k (1 ≤ k ≤ n, op = 1 or op = 2). If op=1, it means this day's a train of model k is added, otherwise the train of model k is removed. It is guaranteed that when a train of model x is added, there is no train of the same model in the department, and when a train of model x is removed, there is such a train in the department.
  
  Output
  
  Print m lines, The i-th of these lines contains one integers, denoting the number of trains in maintenance in the i-th day.
  
  Examples
  
  Input
  
  
  3 4
  10 15
  12 10
  1 1
  1 3
  1 1
  2 1
  2 3
  
  
  Output
  
  
  0
  1
  0
  0
  
  
  Input
  
  
  5 4
  1 1
  10000000 100000000
  998244353 1
  2 1
  1 2
  1 5
  2 5
  1 5
  1 1
  
  
  Output
  
  
  0
  0
  0
  1
  
  Note
  
  Consider the first example:
  
  The first day: Nitori adds a train of model 3. Only a train of model 3 is running and no train is in maintenance.
  
  The second day: Nitori adds a train of model 1. A train of model 1 is running and a train of model 3 is in maintenance.
  
  The third day: Nitori removes a train of model 1. The situation is the same as the first day.
  
  The fourth day: Nitori removes a train of model 3. There are no trains at all.
solution: import java.io.BufferedReader;
  import java.io.IOException;
  import java.io.InputStreamReader;
  import java.io.PrintWriter;
  import java.util.Arrays;
  import java.util.Random;
  import java.util.StringTokenizer;
  
  public class C {
  	static int SQRT=450;
  //	static int SQRT=2;
  
  	public static void main(String[] args) {
  		FastScanner fs=new FastScanner();
  		PrintWriter out=new PrintWriter(System.out);
  		int nTypes=fs.nextInt();
  		int nQueries=fs.nextInt();
  		int[] as=new int[nTypes], bs=new int[nTypes];
  		for (int i=0; i<nTypes; i++) {
  			as[i]=fs.nextInt();
  			bs[i]=fs.nextInt();
  		}
  		int[] deltas=new int[nQueries];
  		//modVal, curMod = offset
  		int[][] smallOffset=new int[SQRT][SQRT];
  		int[] initiallyAddedAt=new int[nTypes];
  		int sum=0;
  		int nAlive=0;
  		for (int qq=0; qq<nQueries; qq++) {
  			int multiplier=fs.nextInt()==1?1:-1;
  			int type=fs.nextInt()-1;
  			nAlive+=multiplier;
  			int a=as[type], b=bs[type];
  			int mod=a+b;
  			int startVal=qq;
  			if (multiplier==-1)
  				startVal=initiallyAddedAt[type];
  			else
  				initiallyAddedAt[type]=qq;
  			
  			if (mod<SQRT) {
  				int curVal=startVal%mod;
  				for (int i=0; i<a; i++) {
  					smallOffset[mod][curVal]+=multiplier;
  					curVal=curVal==mod-1?0:curVal+1;
  				}	
  				
  			}
  			else {
  				if (multiplier==-1 && (qq-startVal)%mod!=0 && (qq-startVal)%mod<=a) {
  					sum--;
  //					System.out.println("Subtracting from sum");
  				}
  //				else {
  //					System.out.println(multiplier+" "+qq+" "+startVal+" "+mod+" "+a);
  //				}
  				for (int start=startVal; start<nQueries; start+=mod) {
  					deltas[start]+=multiplier;
  					if (start+a<nQueries) deltas[start+a]-=multiplier;
  				}
  			}
  			sum+=deltas[qq];
  //			System.out.println("Deltas "+Arrays.toString(deltas)+" "+sum);
  			int curAns=sum;
  			for (mod=2; mod<SQRT; mod++) {
  				curAns+=smallOffset[mod][qq%mod];
  			}
  			out.println(nAlive-curAns);
  		}
  		out.close();
  	}
  	static class Pair {
  		int x, y;
  		public Pair(int x, int y) {
  				this.x=x;
  				this.y=y;
  		}
  	}
  
  	static final Random random=new Random();
  	
  	static void ruffleSort(int[] a) {
  		int n=a.length;//shuffle, then sort 
  		for (int i=0; i<n; i++) {
  			int oi=random.nextInt(n), temp=a[oi];
  			a[oi]=a[i]; a[i]=temp;
  		}
  		Arrays.sort(a);
  	}
  	
  	static class FastScanner {
  		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
  		StringTokenizer st=new StringTokenizer("");
  		String next() {
  			while (!st.hasMoreTokens())
  				try {
  					st=new StringTokenizer(br.readLine());
  				} catch (IOException e) {
  					e.printStackTrace();
  				}
  			return st.nextToken();
  		}
  		
  		int nextInt() {
  			return Integer.parseInt(next());
  		}
  		int[] readArray(int n) {
  			int[] a=new int[n];
  			for (int i=0; i<n; i++) a[i]=nextInt();
  			return a;
  		}
  		long nextLong() {
  			return Long.parseLong(next());
  		}
  	}
  
  	
  }
  