#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double Double;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)


namespace sub {
    template<typename T>
    constexpr typename std::enable_if<std::is_integral<T>::value, T>::type
    inf_sub() {
        return std::numeric_limits<T>::max() / 2 - 1000;
    }

    template<typename T>
    constexpr typename std::enable_if<std::is_floating_point<T>::value, T>::type
    inf_sub() {
        return std::min(std::numeric_limits<T>::max() / 2 - 1000, T(1e50));
    }
}  // namespace sub

template<typename T>
constexpr T inf() {
    static_assert(std::is_arithmetic<T>::value, "T must be arithmetic value");
    return sub::inf_sub<T>();
}

template<typename T>
constexpr T zero() {
    static_assert(std::is_arithmetic<T>::value, "T must be arithmetic value");
    return T(0);
}

const long double pi = acos(-1.0);

template<class edge_t>
class graph_t {
    std::vector<std::vector<edge_t>> g;

public:
    using reference = std::vector<edge_t> &;
    using const_reference = const std::vector<edge_t> &;
    using iterator = typename std::vector<edge_t>::iterator;

    graph_t() : g(0) { ; }

    graph_t(int n) : g(n) { ; }

    int size() const { return g.size(); }

    void push_back(const std::vector<edge_t> &es) { g.push_back(es); }

    reference operator[](int x) { return g[x]; }

    const_reference operator[](int x) const { return g[x]; }

    iterator &begin() { return begin(g); }

    iterator &end() { return end(g); }
};

template<typename edge_t, typename cost_type = typename edge_t::cost_type>
std::vector<cost_type> dijkstra(const graph_t<edge_t> &g, int s) {
    std::vector<cost_type> d(g.size(), inf<cost_type>());
    d[s] = zero<cost_type>();
    using P = std::pair<cost_type, int>;
    std::priority_queue<P, std::vector<P>, std::greater<P>> que;
    que.push(P(zero<cost_type>(), s));
    while (!que.empty()) {
        cost_type dist = que.top().first;
        int v = que.top().second;
        que.pop();
        if (d[v] < dist) continue;
        for (const auto &e : g[v]) {
            if (d[e.to] <= d[v] + e.cost) continue;
            d[e.to] = d[v] + e.cost;
            que.push(P(d[e.to], e.to));
        }
    }
    return d;
}


template<typename Cost>
class WeightedEdge {
public:
    using cost_type = Cost;
    int to;
    cost_type cost;

    WeightedEdge(int, int t, cost_type c) : to(t), cost(c) { ; }
};

template<typename Cost> using WeightedGraph = graph_t<WeightedEdge<Cost>>;

template<typename Cost>
void add_edge(WeightedGraph<Cost> &g, int from, int to, Cost cost) {
    g[from].emplace_back(from, to, cost);
}

int main() {
    int R, C, r1, c1, r2, c2;
    cin >> R >> C >> r1 >> c1 >> r2 >> c2;

    WeightedGraph<int> g(R * C);
    auto id = [&](int r, int c) {
        return r * C + c;
    };
    auto valid = [&](int r, int c) {
        return r >= 0 && r < R && c >= 0 && c < C;
    };

    int dr[] = {-1, 0, 1, 0};
    for (int i = 0; i < R; i++) {
        for (int j = 0; j < C; j++) {
            for (int d = 0; d < 4; d++) {
                int r = i + dr[d];
                int c = j + dr[(d + 1) % 4];
                if (valid(r, c)) {
                    add_edge(g, id(i, j), id(r, c), 1);
                }
            }
            add_edge(g, id(i, j), id(0, j), 1);
            add_edge(g, id(i, j), id(i, 0), 1);
            add_edge(g, id(i, j), id(R - 1, j), 1);
            add_edge(g, id(i, j), id(i, C - 1), 1);
        }
    }
    auto costs = dijkstra(g, id(r1, c1));
    vector<pair<int,int>> ws;
    for(int i = 0 ; i < costs.size() ; i++){
        ws.push_back({costs[i], i});
    }
    sort(ws.begin(), ws.end());
    vector<int> dp(R * C);
    dp[id(r1, c1)] = 1;
    for( auto I : ws ){
        int i = I.second;
        for(auto j : g[i]){
            if( j.cost + costs[i] == costs[j.to]) {
                dp[j.to] += dp[i];
                dp[j.to] %= 1000000007;
            }
        }
    }
    cout << costs[id(r2, c2)] << " " << dp[id(r2, c2)] << endl;
}



Measured memory_bytes: 24244