#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <map>
#include <algorithm>
#include <cmath>
#include <bitset>
#include <unordered_map>
#include <random>

#define all(v) v.begin(), v.end()
#define len(v) (int)v.size()
#define coutd cout << fixed << setprecision(20)

using namespace std;
using ll = long long;
using ld = long double;

const ll Mod = 1e9 + 7;

vector<vector<int>> g;
vector<vector<int>> rg;

int cnt = 0;
int n, m;
vector<bool> used;

void dfs(int v, int fl, int fr)
{
    used[v] = 1;
    for (int u : g[v])
    {
        if (v == fl && u == fr) continue;
        if (!used[u])
        {
            dfs(u, fl, fr);
        }
    }
}

int main()
{
    cin.tie(0)->sync_with_stdio(0);
    int group;
    cin >> n >> m >> group;
    g.resize(n);
    rg.resize(n);
    for (int i = 0; i < m; ++i)
    {
        int v, u;
        cin >> v >> u;
        --v;
        --u;
        g[v].push_back(u);
        rg[u].push_back(v);
    }
    int cnt = 1;
    for (int i = 0; i < n; ++i)
    {
        used.assign(n, 0);
        dfs(i, i, (i + 1) % n);
        if (used[(i + 1) % n])
        {
            --cnt;
        }
    }
    cout << n - 1 << ' ' << -1;

    return 0;
}
