Problem: Note that the difference between easy and hard versions is that in hard version unavailable cells can become available again and in easy version can't. You can make hacks only if all versions are solved.

Ildar and Ivan are tired of chess, but they really like the chessboard, so they invented a new game. The field is a chessboard 2n × 2m: it has 2n rows, 2m columns, and the cell in row i and column j is colored white if i+j is even, and is colored black otherwise.

The game proceeds as follows: Ildar marks some of the white cells of the chessboard as unavailable, and asks Ivan to place n × m kings on the remaining white cells in such way, so that there are no kings attacking each other. A king can attack another king if they are located in the adjacent cells, sharing an edge or a corner.

Ildar would like to explore different combinations of cells. Initially all cells are marked as available, and then he has q queries. In each query he marks a cell as unavailable. After each query he would like to know whether it is possible to place the kings on the available cells in a desired way. Please help him!

Input

The first line of input contains three integers n, m, q (1 ≤ n, m, q ≤ 200 000) — the size of the board and the number of queries.

q lines follow, each of them contains a description of a query: two integers i and j, denoting a white cell (i, j) on the board (1 ≤ i ≤ 2n, 1 ≤ j ≤ 2m, i + j is even) that becomes unavailable. It's guaranteed, that each cell (i, j) appears in input at most once.

Output

Output q lines, i-th line should contain answer for a board after i queries of Ildar. This line should contain "YES" if it is possible to place the kings on the available cells in the desired way, or "NO" otherwise.

Examples

Input


1 3 3
1 1
1 5
2 4


Output


YES
YES
NO


Input


3 2 7
4 2
6 4
1 3
2 2
2 4
4 4
3 1


Output


YES
YES
NO
NO
NO
NO
NO

Note

In the first example case after the second query only cells (1, 1) and (1, 5) are unavailable. Then Ivan can place three kings on cells (2, 2), (2, 4) and (2, 6).

After the third query three cells (1, 1), (1, 5) and (2, 4) are unavailable, so there remain only 3 available cells: (2, 2), (1, 3) and (2, 6). Ivan can not put 3 kings on those cells, because kings on cells (2, 2) and (1, 3) attack each other, since these cells share a corner.

Solution (in CPP):

Solution:
#include <bits/stdc++.h>
using namespace std;
const int st_size = 2000005, maxn = 200005;
int cur_state = 1, mn[st_size], mx[st_size], arr[2 * maxn], state[2 * maxn],
    ans[2 * maxn], ep, n, m, q;
pair<int, int> maxp[2 * maxn], minp[2 * maxn];
vector<pair<int, int> > point[st_size];
map<pair<int, int>, int> event;
void update_max(int i, int l, int r, int pos, int val) {
  if (l > pos or pos > r) return;
  if (l == r) {
    mx[i] = val;
  } else {
    int mid = (l + r) / 2;
    update_max(2 * i, l, mid, pos, val);
    update_max(2 * i + 1, mid + 1, r, pos, val);
    mx[i] = max(mx[2 * i], mx[2 * i + 1]);
  }
}
void update_min(int i, int l, int r, int pos, int val) {
  if (l > pos or pos > r) return;
  if (l == r) {
    mn[i] = val;
  } else {
    int mid = (l + r) / 2;
    update_min(2 * i, l, mid, pos, val);
    update_min(2 * i + 1, mid + 1, r, pos, val);
    mn[i] = min(mn[2 * i], mn[2 * i + 1]);
  }
}
int get_max(int i, int l, int r, int ll, int rr) {
  if (l > rr or ll > r) return INT_MIN;
  if (ll <= l and r <= rr) {
    return mx[i];
  } else {
    int mid = (l + r) / 2;
    return max(get_max(2 * i, l, mid, ll, rr),
               get_max(2 * i + 1, mid + 1, r, ll, rr));
  }
}
int get_min(int i, int l, int r, int ll, int rr) {
  if (l > rr or ll > r) return INT_MAX;
  if (ll <= l and r <= rr) {
    return mn[i];
  } else {
    int mid = (l + r) / 2;
    return min(get_min(2 * i, l, mid, ll, rr),
               get_min(2 * i + 1, mid + 1, r, ll, rr));
  }
}
void dfs(int i, int l, int r) {
  for (auto p : point[i]) {
    ep++;
    int x = p.first, y = p.second;
    state[ep] = cur_state;
    if (x & 1) {
      maxp[ep] = {-1, -1};
      minp[ep] = {x, arr[x]};
      arr[x] = min(arr[x], y);
      update_min(1, 1, 2 * n, x, arr[x]);
      if (get_max(1, 1, 2 * n, x + 1, 2 * n) > y) cur_state = 0;
    } else {
      maxp[ep] = {x, arr[x]};
      minp[ep] = {-1, -1};
      arr[x] = max(arr[x], y);
      update_max(1, 1, 2 * n, x, arr[x]);
      if (get_min(1, 1, 2 * n, 1, x - 1) < y) cur_state = 0;
    }
  }
  if (l == r) {
    ans[l] = cur_state;
  } else {
    int mid = (l + r) / 2;
    dfs(2 * i, l, mid);
    dfs(2 * i + 1, mid + 1, r);
  }
  for (auto p : point[i]) {
    cur_state = state[ep];
    if (maxp[ep].first != -1) {
      update_max(1, 1, 2 * n, maxp[ep].first, maxp[ep].second);
      arr[maxp[ep].first] = maxp[ep].second;
    }
    if (minp[ep].first != -1) {
      update_min(1, 1, 2 * n, minp[ep].first, minp[ep].second);
      arr[minp[ep].first] = minp[ep].second;
    }
    ep--;
  }
}
void add_query(int i, int l, int r, int ll, int rr, pair<int, int> p) {
  if (l > rr or ll > r) return;
  if (ll <= l and r <= rr)
    point[i].emplace_back(p);
  else {
    int mid = (l + r) / 2;
    add_query(2 * i, l, mid, ll, rr, p);
    add_query(2 * i + 1, mid + 1, r, ll, rr, p);
  }
}
signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  cin >> n >> m >> q;
  for (int i = 0; i < st_size; i++) {
    mx[i] = INT_MIN;
    mn[i] = INT_MAX;
  }
  for (int i = 0; i < 2 * maxn; i++) {
    arr[i] = (i & 1) ? INT_MAX : INT_MIN;
  }
  for (int i = 1; i <= q; i++) {
    int x, y;
    cin >> x >> y;
    if (!event.count({x, y}))
      event[{x, y}] = i;
    else {
      int j = event[{x, y}];
      event.erase({x, y});
      add_query(1, 1, q, j, i - 1, make_pair(x, y));
    }
  }
  for (auto lft : event) {
    int x = lft.first.first, y = lft.first.second, j = lft.second;
    add_query(1, 1, q, j, q, make_pair(x, y));
  }
  dfs(1, 1, q);
  for (int i = 1; i <= q; i++) cout << (ans[i] ? "YES" : "NO") << "\n";
}