from collections import deque,defaultdict import math import heapq import sys import pypyjit pypyjit.set_param('max_unroll_recursion=-1') sys.setrecursionlimit(pow(2,19)-1) input=sys.stdin.readline INF=float("inf") class mf_graph: n=1 g=[[] for i in range(1)] pos=[] def __init__(self,N): self.n=N self.g=[[] for i in range(N)] self.pos=[] def add_edge(self,From,To,cap): assert 0<=From and From=0:continue level[to]=level[v]+1 if to==t:return level que.append(to) return level def dfs(v,up): if (v==s):return up res=0 level_v=level[v] for i in range(Iter[v],len(self.g[v])): Iter[v]=i to,rev,cap=self.g[v][i] if (level_v<=level[to] or self.g[to][rev][2]==0):continue d=dfs(to,min(up-res,self.g[to][rev][2])) if d<=0:continue self.g[v][i][2]+=d self.g[to][rev][2]-=d res+=d if res==up:return res level[v]=self.n return res flow=0 while(flow0): p=que.popleft() visited[p]=True for to,rev,cap in self.g[p]: if cap and not(visited[to]): visited[to]=True que.append(to) return visited N,M=map(int,input().split()) d=[0 for i in range(N)] graph=mf_graph(N+2) for i in range(M): U,V=map(int,input().split()) d[U-1]+=1 d[V-1]-=1 graph.add_edge(U-1,V-1,1) maximum=500000 for i in range(N): graph.add_edge(N,i,maximum) graph.add_edge(i,N+1,maximum-d[i]) ans=[] graph.flow(N,N+1) for i in graph.edges(): if i["flow"]==0 or i["from"]==N or i["to"]==N+1: continue ans.append((i["from"]+1,i["to"]+1)) print(N,len(ans)) for i in ans: print(*i)