You are given N integers. You are required to perform Q queries. In each query, you are given two integers x and y. Your task is to merge the groups that contain the xth and yth integer to a single group. After performing each query, you are required to print the range of numbers that lie in the newly-formed group. Initially, the numbers do not belong to any group.
Input format
Output format
For every query, print two space-separated integers min and max in a new line, where min is the minimum element and max is the maximum element of the new group formed.
Constraints
1≤N,Q≤2∗105
−1018≤integeri≤1018
1≤x,y≤N
Query 1: The group now contans {5, 12}
Query 2: The group now contans {6, 8}
Query 3: The group now contans {1}