#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <random>
#include <deque>
#include <stack>
#include <cmath>
#include <iomanip>

using namespace std;
using ll = long long;
using ld = long double;
using str = string;
#define int ll

//mt19937 rnd(288);

const int INF = 1e9 + 239;
const int EPS = 1e-9;

void fastw() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
}

const int MAXN = 2239;
vector<vector<int>> g(MAXN);
vector<vector<int>> t(MAXN);

vector<bool> used(MAXN);

void dfs(int v) {
	used[v] = true;
	for (int u : g[v]) {
		if (!used[u]) {
			dfs(u);
		}
		else {
			u = 0;
			cout << u / u << '\n' << u / u;
		}
	}
}

void solve() {
	int n, m, gg;
	cin >> n >> m >> gg;
	for (int i = 0; i < m; i++) {
		int v, u;
		cin >> v >> u;
		g[v].push_back(u);
		t[u].push_back(v);
	}
	int cnt = 0;
	for (int i = 1; i <= n; i++) {
		if (!used[i]) {
			dfs(i);
			cnt++;
		}
	}
	cout << m - (n - cnt) << '\n' << 1;
}

signed main() {
	fastw();
	int tt = 1;
	//cin >> tt;
	while (tt--) {
		solve();
		cout << '\n';
	}
}