#include <bits/extc++.h>
using namespace std;
#define int long long
const int MAX_N = 2007;
vector<int> g[MAX_N];
bitset<MAX_N> rw[MAX_N];
int cn[MAX_N][MAX_N];
int p[MAX_N];
void dfs(int v, int root){
    rw[root][v] = true;
    for(auto u:g[v]){
        if(rw[root][u]){
            continue;
        }
        dfs(u, root);
    }
}
void dfs_s(int v, int root){
    for(auto u:g[v]){
        cn[root][u] += cn[root][v];
        dfs_s(u, root);
    }
}
void solve(){
    int n, m, G;
    cin >> n >> m >> G;
    for(int i = 0; i < m; i++){
        int u, v;
        cin >> u >> v;
        u--;v--;
        g[u].push_back(v);
    }
    for(int i = 0; i < n; i++){
        cn[i][i] = 1;
        dfs_s(i, i);
    }
    int ans = 0;
    for(int v = 0; v < n; v++){
        for(auto u:g[v]){
            //cout << v << " " << u << " " << cn[v][u] << "\n";
            if(cn[v][u] > 1){
                ans++;
            }
        }
    }
    cout << ans << "\n" << 1 << "\n";
    /*for(int i = 0; i < n; i++){
        p[i] = i;
    }
    for(int i = 0; i < n; i++){
        for(int j = i + 1; j < n; j++){
            if(rw[i][j] && rw[j][i]){
                p[j] = p[i];
            }
        }
    }*/

}
signed main() {
    ios::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);
    int tim = clock();
    int tt =  1;
    //cin >> tt;
    while(tt--){
        solve();
    }
    //cout << (long double)(clock() - tim) / CLOCKS_PER_SEC << "\n";
}
/*
4 5 0
1 2
2 3
3 4
1 3
2 4
 */