#include <iostream>
#include <vector>
#include <math.h>
#include <map>
#include <algorithm>
#include <set>
#include <iomanip>
#include <unordered_map>
#include <unordered_set>
#include <string>

typedef long long ll;
typedef long double ld;

using namespace std;

ll const MAXN = 2e3+1;
ll const A = 367;
ll const B = 1e9 + 7;
ll o = 0;
ll rex[MAXN];
vector <vector<ll>> point(MAXN);
ll ans = 0;


ll logpow(ll num, ll deb) {
	ll sum = 1;
	while (deb != 0) {
		if (deb % 2 == 0) {
			num *= num;
			deb /= 2;
		}
		else {
			sum *= num;
			deb--;
		}
	}
	return sum;
}

void dfs(ll v) {
	rex[v] = 1;
	for (ll i = 0; i < point[v].size(); i++) {
		if (rex[point[v][i]] == 0) {
			dfs(point[v][i]);
		}
		else if (rex[point[v][i]] == 1) {
			ans++;
		}
	}
}
void dfs2(ll v) {
	rex[v] = 2;
	for (ll i = 0; i < point[v].size(); i++) {
		if (rex[point[v][i]] == 1) {
			dfs2(point[v][i]);
		}
	}
}

void solve() {
	ll n, m, g;
	cin >> n >> m >> g;
	for (ll i = 1; i <= m; i++) {
		ll a, b;
		cin >> a >> b;
		point[a].emplace_back(b);
	}
	for (ll i = 0; i < MAXN; i++) {
		rex[i] = 0;
	}
	for (ll i = 1; i <= n; i++) {
		if (rex[i] == 0) {
			dfs(i);
			dfs2(i);
		}
	}
	cout << ans << endl << 1 << endl;
}

int main()
{
	ll t = 1;
	//cin>> t;
	while (t--) {
		solve();
	}
}
