import java.io.IOException;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.List;
import java.util.Queue;
import java.util.Scanner;
public class Main{
public static int n;
public static int m;
public static int ans;
public static void dfs(int x,int y,int fx,int fy,int [][] zhangai,int[][] biaoji) {
if(x<=0||x>n||y<=0||y>m||zhangai[x][y]==1||biaoji[x][y]!=0) {
}
else {
if(x==fx&&y==fy) {
ans++;
}
else
{
biaoji[x][y]=1;
dfs(x-1,y,fx,fy,zhangai,biaoji);
dfs(x,y-1,fx,fy,zhangai,biaoji);
dfs(x+1,y,fx,fy,zhangai,biaoji);
dfs(x,y+1,fx,fy,zhangai,biaoji);
biaoji[x][y]=0;
}
}
}
public static void main(String args[]) throws IOException {
Scanner in =new Scanner(System.in);
n=in.nextInt();
m=in.nextInt();
int t=in.nextInt();
int sx=in.nextInt();
int sy=in.nextInt();
int fx=in.nextInt();
int fy=in.nextInt();
int[][] zhangai=new int[n+1][m+1];
int[][] cishu=new int [n+1][m+1];
for(int i=0;i<t;i++) {
int tempx=in.nextInt();
int tempy=in.nextInt();
zhangai[tempx][tempy]=1;
}
ans=0;
dfs(sx,sy,fx,fy,zhangai,cishu);
System.out.println(ans);
}
}
|