#include <bits/stdc++.h>
using namespace std;
string to_string(string s) { return '"' + s + '"'; }
string to_string(char s) { return string(1, s); }
string to_string(const char *s) { return to_string((string)s); }
string to_string(bool b) { return (b ? "true" : "false"); }
template <typename A>
string to_string(A);
template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
template <typename A>
string to_string(A v) {
  bool f = 1;
  string r = "{";
  for (const auto &x : v) {
    if (!f) r += ", ";
    f = 0;
    r += to_string(x);
  }
  return r + "}";
}
void debug_out() { cout << endl; }
void show() { cout << endl; }
void pret() {
  cout << endl;
  exit(0);
}
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cout << " " << to_string(H);
  debug_out(T...);
}
template <typename Head, typename... Tail>
void show(Head H, Tail... T) {
  cout << H << " ";
  show(T...);
}
template <typename Head, typename... Tail>
void pret(Head H, Tail... T) {
  cout << H << " ";
  pret(T...);
}
const long long MOD = 1e9 + 7;
const long long maxn = 1000 + 10;
long long n, m, q;
bool a[maxn][maxn];
long long dp[maxn][maxn][2];
long long find(long long x, long long y, long long t) {
  long long &ans = dp[x][y][t];
  if (ans != -1) return ans;
  ans = 0;
  if (t == 0) {
    if (x + 1 > n) {
      ans = 0;
    } else
      ans = 1 + find(x + 1, y, 1 - t);
  } else {
    if (y + 1 > m)
      ans = 0;
    else
      ans = 1 + find(x, y + 1, 1 - t);
  }
  return ans;
}
long long leftt(long long x, long long y) {
  long long i = x, j = y;
  bool flag = 0;
  long long curr = 0, temp = 0;
  while (i >= 1 and j >= 1) {
    if (a[i][j]) break;
    curr++;
    if (!flag)
      j--;
    else
      i--;
    flag = 1 - flag;
  }
  flag = 0;
  i = x, j = y;
  while (i <= n and j <= m) {
    if (a[i][j]) break;
    temp++;
    if (!flag)
      i++;
    else
      j++;
    flag = 1 - flag;
  }
  return curr * temp;
}
long long upp(long long x, long long y) {
  long long i = x, j = y;
  bool flag = 0;
  long long curr = 0, temp = 0;
  while (i >= 1 and j >= 1) {
    if (a[i][j]) break;
    curr++;
    if (!flag)
      i--;
    else
      j--;
    flag = 1 - flag;
  }
  flag = 0;
  i = x, j = y;
  while (i <= n and j <= m) {
    if (a[i][j]) break;
    temp++;
    if (!flag)
      j++;
    else
      i++;
    flag = 1 - flag;
  }
  return curr * temp;
}
int32_t main() {
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  ;
  cin >> n >> m >> q;
  long long ans = 0;
  for (long long i = 1; i <= (long long)n; i++) {
    for (long long j = 1; j <= (long long)m; j++) {
      dp[i][j][0] = -1;
      dp[i][j][1] = -1;
    }
  }
  for (long long i = 1; i <= (long long)n; i++) {
    for (long long j = 1; j <= (long long)m; j++) {
      ans += find(i, j, 0ll);
      ans += find(i, j, 1ll);
      ans += 1;
    }
  }
  while (q--) {
    long long x, y;
    cin >> x >> y;
    long long flag = a[x][y];
    a[x][y] = 0;
    long long curr = leftt(x, y) + upp(x, y) - 1;
    if (flag) {
      ans += curr;
    } else {
      ans -= curr;
    }
    a[x][y] = 1 - flag;
    show(ans);
  }
  return 0;
}

### Prompt

Your task is to create a cpp solution to the following problem:

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

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
string to_string(string s) { return '"' + s + '"'; }
string to_string(char s) { return string(1, s); }
string to_string(const char *s) { return to_string((string)s); }
string to_string(bool b) { return (b ? "true" : "false"); }
template <typename A>
string to_string(A);
template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
template <typename A>
string to_string(A v) {
  bool f = 1;
  string r = "{";
  for (const auto &x : v) {
    if (!f) r += ", ";
    f = 0;
    r += to_string(x);
  }
  return r + "}";
}
void debug_out() { cout << endl; }
void show() { cout << endl; }
void pret() {
  cout << endl;
  exit(0);
}
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cout << " " << to_string(H);
  debug_out(T...);
}
template <typename Head, typename... Tail>
void show(Head H, Tail... T) {
  cout << H << " ";
  show(T...);
}
template <typename Head, typename... Tail>
void pret(Head H, Tail... T) {
  cout << H << " ";
  pret(T...);
}
const long long MOD = 1e9 + 7;
const long long maxn = 1000 + 10;
long long n, m, q;
bool a[maxn][maxn];
long long dp[maxn][maxn][2];
long long find(long long x, long long y, long long t) {
  long long &ans = dp[x][y][t];
  if (ans != -1) return ans;
  ans = 0;
  if (t == 0) {
    if (x + 1 > n) {
      ans = 0;
    } else
      ans = 1 + find(x + 1, y, 1 - t);
  } else {
    if (y + 1 > m)
      ans = 0;
    else
      ans = 1 + find(x, y + 1, 1 - t);
  }
  return ans;
}
long long leftt(long long x, long long y) {
  long long i = x, j = y;
  bool flag = 0;
  long long curr = 0, temp = 0;
  while (i >= 1 and j >= 1) {
    if (a[i][j]) break;
    curr++;
    if (!flag)
      j--;
    else
      i--;
    flag = 1 - flag;
  }
  flag = 0;
  i = x, j = y;
  while (i <= n and j <= m) {
    if (a[i][j]) break;
    temp++;
    if (!flag)
      i++;
    else
      j++;
    flag = 1 - flag;
  }
  return curr * temp;
}
long long upp(long long x, long long y) {
  long long i = x, j = y;
  bool flag = 0;
  long long curr = 0, temp = 0;
  while (i >= 1 and j >= 1) {
    if (a[i][j]) break;
    curr++;
    if (!flag)
      i--;
    else
      j--;
    flag = 1 - flag;
  }
  flag = 0;
  i = x, j = y;
  while (i <= n and j <= m) {
    if (a[i][j]) break;
    temp++;
    if (!flag)
      j++;
    else
      i++;
    flag = 1 - flag;
  }
  return curr * temp;
}
int32_t main() {
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  ;
  cin >> n >> m >> q;
  long long ans = 0;
  for (long long i = 1; i <= (long long)n; i++) {
    for (long long j = 1; j <= (long long)m; j++) {
      dp[i][j][0] = -1;
      dp[i][j][1] = -1;
    }
  }
  for (long long i = 1; i <= (long long)n; i++) {
    for (long long j = 1; j <= (long long)m; j++) {
      ans += find(i, j, 0ll);
      ans += find(i, j, 1ll);
      ans += 1;
    }
  }
  while (q--) {
    long long x, y;
    cin >> x >> y;
    long long flag = a[x][y];
    a[x][y] = 0;
    long long curr = leftt(x, y) + upp(x, y) - 1;
    if (flag) {
      ans += curr;
    } else {
      ans -= curr;
    }
    a[x][y] = 1 - flag;
    show(ans);
  }
  return 0;
}

```