#pragma GCC optimize("O3")
#include <bits/stdc++.h>

using namespace std;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);

    int n, m, g; cin >> n >> m >> g;
    vector<vector<int>> graph(n);
    vector<int> c1(n), c2(n);
    for (int i = 0; i < m; ++i) {
        int u, v; cin >> u >> v; --u; --v;
        graph[u].emplace_back(v);
        ++c1[u]; ++c2[v];
    }
    int cnt = 0;
    for (int i = 0; i < n; ++i) {
        if (c1[i]==1 && c2[i]==1) ++cnt;
    }
    if (cnt==n) --cnt;
    cout << cnt << " 1\n";
    /*int64_t ans = 0;
    for (int u = 0; u < n; ++u) {
        for (auto v : graph[u]) {
            vector<bool> can(n, false);
            for (auto h : graph[u]) if (h!=v) can[h] = true;
            for (int i = u+1; i < n; ++i) {
                if (!can[i]) continue;
                for (auto j : graph[i]) can[j] = true;
            }
            ans += can[v];
        }
    }
    cout << ans << ' ' << 1 << '\n';*/

    return 0;
}
