#include<bits/stdc++.h>
using namespace std;
#define int long long

struct P {
  int x, y;
  P(){}
  P(int x, int y):x(x), y(y){}
  bool operator == (const P &p) const {
    return x == p.x && y == p.y;
  }
  bool operator < (const P &p) const {
    return x != p.x ? x < p.x : y < p.y;
  }
};

P min(P p, P q) {
  return p < q ? p : q;
}

int W, H, N;
P ip, op;

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

bool wall[55][55][55][55];

bool in(int y, int x) {
  return 0<=y&&y<H&&0<=x&&x<W;
}

int bfs() {
  queue<P> que;
  int dist[55][55];
  memset(dist, -1, sizeof(dist));
  que.emplace(ip);
  dist[ip.y][ip.x] = 0;
  while(!que.empty()) {
    P p = que.front(); que.pop();
    //cout << p.x << " " << p.y << ":"<< dist[p.y][p.x]<<endl; 
    if(p == op) break;   
    for(int i = 0; i < 4; i++) {
      int ny = p.y+dy[i], nx = p.x+dx[i];
      if(!in(ny, nx)) continue;
      if(dist[ny][nx] != -1) continue;
      if((i == 0 && !wall[ny][nx][ny][nx+1]) ||
	 (i == 1 && !wall[ny][nx][ny+1][nx]) ||
	 (i == 2 && !wall[p.y][p.x][p.y][p.x+1]) ||
	 (i == 3 && !wall[p.y][p.x][p.y+1][p.x])) {
	que.emplace(nx, ny);
	dist[ny][nx] = dist[p.y][p.x]+1;
	//cout<<ny<<" "<<nx<<" "<<dist[ny][nx]<<endl;
	//cout<<"          "<<dist[p.y][p.x]+1<<endl;
      }
    }
  }
  //cout<<dist[op.y][op.x]<<endl;
  return dist[op.y][op.x];
}

void print(){
  for(int i=0;i<H;i++){
    for(int j=0;j<W;j++){
      cout<<wall[i][j][i][j+1]<<" "<<wall[i][j][i+1][j]<<endl;
    }
  }
  cout<<endl;
}

signed main(){
  cin >> W >> H >> N;
  for(int i = 0; i < N; i++) {
    P s, d;
    cin >> s.x >> s.y >> d.x >> d.y;
    P p = min(s, d);
    P q = p == s ? d : s;
    if(p.y == q.y) {
      for(int x = p.x; x < q.x; x++) wall[p.y][x][p.y][x+1] = true;
    } else if(p.x == q.x) {
      for(int y = p.y; y < q.y; y++) wall[y][p.x][y+1][p.x] = true;      
    } else {
      assert(false);
    }
  }

  cin >> ip.x >> ip.y >> op.x >> op.y;

  int ini = bfs(), ans = ini;
  
  for(int i = 0; i < H; i++) {
    for(int j = 0; j < W; j++) {
      if(in(i+1, j) && !wall[i][j][i+1][j]) {
	wall[i][j][i+1][j] = true;
	//print();
	ans = max(ans, bfs());
	wall[i][j][i+1][j] = false;
      }
      if(in(i, j+1) && !wall[i][j][i][j+1]) {
	wall[i][j][i][j+1] = true;
	//print();
	ans = max(ans, bfs());
	wall[i][j][i][j+1] = false;
      }
    }
  }
  
  //cout << ans << " " << ini << endl;
  cout << ans - ini << endl;
  
  return 0;
}