#include <iostream>
#include <vector>
#include <stack>
#include <algorithm>
#include <set>
#include <map>

using namespace std;


vector<vector<int>> rgr;

vector<bool> used;
vector<int> top;

void dfs(int v, vector<vector<int>> &gr) {
    used[v] = true;
    for (auto u : gr[v]) {
        if (!used[u]) {
            dfs(u, gr);
        }
    }
    top.push_back(v);
}



void dfs2(int v, int col, vector<int> &cmp) {
    cmp[v] = col;
    for (auto u : rgr[v]) {
        if (cmp[u] == -1) {
            dfs2(u, col, cmp);
        }
    }
}

void f(vector<int> &cmp) {
    int it = 0;
    map<int, int> mp;
    for (int i = 0; i < cmp.size(); i++) {
        if (mp.find(cmp[i]) == mp.end()) {
            mp[cmp[i]] = it++;
        }
    }
    for (int i = 0; i < cmp.size(); i++) {
        cmp[i] = mp[cmp[i]];
    }
}

vector<int> css(vector<vector<int>> &gr, int n) {
    rgr.clear();
    rgr.resize(n);
    top.clear();
    for (int i = 0; i < n; i++) {
        for (auto j : gr[i]) {
            rgr[j].push_back(i);
        }
    }
    used.assign(n, false);
    for (int i = 0; i < n; i++) {
        if (!used[i]) {
            dfs(i, gr);
        }
    }
    reverse(top.begin(), top.end());
    vector<int> cmp(n, -1);
    int col = 0;
    for (int i = 0; i < n; i++) {
        if (cmp[top[i]] == -1) {
            dfs2(top[i], col++, cmp);
        }
    }
    f(cmp);
    return cmp;
}

int main()
{
    int n, m, g;
    cin >> n >> m >> g;
    vector<vector<int>> gr;
    gr.resize(n);
    vector<pair<int, int>> edg;
    for (int i = 0; i < m; i++) {
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        gr[a].push_back(b);
        edg.push_back({a, b});
    }
    
    cout << n - 1 << endl << "1" << endl;

    return 0;
}