#include<bits/stdc++.h>
using namespace std;
struct p{
int x,y;
}w,r;
queue<p> q;
int n,m,t,sx,sy,fx,fy,a[10][10],ans;
int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};
bool vis[10][10];
void bfs(int i,int j){
w.x=i,w.y=j;
q.push(w);
vis[i][j]=1;
while(!q.empty()){
w=q.front();
q.pop();
for(int k=0;k<4;k++){
int xx=dx[k]+w.x;
int yy=dy[k]+w.y;
if(xx>=1&&xx<=n&&yy>=1&&yy<=m&&!vis[xx][yy]&&a[xx][yy]==0){
if(xx==fx&&yy==fy){
ans++;
continue;
}
vis[xx][yy]=1;
r.x=xx,r.y=yy;
q.push(r);
}
}
}
}
int main(){
cin>>n>>m>>t>>sx>>sy>>fx>>fy;
for(int i=1;i<=t;i++){
int x,y;
cin>>x>>y;
a[x][y]=1;
}
bfs(sx,sy);
cout<<ans;
return 0;
}
用了BFS,不知道哪错了