#include<bits/stdc++.h>

using namespace std;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

#define int long long
vector<vector<int>> g;
vector<int> color;
int timer = 1;

void dfs(int v) {
    color[v] = timer;
    for (auto u : g[v]) {
        if (color[u] != color[v]) {
            dfs(u);
        }
    }
}


bool cmp(pair<int, int> a, pair<int, int>  b) {
    if (a.second - a.first != b.second - b.first) {
        return a.second - a.first < b.second - b.first;
    }
    return a.first < b.first;
}

const int MOD = 1e9 + 7;

signed main() {
    // freopen("in.txt", "r", stdin);
    // freopen("out.txt", "w", stdout);
    cout.precision(20);
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    int n, m, gg;
    cin >> n >> m >> gg;
    g.resize(n);
    color.resize(n);
    // for (int i = 0; i < n; i++) color[i] = i;
    vector<vector<int>> edge(n);
    for (int i = 0; i < m; i++) {
        int a, b;
        cin >> a >> b;
        if (a + 1 != b && a - b != n - 1) {
            if (a < b) {
                edge[a - 1].push_back(b - 1);
            } else {
                edge[a - 1].push_back(b - 1 + n);
                // cout << a - 1 << ' ' << b - 1 + n << endl;
            }
        }
    }
    for (int i = 0; i < n; i++) {
        sort(edge[i].begin(), edge[i].end());
    }
    int ans = 0, ans1 = 1, i = 0;
    while (i < n) {
        if ((int)edge[i].size() == 0) {
            i++;
            continue;
        }
        int ed = edge[i][0];
        int sz = 0;
        for (int j = min(n - 1, ed - 1); j >= i; j--) {
            // cout << j << endl;
            if (edge[j].size() != 0) {
                sz = ed - j;
                break;
            }
        }
        ans++;
        ans1 *= sz;
        i = ed;
    }
    cout << n - ans << ' ' << ans1 << '\n';
}