#include <bits/stdc++.h>
using namespace std;
bool a[1010][1010];
int n, m, k;
bool square(int x, int y) {
  return a[x][y] && a[x + 1][y] && a[x][y + 1] && a[x + 1][y + 1];
}
bool check(int x, int y) {
  if (square(x, y)) return true;
  if (square(x - 1, y)) return true;
  if (square(x, y - 1)) return true;
  if (square(x - 1, y - 1)) return true;
  return false;
}
int main() {
  int x, y;
  cin >> n >> m >> k;
  for (int i = 1; i <= k; i++) {
    cin >> x >> y;
    a[x][y] = true;
    if (check(x, y)) {
      cout << i;
      return 0;
    }
  }
  cout << 0;
  return 0;
}
