Given an unsorted array of size **N** of positive integers. **One number 'A'** from set {1, 2, …N} is missing and **one number 'B'** occurs twice in array. Find these two numbers.

**Note**: If you find multiple answers then print the Smallest number found. Also, expected solution is O(n) time and constant extra space.

**Input:**

The first line of input contains an integer **T** denoting the number of test cases. The description of T test cases follows. The first line of each test case contains a single integer N denoting the size of array. The second line contains N space-separated integers A_{1}, A_{2}, ..., A_{N} denoting the elements of the array.

**Output:**

Print B, the repeating number followed by A which is missing in a single line.

**Constraints:**

1 ≤ T ≤ 100

1 ≤ N ≤ 10^{6}

1 ≤ A[i] ≤ N

**Example:**

**Input**:

2

2

2 2

3

1 3 3

**Output**:

2 1

3 2

**Explanation:**

**Testcase 1:** Repeating number is 2 and smallest positive missing number is 1.

**Testcase 2:** Repeating number is 3 and smallest positive missing number is 2.

If you have purchased any course from GeeksforGeeks then please ask your doubt on course discussion forum. You will get quick replies from GFG Moderators there.

the_coder95 | 465 |

thanuvinu94 | 388 |

adityasuman2025 | 348 |

Senbonzakura_Kageyoshi | 321 |

PrakharBansal1 | 294 |

the_coder95 | 1691 |

RishabhTanwar1 | 1110 |

thanuvinu94 | 1064 |

samay_kam_hai | 726 |

adityasuman2025 | 646 |

blackshadows | 5331 |

Ibrahim Nash | 5219 |

akhayrutdinov | 5111 |

mb1973 | 4897 |

Quandray | 4547 |

Login to report an issue on this page.