#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <set>
#include <string>
#include <queue>

#define len(v) (int)((v).size())
#define ss second
#define ff first


typedef long long ll;

using namespace std;

const ll inf = 1e12 + 7;

const int N = 2005;
vector<int> g[N];

const int M = 1e9 + 7;

void solve() {
	int n, m, gr;
	cin >> n >> m >> gr;

	for (int i = 0; i < m; ++i) {
		int x, y;
		cin >> x >> y;
		g[--x].push_back(--y);
	}

	int res = 0;

	vector<vector<int>> ng(n);

	for (int v = 0; v < n; ++v) {
		for (int u : g[v]) {
			g[u].push_back(v);
			vector<bool> us(n);
			us[v] = true;
			queue<int> q;
			q.push(v);
			while (!q.empty()) {
				int qv = q.front();
				q.pop();

				for (int qu : g[qv]) {
					if (qv == v && qu == u) continue;
					if (us[qu]) continue;

					us[qu] = true;
					q.push(qu);
				}
			}
			if (us[u])
				g[u].pop_back();
			if (!us[u]) {
				++res;
				ng[v].push_back(u);
			}
		}
	}

	if (res == n) {
		cout << n - 1 << '\n' << n << '\n';
	}
	else {
		cout << res << '\n' << 1 << '\n';
	}
}

signed main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	cout.precision(30);

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



