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


void obla() {
    int n, m, gr; cin >> n >> m >> gr;
    vector<vector<int>> g(n);
    for (int i = 0; i < n; i++) {
        int v, u; cin >> v >> u;
        v--, u--;
        g[v].push_back(u);
    }
    vector<int> comp(n);
    for (int i = 0; i < n; i++) {
        comp[i] = i;
    }
    for (int i = 0; i < n - 1; i++) {
        for (auto to : g[i]) {
            comp[i] = min(comp[i], comp[to]);
        }
    }
    vector<int> vert(n), ed(n);
    for (int i = 0; i < n; i++) {
        vert[comp[i]]++;
    }
    for (int i = 0; i < n; i++) {
        for (auto to : g[i]) {
            if (comp[i] == comp[to]) ed[comp[i]]++;
        }
    }
    int need = 0;
    for (int i = 0; i < n; i++) {
        if (!vert[i]) continue;
        need += ed[i] - (vert[i] - 1);
    }
    cout << need << '\n';
    cout << 1 << '\n';
}

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