#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <math.h>
#define pi acos(-1)
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
typedef long long LL;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;
const int INF = 0x3f3f3f3f;
const LL LL_INF = 0x3f3f3f3f3f3f3f3f;
const int maxn = 100 + 10;
const int maxm = 2500 + 10;
const int maxv = maxn * 2;
const int maxe = maxm * 2;
const int mod = 1e9 + 7;
int wi[maxv], wo[maxv];
int S, T;
int head[maxe], tot=0, nowedge[maxe];
int dis[maxv];
int vis[maxv];
struct Edge
{
int to, next, cap;
}es[maxe];
int read(){
int x=0,f=1;char ch=getchar();
while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
return x*f;
}
void init()
{
memset(head, -1, sizeof(head));
memset(vis, 0, sizeof(vis));
tot=0;
}
void add(int u, int v, int vol)
{
es[tot].to = v;
es[tot].cap = vol;
es[tot].next = head[u];
head[u] = tot++;
es[tot].to = u;
es[tot].cap = 0;
es[tot].next = head[v];
head[v] = tot++;
}
bool BFS()
{
queue<int> que;
memset(dis, -1, sizeof(dis));
dis[S] = 0;
que.push(S);
int cur, v;
while(!que.empty())
{
cur = que.front(); que.pop();
for(int i=head[cur]; i!=-1; i=es[i].next){
v = es[i].to;
if(dis[v]==-1 && es[i].cap>0){
dis[v] = dis[cur]+1;
que.push(v);
}
}
}
if(dis[T] == -1) return false;
else return true;
}
LL DFS(int cur, LL low)
{
LL res=0, add=0;
if(cur == T) return low;
for(int i=nowedge[cur]; i!=-1; i=es[i].next){
nowedge[cur] = i;
if(dis[es[i].to]==dis[cur]+1
&& es[i].cap>0
&& (add = DFS(es[i].to, min(low, (LL)es[i].cap))) ){
es[i].cap -= add;
es[i^1].cap += add;
low -= add;
res += add;
if(low == 0) break;
}
}
if(res == 0) dis[cur] = 0;
return res;
}
LL MAXFLOW()
{
LL ans=0 , tmp=0;
while(BFS()){
for(int i=S; i<=T; i++){
nowedge[i] = head[i];
}
if(tmp = DFS(S, INF))
ans += tmp;
}
return ans;
}
int left_net(int cur)
{
vis[cur] = 1;
int ans = 1;
for(int i=head[cur]; i!=-1; i = es[i].next){
if(es[i].cap > 0 && !vis[es[i].to]) ans += left_net(es[i].to);
}
return ans;
}
int main()
{
int n, m;
init();
scanf("%d%d", &m, &n);
S = 0;
T = n+1;
for(int i=1; i<=m; i++) add(S, i, 1);
for(int i=m+1; i<=n; i++) add(i, T, 1);
int tmp1, tmp2;
while(~scanf("%d%d", &tmp1, &tmp2)){
if(tmp1==-1 && tmp2==-1) break;
add(tmp1, tmp2, INF);
}
LL ans = MAXFLOW();
cout << ans << '\n';
if(ans == 0){
printf("No Solution!\n");
return 0;
}
for(int i=1; i<=m; i++){
for(int j=head[i]; j!=-1; j=es[j].next){
if(es[j].to == S || es[j].cap>=INF) continue;
printf("%d %d\n", i, es[j].to);
}
}
}