#include #include #include #include #include #include #define MAX(a , b) ((a) > (b) ? (a) : (b)) #define sqr(x) ((x) * (x)) #define mp make_pair typedef long long ll; using namespace std; const int maxn = 12; const int maxm = 400000; const int kr = 1; const int prime = 999997; struct ddd { int x,y; int step; }; struct node { int x,y; int next; }edge[maxm]; int head[prime],vec[maxn][2]; queue Q; int sx,sy,tx,ty,a,b,c,d,n,idx; void init() { memset(head,-1,sizeof(head)); idx = 0; return; } int ha(int x,int y) { return (((x << 15) ^ y) % prime + prime) % prime; } bool addedge(int key,int x,int y) { for(int i=head[key];i != -1;i=edge[i].next) { if(edge[i].x == x && edge[i].y == y) return false; } edge[idx].x = x; edge[idx].y = y; edge[idx].next = head[key]; head[key] = idx++; return true; } void read() { d = 0; scanf("%d %d %d %d",&sx,&sy,&tx,&ty); scanf("%d",&n); for(int i=0;i