Given an array of size n and an integer b, traverse the array and if the element in array is b, double b and continue traversal. In the end return value of b.

**Input:**

The first line of the input contains T denoting the number of testcases. Then follows the description of testcases. The first line of each testcase contains two space separated positive integers n and b denoting the size of array and initial value of b respectively.The second line contains n space separated positive integers denoting the elements of array.

**Output:**

For each testcase, print the final value of b.

**Constraints:**

1<=T<=100

1<=n<=50

1<=b<=1000

1<=A[i]<=10^{18} (1<=i<=N)

**Example:**

Input:

1

5 2

1 2 3 4 8

Output:

16

**Explanation: **The initial value of b is 2. Traversing from the first element, 2 is found in 2nd position, so doubling b we get b = 4 . 4 is found in 4th position so doubling b we get b = 8. 8 is found in 5th position, so doubling b we get b = 16.

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.

codersanjeev | 66 |

snow_den_ | 60 |

BoggavarapuRamSaranSaiSrinivasGupta | 60 |

rajupraaa1234 | 53 |

SUZAKU | 49 |

mr_kksparrow | 433 |

manvirag982 | 258 |

snow_den_ | 232 |

arpit_anshuman | 228 |

SoumyaKaushik | 205 |

blackshadows | 5331 |

Ibrahim Nash | 5219 |

akhayrutdinov | 5111 |

mb1973 | 4929 |

Quandray | 4567 |

Login to report an issue on this page.