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


using ll = long long;

const ll inf = 1e18;

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

    int n, m, c;
    cin >> n >> m >> c;
    vector<int> delt(n);
    for (int i = 0; i < m; ++i) {
        int u, v;
        cin >> u >> v;
        if (abs(u - v) == 1 || abs(u - v) == n - 1) continue;
        if (v < u) delt[v]++, delt[u]--;
        else {
            delt[v]++;
            delt[0]++;
            delt[u]--;
        }
    }
    for (int i = 1; i < n; ++i) delt[i] += delt[i - 1];
    int ans = 0;
    for (int i = 0; i < n; ++i) {
        if (delt[i] != 0) continue;
        if (delt[(i + 1) % n] == 0) ans++;
    }
    cout << ans << endl << 1;
}