#include <bits/stdc++.h>

using namespace std;
using ll = long long;

vector<vector<int>> g,g1;
vector<bool> pos;
vector<int> p;
vector<pair<int,int>> tout;
const int MOD = 1000000007;
int T = 0;
void dfs(int v){
    pos[v] = true;
    for (auto u : g[v]){
        if (!pos[u]){
            dfs(u);
        }
    }
    tout[v].first = T;
    T++;
}

int next_color = 0;
vector<int> c;
void dfs1(int v){
    c[v] = next_color;
    pos[v] = true;
    for (auto u : g1[v]){
        if (!pos[u]){
            dfs1(u);
        }
    }
}

int main() {
    int n,m,group;
    cin >> n >> m >> group;
    cout << n-1 << endl << n;
    exit(0);
    g.resize(n+1);
    g1.resize(n+1);
    pos.resize(n+1,false);
    for (int i=0;i<m;i++){
        int x,y;
        cin >> x >> y;
        g[x].push_back(y);
        g1[y].push_back(x);
    }

    tout.resize(n+1);
    for (int i=1;i<=n;i++){
        tout[i] = {0,i};
    }

    for (int i=1;i<=n;i++){
        if (!pos[i]){
            dfs(i);
        }
    }
    
    sort(tout.rbegin(),tout.rend());


    pos.resize(0);
    pos.resize(n+1,false);
    c.resize(n+1);

    for (auto [time,i] : tout){
        if (i == 0){continue;}
        if (!pos[i]){
            dfs1(i);
            next_color++;
        }
    }
    
    vector<vector<int>> comp(next_color);
    for (int i=1;i<=n;i++){
        comp[c[i]].push_back(i);
    }

    // for (int i=0;i<comp.size();i++){
    //     cout << i << " | ";
    //     for (auto v : comp[i]){
    //         cout << v << ' ';
    //     }cout << endl;
    // }

    pos.resize(0);
    pos.resize(n+1,false);

    vector<int> vectr;
    for (int i=1;i<=n;i++){
        if (g[i].size() == 1 && g1[i].size() == 1){
            vectr.push_back(i);
        }
    }

    ll ans = 1;
    ll kol = 0;
    for (auto i : vectr){
        if (!pos[i]){
            set<pair<int,int>> st;
            pos[i] = true;
            // cout << '!' << i << ' ';
            int l = 0;
            int v = i;
            while (true){
                int u = g[v][0];
                st.insert({min(u,v),max(u,v)});
                if (pos[u]){
                    break;
                }
                
                if (g[u].size()>1 || g1[u].size()>1){
                    break;
                }
                pos[u] = true;
                v = u;
            }
            v = i;
            while (true){
                int u = g1[v][0];
                st.insert({min(u,v),max(u,v)});
                if (pos[u]){
                    break;
                }
                
                if (g1[u].size()>1 || g[u].size()>1){
                    break;
                }
                pos[u] = true;
                v = u;
            }
            // cout << l << endl;
            l = st.size();
            ans = ans * l % MOD;
            kol += (l-1);
        }
    }
    if (ans == 1){
        ans = 0;
    }
    cout << kol << endl;
    cout << ans;
}