#include <iostream>
#include <cstring>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <set>
#include <utility>
#include <cstdlib>
#include <queue>
#include <stack>
#include <iomanip>
#include <cstdio>
#include <map>
#include <list>

using namespace std;

typedef long long ll;
typedef pair<ll,ll> P;

#define _upgrade ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define rep(i,x) for(ll i = 0; i < (ll)(x); i++)
#define all(x) (x).begin(), (x).end()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define pb push_back

template<class T1, class T2> void chmin(T1 &a, T2 b){if(a>b)a=b;}
template<class T1, class T2> void chmax(T1 &a, T2 b){if(a<b)a=b;}
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;

//ll gcd(ll a, ll b){return b?gcd(b,a%b):a;}
//ll lcm(ll x, ll y) {return x / gcd(x, y) * y;}

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

const ll INF = 1e9;
const long double PI = 3.14159265358979323846;


// ****************************************CODE***************************************//

template<int MOD> struct ModInt {
    static const int Mod = MOD; unsigned x; ModInt() : x(0) { }
    ModInt(signed sig) { x = sig < 0 ? sig % MOD + MOD : sig % MOD; }
    ModInt(signed long long sig) { x = sig < 0 ? sig % MOD + MOD : sig % MOD; }
    int get() const { return (int)x; }
    ModInt &operator+=(ModInt that) { if ((x += that.x) >= MOD) x -= MOD; return *this; }
    ModInt &operator-=(ModInt that) { if ((x += MOD - that.x) >= MOD) x -= MOD; return *this; }
    ModInt &operator*=(ModInt that) { x = (unsigned long long)x * that.x % MOD; return *this; }
    ModInt &operator/=(ModInt that) { return *this *= that.inverse(); }
    ModInt operator+(ModInt that) const { return ModInt(*this) += that; }
    ModInt operator-(ModInt that) const { return ModInt(*this) -= that; }
    ModInt operator*(ModInt that) const { return ModInt(*this) *= that; }
    ModInt operator/(ModInt that) const { return ModInt(*this) /= that; }
    ModInt inverse() const {
        long long a = x, b = MOD, u = 1, v = 0;
        while (b) { long long t = a / b; a -= t * b; std::swap(a, b); u -= t * v; std::swap(u, v); }
        return ModInt(u);
    }
    bool operator==(ModInt that) const { return x == that.x; }
    bool operator!=(ModInt that) const { return x != that.x; }
    ModInt operator-() const { ModInt t; t.x = x == 0 ? 0 : Mod - x; return t; }
};
template<int MOD> ostream& operator<<(ostream& st, const ModInt<MOD> a) { st << a.get(); return st; };
template<int MOD> ModInt<MOD> operator^(ModInt<MOD> a, unsigned long long k) {
    ModInt<MOD> r = 1; while (k) { if (k & 1) r *= a; a *= a; k >>= 1; } return r;
}
typedef ModInt<1000000007> mint;



int W, H, ax, ay, bx, by;
int dst[505][505], vis[505][505];
mint cnt[505][505];

