#include <bits/stdc++.h>

#define sz(a) int(a.size())
#define all(a) a.begin(),a.end()

using namespace std;
using ll = long long;

const ll infll = (ll) 1e18;
const int inf = (int) 1e9;
const ll MOD = 1e9 + 7;

ll mod(ll a) {
    ll r = a % MOD;
    if (r < 0) {
        return r + MOD;
    }
    return r;
}

mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());

vector<vector<int>> g, gt;
vector<int> ord;
vector<bool> used;

void dfs(int v) {
    used[v] = true;
    for (auto to : g[v]) {
        if (used[to]) continue;
        dfs(to);
    }
    ord.push_back(v);
}

int id = 1;
vector<int> col;

void dfs2(int v) {
    col[v] = id;
    for (auto to : gt[v]) {
        if (col[to] == 0) {
            dfs2(to);
        }
    }
}

void solve() {
    int n, m, T;
    cin >> n >> m >> T;
    gt.resize(n);
    g.resize(n);
    col.resize(n);
    used.resize(n);
    vector<pair<int, int>> edges;
    for (int i = 0; i < m; ++i) {
        int u, v;
        cin >> u >> v;
        u--;
        v--;
        edges.push_back({u, v});
        g[u].push_back(v);
        gt[v].push_back(u);
    }
    for (int i = 0; i < n; ++i) {
        if (!used[i]) {
            dfs(i);
        }
    }
    reverse(ord.begin(), ord.end());
    for (int i = 0; i < n; ++i) {
        if (!col[ord[i]]) {
            dfs2(ord[i]);
            id++;
        }
    }
    map<int, vector<int>> mp;
    for (int i = 0; i < n; ++i) {
        mp[col[i]].push_back(i);
    }
    vector<vector<int>> res;
    for (auto &[x, v] : mp) {
        res.push_back(v);
    }
    sort(all(res));
    int mx = 0, cnt = 1;
    for (int mask = 1; mask < (1 << m); ++mask) {
        int d = __builtin_popcount(mask);
        bool fl = true;
        for (int k = 1; k < (1 << d); ++k) {
            g.clear();
            gt.clear();
            ord.clear();
            col.clear();
            used.clear();
            g.resize(n);
            gt.resize(n);
            col.resize(n);
            used.resize(n);
            id = 1;
            int c = 0;
            for (int j = 0; j < m; ++j) {
                if (mask & (1 << j)) {
                    if (k & (1 << c)) {
                        g[edges[j].second].push_back(edges[j].first);
                        gt[edges[j].first].push_back(edges[j].second);
                    } else {
                        gt[edges[j].second].push_back(edges[j].first);
                        g[edges[j].first].push_back(edges[j].second);
                    }
                    c++;
                } else {
                    gt[edges[j].second].push_back(edges[j].first);
                    g[edges[j].first].push_back(edges[j].second);
                }
            }
            for (int i = 0; i < n; ++i) {
                if (!used[i]) {
                    dfs(i);
                }
            }
            reverse(ord.begin(), ord.end());
            for (int i = 0; i < n; ++i) {
                if (!col[ord[i]]) {
                    dfs2(ord[i]);
                    id++;
                }
            }
            map<int, vector<int>> mp2;
            for (int i = 0; i < n; ++i) {
                mp2[col[i]].push_back(i);
            }
            vector<vector<int>> res2;
            for (auto &[x, v] : mp2) {
                res2.push_back(v);
            }
            sort(all(res2));
            fl &= (res != res2);
        }
        if (fl) {
            if (d > mx) {
                mx = d;
                cnt = 1;
            } else if (d == mx) {
                cnt++;
            }
        }
    }
    cout << mx << '\n' << cnt << '\n';
}

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int T = 1;
    //cin >> T;
    while (T--) {
        solve();
    }
    return 0;
}