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