Given a sorted array and a number X, find a pair in array whose sum is closest to X.

**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 and X denoting the size of array and value of X.

The second line contains N space-separated integers A1, A2, ..., AN denoting the elements of the array.

**Output:**

Print the pair whose sum is closest to X. If multiple pairs are possible print the largest sum pair.

**Constraints:**

1 <= T <= 100

2 <= N <= 100

0 <= X <= 500

0 =A[i]<=100

**Example:**

Input:

2

6 54

10 22 28 29 30 40

5 10

1 2 3 4 5

Output:

22 30

4 5

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.

Vagesh Verma | 98 |

UrGuru | 98 |

chaolinyu | 84 |

prernaus24 | 83 |

devendrachoudhary5485 | 74 |

abducodes | 624 |

harshtyagi36 | 298 |

highway_to_hell | 252 |

rajeswarii | 248 |

arpit_anshuman | 240 |

blackshadows | 5331 |

Ibrahim Nash | 5219 |

akhayrutdinov | 5111 |

mb1973 | 4929 |

Quandray | 4567 |

Login to report an issue on this page.