#include<bits/stdc++.h>
//#include<ext/pb_ds/assoc_container.hpp>
#define ll long long

using namespace std;
//using namespace __gnu_pbds;

ll n, m, ghsdf;
vector<bool> used;
vector<vector<ll>> g, revg;
vector<pair<ll, ll>> a;
vector<ll> mask, comp, tekk, topp, can;

void dfs(ll u) {
    used[u] = true;
    for (ll i = 0; i < g[u].size(); i++) {
        if (!used[g[u][i]]) {
            dfs(g[u][i]);
        }
    }
    topp.push_back(u);
}

void dfs2(ll u, ll cn) {
    tekk[u] = cn;
    for (ll i = 0; i < revg[u].size(); i++) {
        if (tekk[revg[u][i]] == -1) {
            dfs2(revg[u][i], cn);
        }
    }
}

void find_comps() {
    revg.clear();
    revg.resize(n);
    for (ll i = 0; i < g.size(); i++) {
        for (ll j = 0; j < g[i].size(); j++) {
            revg[g[i][j]].push_back(i);
        }
    }
    used.assign(n, 0);
    topp = {};
    for (ll i = 0; i < n; i++) {
        if (!used[i]) {
            dfs(i);
        }
    }
    reverse(topp.begin(), topp.end());
    ll cn = 1;
    tekk.assign(n, -1);
    for (ll i = 0; i < n; i++) {
        if (tekk[topp[i]] == -1) {
            dfs2(topp[i], cn);
            cn++;
        }
    }
}

void rec(ll ind) {
    if (ind == m) {
        g.clear();
        g.resize(n);
        for (ll i = 0; i < m; i++) {
            if (mask[i] != 0) {
                g[a[i].first].push_back(a[i].second);
            } else {
                g[a[i].second].push_back(a[i].first);
            }
        }
        find_comps();
        bool fl = true;
        vector<ll> st(n, -1), sc(n, -1);
        for (ll i = 0; i < n; i++) {
            //cout << comp[i] << " " << tekk[i]
            if (sc[comp[i] - 1] == -1 && st[tekk[i] - 1] == -1) {
                sc[comp[i] - 1] = tekk[i] - 1;
                st[tekk[i] - 1] = comp[i] - 1;
            } else if (sc[comp[i] - 1] == tekk[i] - 1 && st[tekk[i] - 1] == comp[i] - 1) {
                continue;
            } else {
                fl = false;
                break;
            }
        }
        if (fl) {
            ll r = 0;
            for (ll i = 0; i < m; i++) {
                if (mask[i] != 2) {
                    r += (1 << i);
                }
            }
            can[r]++;
        }
        return;
    }
    mask[ind] = 0;
    rec(ind + 1);
    mask[ind] = 1;
    rec(ind + 1);
    mask[ind] = 2;
    rec(ind + 1);
}

void input() {
    cin >> n >> m >> ghsdf;
    a.resize(m);
    for (ll i = 0; i < m; i++) {
        cin >> a[i].first >> a[i].second;
        a[i].first--;
        a[i].second--;
    }
}

void solve() {
    g.resize(n);
    can.assign((1 << m), 0);
    for (ll i = 0; i < m; i++) {
        g[a[i].first].push_back(a[i].second);
    }
    find_comps();
    comp = tekk;
    mask.resize(m);
    rec(0);
    ll ans = 0, cnt = 0;
    for (ll i = 0; i < (1 << m); i++) {
        if (can[i] == 1) {
            ll vv = 0;
            for (ll j = 0; j < m; j++) {
                if (i & (1 << j)) {
                    vv++;
                }
            }
            if (vv > ans) {
                ans = vv;
                cnt = 1;
            } else if (vv == ans) {
                cnt++;
            }
        }
    }
    cout << ans << "\n" << cnt;
}

void output() {

}

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    input();
    solve();
    output();
    return 0;
}
