#include <bits/stdc++.h>

using namespace std;
using ll = long long;
const int mod = 1e9 + 7;

void solve3(int n, int m, vector<vector<int>> g) {
    cout << m - n + 1 << ' ' << 1 << '\n';
}

void solve() {
    int n, m, g;
    cin >> n >> m >> g;
    vector<vector<int>> gr(n, {});
    for (int i = 0, u, v; i < m; ++i) {
        cin >> u >> v;
        --u, --v;
        g[u].push_back(v);
    }
    if (g == 3) {
        solve3(n, m, g);
        return;
    }
    cout << "1 1\n";
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    solve();
}
