#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#define int long long

using namespace std;

vector<vector<int>> gr;
vector<int> used;
vector<int> ti;
int ans = 0, timer = 0;

bool check(int v, int t) {
    return ti[v] <= ti[t];
}

void dfs(int v, int tm) {
    ti[v] = timer++;
    used[v] = tm;
    for (auto t : gr[v]) {
        if (used[t] != tm) {
            dfs(t, tm);
        } else if (check(v, t)) {
            ans++;
        }
    }
}

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int n, m, g;
    cin >> n >> m >> g;
    gr.resize(n);
    for (int i = 0; i < m; ++i) {
        int u, v;
        cin >> u >> v;
        u--, v--;
        gr[u].push_back(v);
    }
    for (int i = 0; i < n; ++i) {
        sort(gr[i].begin(), gr[i].end());
    }
    used.resize(n);
    ti.resize(n);
    for (int i = 0; i < n; ++i) {
        if (!used[i]) {
            dfs(i, i + 1);
        }
    }
    cout << ans << ' ' << 1 << '\n';
}
