#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
//
//#pragma GCC optimize("O3")
//#pragma GCC target("avx2,bmi")

using namespace std;
using namespace __gnu_pbds;

#define int long long
#define endl "\n"
#define ordered_set tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>

constexpr int INF = 2e13;
constexpr int MOD = 1e9 + 7;
vector<vector<int>> gr;


signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);

    int n, m, g;
    cin >> n >> m >> g;
    vector<vector<int>> otr(m);
    vector<vector<int>> kon(m + 1);
    bool ok = false;
    for (int i = 0; i < m; i++) {
        int v, u;
        cin >> v >> u;
        v--;
        u--;
        if (v == n - 1 && u == 0) continue;
        otr[v].push_back(u);
        kon[u + 1].push_back(v);
    }
    int alive = 0;
    int cnt = 0;
    for (int i = 0; i < n; i++) {
        for (int j : otr[i]) {
            alive++;
        }
        for (int j : kon[i]) {
            alive--;
        }
        if (alive == 1) {
            cnt++;
        }
    }
    cout << cnt << " " << -1 << endl;
}
