#include <bits/stdc++.h>

using ll = long long;
using namespace std;

void dfs(int num, vector <vector <int>> &gr, vector <int> &topsort, vector <int> &vis) {
    vis[num] = 1;
    for (int next : gr[num]) {
        if (!vis[next]) {
            dfs(next, gr, topsort, vis);
        }
    }
    topsort.push_back(num);
}
const int len = 2000;
void dfs1(int num, vector <vector <int>> &gr, vector <int> &vis, int &ans, vector <bitset <len>> &now) {
    vis[num] = 1;
    now[num][num] = 1;
    vector <int> list{};
    for (int next : gr[num]) {
        if (!vis[next]) {
            dfs1(next, gr, vis, ans, now);
            now[num] |= now[next];
        } else {
            list.push_back(next);
        }
    }
    for (int next : list) {
        if (now[num][next]) {
            ++ans;
        }
    }
}
void solve() {
    int n, m, g;
    cin >> n >> m >> g;
    vector <vector <int>> gr(n);
    for (int i = 0; i < n; ++i) {
        int a, b;
        cin >> a >> b;
        --a;
        --b;
        gr[a].push_back(b);
    }
    vector <bitset <len>> now(n);
    vector <int> topsort{}, vis(n, 0);
    for (int i = 0; i < n; ++i) {
        if (!vis[i]) {
            dfs(i, gr, topsort, vis);
        }
    }
    int ans = 0;
    reverse(topsort.begin(), topsort.end());
    fill(vis.begin(), vis.end(), 0);
    for (int num : topsort) {
        if (!vis[num]) {
            dfs1(num, gr, vis, ans, now);
        }
    }
    cout << ans << " " << 1 << '\n';
}
signed main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    solve();
}
