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


using ll = long long;
const int inf = 1e9 + 10;

const int mod = 1e9 + 7;

int add(int a, int b) {
    return a + b >= mod ? a + b - mod : a + b;
}
int sub(int a, int b) {
    return a >= b ? a - b : a + mod - b;
}
int mul(int a, int b) {
    return 1ll * a * b % mod;
}

int solve(vector<vector<int>> g) {
    int n = g.size();
    vector<vector<int>> in(n);
    for (int i = 0; i < n; ++i) {
        for (auto j : g[i]) in[j].push_back(i);
    }
    vector<bool> used(n);
    vector<vector<bool>> adj(n, vector<bool>(n, false));
    auto dfs = [&](auto dfs, int u) -> void {
        used[u] = true;
        adj[u][u] = true;
        for (auto to : g[u]) {
            if (!used[to]) dfs(dfs, to);
            for (int k = 0; k < n; ++k) {
                if (adj[to][k]) adj[u][k] = true;
            }
        }
    };
    for (int i = 0; i < n; ++i) {
        if (!used[i]) dfs(dfs, i);
    }
    int mn = 0;
    for (int i = 0; i < n; ++i) {
        for (auto j : in[i]) {
            bool ok = true;
            for (auto k : in[i]) {
                if (j == k) continue;
                ok &= !adj[j][k];
            }
            if (ok) {
                mn++;
            }
        }
    }
    return mn;
}

signed main() {
    cin.tie(nullptr)->sync_with_stdio(false);

    int n, m, group;
    cin >> n >> m >> group;
    vector<vector<int>> g(n), in(n);
    for (int i = 0; i < n; ++i) {
        int u, v;
        cin >> u >> v;
        if (abs(u - v) == 1 || abs(u - v) == n - 1) continue;
        g[u].push_back(v);
        in[v].push_back(u);
    }
    vector<int> topsort;
    vector<bool> used(n);
    auto dfs = [&](auto dfs, int u) -> void {
        used[u] = true;
        for (auto to : g[u]) {
            if (!used[to]) dfs(dfs, to);
        }
        topsort.push_back(u);
    };
    for (int i = 0; i < n; ++i) {
        if (!used[i]) {
            dfs(dfs, i);
        }
    }
    reverse(topsort.begin(), topsort.end());
    vector<int> col(n, -1);
    int c = 0;
    auto dfs2 = [&](auto dfs2, int u) -> void {
        col[u] = c;
        for (auto to : in[u]) {
            if (col[to] == -1) dfs2(dfs2, to);
        }
    };
    for (auto i : topsort) {
        if (col[i] == -1) {
            dfs2(dfs2, i);
            c++;
        }
    }
    int cnt = 0;
    for (int i = 0; i < n; ++i) {
        cnt += col[i] == col[(i + 1) % n];
    }
    cnt = min(cnt, n - 1);
    cout << cnt << endl << 1;
}