#include <bits/stdc++.h>
using namespace std;
int n, m, k, i, x, y, a[1002][1002];
int foo(int x, int y) {
  if (x < 1 || x > n || y < 1 || y > m) return 0;
  return a[x][y];
}
void Try(int xl, int xr, int yl, int yr, int step) {
  for (int i = xl; i <= xr; ++i)
    for (int j = yl; j <= yr; ++j) {
      int F = 0;
      F = foo(i, j) + foo(i, j + 1) + foo(i + 1, j) + foo(i + 1, j + 1);
      if (F == 4) {
        printf("%d\n", step);
        exit(0);
      }
    }
}
int main(int argc, const char *argv[]) {
  scanf("%d%d%d", &n, &m, &k);
  for (i = 1; i <= k; ++i) {
    scanf("%d%d", &x, &y);
    a[x][y] = 1;
    Try(x - 5, x + 5, y - 5, y + 5, i);
  }
  puts("0");
  return 0;
}
