#include // #include using namespace std; #define rep(i, n) for (int i = 0; i < (n); i++) #define rrep(i, n) for (int i = n - 1; i >= 0; i--) #define FOR(i,s, n) for (int i = (s); i < (n); i++) #define ALL(x) x.begin(),x.end() #define rALL(x) x.rbegin(),x.rend() using ll = long long; using ld = long double; using Graph = vector>; // using mint = atcoder::modint998244353; // using Mint = atcoder::modint1000000007; const ll INF = 1LL << 60; const ll inf = 1E9 + 7; const ll MOD = 998244353; const ll mod = 1E9 + 7; const ll int_max = 1LL << 32; template inline bool chmin(T& a, T b) { if (a > b) { a = b;return true; }return false; } template inline bool chmax(T& a, T b) { if (a < b) { a = b;return true; }return false; } template inline ll pair2idx(T x, T y, T n) { return (ll)x * n + y; } template inline pair idx2pair(T idx, T n) { return { idx / n, idx % n }; } long long _pow(long long x, long long n) { long long ret = 1; while (n > 0) { if (n & 1) ret *= x; x *= x; n >>= 1; } return ret; } int dist(int x1,int y1,int x2,int y2){ return abs(x1-x2)+abs(y1-y2); } int main(){ int h,w;cin>>h>>w; int a,b;cin>>a>>b; int r1,c1,r2,c2;cin>>r1>>c1>>r2>>c2; int p,q;cin>>p>>q; int ans=inf; for(int y=r1;y<=r2;y++){ for(int x=c1;x<=c2;x++){ if((y>r1&&yc1&&x