#include <bits/stdc++.h>
using namespace std;
const int N = 1000 * 100 + 5;
long long pow(long long num, long long power) {
  if (power == 0) return 1;
  if (power == 1) return num;
  long long t = pow(num, power / 2);
  return power % 2 ? t * t * num : t * t;
}
int a[1005][1005], n, m, k, i, q, w, s;
int main() {
  cin >> n >> m >> k;
  for (i = 1; i <= k; i++) {
    cin >> q >> w;
    s++;
    a[q][w] = 1;
    if (a[q - 1][w] == 1 && a[q - 1][w - 1] == 1 && a[q][w - 1] == 1) {
      cout << s;
      return 0;
    }
    if (a[q - 1][w] == 1 && a[q - 1][w + 1] == 1 && a[q][w + 1] == 1) {
      cout << s;
      return 0;
    }
    if (a[q][w - 1] == 1 && a[q + 1][w - 1] == 1 && a[q + 1][w] == 1) {
      cout << s;
      return 0;
    }
    if (a[q][w + 1] == 1 && a[q + 1][w + 1] == 1 && a[q + 1][w] == 1) {
      cout << s;
      return 0;
    }
  }
  cout << '0';
  return 0;
}
