#include<bits/stdc++.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) for(int i = 0; i < (b); i++)
#define all(a) (a).begin(), (a).end()
#define show(x)  cerr << #x << " = " << (x) << endl;
using namespace std;

template<typename T>
ostream& operator << (ostream& os, vector<T>& v){
	rep(i,v.size()){ os << v[i] << (i == v.size() - 1 ? "" : " "); } return os;
}
template<typename T>
istream& operator >> (istream& is, vector<T>& v){
	for(T& x: v){ is >> x; } return is;
}

const int MAX = 510;
const long long M = 1000000007;

int r, c, ay, ax, by, bx;
int dis[MAX][MAX];
long long cnt[MAX][MAX];

struct P{
	int y, x;
	int cost;
	P(int y, int x, int cost) : y(y), x(x), cost(cost) { }
	bool operator < ( const P &right ) const {
		return cost < right.cost;
	}
	bool operator > ( const P &right ) const {
		return cost > right.cost;
	}
};

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

int shortestPath(){
	priority_queue<P, vector<P>, greater<P>> q;
	q.emplace(P(ay, ax, 0));

	while(not q.empty()){
		P cur = q.top(); q.pop();

		if(dis[cur.y][cur.x] != INT_MAX) continue;
		dis[cur.y][cur.x] = cur.cost;

		if(cur.y == by and cur.x == bx) continue;

		//cout << cur.y << ' ' << cur.x << endl;
		rep(d,4){ // 隣接
			int ny = cur.y + dy[d];
			int nx = cur.x + dx[d];
			if(ny < 0 || ny >= r || nx < 0 || nx >= c) continue;
			if(dis[ny][nx] <= cur.cost + 1) continue;
			q.emplace(ny, nx, cur.cost + 1);
		}
		rep(d,4){
			int ny = cur.y, nx = cur.x;
			if(dy[d] == 1) ny = r - 1;
			if(dy[d] == -1) ny = 0;

			if(dx[d] == 1) nx = c - 1;
			if(dx[d] == -1) nx = 0;

			if(dis[ny][nx] <= cur.cost + 1) continue;
			q.emplace(ny, nx, cur.cost + 1);
		}
	}

	//rep(i,r){ rep(j,c){ cout << dis[i][j] << ' '; } cout << endl; }
	
	return dis[by][bx];
}

long long solve(){
	priority_queue<P, vector<P>, greater<P>> q;
	q.emplace(P(ay, ax, 0));

	cnt[ay][ax] = 1;

	bool used[MAX][MAX] = {};
	while(not q.empty()){
		P cur = q.top(); q.pop();

		if(cur.y == by and cur.x == bx) continue;
		if(used[cur.y][cur.x]) continue;
		used[cur.y][cur.x] = true;

		//cout << "cur " << cur.y << ' ' << cur.x << endl;

		rep(d,4){ // 隣接
			int ny = cur.y + dy[d];
			int nx = cur.x + dx[d];
			if(ny < 0 || ny >= r || nx < 0 || nx >= c) continue;
			if(dis[ny][nx] < cur.cost + 1) continue;
			//cout << dy[d] << ' ' << dx[d] << endl;
			//cout << ny << ' ' << nx << ' ' << cur.y << ' ' << cur.x << endl;
			(cnt[ny][nx] += cnt[cur.y][cur.x]) %= M;
			q.emplace(ny, nx, cur.cost + 1);
		}
		rep(d,4){
			int ny = cur.y, nx = cur.x;
			if(dy[d] == 1) ny = r - 1;
			if(dy[d] == -1) ny = 0;

			if(dx[d] == 1) nx = c - 1;
			if(dx[d] == -1) nx = 0;

			if(dis[ny][nx] < cur.cost + 1) continue;
			//cout << ny << ' ' << nx << ' ' << cur.y << ' ' << cur.x << endl;
			(cnt[ny][nx] += cnt[cur.y][cur.x]) %= M;
			q.emplace(ny, nx, cur.cost + 1);
		}
	}
	//rep(i,r){ rep(j,c){ cout << cnt[i][j] << ' '; } cout << endl; }

	return cnt[by][bx];
}

int main(){
	cin >> r >> c >> ay >> ax >> by >> bx;
	rep(i,MAX) rep(j,MAX) dis[i][j] = INT_MAX;

	shortestPath();
	cout << shortestPath() << ' ' << solve() << endl;
}



Measured memory_bytes: 6272