#include "bits/stdc++.h"
#include "ext/pb_ds/assoc_container.hpp"

using namespace __gnu_pbds;
using namespace std;

#define fi first
#define se second
#define for0(i, n) for (ll i = 0; i < n; i++)
#define for1(i, n) for (ll i = 1; i < n; i++)
#define con continue
#define ret return
#define pb push_back
#define sz(x) x.size()
#define pob pop_back
#define be(x) x.begin()
#define en(x) x.end()
#define all(x) be(x), en(x)
#define rfor0(i, n) for (ll i = 0; i < n; i++)
#define rfor1(i, n) for (ll i = 1; i < n; i++)
#define rep(i, a, n) for (ll i = a; i < n; i++)
#define endl '\n'
#define rev reverse
#define co count
#define lb lower_bound
#define ub upper_bound
#define bs binary_search
#define rs resize
#define rsun(x) x.rs(unique(all(x)) - be(x))
#define ins insert
#ifdef OG_Matveychick1
bool local = 1;
#else
bool local = 0;
#endif


typedef long long ll;
typedef vector<ll> vll;
typedef pair<ll, ll> pll;
typedef string str;
typedef vector<pll> vpll;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef set<ll> sll;
typedef queue<ll> qll;
typedef vector<vector<ll>> vvll;
typedef set<pll> spll;
typedef vector<str> vs;
typedef long double ld;
typedef vector<vpll> vvpll;
typedef multiset<ll> msll;
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> orderes_set;
typedef tree<ll, null_type, less_equal<ll>, rb_tree_tag, tree_order_statistics_node_update> orderes_multiset;

template<typename T>
istream &operator>>(istream &in, vector<T> &a) {
    for (auto &x: a) in >> x;
    ret in;
}

template<typename T1, typename T2>
istream &operator>>(istream &in, pair<T1, T2> &a) {
    in >> a.first >> a.second;
    ret in;
}

template<typename T1, typename T2>
ostream &operator<<(ostream &out, pair<T1, T2> &a) {
    out << a.first << ' ' << a.second << endl;
    ret out;
}

template<typename T>
ostream &operator<<(ostream &out, vector<T> &a) {
    for (auto &x: a) out << x << ' ';
    ret out;
}

template<typename T1, typename T2>
T1 min(T1 a, T2 b) {
    ret min(a, (T1) b);
}

template<typename T1, typename T2>
T1 max(T1 a, T2 b) {
    ret max(a, (T1) b);
}

template<typename T1, typename T2>
void amin(T1 &a, T2 b) {
    a = min(a, (T1) b);
}

template<typename T1, typename T2>
void amax(T1 &a, T2 b) {
    a = max(a, (T1) b);
}

void solve();

ld getTime() {
    ret (ld) clock() / CLOCKS_PER_SEC;
}

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

ll rnd(ll l, ll r) {
    ret rn() % (r - l) + l;
}

signed main(int argc, char *argv[]) {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cout.precision(12);
    cout << fixed;
    if (local && argc == 1) {
        freopen("input.txt", "r", stdin);
    }
    ll T = 1;
//    cin >> T;
    while (T--) {
        solve();
    }
    if (local && argc == 1) {
        cout << endl << getTime();
    }
}

struct ST {
    struct node {
        ll x, pl;

        node() : x(0), pl(0) {}

        node(ll x) : x(x), pl(0) {}
    };

    vector<node> t;
    ll n;

    ST(ll n) : n(n), t(4 * n) {}

    void update(ll v, ll x) {
        t[v].pl += x;
        t[v].x += x;
    }

    void push(ll v) {
        update(v * 2, t[v].pl);
        update(v * 2 + 1, t[v].pl);
        t[v].pl = 0;
    }

    node merge(node a, node b) {
        node c;
        c.x = max(a.x, b.x);
        ret c;
    }

    void update(ll l, ll r, ll x) {
        update(1, 0, n, l, r, x);
    }

    void update(ll v, ll l, ll r, ll L, ll R, ll x) {
        if (l >= R || r <= L) ret;
        if (l >= L && r <= R) {
            update(v, x);
            ret;
        }
        push(v);
        ll m = (l + r) / 2;
        update(v * 2, l, m, L, R, x);
        update(v * 2 + 1, m, r, L, R, x);
        t[v] = merge(t[v * 2], t[v * 2 + 1]);
    }

    ll get(ll l, ll r) {
        ret get(1, 0, n, l, r).x;
    }

    node get(ll v, ll l, ll r, ll L, ll R) {
        if (l >= R || r <= L) ret node(-1e18);
        if (l >= L && r <= R) ret t[v];
        ll m = (l + r) / 2;
        push(v);
        ret merge(get(v * 2, l, m, L, R), get(v * 2 + 1, m, r, L, R));
    }
};

struct CD {
    vvpll g;
    ll n;
    vll s, used;

    CD(ll n, vvll &g1) : n(n) {
        g.rs(n);
        for0(i, n) for (auto x: g1[i]) g[i].pb({x, 1});
    }

    CD(ll n, vvpll &g) : n(n), g(g) {}

    ll sizes(ll v, ll p) {
        s[v] = 1;
        for (auto [x, w]: g[v]) {
            if (used[x] || x == p) con;
            s[v] += sizes(x, v);
        }
        ret s[v];
    }

    ll get_c(ll v, ll p, ll S) {
        for (auto [x, w]: g[v]) {
            if (used[x] || x == p) con;
            if (s[x] > S / 2) ret get_c(x, v, S);
        }
        ret v;
    }

    void build() {
        s.rs(n);
        used.rs(n);
        centroidka(get_c(0, 0, sizes(0, 0)));
    }

    void centroidka(ll v) {
        // ACTUAL CODE
        used[v] = 1;
        for (auto [x, w]: g[v]) {
            if (used[x]) con;
            centroidka(get_c(x, x, sizes(x, x)));
        }
    }
};

struct kss {
    vvll g, rg;
    ll n;
    vll ts, used;

    kss(ll n, vvll &g1) : n(n), g(g1) {
        rg.rs(n);
        used.rs(n);
        for0(i, n) for (auto x: g[i]) rg[x].pb(i);
    }

    void top(ll v) {
        used[v] = 1;
        for (auto x: g[v]) if (!used[x]) top(x);
        ts.pb(v);
    }

    void dfs(ll v) {
        used[v] = 1;
        for (auto x: rg[v]) if (!used[x]) dfs(x);
    }

    ll go() {
        for0(i, n) {
            if (used[i]) con;
            top(i);
        }
        rev(all(ts));
        ll ans = 0;
        fill(all(used), 0);
        for0(i, n) {
            if (used[i]) con;
            dfs(i);
            ans++;
        }
        ret ans;
    }
};

const ll N = 2e3 + 5;

ll n, m, G;
vvll g;
pll e[N];

void solve() {
    cin >> n >> m >> G;
    g.assign(n, vll());
    for0(i, m) {
        ll u, v;
        cin >> u >> v;
        u--;
        v--;
        e[i] = {u, v};
    }
    ll cnt = 0;
    for0(i, m) {
        g.assign(n, vll());
        for0(j, m) {
            if (i == j) con;
            g[e[i].fi].pb(e[i].se);
        }
        kss k(n, g);
        cnt += (k.go() == 2);
    }
    cout << max(0, cnt - 1) << ' ' << -1;
}