#include <bits/stdc++.h>
using namespace std;
bool s[1001][1001];
bool judge(int x, int y) {
  if (s[x + 1][y] && s[x + 1][y + 1] && s[x][y + 1] ||
      s[x - 1][y] && s[x - 1][y + 1] && s[x][y + 1] ||
      s[x - 1][y] && s[x - 1][y - 1] && s[x][y - 1] ||
      s[x][y - 1] && s[x + 1][y - 1] && s[x + 1][y])
    return 1;
  else
    return 0;
}
int main() {
  memset(s, 0, sizeof(s));
  int n, m, i, k, l = 0, a, b;
  cin >> n >> m >> k;
  for (i = 1; i <= k; ++i) {
    cin >> a >> b;
    s[a][b] = 1;
    if (judge(a, b) && l == 0) l = i;
  }
  cout << l << "\n";
}
