#include <cstdio>
#include <cstring>
#include <vector>
#include <queue>
#include <algorithm>

using namespace std;
typedef pair<int,int> P;
int w,h,n;
int fie[101][101];
int dist[101][101];
int ix,iy,ox,oy;
int dx[4]={1,0,-1,0};
int dy[4]={0,-1,0,1};

int bfs(){
	queue<P> que;
	memset(dist,-1,sizeof(dist));
	que.push(P(ix,iy));
	dist[iy][ix]=0;
	while(que.size()){
		P q=que.front();
		que.pop();
		for(int i=0;i<4;i++){
			int nx=q.first+dx[i],ny=q.second+dy[i];
			if(fie[ny][nx]==0){
				nx+=dx[i];
				ny+=dy[i];
				if(dist[ny][nx]!=-1)continue;
				dist[ny][nx]=dist[q.second][q.first]+1;
				que.push(P(nx,ny));
			}
		}
	}
	return dist[oy][ox];
}

int main(void){
	scanf("%d %d %d",&w,&h,&n);
	w*=2;
	h*=2;
	for(int i=0;i<=h;i++){
		fie[i][0]=1;
		fie[i][w]=1;
	}
	for(int i=0;i<=w;i++){
		fie[0][i]=1;
		fie[h][i]=1;
	}
	for(int i=0;i<n;i++){
		int sx,sy,ddx,ddy;
		scanf("%d %d %d %d",&sx,&sy,&ddx,&ddy);
		if(sx>ddx)swap(sx,ddx);
		if(sy>ddy)swap(sy,ddy);
		sx*=2;
		sy*=2;
		ddx*=2;
		ddy*=2;
		for(int j=sx;j<=ddx;j++){
			fie[ddy][j]=1;
			fie[sy][j]=1;
		}
		for(int j=sy;j<=ddy;j++){
			fie[j][ddx]=1;
			fie[j][sx]=1;
		}
	}
	scanf("%d%d",&ix,&iy);
	scanf("%d%d",&ox,&oy);
	ix=ix*2+1;
	iy=iy*2+1;
	ox=ox*2+1;
	oy=oy*2+1;
	int prev=bfs();
	int res=prev;
	for(int i=1;i<h;i+=2){
		for(int j=0;j<w;j+=2){
			if(fie[i][j]==0){
				fie[i][j]=1;
				int di=bfs();
				if(di!=-1)res=max(di,res);
				fie[i][j]=0;
			}
		}
	}
	for(int i=0;i<h;i+=2){
		for(int j=1;j<w;j+=2){
			if(fie[i][j]==0){
				fie[i][j]=1;
				int di=bfs();
				if(di!=-1)res=max(di,res);
				fie[i][j]=0;
			}
		}
	}
	printf("%d\n",res-prev);
	return 0;
}