from collections import deque def DFS(pos): global graph,delete rem=deque([(pos,-1)]) use={pos} while len(rem)>0: now=rem[-1][0] ok=False for i,j in graph[now]: ok=True graph[now].discard((i,j)) if i in use: delete.add(j) while rem[-1][0]!=i: delete.add(rem[-1][1]) use.discard(rem[-1][0]) rem.pop() else: rem.append((i,j)) use.add(i) break if not(ok): use.discard(rem[-1][0]) rem.pop() N,M=map(int,input().split()) graph=[set() for i in range(N)] edge=[] for i in range(M): U,V=map(int,input().split()) edge.append((U,V)) graph[U-1].add((V-1,i)) delete=set() rem=[] for i in range(N): DFS(i) print(N,M-len(delete)) for i in range(M): if i not in delete: print(*edge[i])