GCD What#12282

GCD What

1 second
256 megabytes
Easy

You are given an array of non-negative integers a_1, a_2, \ldots, a_n. You are allowed to perform at most operations. Each operation consists of two steps:

  1. Let g = \gcd(a_1, \ldots, a_n).

  2. Choose an index j~(1 \le j \le n) and set a_j \leftarrow a_j + g.

Find the maximum possible element of the array after performing at most operations.

Input

The first line contains one positive integer t~(1 \le t \le 10) — the number of test cases.

Each test case is described by two lines:

  • The first line contains two integers and k~(1 \le n \le 100, 0 \le k \le 3) — the length of the array and the number of allowed operations.

  • The second line contains integers a_i~(0 \le a_i \le 1000) — the elements of the array .

Output

For each test case, output one number — the maximum element of the array that can be obtained by applying the described operation at most times.

Examples

Example 32

Loading
Loading

Scoring

  1. Subtask ( points): k = 0

  2. Subtask ( points): k = 1

  3. Subtask ( points): No additional constraints.