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

using namespace std;

#define X first
#define Y second

const int dx[]={0,0,-1,1};
const int dy[]={1,-1,0,0};

vector<pair<int,int> > way;
pair<int,int> fr[52][52],s[52*52],p1,p2,be,ed,cur;
int d[52][52],dir[52][52][5];
bool vis[52][52];
int w,h,n,ans,mindis;

int calc(pair<int,int>	src,pair<int,int> tar){
	int l=1,r=1,cx,cy,ex,ey;
	for	(int i=1;i<=w;++i)	for	(int j=1;j<=h;++j){
		vis[i][j]=0;d[i][j]=w*h+1;
	}
	s[1]=src;vis[src.X][src.Y]=1;d[src.X][src.Y]=0;
	while	(l<=r){
		if	(vis[tar.X][tar.Y])	break;
		cx=s[l].X;cy=s[l].Y;
		//printf("%d %d\n",cx,cy);
		for	(int k=0;k<4;++k)
			if	(dir[cx][cy][k]){
				ex=cx+dx[k];ey=cy+dy[k];
				if	(!vis[ex][ey]){
					vis[ex][ey]=1;
					fr[ex][ey]=make_pair(cx,cy);
					d[ex][ey]=d[cx][cy]+1;
					s[++r]=make_pair(ex,ey);
				}
			}
		l++;
	}
	if	(d[tar.X][tar.Y]>w*h)	return	-1;
	else	return	d[tar.X][tar.Y];
}

int main(){
	while	(~scanf("%d%d%d",&w,&h,&n)){
		for	(int i=1;i<=w;++i)	for	(int j=1;j<=h;++j)
			for	(int k=0;k<4;++k)
				if	(i+dx[k] && i+dx[k]<=w && j+dy[k] && j+dy[k]<=h)	dir[i][j][k]=1;
				else	dir[i][j][k]=0;
		for	(int i=1;i<=n;++i){
			scanf("%d%d%d%d",&p1.X,&p1.Y,&p2.X,&p2.Y);
			if	(p1>p2)	swap(p1,p2);
			if	(p1.X==p2.X){
				for	(int j=p1.Y+1;j<=p2.Y;++j){
					dir[p1.X][j][3]=dir[p1.X+1][j][2]=0;
					//printf("Cutting %d %d %d %d\n",p1.X,j,p1.X+1,j);
				}
			}
			else{
				for	(int j=p1.X+1;j<=p2.X;++j){
					dir[j][p1.Y][0]=dir[j][p1.Y+1][1]=0;
					//printf("Cutting %d %d %d %d\n",j,p1.Y,j,p1.Y+1);
				}
			}
		}
		scanf("%d%d%d%d",&be.X,&be.Y,&ed.X,&ed.Y);
		be.X++;be.Y++;ed.X++;ed.Y++;
		mindis=calc(be,ed);
		//printf("%d\n",mindis);
		cur=ed;way.clear();
		while	(cur!=be){
			way.push_back(cur);
			cur=fr[cur.X][cur.Y];
		}
		way.push_back(be);
		reverse(way.begin(),way.end());
		ans=0;
		for	(int i=0;i<way.size()-1;++i){
			p1=way[i];p2=way[i+1];
			if	(p1>p2)	swap(p1,p2);
			if	(p1.X==p2.X){
				dir[p1.X][p1.Y][0]=dir[p2.X][p2.Y][1]=0;
				ans=max(ans,calc(be,ed)-mindis);
				dir[p1.X][p1.Y][0]=dir[p2.X][p2.Y][1]=1;
			}
			else{
				dir[p1.X][p1.Y][3]=dir[p2.X][p2.Y][2]=0;
				ans=max(ans,calc(be,ed)-mindis);
				dir[p1.X][p1.Y][3]=dir[p2.X][p2.Y][2]=1;
			}
		}
		printf("%d\n",ans);
	}
}