#include <bits/stdc++.h>
using namespace std;
int mark[1005][1005];
int main() {
  memset(mark, 0, sizeof(mark));
  int n, m, k;
  cin >> n >> m >> k;
  int ans = 0;
  for (int i = 1; i <= k; i++) {
    int p, q;
    scanf("%d%d", &p, &q);
    mark[p][q] = 1;
    if (ans == 0) {
      if (mark[p][q] == 1 && mark[p + 1][q] == 1 && mark[p][q + 1] == 1 &&
          mark[p + 1][q + 1] == 1)
        ans = i;
      if (mark[p][q] == 1 && mark[p + 1][q] == 1 && mark[p][q - 1] == 1 &&
          mark[p + 1][q - 1] == 1)
        ans = i;
      if (mark[p][q] == 1 && mark[p - 1][q] == 1 && mark[p][q - 1] == 1 &&
          mark[p - 1][q - 1] == 1)
        ans = i;
      if (mark[p][q] == 1 && mark[p - 1][q] == 1 && mark[p][q + 1] == 1 &&
          mark[p - 1][q + 1] == 1)
        ans = i;
    }
  }
  cout << ans << endl;
}
