#include using namespace std; template vector dijkstra(vector>>&g, const T INF, int s=0) { int n=g.size(); vectordist(n,INF); dist[s]=0; priority_queue,vector>,greater>>q; q.push(make_pair(T(0),s)); while(!q.empty()) { auto[d,u]=q.top(); q.pop(); if(dist[u]d+w) { dist[v]=d+w; q.push(make_pair(dist[v],v)); } } } return dist; } long H,W,N,A[2020],B[2020]; int main() { ios::sync_with_stdio(false); cin.tie(nullptr); cin>>H>>W>>N; for(int i=0;i>A[i]>>B[i]>>A[i+N]>>B[i+N]; vector>>G(2*N+2); for(int i=0;i<2*N;i++)for(int j=0;j<2*N;j++)if(i!=j) { if(i+N==j)G[i].push_back(make_pair(j,1)); else G[i].push_back(make_pair(j,abs(A[j]-A[i])+abs(B[j]-B[i]))); } for(int i=0;i<2*N;i++) { G[2*N].push_back(make_pair(i,A[i]+B[i]-2)); G[i].push_back(make_pair(2*N+1,H+W-A[i]-B[i])); } G[2*N].push_back(make_pair(2*N+1,H+W-2)); cout<<(dijkstra(G,1L<<60,2*N)[2*N+1])<