#ifdef _MSC_VER
#include <__msvc_all_public_headers.hpp>
#else
#include <bits/stdc++.h>
#endif

using namespace std;
using ll = long long;
const int inf = 1e9 + 7;
const ll infll = 1e18;

template<typename T>
istream& operator>>(istream& is, vector<T>& a) {
	for (auto& i : a) {
		is >> i;
	}
	return is;
}

const int N = 2000;

int32_t main() {
#ifdef LOCAL
	assert(freopen("C:\\Users\\User\\input.txt", "r", stdin));
#else
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
#endif
	int n, m, _;
	cin >> n >> m >> _;
	vector<bitset<N>> dp(n);
	vector<pair<int, int>> edg(m);
	for (int i = 0; i < m; ++i) {
		int u, v;
		cin >> u >> v;
		--u, --v;
		dp[u][v] = 1;
		edg[i] = { u, v };
	}
	auto dppp = dp;
	for (int k = 0; k < n; ++k) {
		for (int i = 0; i < n; ++i) {
			if (dppp[i][k]) {
				dppp[i] |= dppp[k];
			}
		}
	}
	vector<int> c(n, -1);
	int num = 0;
	for (int i = 0; i < n; ++i) {
		if (c[i] != -1) {
			continue;
		}
		c[i] = num++;
		for (int j = 0; j < n; ++j) {
			if (dppp[i][j] && dppp[j][i]) {
				c[j] = c[i];
			}
		}
	}
	vector<int> bad;
	for (int mask = 1; mask < (1 << m); ++mask) {
		auto dpp = dp;
		for (int i = 0; i < m; ++i) {
			if ((mask >> i) & 1) {
				auto [u, v] = edg[i];
				dpp[u][v] = 0;
				dpp[v][u] = 1;
			}
		}
		for (int k = 0; k < n; ++k) {
			for (int i = 0; i < n; ++i) {
				if (dpp[i][k]) {
					dpp[i] |= dpp[k];
				}
			}
		}
		vector<int> cc(n, -1);
		int num = 0;
		for (int i = 0; i < n; ++i) {
			if (cc[i] != -1) {
				continue;
			}
			cc[i] = num++;
			for (int j = 0; j < n; ++j) {
				if (dpp[i][j] && dpp[j][i]) {
					cc[j] = cc[i];
				}
			}
		}
		if (c == cc) {
			bad.push_back(mask);
		}
	}
	int ans = 0;
	int cnt = 0;
	for (int mask = 0; mask < (1 << m); ++mask) {
		bool ok = true;
		for (int i = 0; i < min((int)bad.size(), (int)1e5); ++i) {
			if ((mask & bad[i]) == bad[i]) {
				ok = false;
				break;
			}
		}
		int bits = 0;
		for (int i = 0; i < m; ++i) {
			if ((mask >> i) & 1) {
				++bits;
			}
		}
		if (ok) {
			if (ans < bits) {
				ans = bits;
				cnt = 1;
			}
			else if (ans == bits) {
				++cnt;
			}
		}
	}
	cout << ans << "\n";
	cout << cnt << "\n";
	return 0;
}