#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = 1e18;

vector<vector<int>> g, rg;
vector<int> used;
vector<int> ts;
vector<int> comp;

void dfs(int v) {
    used[v] = 1;
    for (auto to : g[v]) {
        if (!used[to]) {
            dfs(to);
        }
    }
    ts.push_back(v);
}

void dfs2(int v, int c) {
    comp[v] = c;
    for (auto to :rg[v]) {
        if (comp[to] == -1) {
            dfs2(to, c);
        }
    }
}

void obla() {
    ll n, m, gr; cin >> n >> m >> gr;
    g.resize(n), rg.resize(n), used.resize(n), comp.resize(n, -1);
    for (int i = 0; i < m; i++) {
        ll v, u; cin >> v >> u;
        v--, u--;
        g[v].push_back(u);
        rg[u].push_back(v);
    }
    /*for (int i = 0; i < n; i++) {
        if (!used[i]) dfs(i);
    }
    reverse(ts.begin(), ts.end());
    int c = 0;
    for (auto v: ts) {
        if (comp[v] == -1) {
            dfs2(v, c);
            c++;
        }
    }*/

    vector<int> go(n);
    int x = 1;
    int s = 0;
    for (int i = 0; i < n; i++) {
        int f = 0;
        if (i == n - 1) {
            go[i] = x;
            continue;
        }
        for (auto to : g[i]) {
            if (to == i + 1) f = 1;
        }
        s += f;
        if (!f) x++;
        go[i] = x;
    }

    ll need = m - s;
    for (int i = 0; i < n; i++) {
        for (auto to : g[i]) {
            if (go[i] != go[to]) need--;
        }
    }
    cout << need << '\n';
    cout << 1 << '\n';
}

int main() {
    int t = 1; //cin >> t;
    cin.tie(0);
    ios::sync_with_stdio(0);
    while (t--) {
        obla();
    }
}
