output_description: Print the maximum possible number and the minimum possible number of
  respondents subscribing to both newspapers, in this order, with a space in
  between.
  
  * * *
input_description: Input is given from Standard Input in the following format:
  
      
      
      N A B
attempt: import sys
  from collections import deque
  
  
  def input():
      return sys.stdin.readline()
  
  
  def inpl():
      return [int(i) for i in input().split()]
  
  
  from collections import defaultdict
  
  N, M = inpl()
  Edge = defaultdict(lambda: [])
  Par = set(range(N))
  for _ in range(N - 1 + M):
      A, B = inpl()
      Par.discard(B - 1)
      Edge[A - 1].append(B - 1)
  par = list(Par)[0]
  dist = [0] * N
  Q = deque([par])
  while Q:
      st = Q.pop()
      for en in Edge[st]:
          if dist[en] < dist[st] + 1:
              dist[en] = dist[st] + 1
              if len(Edge[en]) == 1:
                  Q.append(en)
              else:
                  Q.appendleft(en)
  Ans = [0] * N
  Q = deque([par])
  while Q:
      st = Q.pop()
      for en in Edge[st]:
          if dist[en] == dist[st] + 1:
              Ans[en] = st + 1
              Q.appendleft(en)
  for i in Ans:
      print(i)
  
problem_description: Statement
  
  We conducted a survey on newspaper subscriptions. More specifically, we asked
  each of the N respondents the following two questions:
  
    * Question 1: Are you subscribing to Newspaper X?
    * Question 2: Are you subscribing to Newspaper Y?
  
  As the result, A respondents answered "yes" to Question 1, and B respondents
  answered "yes" to Question 2.
  
  What are the maximum possible number and the minimum possible number of
  respondents subscribing to both newspapers X and Y?
  
  Write a program to answer this question.
samples: [{"input": "10 3 5", "output": "3 0\n    \n\nIn this sample, out of the 10 respondents, 3 answered they are subscribing to\nNewspaper X, and 5 answered they are subscribing to Newspaper Y.\n\nHere, the number of respondents subscribing to both newspapers is at most 3\nand at least 0.\n\n* * *"}, {"input": "10 7 5", "output": "5 2\n    \n\nIn this sample, out of the 10 respondents, 7 answered they are subscribing to\nNewspaper X, and 5 answered they are subscribing to Newspaper Y.\n\nHere, the number of respondents subscribing to both newspapers is at most 5\nand at least 2.\n\n* * *"}, {"input": "100 100 100", "output": "100 100"}]