#include <bits/stdc++.h>
using namespace std;

using lint = long long int;

struct Pos { int x, y, c; };

int R, C, ax, ay, bx, by, cost[555][555];
lint card[555][555], MOD = (lint)1e9 + 7;

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

void update(int x, int y, int nx, int ny, int nc, queue< Pos >& que) {
	if (nx < 0 || nx >= C || ny < 0 || ny >= R) return;
	if (cost[ny][nx] == -1) {
		cost[ny][nx] = nc;
		que.push(Pos{nx, ny, nc});
	}
	if (cost[ny][nx] == nc) card[ny][nx] = (card[ny][nx] + card[y][x]) % MOD;
}

int main() {
	cin >> R >> C >> ay >> ax >> by >> bx;
	
	memset(cost, -1, sizeof(cost));
	memset(card, 0, sizeof(card));
	
	cost[ay][ax] = 0;
	card[ay][ax] = 1;
	
	queue< Pos > que;
	que.push(Pos{ax, ay, 0});
	
	while (!que.empty()) {
		Pos p = que.front(); que.pop();
		int nc = p.c + 1;
		
		for (int d=0; d<4; ++d) {
			int nx = p.x + dx[d], ny = p.y + dy[d];
			update(p.x, p.y, nx, ny, nc, que);
		}
		
		update(p.x, p.y, p.x, 0, nc, que);
		update(p.x, p.y, p.x, R-1, nc, que);
		update(p.x, p.y, 0, p.y, nc, que);
		update(p.x, p.y, C-1, p.y, nc, que);
	}
	
	cout << cost[by][bx] << " " << card[by][bx] << endl;
}
