#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];
        }
    }

}



Measured memory_bytes: 5308