#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
//using namespace __gnu_pbds;

//template<typename T>
//using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define rs resize
#define pb push_back
#define ff first
#define ss second
#define sz(x) (int)x.size()
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define int long long

typedef long double ld;
typedef long long ll;

typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

template<typename T>
istream &operator >>(istream &in, pair<T, T> &a) {
    in >> a.ff >> a.ss;
    return in;
}

template<typename T>
ostream &operator <<(ostream &out, pair<T, T> &a) {
    out << a.ff << " " << a.ss;
    return out;
}

template<typename T>
istream &operator >>(istream &in, vector<T> &a) {
    for (auto &i : a) in >> i;
    return in;
}

template<typename T>
ostream &operator <<(ostream &out, vector<T> &a) {
    for (auto i : a) cout << i << " ";
    return out;
}

int g[2010][2010], st[2010], is[2010], used[2010][2010];
void solve() {
    int n, m, gg; cin >> n >> m >> gg;
    for (int i = 0; i < m; i++) {
        int a, b; cin >> a >> b;
        a--; b--;

        g[a][b] = 1;
        g[b][a] = 2;
        is[a]++; st[b]++;
    }

    for (int i = 0; i < n; i++) {
        if (is[i] == 1 && st[i] == 1) {
            int x1 = -1, x2 = -1, f1 = 0, f2 = 0;
            for (int j = 0; j < n; j++) {
                if (g[i][j]) {
                    if (x1 == -1) x1 = j;
                    else if (x2 == -1) x2 = j;
                    if (is[j] == 1 && st[j] == 1) {
                        if (x1 == j) f1 = 1;
                        if (x2 == j) f2 = 1;
                        if (g[i][j] == 1) used[i][j] = 1;
                        if (g[i][j] == 2) used[j][i] = 1;
                    } else if ((g[i][j] == 1 && st[j] == 1) || (g[i][j] == 2 && is[j] == 1)){
                        if (x1 == j) f1 = 1;
                        if (x2 == j) f2 = 1;
                        if (g[i][j] == 1) used[i][j] = 1;
                        if (g[i][j] == 2) used[j][i] = 1;
                    }
                }
            }
            if (f1 + f2 != 2) {
                if (!f1) {
                    if (g[i][x1] == 1) used[i][x1] = 1;
                    if (g[i][x1] == 2) used[x1][i] = 1;
                } else {
                    if (g[i][x2] == 1) used[i][x2] = 1;
                    if (g[i][x2] == 2) used[x2][i] = 1;
                }
            }
        } else if (is[i] == 1){
            for (int j = 0; j < n; j++) {
                if (g[i][j] == 1) {
                    if (g[i][j] == 1) used[i][j] = 1;
                    if (g[i][j] == 2) used[j][i] = 1;
                }
            }
        } else if (st[i] == 1) {
            for (int j = 0; j < n; j++) {
                if (g[i][j] == 2) {
                    if (g[i][j] == 1) used[i][j] = 1;
                    if (g[i][j] == 2) used[j][i] = 1;
                }
            }
        }
    }

    int cnt = 0;
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            if (used[i][j]) cnt++;
        }
    }
    if (cnt != m) cout << cnt << "\n" << 1 << "\n";
    else cout << cnt - 1 << "\n" << cnt << "\n";
}

int32_t main() {
#ifndef LOCAL
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
#endif
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
    double tim = clock();
#endif

    int tests = 1;
    //cin >> tests;
    while (tests--) {
        solve();
#ifdef LOCAL
        cout << "-------------------\n";
#endif
    }

#ifdef LOCAL
    cout << (double)(clock() - tim) / CLOCKS_PER_SEC;
#endif
}
