#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;
#define int long long

signed main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int n, m, g;
	cin >> n >> m >> g;
	vector<vector<int>> gr(n);
	vector<int> A(n);
	int ans = 0;
	for (int i = 0; i < n; i++) {
		int a, b;
		cin >> a >> b;
		a--;
		b--;
		gr[a].push_back(b);
		gr[b].push_back(a);
		if (a != b - 1) {
			A[a]++;
			A[b]--;
			ans++;
		}
	}
	int upd = 0;
	for (int i = 0; i < n - 1; i++) {
		upd += A[i];
		if (upd == 0) {
			ans++;
		}
	}
	cout << ans << ' ' << 1 << '\n';
}

