#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] = 1;
    for (auto u: g[v]) {
        if (!used[u])dfs(u, v);
        else cnt++;
    }
}

void solve() {
    int n, m, g1;
    cin >> n >> m >> g1;
    vector<bool> v(n);
    for (int i = 0; i < m; i++) {
        int a, b;
        cin >> a >> b;
        if (a == b - 1) {
            v[a - 1] = true;
        }
        a--;
        b--;
        lol[b] = true;
        g[a].push_back(b);
    }
    bool f = true;
    for (int i = 0; i < n - 1; i++){
        if (!v[i])f = false;
    }
    if (!f) {
        cout << "0\n1";
        return;
    }
        for (int i = 0; i < n; i++) {
        if (!lol[i]) {
            dfs(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();
    }
}