#include <bits/stdc++.h>

using namespace std;

#define ll long long
#define ld long double
#define pb push_back
#define all(x) x.begin(), x.end()
#define sz(x) (int)x.size()
#define int long long

const int N = 2010;
int a[N][N], st, kol = 0;
vector<int> g[N];

void dfs(int v, int tek) {
    if (tek > 2) {
        if (a[st][v]) {
            a[st][v] = 0;
            kol++;
        }
    }
    for (int j : g[v]) {
        dfs(j, tek + 1);
    }
}

signed main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int n, m, t;
    cin >> n >> m >> t;
    for (int i = 0; i < m; ++i) {
        int l, r;
        cin >> l >> r;
        a[l][r] = 1;
        g[l].pb(r);
    }
    for (int i = 1; i <= n; ++i) {
        st = i;
        dfs(i, 1);
    }
    cout << kol << " " << 1;
    return 0;
}
