#include <bits/stdc++.h>
using namespace std;
vector<vector<int>> dx = {{-1, 0, -1}, {1, 0, 1}, {1, 1, 0}, {-1, -1, 0}};
vector<vector<int>> dy = {{-1, -1, 0}, {-1, -1, 0}, {1, 0, 1}, {1, 0, 1}};
vector<vector<bool>> graph;
bool check(int a, int b, int n, int m) {
  int counter = 0;
  for (int i = 0; i < 4; i++) {
    counter = 0;
    for (int j = 0; j < 3; ++j) {
      if (a + dx[i][j] > 0 && a + dx[i][j] <= n && b + dy[i][j] > 0 &&
          b + dy[i][j] <= m) {
        if (graph[a + dx[i][j]][b + dy[i][j]]) counter++;
      }
    }
    if (counter == 3) break;
  }
  return counter == 3;
}
int main() {
  int n, m, k;
  cin >> n >> m >> k;
  graph.resize(n + 1);
  for (int i = 1; i <= n; ++i) {
    graph[i].resize(m + 1);
    for (int j = 1; j <= m; ++j) {
      graph[i][j] = false;
    }
  }
  int index = 0;
  for (int i = 1; i <= k; ++i) {
    int a, b;
    cin >> a >> b;
    graph[a][b] = true;
    if (check(a, b, n, m)) {
      index = i;
      break;
    }
  }
  cout << index << '\n';
}
