// #pragma GCC optimize("O3,unroll-loops")
// #pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt")
#ifdef LOCAL
#define _GLIBCXX_DEBUG
#endif
#include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
#define int long long
// #define ll __int128
using namespace std;
// using namespace __gnu_pbds;
// #define unordered_map gp_hash_table
// #define ordered_set tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>

const int INF = 1e9 + 7;

vector<bool> used;
vector<int> d;
vector<vector<int>> g;

void dfs(int v) {
    used[v] = true;
    for (int u : g[v]) {
        if (!used[u]) {
            d[u] = d[v] + 1;
            dfs(u);
        }
    }
}

void solve() {
    int n, m, _g;
    cin >> n >> m >> _g;
    g.resize(n);
    for (int i = 0; i < m; i++) {
        int v, u;
        cin >> v >> u;
        v--;
        u--;
        g[v].push_back(u);
    }
    int res = 0;
    for (int i = 0; i < n; i++) {
        used.assign(n, false);
        d.assign(n, 0);
        dfs(i);
        for (int u : g[i]) {
            if (used[u] && d[u] > 1) {
                res++;
            }
        }
    }
    cout << res << "\n" << 1 << "\n";
}

signed main() {
    // cout << fixed << setprecision(20);
    #ifdef LOCAL
    freopen("C:\\work\\input.txt", "r", stdin);
    #else
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    #endif
    solve();
}