#include <bits/stdc++.h>

using namespace std;

vector<vector<int>> g;
vector<int> used;
bool f;

void dfs(int v, int c) {
    used[v] = 1;
    for (auto u : g[v]) {
        if (abs(v - u) == 1 or abs(v - u) == g.size() - 1) continue;
        if (used[u] == 0) dfs(u, c);
        else if (used[u] == 1 and u == c) f = true;
    }
    used[v] = 2;
}

signed main() {
    int n, m, gg;
    cin >> n >> m >> gg;
    g.resize(n);
    for (int i = 0; i < m; i++) {
        int x, y;
        cin >> x >> y;
        x--;
        y--;
        g[x].push_back(y);
    }
    vector<pair<int, int>> p;
    for (int i = 0; i < n; i++) {
        for (auto j : g[i]) {
            if (abs(i - j) == 1 or abs(i - j) == n - 1) continue;
            if (i < j) {
                p.push_back({i, j - 1});
            } else {
                p.push_back({i, j + n - 1});
            }
        }
    }
    if (!p.empty()) sort(p.begin(), p.end());
    int res = 0;
    int i = 0;
    while (i < p.size()) {
        int r = p[i].second;
        int j = i;
        while (j < p.size()) {
            if (p[j].first > r) break;
            r = min(r, p[j].second);
            j++;
        }
        res++;
        if (j == p.size()) break;
        i = j;
    }
    if (!p.empty()) cout << n - res << '\n' << 1;
    else cout << n - 1 << '\n' << n;
}

