#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
//---------------------------------------------------------------------------------------------------
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;
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧  
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     
　　　　／　　　＼　 　 |　|     
　　　 /　　 /￣￣￣￣/　　|  
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿  
　 　　　＼/＿＿＿＿/　（u　⊃  
---------------------------------------------------------------------------------------------------*/



int W, H, ax, ay, bx, by;
int dst[505][505], vis[505][505]; mint dp[505][505];
int dx[4] = { 0, 1, 0, -1 }, dy[4] = { -1, 0, 1, 0 };
//---------------------------------------------------------------------------------------------------
void _main() {
    cin >> W >> H >> ax >> ay >> bx >> by;

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

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

        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 << " " << dp[y][x] << endl;
            return;
        }

        vector<pair<int, int>> nxt;
        rep(d, 0, 4) nxt.push_back({ x + dx[d], y + dy[d] });
        nxt.push_back({ 0, y });
        nxt.push_back({ W - 1, y });
        nxt.push_back({ x, 0 });
        nxt.push_back({ x, H - 1 });

        fore(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;
                dp[yy][xx] = dp[y][x];
                que.push({ c + 1, yy * 1010 + xx });
            }
            else if (c + 1 == dst[yy][xx]) dp[yy][xx] += dp[y][x];
        }
    }
}



Measured memory_bytes: 5372