description: You are given a matrix, consisting of n rows and m columns. The rows are numbered top to bottom, the columns are numbered left to right.
  
  Each cell of the matrix can be either free or locked.
  
  Let's call a path in the matrix a staircase if it: 
  
    * starts and ends in the free cell; 
    * visits only free cells; 
    * has one of the two following structures: 
      1. the second cell is 1 to the right from the first one, the third cell is 1 to the bottom from the second one, the fourth cell is 1 to the right from the third one, and so on; 
      2. the second cell is 1 to the bottom from the first one, the third cell is 1 to the right from the second one, the fourth cell is 1 to the bottom from the third one, and so on. 
  
  
  
  In particular, a path, consisting of a single cell, is considered to be a staircase.
  
  Here are some examples of staircases:
  
  <image>
  
  Initially all the cells of the matrix are free.
  
  You have to process q queries, each of them flips the state of a single cell. So, if a cell is currently free, it makes it locked, and if a cell is currently locked, it makes it free.
  
  Print the number of different staircases after each query. Two staircases are considered different if there exists such a cell that appears in one path and doesn't appear in the other path.
  
  Input
  
  The first line contains three integers n, m and q (1 ≤ n, m ≤ 1000; 1 ≤ q ≤ 10^4) — the sizes of the matrix and the number of queries.
  
  Each of the next q lines contains two integers x and y (1 ≤ x ≤ n; 1 ≤ y ≤ m) — the description of each query.
  
  Output
  
  Print q integers — the i-th value should be equal to the number of different staircases after i queries. Two staircases are considered different if there exists such a cell that appears in one path and doesn't appear in the other path.
  
  Examples
  
  Input
  
  
  2 2 8
  1 1
  1 1
  1 1
  2 2
  1 1
  1 2
  2 1
  1 1
  
  
  Output
  
  
  5
  10
  5
  2
  5
  3
  1
  0
  
  
  Input
  
  
  3 4 10
  1 4
  1 2
  2 3
  1 2
  2 3
  3 2
  1 3
  3 4
  1 3
  3 1
  
  
  Output
  
  
  49
  35
  24
  29
  49
  39
  31
  23
  29
  27
  
  
  Input
  
  
  1000 1000 2
  239 634
  239 634
  
  
  Output
  
  
  1332632508
  1333333000
