#include <bits/stdc++.h>

using namespace std;

using ll = long long;

const int inf = 1e9 + 10;

vector<vector<int>> g, rg;

void solve() {
    int n, m, gr;
    cin >> n >> m >> gr;
    g.resize(n);
    rg.resize(n);
    for (int i = 0; i < m; i++) {
        int u, v;
        cin >> u >> v;
        u--; v--;
        g[u].push_back(v);
        rg[v].push_back(u);
    }
    int ans = 0;
    for (int i = 0; i < n; i++) {
        vector<int> ways(n);
        ways[i] = 1;
        for (int j = i + 1; j < n; j++) {
            bool was = false;
            for (auto v : rg[j]) {
                if (v == i) {
                    was = true;
                }
                ways[j] += ways[i];
                ways[j] = min(ways[j], 2);
            }
            if (ways[j] >= 2 && was) {
                ans++;
            }
        }
    }
    cout << ans << '\n';
    cout << 1 << '\n';
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    int t = 1;
    for (int i = 0; i < t; i++) solve();
}
