#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = 1e18;

vector<vector<int>> g, rg;
vector<int> used;
vector<int> ts;
vector<int> comp;

void dfs(int v) {
    used[v] = 1;
    for (auto to : g[v]) {
        if (!used[to]) {
            dfs(to);
        }
    }
    ts.push_back(v);
}

void dfs2(int v, int c) {
    comp[v] = c;
    for (auto to :rg[v]) {
        if (comp[to] == -1) {
            dfs2(to, c);
        }
    }
}

void obla() {
    ll n, m, gr; cin >> n >> m >> gr;
    g.resize(n), rg.resize(n), used.resize(n), comp.resize(n, -1);
    vector<pair<int, int>> edges;
    for (int i = 0; i < m; i++) {
        ll v, u; cin >> v >> u;
        v--, u--;
        g[v].push_back(u);
        rg[u].push_back(v);
        edges.push_back({v, u});
    }
    for (int i = 0; i < n; i++) {
        if (!used[i]) dfs(i);
    }
    reverse(ts.begin(), ts.end());
    int c = 0;
    for (auto v: ts) {
        if (comp[v] == -1) {
            dfs2(v, c);
            c++;
        }
    }

    vector<int> go(n);
    int ch = 0;
    go[0] = ch;
    for (int i = 0; i < n - 1; i++) {
        int f = 0;
        for (auto to : g[i]) {
            if (to == i + 1) f = 1;
        }
        if (!f) ch++;
        go[i + 1] = ch;
    }

    vector<int> vert(n), ed(n);
    for (int i = 0; i < n; i++) {
        vert[go[i]]++;
        for (auto to : g[i]) {
            if (go[i] == go[to]) {
                ed[go[i]]++;
            }
        }
    }
    ll need = 0;
    for (int i = 0; i < n; i++) {
        if (!vert[i]) continue;
        need += ed[i] - (vert[i] - 1);
    }
    for (int i = 0; i < n; i++) {
        vert[go[i]]++;
        for (auto to : g[i]) {
            if (go[i] != go[to]) {
                need--;
            }
        }
    }
    cout << need << '\n';
    cout << 1 << '\n';
}

int main() {
    int t = 1; //cin >> t;
    cin.tie(0);
    ios::sync_with_stdio(0);
    while (t--) {
        obla();
    }
}
