#ifndef LOCAL
#pragma GCC optimize("O3")
#endif

#include <bits/extc++.h>

using namespace std;


using namespace __gnu_pbds;
using oset = tree<int, null_type, less<>, rb_tree_tag, tree_order_statistics_node_update>;
using ll = long long;
const ll nMax = 2000 + 228;
const ll mod = 1e9 + 7;
ll a[nMax];
ll diff[nMax];
ll longestway[nMax][nMax];
ll pows[nMax];
vector<int> g[nMax];
ll sinks[nMax];
ll basesinks[nMax];
bool used[nMax];

void dfs1(int v) {
    used[v] = true;
    for (auto u: g[v]) {
        if (used[u])continue;
        sinks[u]++;
        dfs1(u);
    }
}

void dfs(int v, int par) {
    sinks[v] = -1e9;
    for (auto u: g[v]) {
        sinks[u]--;
        longestway[par][u] = max(longestway[par][u], longestway[par][v] + 1);
        if (sinks[u] == 0)dfs(u, par);
    }
}

void solve() {
    pows[0] = 1;
    for (int i = 1; i < nMax; i++)pows[i] = (2 * pows[i - 1]) % mod;
    ll n, m, gg;
    cin >> n >> m >> gg;
    vector<pair<int, int>> segs;
    for (int i = 0; i < m; i++) {
        int u, v;
        cin >> u >> v;
        u--;
        v--;
        if (v - u != 1 && !(v == n - 1 && u == 0)) {
            segs.push_back({u, v});
            if(v < u)
                segs.push_back({u,v+n});
            else
                segs.push_back({u, v});
        }
        g[u].push_back(v);
        basesinks[v]++;
    }
    int sss = segs.size();

    int best = m;
    sort(segs.begin(),segs.end(),[](auto f,auto s){
      return f.second < s.second;
    });
    for(int i=0;i<sss;i++)segs.push_back(segs[i]);
    for(int i=0;i<sss;i++){
        set<int> pts;
        int ans = 0;
        for(int j=i;j<i+sss;j++){
            auto [l,r] = segs[j];
            auto it = pts.lower_bound(l);
            if(it == pts.end() || *it > r) {
                pts.insert(r);
                pts.insert(r+n);
                ans++;
            }
        }
        best=min(best,ans);
    }
    cout << n-best << ' ' << 0;
}

int main() {
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    cin.tie(0)->sync_with_stdio(0);
    int tt = 1;
    //cin >> tt;
    while (tt--)solve();
}