#include using namespace std; using ll=long long; #define all(v) v.begin(),v.end() #define rall(v) v.rbegin(),v.rend() template bool chmax(T &a, T b){if (a < b){a = b;return true;} else return false;} template bool chmin(T &a, T b){if (a > b){a = b;return true;} else return false;} const ll INF=1LL<<60; ll D[2010][2010]; int main(){ ios::sync_with_stdio(false); cin.tie(nullptr); ll H,W; int N; cin>>H>>W>>N; vectora(N),b(N),c(N),d(N); for(int i=0;i>a[i]>>b[i]>>c[i]>>d[i]; vectorX(2*N+2),Y(2*N+2); X[0]=1,Y[0]=1; for(int i=0;idist(2*N+2,INF); dist[0]=0LL; priority_queue,vector>,greater>>pq; pq.push(make_pair(dist[0],0)); while(pq.size()){ auto[c,x]=pq.top(); pq.pop(); if(dist[x]