#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using ll = long long;

using namespace std;
using namespace __gnu_pbds;

const ll mod = (1e9) + 7;

template<typename T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

void dfs(ll v, vector<vector<ll>> &g, vector<ll> &u, vector<ll> &ts) {
    u[v] = 1;
    for (auto i: g[v]) {
        if (!u[i]) {
            dfs(i, g, u, ts);
        }
    }
    ts.push_back(v);
}

inline void solve() {
    /*ordered_set<ll> s;
    cout << (*s.find_by_order(2)) << endl;
    cout << s.order_of_key(2) << endl;*/
    ll n, m, group;
    cin >> n >> m >> group;
    vector<vector<ll>> g(n);
    vector<vector<ll>> gr(n);
    for (ll i = 0; i < m; i++) {
        ll x, y;
        cin >> x >> y;
        x--;
        y--;
        g[x].push_back(y);
        gr[y].push_back(x);
    }
    vector<vector<ll>> g2;
    vector<ll> ts;
    vector<vector<ll>> c;
    vector<ll> u(n, 0);
    for (ll i = 0; i < n; i++) {
        if (!u[i]) {
            dfs(i, g, u, ts);
        }
    }
    reverse(ts.begin(), ts.end());
    u = vector<ll>(n, 0);
    for (ll i = 0; i < n; i++) {
        if (!u[i]) {
            vector<ll> ts2;
            dfs(i, gr, u, ts2);
            c.push_back(ts2);
        }
    }
    if (group == 3) {
        cout << m - n + 1 << " " << 1 << endl;
        return;
    }
    if (group == 5) {
        cout << n - 1 << " " << n << endl;
        return;
    }
}

int main() {
    cin.tie(0);
    cout.tie(0);
    ios_base::sync_with_stdio(0);
    ll q = 1;
    // cin >> q;
    while (q--) {
        solve();
    }
}
