2 5 10
2 2
1 1
1 4
2 1
1 2
1 5
2 4
2 5
1 3
2 3
 2 2 2
1 1
2 2
 3 3 9
1 1
1 2
1 3
2 1
2 2
2 3
3 1
3 2
3 3
 7 5 35
5 3
3 5
1 1
2 5
6 4
7 2
5 1
3 4
6 5
7 3
4 1
2 2
4 2
2 4
4 3
3 3
6 1
1 2
4 5
1 3
2 1
5 5
7 5
7 1
6 2
1 4
1 5
3 2
4 4
5 2
2 3
6 3
7 4
5 4
3 1
 1 5 4
1 1
1 2
1 4
1 5
 1 1 1
1 1
 5 7 21
4 4
4 5
5 5
5 6
5 7
5 1
5 2
4 2
3 2
3 1
3 7
3 6
2 6
1 6
1 7
1 1
1 2
1 3
1 4
2 4
3 4
 2 1 1
1 1
 2 2 4
2 1
1 1
1 2
2 2
 3000 3000 1
2222 738
 5 7 35
1 2
2 3
5 1
5 7
4 4
5 3
3 1
2 6
4 5
2 7
4 1
2 1
2 2
1 7
5 6
3 6
4 6
1 6
1 1
3 3
3 4
4 2
2 5
5 5
3 5
2 4
1 5
1 3
4 3
5 4
1 4
3 7
4 7
3 2
5 2
 5 4 1
4 1
 3 4 12
2 3
3 2
2 2
2 1
1 2
3 1
1 4
1 3
3 3
2 4
3 4
1 1
 3 3 3
1 1
2 2
3 3

8
 1
 6
 26
 4
 0
 20
 0
 2
 1
 28
 1
 9
 3

#include <bits/stdc++.h>
int par[10000001], rank[10000001];
bool map[3001][6001];
int dx[8] = {1, 1, 0, -1, -1, -1, 0, 1}, dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};
int root(int n) {
  if (par[n] == n) return n;
  return par[n] = root(par[n]);
}
bool same(int a, int b) { return root(a) == root(b); }
void unite(int a, int b) {
  int ra = root(a), rb = root(b);
  if (ra != rb) {
    if (rank[ra] < rank[rb])
      par[ra] = rb;
    else if (rank[ra] > rank[rb])
      par[rb] = ra;
    else {
      par[ra] = rb;
      rank[rb]++;
    }
  }
}
bool check(int x, int y, int n, int m) {
  for (int i = 0; i <= 7; i++) {
    for (int j = 0; j <= 7; j++) {
      int tx1 = x + dx[i], ty1 = y + dy[i];
      int tx2 = x + dx[j], ty2 = y + dy[j] + m / 2;
      if (tx1 >= 0 && tx1 < n && ty1 >= 0 && ty1 < m && tx2 >= 0 && tx2 < n &&
          ty2 >= 0 && ty2 < m && map[tx1][ty1] && map[tx2][ty2] &&
          same(tx1 * m + ty1, tx2 * m + ty2)) {
        printf("(1)");
        printf("%d %d %d %d\n", tx1 + 1, ty1 + 1, tx2 + 1, ty2 + 1);
        return false;
      }
    }
  }
  return true;
}
int main() {
  int n, m, k, x, y, cnt;
  while (scanf("%d%d%d", &n, &m, &k) == 3) {
    m *= 2;
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) map[i][j] = false;
    }
    for (int i = 0; i < n * m; i++) {
      par[i] = i;
      rank[i] = 1;
    }
    cnt = 0;
    while (k--) {
      scanf("%d%d", &x, &y);
      x--;
      y--;
      if (m == 1) continue;
      if (map[x][y]) continue;
      if (check(x, y, n, m)) {
        cnt++;
        map[x][y] = true;
        map[x][y + m / 2] = true;
        for (int i = 0; i < 8; i++) {
          int tx = x + dx[i], ty = y + dy[i];
          if (tx >= 0 && tx < n && ty >= 0 && ty < m && map[tx][ty])
            unite(x * m + y, tx * m + ty);
          ty += m / 2;
          if (tx >= 0 && tx < n && ty >= 0 && ty < m && map[tx][ty])
            unite(x * m + y + m / 2, tx * m + ty);
        }
      }
    }
    printf("%d\n", cnt);
  }
}
