#include <bits/stdc++.h>
using namespace std;
#define ll long long
mt19937 rnd(12749123);

int n, m, gggg, cnt = 0;
vector<vector<int>> g, g1;
vector<int> used;

void dfs(int v, int st) {
    used[v] = st;
    for (int to : g[v]) {
        if (used[to] < st) {
            dfs(to, st);
            if (v != st && g1[st][to]) {
                cnt++;
            }
        }
    }
}

void solve() {
    g.resize(n);
    g1.resize(n, vector<int>(n));

    for (int i = 0; i < m; ++i) {
        int u, v; cin >> u >> v;
        g[u-1].push_back(v-1);
        g1[u-1][v-1] = 1;
    }

    used.resize(n, -1);
    for (int i = 0; i < n; ++i) {
        dfs(i, i);
    }
    cout << cnt << '\n' << 1;
}

int main()
{

    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    int ttt = 1;
    //cin >> ttt;
    while (ttt--) {
        cin >> n >> m >> gggg;
        solve();
    }
}
