#include <bits/stdc++.h>
using namespace std;
using ll = long long;
//using ll = int;
using ld = long double;
using ull = unsigned long long;
#define pb push_back
#define all(vec) vec.begin(), vec.end()
#define eb emplace_back
#ifdef LOCAL
#define deb(x) cout << #x << " = " << x << '\n'
#else
#define deb(x) 52
#endif
const ll inf = 1e9 + 11;
const long long INF = (long long)2e18 + 11;
const ll P = 73;
const ll MOD = 1e9 + 7;


void solve() {
    ll n, m, g;
    cin >> n >> m >> g;
    ll x, y;
    ll cnt = 0;
    vector<bool> bad(n);
    for (ll i = 0; i < m; ++i) {
        cin >> x >> y;
        --x, --y;
        if (y - x == 1 || (x == n - 1 && y == 0)) {
            continue;
        } 
        while (x != y) {
            bad[x] = true;
            x = (x + 1) % n;
        }
    }
    for (ll i = 0; i < n; ++i) {
        if (!bad[i]) {
            ++cnt;
        }
    }
    cout << cnt << ' ' << 1;
}


int main() {
#ifdef LOCAL
    freopen("C:/work/untitled/input.txt", "r", stdin);
    freopen("C:/work/untitled/output.txt", "w", stdout);
#endif
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    ll cfmode = 0;
    ll tc = 1;
    if (cfmode) {
        cin >> tc;
    }
    while (tc--) {
        solve();
        if (tc) {
            cout << '\n';
        }
    }
}