#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <iomanip>

using namespace std;

const long long mod = 1e9 + 7;

long long n, m, G, ans = 0;

vector<long long> dpp;

void dfs4(long long v, vector<vector<long long>>& g) {
	++dpp[v];
	if (dpp[v] > 2)
		return;
	for (long long i = 0; i < g[v].size(); ++i)
		dfs4(g[v][i], g);
}

long long f(vector<vector<long long>> g) {
	long long x55 = 0;
	for (long long i = 0; i < n; ++i) {
		dpp.clear();
		dpp.resize(n, 0);
		dfs4(i, g);
		for (long long j = 0; j < g[i].size(); ++j)
			if (dpp[g[i][j]] > 1)
				++x55;
	}
	return x55;
}

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);

	cin >> n >> m >> G;

	vector<pair<long long, long long>> v1, v2;
	long long ans = 0;
	for (long long i = 0; i < m; ++i) {
		long long a, b;
		cin >> a >> b;
		--a;
		--b;
		if (b - a == 1 || (a == n - 1 && b == 0))
			continue;
		++ans;
		if (a < b)
			v1.push_back({ b, n + a });
		else
			v1.push_back({ b, a });
	}

	/*sort(v1.begin(), v1.end());
	
	for (long long i = 0; i < (long long)v1.size(); ++i) {
		while ((long long)v2.size() > 0 && v2[(long long)v2.size() - 1].first <= v1[i].first && v2[(long long)v2.size() - 1].second >= v1[i].second)
			v2.pop_back();
		if ((long long)v2.size() == 0 || v2[(long long)v2.size() - 1].first != v1[i].first)
			v2.push_back(v1[i]);
	}

	long long ans1 = -1, ans2 = 1, r = 0, l = -1;

	for (long long i = 0; i < v2.size(); ++i) {
		if (v2[i].first < r) {
			l = v2[i].first;
		}
		else {
			ans2 = (r - l) * ans2 % mod;
			++ans1;
			l = v2[i].first;
			r = v2[i].second;
		}
	}
	ans2 = (r - l) * ans2 % mod;
	++ans1;*/

	cout << n - ans - 1 << ' ' << n - 1;
	return 0;
}
