#include <bits/stdc++.h>

using namespace std;

bool is_d(int i, int v, vector<vector<int>> &gr, vector<bool> &used, int st) {
    if (used[i]) return false;
    used[i] = true;
    if (i == v) return true;
    for (auto &j : gr[i]) {
        if (i == st && j == v) continue;
        if (is_d(j, v, gr, used, st)) return true;
    }
    return false;
}

int ansdag(vector<vector<int>> &gr) {
    int n = gr.size();
    int ans = 0;
    for (int i = 0; i < n; i++) {
        for (auto &j : gr[i]) {
            vector<bool> used(n, false);
            if (is_d(i, j, gr, used, i)) {
                ans++;
            }
        }
    }
    return ans;
}

int main() {
    int n, m, g;
    cin >> n >> m >> g;
    vector<vector<int>> gr(n);
    for (int i = 0; i < m; i++) {
        int u, v;
        cin >> u >> v;
        u--;
        v--;
        gr[u].push_back(v);
    }
    cout << ansdag(gr) << " " << 1 << "\n";
}