#include "bits/stdc++.h"

using namespace std;
#define ll long long
#define ff first
#define ss second
mt19937 rnd(time(0));
#define int long long
const int mod = 1e9 + 7;
const int maxn = 2005;
vector<int> g[maxn];
bool lol[maxn];
int used[maxn];
int cnt = 0;

void dfs(int v, int pr) {
    used[v]++;
    for (auto u: g[v]) {
        dfs(u, v);

    }
}
int cnt1[maxn];
void solve() {
    int n, m, g1;
    cin >> n >> m >> g1;

    for (int i = 0; i < m; i++) {
        int a, b;
        cin >> a >> b;

        a--;
        b--;
        cnt1[b]++;
        lol[b] = true;
        g[a].push_back(b);
    }
    for (int i = 0; i < n; i++) {
        if (!lol[i]) {
            dfs(i, -1);
        }
    }
    for (int i = 0; i < n; i++)cnt += used[i] - 1;
    cout << cnt << '\n' << 1;


}

signed main() {
    ios_base::sync_with_stdio(false);
    cout.tie(nullptr);
    cin.tie(nullptr);
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    int t = 1;
    //cin >> t;
    while (t--) {
        solve();
    }
}