solution: import java.io.BufferedReader;
  import java.io.IOException;
  import java.io.InputStreamReader;
  import java.io.PrintWriter;
  import java.util.*;
  
   
   
  public class Codeforces {
  	
  	static int mod=1000000007 ;
  	static int dx[]= {1,1,1,0,-1,-1,-1,0};
  	static int dy[]= {1,0,-1,-1,-1,0,1,1};
  	public static void main(String[] args) throws Exception {
  		// TODO Auto-generated method stub
  		PrintWriter out=new PrintWriter(System.out);
  	    FastScanner fs=new FastScanner();
  	    int t=1;
  	    
  	    outer:while(t-->0) {
  	    	int n=fs.nextInt(), m=fs.nextInt(),q=fs.nextInt();
  	    	char arr[][]=new char[n][m];
  	    	for(int i=0;i<n;i++) Arrays.fill(arr[i], '.');
  //	    	long ans=0;
  //	    	for(int i=0;i<n;i++) {
  //	    		for(int j=0;j<m;j++) {
  //	    			int r=i, c=j;
  //	    			boolean f=true;
  //	    			while(r<n&&c<m) {
  //	    				ans++;
  //	    				if(f) {
  //	    					c++;
  //	    				}
  //	    				else {
  //	    					r++;
  //	    				}
  //	    				f=!f;
  //	    			}
  //	    			r=i; c=j;
  //	    			
  //	    			f=true;
  //	    			while(r<n&&c<m) {
  //	    				if(f) r++;
  //	    				else c++;
  //	    				f=!f;
  //	    				ans++;
  //	    			}
  //	    			
  //	    			ans--;
  //	    		}
  //	    	}
  	    	long dummy=0;
  	    	long right[][]=new long[n+1][m+1];
  	    	long down[][]=new long[n+1][m+1];
  	    	for(int i=n-1;i>=0;i--) {
  	    		for(int j=m-1;j>=0;j--) {
  	    			if(j+1<m)
  	    			right[i][j]=1+down[i][j+1];
  	    			if(i+1<n)
  	    			down[i][j]=1+right[i+1][j];
  	    			dummy+= 1+ right[i][j]+down[i][j];
  	    		}
  	    	}
  //	    	System.out.println(ans==dummy);
  	    	long ans=dummy;
  	    	while(q-->0) {
  	    		int x=fs.nextInt()-1, y=fs.nextInt()-1;
  	    		
  	    		if(arr[x][y]=='.') {
  	    			long u=0, d=0;
  	    		    int r=x, c=y;
  	    		    boolean f=true;
  	    		    long t1=0, t2=0;
  	    		    while(r>=0&&c>=0&&arr[r][c]=='.') {
  	    		    	u++;
  	    		    	if(f) {
  	    		    		r--;
  	    		    		f=false;
  	    		    	}
  	    		    	else {
  	    		    		c--;
  	    		    		f=true;
  	    		    	}
  	    		    }
  	    		    r=x; c=y;
  	    		    f=true;
  	    		    while(r<n&&c<m&&arr[r][c]=='.') {
  	    		    	d++;
  	    		    	
  	    		    	if(f) {
  	    		    		c++;
  	    		    		f=false;
  	    		    	}
  	    		    	else {
  	    		    		r++;
  	    		    		f=true;
  	    		    	}
  	    		    
  	    		    }
  	    		    ans-= u*d;
  	    		    u=0; d=0;
  	    		    r=x; c=y; f=true;
  	    		    while(r>=0&&c>=0&&arr[r][c]=='.') {
  	    		    	u++;
  	    		    	if(f) {
  	    		    		c--;
  	    		    		f=false;
  	    		    	}
  	    		    	else {
  	    		    		r--;
  	    		    		f=true;
  	    		    	}
  	    		    }
  	    		    r=x; c=y;
  	    		    f=true;
  	    		    while(r<n&&c<m&&arr[r][c]=='.') {
  	    		    	d++;
  	    		    	
  	    		    	if(f) {
  	    		    		r++;
  	    		    		f=false;
  	    		    	}
  	    		    	else {
  	    		    		c++;
  	    		    		f=true;
  	    		    	}
  	    		    
  	    		    }
  	    		    ans-= u*d;
  	    		    ans++;
  	    		    out.println(ans);
  	    		    arr[x][y]='x';
  	    		}
  	    		else {
  	    			arr[x][y]='.';
  	    			long u=0, d=0;
  	    		    int r=x, c=y;
  	    		    boolean f=true;
  	    		    while(r>=0&&c>=0&&arr[r][c]=='.') {
  	    		    	u++;
  	    		    	if(f) {
  	    		    		r--;
  	    		    		f=false;
  	    		    	}
  	    		    	else {
  	    		    		c--;
  	    		    		f=true;
  	    		    	}
  	    		    }
  	    		    r=x; c=y;
  	    		    f=true;
  	    		    while(r<n&&c<m&&arr[r][c]=='.') {
  	    		    	d++;
  	    		    	
  	    		    	if(f) {
  	    		    		c++;
  	    		    		f=false;
  	    		    	}
  	    		    	else {
  	    		    		r++;
  	    		    		f=true;
  	    		    	}
  	    		    
  	    		    }
  	    		    ans+= u*d;
  	    		    u=0; d=0;
  	    		    r=x; c=y; f=true;
  	    		    while(r>=0&&c>=0&&arr[r][c]=='.') {
  	    		    	u++;
  	    		    	if(f) {
  	    		    		c--;
  	    		    		f=false;
  	    		    	}
  	    		    	else {
  	    		    		r--;
  	    		    		f=true;
  	    		    	}
  	    		    }
  	    		    r=x; c=y;
  	    		    f=true;
  	    		    while(r<n&&c<m&&arr[r][c]=='.') {
  	    		    	d++;
  	    		    	
  	    		    	if(f) {
  	    		    		r++;
  	    		    		f=false;
  	    		    	}
  	    		    	else {
  	    		    		c++;
  	    		    		f=true;
  	    		    	}
  	    		    
  	    		    }
  	    		    ans+= u*d;
  	    		    ans--;
  	    		    out.println(ans);
  	    		}
  	    	}
  	    }
  	    
  		out.close();
  	}
      
  	static long pow(long a,long b) {
  		if(b<0) return 1;
  		long res=1;
  		while(b!=0) {
  			if((b&1)!=0) {
  				res*=a;
  				res%=mod;
  			}
  			a*=a;
  			a%=mod;
  			b=b>>1;
  		}
  		return res;
  	}
  	static long gcd(long  a,long  b) {
  		if(b==0) return a;
  		return gcd(b,a%b);
  	}
  	static long nck(int n,int k) {
  		if(k>n) return 0;
  		long res=1;
  		res*=fact(n);
  		res%=mod;
  		res*=modInv(fact(k));
  		res%=mod;
  		res*=modInv(fact(n-k)); 
  		res%=mod;
  		return res;
  	}
  	static long fact(long n) {
  //		return fact[(int)n];
  		long res=1;
  		for(int i=2;i<=n;i++) {
  			res*=i;
  			res%=mod;
  		}
  		return res;
  	}
  	
  	static long modInv(long n) {
  		return pow(n,mod-2);
  	}
  	
  	static void sort(int[] a) {
  		//suffle
  		int n=a.length;
  		Random r=new Random();
  		for (int i=0; i<a.length; i++) {
  			int oi=r.nextInt(n);
  			int temp=a[i];
  			a[i]=a[oi];
  			a[oi]=temp;
  		}
  		
  		//then sort
  		Arrays.sort(a);
  	}
  	
  	// Use this to input code since it is faster than a Scanner
  	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());
  		}
  		long[] lreadArray(int n) {
  			long a[]=new long[n];
  			for(int i=0;i<n;i++) a[i]=nextLong();
  			return a;
  		}
  		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());
  		}
  	}
   
  }