//map用来存图,主要是兵的位置,step用来存步数
//很基础的bfs题,之前都是用数组模拟queue的,今天总算用队列做了一次,一遍过,嘿嘿
#include <bits/stdc++.h>
using namespace std;
int n,m;
int k;
int Map[1010][1010];
int step[1010][1010];
//第0行0列不使用
int sx,sy,ex,ey;
int dx[]={2,-2,2,-2};
int dy[]={2,-2,-2,2};
void bfs(){
queue<pair<int,int>>q;
q.push({sx,sy});
while(!q.empty()){
//取对头
pair<int, int> top_p = q.front();
q.pop();
//拓展队头
int x=top_p.first;
int y=top_p.second;
if(x==ex && y==ey){
cout<<step[x][y];
return ;
}
for(int i=0;i<4;i++){
int nx=dx[i]+x;
int ny=dy[i]+y;
if(nx>0 && ny>0 && nx<=n && ny<=m && step[nx][ny]==0 && Map[(nx+x)/2][(ny+y)/2]!=-1){
//象脚合法,拓展队尾
q.push({nx,ny});
step[nx][ny]=step[x][y]+1;
}
}
}
return ;
}
int main()
{
ios::sync_with_stdio(false);
cin.tie(0);
cin>>n>>m;
cin>>k;
for(int i=0;i<k;i++){
int x,y;
cin>>x>>y;
Map[x][y]=-1;
}
cin>>sx>>sy>>ex>>ey;
if(sx==ex && sy==ey){
//起点与终点相同时,做一个特判
cout<<0;
return 0;
}
bfs();
if(step[ex][ey]==0){
cout<<-1;
}
return 0;
}