#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
vector<vector<int>> a,c;
vector<set<int>> b;
vector<int> us;
void dfs(int x, int &cnt){
    us[x]=1;
    cnt++;
    for (int u:a[x]){
        if (!us[u]){
            dfs(u,cnt);
        }
    }
}
int main(){
    ios_base::sync_with_stdio(false); cin.tie(0);
    int n,m,g,a1,a2;
    cin >> n >> m >> g;
    a.resize(n);
    b.resize(n);
    c.resize(n);
    for (int i=0;i<m;i++){
        cin >> a1 >> a2;
        if (a2==a1+1 || (a2==1 && a1==n)){
            continue;
        }
        a[a1-1].push_back(a2-1);
        c[a2-1].push_back(a1-1);
    }
    for (int i=0;i<n-1;i++){
        a[i].push_back(i+1);
        c[i+1].push_back(i);
    }
    a[n-1].push_back(0);
    c[0].push_back(n-1);
    for (int i=0;i<n;i++){
        us.push_back(0);
    }
    int ans=0;
    /*for (int i=0;i<n;i++){
        int cnt=0;
        a[i].pop_back();
        a[(i+1)%n].push_back(i);
        dfs(i,cnt);
        //cout << i << ' ' << cnt << '\n';
        for (int j=0;j<n;j++){
            us[j]=0;
        }
        if (cnt!=n){
            ans++;
        }
        a[(i+1)%n].pop_back();
        a[i].push_back((i+1)%n);
    }*/
    for (int i=0;i<n;i++){
        if (a.size()==1){
            ans++;
        }
    }
    if (ans==n){
        ans--;
    }
    cout << ans << ' ' << 1 << '\n';
}
