#include <iostream>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <unordered_set>
#include <fstream>
#include <algorithm>
#include <unordered_map>

using ll = long long;
#define endl '\n'
 #pragma GCC target("avx,avx2,fma")
// #pragma GCC optimize("Ofast")
// #pragma GCC optimize("O3")
// #pragma GCC optimize("unrool-loops")

using namespace std;

const int N = 1500000 + 1, mod = 1e9 + 7;
int n, m, k, q;
int st = 1;
int G;
vector<vector<int>> g;

vector<int> tree;
void upd(int v, int vl, int vr, int ql, int qr) {
    if (vr < ql || qr < vl) return;
    if (ql <= ql && vr <= qr) {tree[v]++; return;}
    upd(2 * v, vl, (vl + vr) / 2, ql, qr);
    upd(2 * v + 1, (vl + vr + 1) / 2, vr, ql, qr);
}
int get(int x) {
    x += st;
    int ans = 0;
    ans = tree[x];x/=2;
    while (x > 0) {ans += tree[x];x/=2;}
    return ans;
}
void solve() {
    cin >> n >> m >> G;
    g.resize(n);
    for (int i =0; i < m; i++) {
        int v, u; cin >> v >> u; --v;--u;
        if (u != (v + 1) % n) g[v].push_back(u);
    }
    while (st < n) st<<=1;
    tree.resize(2 * st, 0);
    for (int i = 0; i < n; i++) {
        for (auto u : g[i]) {
            if (i < u) {
                upd(1, 0, st - 1, i, u - 1);
            } else {
                upd(1, 0, st - 1, i, n);
                upd(1, 0, st - 1, 0, u - 1);
            }
        }
    }
    int col = m - n + 1;
    for (int i = 0; i < n; i++) {
        if (get(i) >= 2) col++;
    }
    cout << col << ' ' << 1 << endl;
}


#define LOCAL
signed main() {
	ios_base::sync_with_stdio(false);
	cout.tie(0);
	cin.tie(0);
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
#endif 
    solve();
}