#include <bits/stdc++.h>

using namespace std;
typedef long long ll;

pair<int, int> get_for_groups(int n, int m, vector<vector<int>> & g) {
    vector<int> maxi(n, -1), mini(n, n);
    for (int i = 0; i < n; ++i) {
        for (auto j : g[i]) {
            maxi[j] = max(i, maxi[j]);
            mini[i] = min(j, mini[i]);
        }
    }
    set<pair<int, int>> s;
    for (int i = 0; i < n; ++i) {
        if (maxi[i] != -1) s.insert({maxi[i], i});
        if (mini[i] != n) s.insert({i, mini[i]});
    }
    return {s.size(), 1};
}

vector<vector<int>> g;


void solve() {
    int n, m, G;
    cin >> n >> m >> G;
    g.assign(n, {});
    for (int i = 0; i < m; ++i) {
        int u, v;
        cin >> u >> v;
        g[--u].push_back(--v);
    }
    pair<int, int> ans = get_for_groups(n, m, g);
    cout << ans.first << " " << ans.second << "\n";
}

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