#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n, m, k, i, j, a, b, c, xa, ya, xb, yb, xc, yc;
  while (scanf("%lld %lld %lld", &n, &m, &k) == 3) {
    long long ara[n + 5][m + 5], x, y, bra[k + 1][3];
    for (i = 0; i <= n + 1; i++)
      for (j = 0; j <= m + 1; j++) ara[i][j] = 0;
    a = 0;
    long long sak = k, p;
    for (p = 1, a = 0; p <= k; p++) {
      scanf("%lld %lld", &i, &j);
      ara[i][j] = 1;
      if (p >= 4 && a == 0) {
        if (ara[i - 1][j] == 1 && ara[i - 1][j - 1] == 1 &&
            ara[i][j - 1] == 1) {
          a = p;
        } else if (ara[i - 1][j] == 1 && ara[i - 1][j + 1] == 1 &&
                   ara[i][j + 1] == 1) {
          a = p;
        } else if (ara[i][j + 1] == 1 && ara[i + 1][j + 1] == 1 &&
                   ara[i + 1][j] == 1) {
          a = p;
        } else if (ara[i][j - 1] == 1 && ara[i + 1][j - 1] == 1 &&
                   ara[i + 1][j] == 1) {
          a = p;
        }
      }
    }
    printf("%lld\n", a);
  }
}
