#pragma GCC optimize("03")
#include <iostream>
#include <set>
#include <vector>
#include <random>
#include <iomanip>
//#include <fstream>
#include <algorithm>
#include <map>
#include <unordered_set>
#include <unordered_map>
#pragma GCC target("avx2")
#define int long long
const int INF = 1e7;
const int N = 3e5 + 1;
using namespace std;
int ans = 0;
void dfs(vector<vector<int>>& g, vector<int>& colors, int u, int col) {
    colors[u] = col;
    for (auto v : g[u]) {
        if (colors[v] == col) {
            ans++;
            continue;
        }
        dfs(g, colors, v, col);
    }
}
signed main()
{
    cin.tie(nullptr)->sync_with_stdio(false);
    int n, m, tp;
    cin >> n >> m >> tp;
    vector<vector<int>> g(n);
    vector<vector<int>> g2(n);
    int ans = 0;
    for (int i = 0; i < m; i++) {
        int u, v;
        cin >> u >> v;
        u--, v--;
        g[u].push_back(v);
    }
    for (int i = 0; i < n; i++) {
        sort(g[i].begin(), g[i].end());
    }
    vector<int> colors(n);
    int col = 1;
    for (int i = 0; i < n; i++) {
        if (colors[i] == 0) {
            dfs(g, colors, i, col++);
        }
    }
    cout << ans << "\n" << 1 << '\n';
}