#include <bits/stdc++.h>
using namespace std;
int n, m, k;
int a[2001][2001];
bool check(int r, int f) {
  for (int i = r; i <= r + 2; i++) {
    for (int j = f; j <= f + 2; j++) {
      if ((a[i][j] == 1 && a[i + 1][j] == 1 && a[i][j + 1] == 1 &&
           a[i + 1][j + 1] == 1) ||
          (a[i][j] == 1 && a[i][j - 1] == 1 && a[i + 1][j] == 1 &&
           a[i + 1][j - 1] == 1) ||
          (a[i][j] == 1 && a[i - 1][j] == 1 && a[i - 1][j + 1] == 1 &&
           a[i][j + 1] == 1) ||
          (a[i][j] == 1 && a[i - 1][j] == 1 && a[i - 1][j - 1] == 1 &&
           a[i][j - 1] == 1))
        return 1;
      else
        return 0;
    }
  }
}
int main() {
  int cnt = 0;
  int val = 0;
  int n, m, k;
  int id1, id2;
  cin >> n >> m >> k;
  int vals;
  for (int i = 0; i < k; i++) {
    cin >> id1 >> id2;
    a[id1][id2] = 1;
    cnt++;
    vals = check(id1, id2);
    if (check(id1, id2) == 1) {
      val = cnt;
      break;
    }
  }
  if (vals == 0)
    cout << 0 << endl;
  else
    cout << val;
  return 0;
}
