#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops")
#define int long long

using namespace std;
using ll = long long;
using ld = long double;
const int INF = 1e18;
const int MOD = 1e9 + 7;
const int N = 3e5 + 69;

vector<vector<int>> g;
vector<bool> vis;
vector<int> tps;
int cnt = 0;

void make_tps(int v) {
    vis[v] = true;
    for (int u : g[v]) {
        if (!vis[u]) make_tps(u);
        else ++cnt;
    }
    tps.push_back(v);
}

void solve() {
    int n, m, testgr;
    cin >> n >> m >> testgr;
    g.resize(n);
    for (int i = 0; i < m; ++i) {
        int v, u;
        cin >> v >> u;
        --v, --u;
        g[v].push_back(u);
    }
    vis.assign(n, false);
    for (int v = 0; v < n; ++v) {
        if (!vis[v]) {
            make_tps(v);
        }
    }
    cout << cnt << "\n" << 1;
}

signed main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    solve();
    return 0;
}
