#define _CRT_SECURE_NO_WARNINGS
#ifndef _DEBUG
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#endif
#include <iostream>
#include <iomanip>
#include <cmath>
#include <chrono>
#include <random>
#include <string>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <vector>
#include <deque>
#include <queue>


using namespace std;
#define int long long
using ll = long long;
using ld = long double;
using pll = pair<ll, ll>;
using pii = pair<int, int>;
auto sd = chrono::high_resolution_clock::now().time_since_epoch().count();
mt19937 rnd(sd);
using str = string;
//ll msk[1ll << 21];
void solve1() {
	ll n, m, g;
	cin >> n >> m >> g;
	ll cnt = 0;
	ll cnt1 = 0;
	for (int j = 0; j < m; j++) {
	
		ll u, v;
		cin >> u >> v;
		if (u + 1 != v) {
			cnt++;
		}
		else cnt1++;
	}
	if (cnt1 == n-1 ||g==3 || g==0) {
		cout << cnt << " " << 1;
	}
	else {
		cout << 0 << " " << 1;
	}
}

signed main() {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);

#ifdef _DEBUG
	freopen("in.txt", "r", stdin);
	freopen("out.txt", "w", stdout);
#endif

	ll t1 = 1;
	//cin >> t1;
	while (t1 > 0) t1--, solve1();
}

