#include <bits/stdc++.h>
using namespace std;


using ll = long long;
const int inf = 1e9 + 10;

const int mod = 1e9 + 7;

int add(int a, int b) {
    return a + b >= mod ? a + b - mod : a + b;
}
int sub(int a, int b) {
    return a >= b ? a - b : a + mod - b;
}
int mul(int a, int b) {
    return 1ll * a * b % mod;
}

int solve(vector<vector<int>> g) {
    int n = g.size();
    vector<vector<int>> in(n);
    for (int i = 0; i < n; ++i) {
        for (auto j : g[i]) in[j].push_back(i);
    }
    vector<bool> used(n);
    vector<vector<bool>> adj(n, vector<bool>(n, false));
    auto dfs = [&](auto dfs, int u) -> void {
        used[u] = true;
        adj[u][u] = true;
        for (auto to : g[u]) {
            if (!used[to]) dfs(dfs, to);
            for (int k = 0; k < n; ++k) {
                if (adj[to][k]) adj[u][k] = true;
            }
        }
    };
    for (int i = 0; i < n; ++i) {
        if (!used[i]) dfs(dfs, i);
    }
    int mn = 0;
    for (int i = 0; i < n; ++i) {
        for (auto j : in[i]) {
            bool ok = true;
            for (auto k : in[i]) {
                if (j == k) continue;
                ok &= !adj[j][k];
            }
            if (ok) {
                mn++;
            }
        }
    }
    return mn;
}

signed main() {
    cin.tie(nullptr)->sync_with_stdio(false);

    int n, m, group;
    cin >> n >> m >> group;
    vector<pair<int, int>> edges;
    vector<vector<int>> g(n), in(n);
    for (int i = 0; i < m; ++i) {
        int u, v;
        cin >> u >> v;
        v--, u--;
        g[u].push_back(v);
        in[v].push_back(u);
        edges.emplace_back(u, v);
    }
    vector<int> topsort;
    vector<bool> used(n);
    auto dfs = [&](auto dfs, int u) -> void {
        used[u] = true;
        for (auto to : g[u]) {
            if (!used[to]) dfs(dfs, to);
        }
        topsort.push_back(u);
    };
    for (int i = 0; i < n; ++i) {
        if (!used[i]) {
            dfs(dfs, i);
        }
    }
    reverse(topsort.begin(), topsort.end());
    vector<int> col(n, -1);
    int c = 0;
    auto dfs2 = [&](auto dfs2, int u) -> void {
        col[u] = c;
        for (auto to : in[u]) {
            if (col[to] == -1) dfs2(dfs2, to);
        }
    };
    for (auto i : topsort) {
        if (col[i] == -1) {
            dfs2(dfs2, i);
            c++;
        }
    }
    vector<int> cnt(1 << m);
    for (int mask = 1; mask < 1 << m; ++mask) {
        vector<int> adj(n);
        for (int i = 0; i < m; ++i) {
            auto [u, v] = edges[i];
            if (mask >> i & 1) swap(u, v);
            adj[u] |= 1 << v;
        }
        for (int i = 0; i < n; ++i) adj[i] |= 1 << i;
        for (int k = 0; k < n; ++k) {
            for (int i = 0; i < n; ++i) {
                if (adj[i] >> k & 1) adj[i] |= adj[k];
            }
        }
        bool ok = true;
        for (int i = 0; i < n; ++i) {
            for (int j = 0; j < n; ++j) {
                if (col[i] == col[j]) ok &= (adj[i] >> j & 1) && (adj[j] >> i & 1);
                else ok &= (~adj[i] >> j & 1) || (~adj[j] >> i & 1);
            }
        }
        cnt[mask] = ok;
    }
    int mx = 0;
    int cc = 0;
    for (int mask = 0; mask < 1 << m; ++mask) {
        if (cnt[mask]) continue;
        for (int j = 0; j < m; ++j) {
            if (mask >> j & 1) {
                if (cnt[mask ^ (1 << j)]) {
                    cnt[mask] = 1;
                    break;
                }
            }
        }
        if (cnt[mask]) continue;
        int l = __builtin_popcount(mask);
        if (mx < l) mx = l, cc = 0;
        if (mx == l) cc++;
    }
    cout << mx << endl << cc;
}