#include <bits/stdc++.h>


using namespace std;


using ll = long long;


const ll mod = 1e9 + 7;


template<typename T>
ostream & operator <<(ostream &os, const vector<T> &a) {
    for (T el : a) {
        os << el << " ";
    }
    os << '\n';
    return os;
}


void dfs(const vector<vector<int>> &g, vector<int> &used, int v, int &ans, int color) {
    used.at(v) = color;
    for (int to : g.at(v)) {
        if (used.at(to) == color) {
            ans += 1;
        } else if (used.at(to) == 0) {
            dfs(g, used, to, ans, color);
        }
    }
}


int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    int n, m, group;
    cin >> n >> m >> group;
    vector<vector<int>> g(n);
    vector<pair<int, int>> edges(m);
    for (int i = 0; i < m; i++) {
        int v, u;
        cin >> v >> u;
        v--;
        u--;
        g.at(v).push_back(u);
        edges.push_back({v, u});
    }
    int ans = 0;
    vector<int> used(n, 0);
    int color = 1;
    for (int i = 0; i < n; i++) {
        if (used.at(i) == 0) {
            dfs(g, used, i, ans, color);
        }
        color++;
    }
    cout << ans << " " << 0;
    return 0;
}