int main(){
    cin >> W >> H >> ax >> ay >> bx >> by;

    rep(y,H) rep(x,W) dst[y][x] = INF;
    min_priority_queue<pair<int, int>> que;

    dst[ay][ax] = 0;
    cnt[ay][ax] = 1;
    que.push({0, ay * 1010 + ax});
    while(!que.empty()){
        auto q = que.top(); que.pop();

        //この場合分けのやり方すごい画期的過ぎんか
        //何それすごいってやつ
        //んーコストとグリッド状の座標を保存する時にこれは便利になるのかなーと思う。すごいなー。
        //今回はグラフを作るという作業はしないみたいやね。というよりはもともと全てのグラフはグリッドとして用意されていてあとはコストが1ってある程度決まってるからbfs的な感じでも解けるんだよね。
        //
        int x = q.second % 1010;
        int y = q.second / 1010;
        int c = q.first;

        if(vis[y][x]) continue;
        vis[y][x] = 1;

        if(y == by and x == bx){
            cout << c << " " << cnt[y][x] << endl;
            return 0;
        }

        //次に行くパターンを全部ここに入れるのかーなるほど
        vector<pair<int, int>> nxt;
        rep(i,4) nxt.push_back({x + dx[i], y + dy[i]});
        nxt.push_back({0,y});
        nxt.push_back({W-1, y});
        nxt.push_back({x, 0});
        nxt.push_back({x, H-1});

        for(auto p : nxt){
            int xx, yy;
            tie(xx, yy) = p;

            if(xx < 0 or W <= xx or yy < 0 or H <= yy) continue;

            //最短経路数問題の感じはこんな感じだねー覚えとかないとねー
            if(c + 1 < dst[yy][xx]){
                dst[yy][xx] = c + 1;
                cnt[yy][xx] = cnt[y][x];
                que.push({c + 1, yy * 1010 + xx});
            }
            else if(c+1 == dst[yy][xx]) cnt[yy][xx] += cnt[y][x];
        }
    }

}


### Prompt

Your challenge is to write a cpp solution to the following problem:

Problem

There is a grid of $ R \ times C $ squares with $ (0, 0) $ in the upper left and $ (R-1, C-1) $ in the lower right. When you are in a square ($ e $, $ f $), from there $ (e + 1, f) $, $ (e-1, f) $, $ (e, f + 1) $, $ (e) , f-1) $, $ (e, 0) $, $ (e, C-1) $, $ (0, f) $, $ (R-1, f) $ can be moved at a cost of $ 1 $ .. However, you cannot go out of the grid. When moving from the mass $ (a_i, a_j) $ to $ (b_i, b_j) $, calculate the cost of the shortest path and the remainder of the total number of shortest path combinations divided by $ 10 ^ 9 + 7 $.

However, the combination of routes shall be distinguished by the method of movement. For example, if your current location is $ (100, 1) $, you can go to $ (100, 0) $ with the above $ (e, f-1) $ or $ (e, 0) $ to get to $ (100, 0) $ at the shortest cost. You can do it, so count it as $ 2 $.

Constraints

The input satisfies the following conditions.

* $ 1 \ le R, C \ le 500 $
* $ 0 \ le a_i, b_i \ le R --1 $
* $ 0 \ le a_j, b_j \ le C --1 $
* All inputs given are integers.

Input

The input is given in the following format.


$ R $ $ C $ $ a_i $ $ a_j $ $ b_i $ $ b_j $


Output

When moving from the mass $ (a_i, a_j) $ to $ (b_i, b_j) $, the cost of the shortest path and the remainder of the total number of combinations of the shortest paths divided by $ 10 ^ 9 + 7 $ are separated by $ 1 $. Print on a line.

Examples

Input

2 2 0 0 1 1


Output

2 8


Input

1 1 0 0 0 0


Output

0 1


Input

1 10 0 0 0 9


Output

1 1


Input

5 5 0 0 4 4


Output

2 2


Input

421 435 196 169 388 9


Output

43 917334776

### Response

