#define rep(i, a, n) for (int i = a; i < n; ++i) #define per(i, a, n) for (int i = n - 1; i >= a; --i) #define fi first #define se second #define mp make_pair #define np next_permutation #define pb push_back #define INF 0x3f3f3f3f
constint maxn = 1e3 + 5;
vi e[maxn]; int n, m; bitset<maxn> v; int fa[maxn], ans;
intdfs(int x) { rep(i, 0, e[x].size()) { int y = e[x][i]; if (v[y]) continue; v[y] = 1; if (!fa[y] || dfs(fa[y])) { fa[y] = x; return1; } } return0; }
intmain() { ios::sync_with_stdio(false); while (cin >> m >> n) { init(); int a, b; while (cin >> a >> b && a != -1) { e[a].pb(n + b); e[n + b].pb(a); } rep(i, 1, m + 1) { v.reset(); ans += dfs(i); } if (ans == 0) { cout << "No Solution!" << endl; continue; } cout << ans << endl; rep(i, n + 1, n + n + 1) { if (fa[i] != 0) cout << fa[i] << " " << i - n << endl; } } }