#pragma GCC optimize("O3")
#include <bits/stdc++.h>
//#define int long long
#define all(x) (x).begin(), (x).end()
#define f first
#define s second
#define pi pair<int, int>


using namespace std;

vector<vector<int>> g, rg;
vector<int> was, tps, comp;

void dfs1(int u) {
    if (was[u]) return;
    was[u] = 1;
    for (auto& v : g[u]) {
        dfs1(v);
    }
    tps.push_back(u);
}

int c = 0;

void dfs2(int u) {
    if (was[u]) return;
    was[u] = 1;
    comp[u] = c;
    for (auto& v : rg[u]) {
        dfs2(v);
    }
}

int n;

inline void recalc() {
    was.assign(n, 0);
    vector<vector<int>> cc(n);
    for (int i = 0; i < n; ++i) {
        cc[comp[i]].push_back(i);
    }
    int cr = 0;
    for (int i = 0; i < n; ++i) {
        if (was[comp[i]]) continue;
        int c = comp[i];
        for (auto& el : cc[cr]) {
            comp[el] = c;
        }
        for (auto& el : cc[c]) {
            comp[el] = cr;
        }
        swap(cc[cr], cc[c]);
        was[comp[i]] = 1;
        ++cr;
    }
}

void solve() {
    int m, grp;
    cin >> n >> m >> grp;
    g.assign(n, {});
    rg.assign(n, {});
    vector<pi> eds(m);
    for (int i = 0; i < m; ++i) {
        int u, v;
        cin >> u >> v;
        --u, --v;
        if (abs(v - u) == 1) continue;
        eds[i] = {u, v};
        g[u].push_back(v);
        rg[v].push_back(u);
    }

    was.assign(n, 0);
    for (int i = 0; i < n; ++i) {
        if (!was[i]) dfs1(i);
    }
    reverse(all(tps));
    comp.assign(n, 0);
    was.assign(n, 0);
    for (auto& el : tps) {
        if (!was[el]) {
            dfs2(el);
            ++c;
        }
    }
    cout << c - 1 << " " << -1 << "\n";
}

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int t = 1;
    //cin >> t;
    while (t--) {
        solve();
    }
}
