#include <iostream>

#include <vector>

#include <algorithm>

using namespace std;

int main() {
    int n, m, g, x, y;
    cin >> n >> m >> g;
    vector <vector <int>> a(n);
    for (int i = 0; i < m; i++) {
        cin >> x >> y;
        a[x - 1].push_back(y - 1);
    }
    int ans = 0;
    vector <vector <int>> dp(n, vector <int>(n, 0));
    for (int i = n - 1; i >= 0; i--) {
        dp[i][i] = 1;
        for (int j : a[i]) {
            for (int k = 0; k < n; k++) {
                dp[i][k] = max(dp[i][k], dp[j][k]);
            }
            for (int k = 0; k < n; k++) {
                if (k != j && k != i && dp[i][k] && dp[k][j]) {
                    ans++;
                }
            }
        }
    }
    cout << ans << ' ' << 1;
    return 0;
}