```cpp
#include <iostream>
#include <cstring>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <set>
#include <utility>
#include <cstdlib>
#include <queue>
#include <stack>
#include <iomanip>
#include <cstdio>
#include <map>
#include <list>

using namespace std;

typedef long long ll;
typedef pair<ll,ll> P;

#define _upgrade ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define rep(i,x) for(ll i = 0; i < (ll)(x); i++)
#define all(x) (x).begin(), (x).end()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define pb push_back

template<class T1, class T2> void chmin(T1 &a, T2 b){if(a>b)a=b;}
template<class T1, class T2> void chmax(T1 &a, T2 b){if(a<b)a=b;}
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;

//ll gcd(ll a, ll b){return b?gcd(b,a%b):a;}
//ll lcm(ll x, ll y) {return x / gcd(x, y) * y;}

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

const ll INF = 1e9;
const long double PI = 3.14159265358979323846;


// ****************************************CODE***************************************//

template<int MOD> struct ModInt {
    static const int Mod = MOD; unsigned x; ModInt() : x(0) { }
    ModInt(signed sig) { x = sig < 0 ? sig % MOD + MOD : sig % MOD; }
    ModInt(signed long long sig) { x = sig < 0 ? sig % MOD + MOD : sig % MOD; }
    int get() const { return (int)x; }
    ModInt &operator+=(ModInt that) { if ((x += that.x) >= MOD) x -= MOD; return *this; }
    ModInt &operator-=(ModInt that) { if ((x += MOD - that.x) >= MOD) x -= MOD; return *this; }
    ModInt &operator*=(ModInt that) { x = (unsigned long long)x * that.x % MOD; return *this; }
    ModInt &operator/=(ModInt that) { return *this *= that.inverse(); }
    ModInt operator+(ModInt that) const { return ModInt(*this) += that; }
    ModInt operator-(ModInt that) const { return ModInt(*this) -= that; }
    ModInt operator*(ModInt that) const { return ModInt(*this) *= that; }
    ModInt operator/(ModInt that) const { return ModInt(*this) /= that; }
    ModInt inverse() const {
        long long a = x, b = MOD, u = 1, v = 0;
        while (b) { long long t = a / b; a -= t * b; std::swap(a, b); u -= t * v; std::swap(u, v); }
        return ModInt(u);
    }
    bool operator==(ModInt that) const { return x == that.x; }
    bool operator!=(ModInt that) const { return x != that.x; }
    ModInt operator-() const { ModInt t; t.x = x == 0 ? 0 : Mod - x; return t; }
};
template<int MOD> ostream& operator<<(ostream& st, const ModInt<MOD> a) { st << a.get(); return st; };
template<int MOD> ModInt<MOD> operator^(ModInt<MOD> a, unsigned long long k) {
    ModInt<MOD> r = 1; while (k) { if (k & 1) r *= a; a *= a; k >>= 1; } return r;
}
typedef ModInt<1000000007> mint;



int W, H, ax, ay, bx, by;
int dst[505][505], vis[505][505];
mint cnt[505][505];

int main(){
    cin >> W >> H >> ax >> ay >> bx >> by;

    rep(y,H) rep(x,W) dst[y][x] = INF;
    min_priority_queue<pair<int, int>> que;

    dst[ay][ax] = 0;
    cnt[ay][ax] = 1;
    que.push({0, ay * 1010 + ax});
    while(!que.empty()){
        auto q = que.top(); que.pop();

        //この場合分けのやり方すごい画期的過ぎんか
        //何それすごいってやつ
        //んーコストとグリッド状の座標を保存する時にこれは便利になるのかなーと思う。すごいなー。
        //今回はグラフを作るという作業はしないみたいやね。というよりはもともと全てのグラフはグリッドとして用意されていてあとはコストが1ってある程度決まってるからbfs的な感じでも解けるんだよね。
        //
        int x = q.second % 1010;
        int y = q.second / 1010;
        int c = q.first;

        if(vis[y][x]) continue;
        vis[y][x] = 1;

        if(y == by and x == bx){
            cout << c << " " << cnt[y][x] << endl;
            return 0;
        }

        //次に行くパターンを全部ここに入れるのかーなるほど
        vector<pair<int, int>> nxt;
        rep(i,4) nxt.push_back({x + dx[i], y + dy[i]});
        nxt.push_back({0,y});
        nxt.push_back({W-1, y});
        nxt.push_back({x, 0});
        nxt.push_back({x, H-1});

        for(auto p : nxt){
            int xx, yy;
            tie(xx, yy) = p;

            if(xx < 0 or W <= xx or yy < 0 or H <= yy) continue;

            //最短経路数問題の感じはこんな感じだねー覚えとかないとねー
            if(c + 1 < dst[yy][xx]){
                dst[yy][xx] = c + 1;
                cnt[yy][xx] = cnt[y][x];
                que.push({c + 1, yy * 1010 + xx});
            }
            else if(c+1 == dst[yy][xx]) cnt[yy][xx] += cnt[y][x];
        }
    }

}


```