import com.sun.corba.se.internal.Interceptors.PIORB; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.StringTokenizer; /** * * @author cteam07 */ public class ith { public static int pole[][]; public static int count = 0; public static int now = 0; public static boolean started = false; /** * @param args the command line arguments */ public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); String line = br.readLine(); int x, y, n; int xco, yco; while(line != null) { StringTokenizer tk = new StringTokenizer(line); if(tk.hasMoreTokens()) { if(tk.countTokens() == 3) { try{ x = Integer.parseInt(tk.nextToken()); y = Integer.parseInt(tk.nextToken()); n = Integer.parseInt(tk.nextToken()); if(x == 0 && y == 0 && n == 0) { System.exit(0); } else { startTask(x, y, n); } } catch(Exception e) {} } else if(tk.countTokens() == 2 && started) { try { xco = Integer.parseInt(tk.nextToken()); yco = Integer.parseInt(tk.nextToken()); insertQ(xco, yco); } catch (Exception e) {} } } line = br.readLine(); } } public static void startTask(int x, int y, int n) { if(x < 1 || x > 20000 || y < 1 || y > 20000 || n < 0 || n > (x*y)) { //System.out.println("new task refused, invalid input"); return; } if(n == 0) { System.out.println(x*y); } started = true; pole = new int[x][y]; count = n; now = 0; } public static void insertQ(int x, int y) { if(x < 1 || x > pole.length || y < 1 || y > pole[0].length) { return; } now++; vyplnRadek(x-1); //debug(x-1, y-1); vyplnSloupec(y-1); //debug(x-1, y-1); vyplnLP(x-1, y-1); //debug(x-1, y-1); vyplnPL(x-1, y-1); //debug(x-1, y-1); if(count == now) { started = false; System.out.println(countFree()); } } public static int countFree() { int sum = 0; for(int i = 0; i < pocetR(); i++) { for(int j = 0; j < pocetS(); j++) { if(pole[i][j] == 0) sum ++; } } return sum; } public static void debug(int x, int y) { for(int i = 0; i < pole.length; i++) { for(int j = 0; j < pole[0].length; j++) { if((i == x) && (j == y)) { System.out.print(" X"); } else { System.out.print(" " + pole[i][j]); } } System.out.println(""); } System.out.println(""); } private static int pocetR() { return pole.length; } private static int pocetS() { return pole[0].length; } private static void vyplnLP(int x, int y) { int i = x-1; int j = y-1; for(; (i > -1&& j > -1); i--, j--) { pole[i][j] = 1; } i = x+1; j = y+1; for(; (i < pocetR() && j < pocetS()); i++, j++) { pole[i][j] = 1; } } private static void vyplnPL(int x, int y) { int i = x-1; int j = y+1; for(; (i > -1 && j < pocetS()); i--, j++) { pole[i][j] = 1; } i = x+1; j = y-1; for(; (i < pocetR() && j > -1); i++, j--) { pole[i][j] = 1; } } private static void vyplnRadek(int x) { for(int i = 0; i < pocetS(); i++) { pole[x][i] = 1; } } private static void vyplnSloupec(int y) { for(int i = 0; i < pocetR(); i++) { pole[i][y] = 1; } } }