#include <bits/stdc++.h>
using namespace std;
long long n, m, k, a, b;
vector<pair<long long, long long> > cor;
map<pair<long long, long long>, long long> bla;
pair<long long, long long> up, down, lef, rig, dul, dur, ddl, ddr;
int main() {
  cin >> n >> m >> k;
  for (long long i = 0; i < k; i++) {
    cin >> a >> b;
    bla[make_pair(a, b)] = 1;
    up = make_pair(a, (b + 1));
    down = make_pair(a, (b - 1));
    rig = make_pair((a + 1), b);
    lef = make_pair((a - 1), b);
    dur = make_pair((a + 1), (b + 1));
    dul = make_pair((a - 1), (b + 1));
    ddr = make_pair((a + 1), (b - 1));
    ddl = make_pair((a - 1), (b - 1));
    if ((bla[up] && bla[rig] && bla[dur]) ||
        (bla[up] && bla[lef] && bla[dul]) ||
        (bla[down] && bla[rig] && bla[ddr]) ||
        (bla[down] && bla[lef] && bla[ddl])) {
      cout << (i + 1);
      return 0;
    }
  }
  cout << 0;
  return 0;
}
