#include <iostream>
#include <vector>
#include <set>
#include <string>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
//#include <cmath>
//#include <numeric>

//#pragma GCC optimize("O3, unroll-loops")
//#pragma GCC target("avx2, avx, lzcnt, popcnt, bmi, bmi2")

using namespace std;

int ans = 0;
int time = 0;

void dfs(int v, vector<vector<int>>& gr, vector<int>& used, vector<pair<int, int>>&tin) {
	used[v] = 1;
	tin[v].first = time;
	time++;
	for (int u : gr[v]) {
		if (used[u] == 0) {
			dfs(u, gr, used, tin);
			ans--;
		}
	}
	tin[v].second = time;
	time++;
}

signed main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int n, m, g;
	cin >> n >> m >> g;
	vector<vector<int>> gr(n);
	for (int i = 0; i < m; i++) {
		int a, b;
		cin >> a >> b;
		a--;
		b--;
		gr[a].push_back(b);
	}
	vector<int> used(n);
	vector<pair<int, int>> tin(n);
	for (int i = 0; i < n; i++) {
		if (used[i] == 0) {
			dfs(i, gr, used, tin);
		}
	}
	for (int i = 0; i < n; i++) {
		for (int u : gr[i]) {
			if (tin[u].first < tin[i].first and tin[i].second < tin[u].second) {
				ans++;
			}
			if (tin[i].first < tin[u].first and tin[u].second < tin[i].second) {
				ans++;
			}
		}
	}
	cout << ans << '\n' << 1;
}