#include <bits/stdc++.h>
using namespace std;


using ll = long long;
const int inf = 1e9 + 10;

const int mod = 1e9 + 7;

int add(int a, int b) {
    return a + b >= mod ? a + b - mod : a + b;
}
int sub(int a, int b) {
    return a >= b ? a - b : a + mod - b;
}
int mul(int a, int b) {
    return 1ll * a * b % mod;
}

signed main() {
    cin.tie(nullptr)->sync_with_stdio(false);

    int n, m, group;
    cin >> n >> m >> group;
    vector<vector<int>> g(n), in(n);
    for (int i = 0; i < m; ++i) {
        int u, v;
        cin >> u >> v;
        v--, u--;
        g[u].push_back(v);
        in[v].push_back(u);
    }
    vector<vector<bool>> adj(n, vector<bool>(n, false));
    for (int i = n - 1; i >= 0; --i) {
        adj[i][i] = true;
        for (auto j : g[i]) {
            for (int k = 0; k < n; ++k) {
                if (adj[j][k]) adj[i][k] = true;
            }
        }
    }
    int mn = 0, cnt = 1;
    for (int i = 0; i < n; ++i) {
        for (auto j : in[i]) {
            bool ok = true;
            for (auto k : in[i]) {
                if (j == k) continue;
                ok &= !adj[j][k];
            }
            if (ok) {
                mn++;
            }
        }
    }
    cout << m - mn << endl << 1;
}