Input: arr[] = {1, 2, 3, 4, 5, 6}
Output:
1 3
2 4
Explanation: The given array has 3 * 2 elements. The pair (1, 3) and (2, 4) has sum of elements as 4 and 6 respectively. Also, GCD(4, 6) > 1. Hence, (1, 3) and (2, 4) are the required pairs. Other possible pairs are (1, 5) and (2, 6), (3, 5) and (2, 5), etc..
Input: arr[] = {1, 1, 1, 2, 3, 4}
Output:
1 3
2 4