#include <bits/stdc++.h>

using namespace std;

#define ll long long
//#define ld long double
//#define ull unsigned long long
//#define sll __int128
#define size(x) (int)(x).size()
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define int long long

mt19937 rnd(time(0));

ll INF = 1e18;
int mod = 1e9 + 7;

int kv(int x) {
    return ((ll)x * x) % mod;
}

int mult(int a, int b){
    return ((ll)a * b) % mod;
}

int fast_pow(int x, int a){
    if (a == 0) return 1;
    if (a == 1) return x;
    if (a & 1) return mult(x, fast_pow(x, a - 1));
    return kv(fast_pow(x, a / 2));
}



void gsrt(int v, vector<bool> &used, vector<vector<int>> &g, vector<int> &ord){
    used[v] = true;
    for (auto to : g[v]){
        if (!used[to]) gsrt(to, used, g, ord);
    }
    ord.push_back(v);
}

void recol(int v, int c, vector<bool> &used, vector<vector<int>> &cl, vector<vector<int>> &g){
    cl.back().push_back(v);
    used[v] = true;
    for (auto to : g[v]){
        if (used[to]) continue;
        recol(to, c, used, cl, g);
    }
}

void solve(){
    int n, m, G;
    cin >> n >> m >> G;
    vector<pair<int, int>> edges(m);
    for (int i = 0; i < m; i++){
        int v, u;
        cin >> v >> u;
        v--; u--;
        edges[i] = {v, u};
    }
    int all = (1 << m);
    int mx = 0, cnt = 1;
    vector<vector<int>> nw;
    vector<bool> dp(all, 1);
    for (int mask = 0; mask < all; mask++){
        vector<vector<int>> g(n), gr(n);
        for (int i = 0; i < m; i++){
            auto [v, u] = edges[i];
            if ((mask >> i) & 1) swap(v, u);
            g[v].push_back(u);
            gr[u].push_back(v);
        }
        vector<bool> used(n);
        vector<vector<int>> cl;
        vector<int> ord;
        for (int i = 0; i < n; i++){
            if (!used[i]){
                gsrt(i, used, g, ord);
            }
        }
        reverse(ord.begin(), ord.end());
        used = vector<bool>(n, false);
        for (auto v : ord){
            if (!used[v]){
                cl.push_back({});
                recol(v, size(cl) - 1, used, cl, gr);
                sort(all(cl.back()));
            }
        }
        sort(all(cl));
        //cerr << mask << endl;
        if (mask == 0){
            nw = cl;

            continue;
        }

        bool fl = true;
        if (cl != nw) {
            fl = false;
        }
        if (fl) dp[mask] = 0;
        for (int j = 0; j < m; j++){
            if ((mask >> j) & 1){
                dp[mask] = min(dp[mask], dp[mask ^ (1 << j)]);
            }
        }
        int c = __builtin_popcount(mask);
        if (dp[mask]){
            if (mx < c){
                mx = c;
                cnt = 0;
            }
            if (mx == c){
                cnt++;
            }
        }
    }
    cout << mx << "\n" << cnt;
}

signed main(){
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    ios::sync_with_stdio(0);
    cin.tie(0);
    int ttt = 1;
    //cin >> ttt;
    while (ttt--){
        solve();
    }
}
