#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
//#define int ll
#define pb push_back
#define pii pair<int, int>
#define X first
#define Y second
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()

const int MOD = 1e9 + 7;
const int INF = 1e9 + 7;
const int N = 2010;

int n, m, G, comp[N], tmr = 0, sz_comp[N], ans = 0, in[N], edg[N];
bool usd[N], u_comp[N];
vector<int> g[N], gt[N], top_sort;
set<int> g_comp[N];

void dfs(int v) {
    usd[v] = true;
    for(int to : g[v]) {
        if(usd[to]) continue;
        dfs(to);
    }
    top_sort.pb(v);
}

void dfs1(int v) {
    comp[v] = tmr;
    ++sz_comp[tmr];
    for(int to : gt[v]) {
        if(comp[to] != -1) continue;
        dfs1(to);
    }
}

void calc(int v) {
    u_comp[v] = true;
    for(int to : g_comp[v]) {
        if(u_comp[to]) continue;
        ++ans;
        calc(to);
    }
}

void solve() {
    cin >> n >> m >> G;
    for(int i = 1; i <= m; ++i) {
        int x, y;
        cin >> x >> y;
        g[x].pb(y);
        gt[y].pb(x);
    }
    for(int i = 1; i <= n; ++i) {
        if((int)gt[i].size() == 0 && !usd[i]){
            dfs(i);
        }
    }
    for(int i = 1; i <= n; ++i) if(!usd[i]) dfs(i);

    fill(comp, comp + n + 1, -1);
    reverse(all(top_sort));

    for(int v : top_sort) {
        if(comp[v] == -1) {
            dfs1(v);
            ++tmr;
        }
    }

    for(int i = 1; i <= n; ++i) {
        for(int to : g[i]) {
            if(comp[to] == comp[i]) {
                ++edg[comp[i]];
                continue;
            }
            g_comp[comp[i]].insert(comp[to]);
            ++in[comp[to]];
        }
    }

    for(int i = 0; i < tmr; ++i) {
        ans += max(0, edg[i] - 2);//1 + edg[i] - sz_comp[i];
    }

    for(int i = 0; i < tmr; ++i) {
        if(in[i] == 0) calc(i);
    }

    cout << m - ans << '\n' << 1 << '\n';
}

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
#ifdef LOCAL
    freopen("inp.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
    auto start = clock();
#endif
    int ttt = 1;
    //cin >> ttt;
    while(ttt--) {
        solve();
    }
#ifdef LOCAL
    auto end = clock();
    cerr << "TIME: " << (end - start) << "ms" << '\n';
#endif
}

/*
11 17 0
1 2
2 3
3 4
4 1
1 3
4 2
1 5
2 7
5 6
6 7
7 5
6 8
3 11
8 11
11 10
10 9
9 8
 */