#include <bits/stdc++.h>

using namespace std;
using ll = long long;
#define int ll
using PII = pair<int, int>;
template <typename T> using V = vector<T>;
template <typename T> using VV = vector<V<T>>;
template <typename T> using VVV = vector<VV<T>>;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define PB push_back

const ll INF = (1LL<<60);
const int MOD = 1000000007;

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template <typename T> bool IN(T a, T b, T x) { return a<=x&&x<b; }
template<typename T> T ceil(T a, T b) { return a/b + !!(a%b); }
template<class S,class T>
ostream &operator <<(ostream& out,const pair<S,T>& a){
  out<<'('<<a.first<<','<<a.second<<')';
  return out;
}
template<class T>
ostream &operator <<(ostream& out,const vector<T>& a){
  out<<'[';
  REP(i, a.size()) {out<<a[i];if(i!=a.size()-1)out<<',';}
  out<<']';
  return out;
}

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

PII d[510][510];
signed main(void)
{
  cin.tie(0);
  ios::sync_with_stdio(false);

  int h, w, sy, sx, gy, gx;
  cin >> h >> w >> sy >> sx >> gy >> gx;

  REP(i, h) REP(j, w) d[i][j] = {INF, 0};
  d[sy][sx] = {0, 1};
  priority_queue<V<int>, VV<int>, greater<V<int>>> que;
  que.push({0, sy, sx});

  while(que.size()) {
    V<int> v = que.top(); que.pop();
    // cout << v << " " << d[v[1]][v[2]] << endl;
    if(d[v[1]][v[2]].first < v[0]) continue;
    REP(i, 4) {
      int ny = v[1] + dy[i], nx = v[2] + dx[i];
      // cout << ny << " " << nx << endl;
      if(!IN(0LL,h,ny) || !IN(0LL,w,nx)) continue;
      // cout << "a" << endl;
      if(d[ny][nx].first > d[v[1]][v[2]].first + 1) {
        d[ny][nx] = {d[v[1]][v[2]].first+1, d[v[1]][v[2]].second};
        que.push({d[ny][nx].first, ny, nx});
      } else if(d[ny][nx].first == d[v[1]][v[2]].first + 1) {
        (d[ny][nx].second += d[v[1]][v[2]].second) %= MOD;
      }
      // cout << ny << " " << nx << " " << d[ny][nx] << endl;
    }
    int ny = v[1], nx = 0;
    if(d[ny][nx].first > d[v[1]][v[2]].first + 1) {
      d[ny][nx] = {d[v[1]][v[2]].first+1, d[v[1]][v[2]].second};
      que.push({d[ny][nx].first, ny, nx});
    } else if(d[ny][nx].first == d[v[1]][v[2]].first + 1) {
      (d[ny][nx].second += d[v[1]][v[2]].second) %= MOD;
    }
    ny = v[1], nx = w-1;
    // cout << d[ny][nx] << endl;
    if(d[ny][nx].first > d[v[1]][v[2]].first + 1) {
      d[ny][nx] = {d[v[1]][v[2]].first+1, d[v[1]][v[2]].second};
      que.push({d[ny][nx].first, ny, nx});
    } else if(d[ny][nx].first == d[v[1]][v[2]].first + 1) {
      (d[ny][nx].second += d[v[1]][v[2]].second) %= MOD;
    }
    ny = 0, nx = v[2];
    if(d[ny][nx].first > d[v[1]][v[2]].first + 1) {
      d[ny][nx] = {d[v[1]][v[2]].first+1, d[v[1]][v[2]].second};
      que.push({d[ny][nx].first, ny, nx});
    } else if(d[ny][nx].first == d[v[1]][v[2]].first + 1) {
      (d[ny][nx].second += d[v[1]][v[2]].second) %= MOD;
    }
    ny = h-1, nx = v[2];
    if(d[ny][nx].first > d[v[1]][v[2]].first + 1) {
      d[ny][nx] = {d[v[1]][v[2]].first+1, d[v[1]][v[2]].second};
      que.push({d[ny][nx].first, ny, nx});
    } else if(d[ny][nx].first == d[v[1]][v[2]].first + 1) {
      (d[ny][nx].second += d[v[1]][v[2]].second) %= MOD;
    }
  }

  cout << d[gy][gx].first << " " << d[gy][gx].second << endl;

  return 0;
}



Measured memory_bytes: 6992