#include <bits/stdc++.h>
using namespace std;
bool MAP[1010][1010];
int n, m, k;
int Check(int r, int c) {
  return (MAP[r][c] + MAP[r + 1][c] + MAP[r][c + 1] + MAP[r + 1][c + 1]) / 4;
}
int main() {
  int i, r, c;
  scanf("%d%d%d", &n, &m, &k);
  for (i = 1; i <= k; i++) {
    scanf("%d%d", &r, &c);
    MAP[r][c] = true;
    if (Check(r - 1, c - 1) + Check(r, c - 1) + Check(r - 1, c) + Check(r, c) >
        0) {
      printf("%d\n", i);
      return 0;
    }
  }
  printf("0\n");
  return 0;
}
