#include <bits/stdc++.h>
#include <immintrin.h>

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#ifndef lisie_bimbi
#define endl '\n'
#endif

using namespace __gnu_pbds;

#define ordered_set tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>

using namespace std;


const int mod = 1'000'000'007;

int add(int a, int b){
    if(a + b < mod){
        return a + b;
    }else{
        return a + b - mod;
    }
}


int sub(int a, int b){
    if(a >= b){
        return a - b;
    }else{
        return a - b + mod;
    }
}

using ll = long long;

int mul(int a, int b){
    return ((ll)a * b) % mod;
}

int binpow(int a, int b){
    if(b == 0){
        return 1;
    }
    int ans = binpow(a, b / 2);
    ans = mul(ans, ans);
    if(b % 2 == 1){
        ans = mul(ans, a);
    }
    return ans;
}

int del(int a, int b){
    return mul(a, binpow(b, mod - 2));
}

vector<set<int>> v;

vector<int> o;
vector<int> used;

void dfs1(int u){
    used[u] = 1;
    for(auto i : v[u]){
        if(!used[i]){
            dfs1(i);
        }
    }
    o.push_back(u);
}

int tt = 0;
vector<int> c;
vector<vector<int>> comps;

void dfs2(int u){
    used[u] = 1;
    c[u] = tt++;
    comps.back().push_back(u);
    for(auto i : v[u]){
        if(!used[i]){
            dfs2(i);
        }
    }
}

vector<vector<int>> v1;

void dfs(int u){
    used[u] = 1;
    for(auto i : v1[u]){
        if(!used[i]){
            dfs(i);
        }
    }
}

const int N = 100'000;

int fac[N], fac1[N];

int cnk(int n, int k){
    if(k > n){
        return 0;
    }
    return (mul(fac[n], mul(fac1[k], fac1[n - k])));
}

void solve(){
    fac[0] = 1;
    for(int i = 1; i < N; i++){
        fac[i] = mul(fac[i - 1], i);
    }
    fac1[N - 1] = del(1, fac[N - 1]);
    for(int i = N - 2; i >= 0; i--){
        fac1[i] = mul(fac1[i + 1], i + 1);
    }
    int n, m, g;
    cin >> n >> m >> g;
    v.resize(n);
    v1.resize(n);
    c.resize(n);
    vector<pair<int, int>> r;
    for(int i = 0; i < m; i++){
        int a, b;
        cin >> a >> b;
        a--;b--;
        r.emplace_back(a, b);
        v[a].insert(b);
        v1[a].push_back(b);
        v1[b].push_back(a);
    }
    int cnt = 0;
    used.clear();
    used.resize(n);
    for(int i = 0; i < n; i++){
        if(!used[i]){
            cnt++;
            dfs(i);
        }
    }
    used.clear();
    used.resize(n);
    for(int i = 0; i < n; i++){
        if(!used[i]){
            dfs1(i);
        }
    }
    used.clear();
    used.resize(n);
    for(auto i : o){
        if(!used[i]){
            comps.emplace_back();
            dfs2(i);
            tt++;
        }
    }
    int cnt2 = 0;
    for(auto [a, b] : r){
        v[a].erase(b);
        used.clear();
        used.resize(n);
        dfs(a);
        bool f = used[b];
        used.clear();
        used.resize(n);
        dfs(b);
        f &= used[a];
        if(!f){
            cnt2++;
        }
    }
    if(cnt2 <= n - 1){
        cout << cnt2 << endl << 1 << endl;
        return;
    }
    cout << n - 1 << endl << 0 << endl;
}

signed main(){
#ifdef lisie_bimbi
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#else
    cin.tie(nullptr)->sync_with_stdio(false);
#endif            
    int t = 1;
    //cin >> t;
    while(t--){
        solve();
    }
}