#include <bits/stdc++.h>
using namespace std;
int n, m, k, i, x, y, ans, a[1001][1001] = {0};
int main() {
  std::ios::sync_with_stdio(false);
  cin >> n >> m >> k;
  for (ans = i = 0; i < k; i++) {
    cin >> x >> y;
    a[x - 1][y - 1] = 1;
    if (a[x - 1][y - 1] == 1 && a[x - 2][y - 1] == 1 && a[x - 2][y - 2] == 1 &&
            a[x - 1][y - 2] == 1 ||
        a[x - 1][y - 1] == 1 && a[x - 1][y] == 1 && a[x][y] == 1 &&
            a[x][y - 1] == 1 ||
        a[x - 1][y - 1] == 1 && a[x - 2][y - 1] == 1 && a[x - 2][y] == 1 &&
            a[x - 1][y] == 1 ||
        a[x - 1][y - 1] == 1 && a[x - 1][y - 2] == 1 && a[x][y - 1] == 1 &&
            a[x][y - 2] == 1)
      ans = i + 1;
    if (ans) break;
  }
  cout << ans << '\n';
}
