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