#include "bits/stdc++.h"

using namespace std;

template<class T>
istream& operator>>(istream &is, vector<T> &vec) {
      for (auto &elem: vec) is >> elem;
      return is;
}
template<class T>
ostream& operator<<(ostream &os, const vector<T> &vec) {
      for (auto &elem: vec) os << elem << ' ';
      os << '\n';
      return os;
}

const int N = 3000;
vector<int> g[N], rg[N], used(N), used2(N), ts, nowcomp;
vector<vector<int>> comps;

void topsort(int u) {
      used[u] = true;
      for (int v: g[u]) {
            if (!used[v]) topsort(v);
      }
      ts.push_back(u);
}

void dfs2(int u) {
      used2[u] = true;
      nowcomp.push_back(u);
      for (int v: rg[u]) {
            if (!used2[v]) dfs2(v);
      }
}

signed main() {
#ifdef LOCAL
      freopen("input.txt", "r", stdin);
      freopen("output.txt", "w", stdout);
#else
      ios_base::sync_with_stdio(false);
      cin.tie(nullptr);
#endif
      int n, m, group;
      cin >> n >> m >> group;

      for (int i = 0; i < m; ++i) {
            int u, v;
            cin >> u >> v;

            g[--u].push_back(--v);
            rg[v].push_back(u);
      }

      for (int i = 0; i < n; ++i) {
            if (!used[i]) topsort(i);
      }
      std::reverse(ts.begin(), ts.end());
//
//      int cntcomp = 0;
//      for (int i = 0; i < n; ++i) {
//            int u = ts[i];
//            if (used2[u]) continue;
//            dfs2(u);
//            comps.push_back(nowcomp);
//            nowcomp.clear();
//      }

      vector is_p(n, vector<int>(n));
      for (int i = 0; i < n; ++i) {
            function<void(int)> dfs = [&](int u) {
                  is_p[i][u] = true;
                  for (int v: g[u]) {
                        dfs(v);
                  }
            };

            dfs(i);
      }

      vector<int> pos(n);
      for (int i = 0; i < n; ++i) {
            pos[ts[i]] = i;
      }

      int res = 0;

      for (int u: ts) {
            sort(rg[u].begin(), rg[u].end(), [&](int i, int j) {
                  return pos[i] > pos[j];
            });
            vector<int> prev;
            for (int p1: rg[u]) {
                  for (int p2: prev) {
                        if (is_p[p1][p2]) {
                              res++;
                              break;
                        }
                  }
                  prev.push_back(p1);
            }
      }
      cout << res << ' ' << 1 << endl;
}