#include <iostream>
#include <vector>
#include <queue>
using namespace std;

const int N = 1e3 + 10;
bool st[N][N];
int g[N][N];
int dx[4] = {-2, -2, 2, 2};
int dy[4] = {-2, 2, -2, 2};
int fx[4] = {-1, -1, 1, 1};
int fy[4] = {-1, 1, -1, 1};
int main() {
    int n, m;
    cin >> n >> m;
    int k;
    cin >> k;
    for (int i = 0; i < k; i++) {
        int x, y;
        cin >> x >> y;
        g[x][y] = -1;
    }
    int sx, sy, ex, ey;
    cin >> sx >> sy >> ex >> ey;
    queue<pair<int, int>> que;
    que.push({sx, sy});
    st[sx][sy] = true;
    while (!que.empty()) {
        auto t = que.front();
        if (t.first == ex && t.second == ey) {
            break;
        }
        que.pop();
        for (int i = 0; i < 4; i++) {
            int nx = t.first + dx[i];
            int ny = t.second + dy[i];
            int cx = t.first +  fx[i];
            int cy = t.second + fy[i];
            if (nx >= 1 && nx <= n && ny >= 1 && ny <= m && !st[nx][ny] &&
                    g[cx][cy] != -1) {
                que.push({nx, ny});
                st[nx][ny] = true;  
                g[nx][ny] = g[t.first][t.second] + 1;
            }
        }
    }
    if (g[ex][ey] == 0) cout << -1;
    else cout << g[ex][ey];
}