Raspberries
You are given an array of integers $$$a_1, a_2, \ldots, a_n$$$ and a number $$$k$$$ ($$$2 \leq k \leq 5$$$). In one operation, you can do the following: Choose an index $$$1 \leq i \leq n$$$, Set $$$a_i = a_i + 1$$$.Find the minimum number of operations needed to make the product of all the numbers in the array $$$a_1 \cdot a_2 \cdot \ldots \cdot a_n$$$ divisible by $$$k$$$.
In the first test case, we need to choose the index $$$i = 2$$$ twice. After that, the array will be $$$a = [7, 5]$$$. The product of all the numbers in the array is $$$35$$$.In the fourth test case, the product of the numbers in the array is $$$120$$$, which is already divisible by $$$5$$$, so no operations are needed.In the eighth test case, we can perform two operations by choosing $$$i = 2$$$ and $$$i = 3$$$ in any order. After that, the array will be $$$a = [1, 6, 10]$$$. The product of the numbers in the array is $$$60$$$.
Each test consists of multiple test cases. The first line contains a single integer $$$t$$$ ($$$1 \leq t \leq 10^4$$$) — the number of test cases. Then follows the description of the test cases.The first line of each test case contains two integers $$$n$$$ and $$$k$$$ ($$$2 \leq n \leq 10^5$$$, $$$2 \leq k \leq 5$$$) — the size of the array $$$a$$$ and the number $$$k$$$.The second line of each test case contains $$$n$$$ integers $$$a_1, a_2, \ldots, a_n$$$ ($$$1 \leq a_i \leq 10$$$).It is guaranteed that the sum of $$$n$$$ over all test cases does not exceed $$$2 \cdot 10^5$$$.
For each test case, output the minimum number of operations needed to make the product of all the numbers in the array divisible by $$$k$$$.
import sys
input = sys.stdin.readline

def readList():
    return list(map(int, input().split()))

def readInt():
    return int(input())

def readInts():
    return map(int, input().split())

def readStr():
    return input().strip()

def solve():
    (n, k) = readInts()
    arr = readList()
    freq = [0] * k
    for v in arr:
        freq[v % k] += 1
    if freq[0]:
        return 0
    elif k == 4:
        if freq[2] >= 2:
            return 0
        elif freq[2] == freq[3] == 0:
            return 2
        else:
            return 1
    else:
        for i in range(k - 1, 0, -1):
            if freq[i]:
                return k - i
    return
for _ in range(int(input())):
    print(solve())
import sys
from os import path
from collections import Counter, defaultdict, deque

def get_str():
    return sys.stdin.readline().strip()

def get_int():
    return int(get_str())

def get_arr():
    return list(map(int, get_str().split()))
if path.exists('input.txt'):
    sys.stdin = open('input.txt', 'r')
    sys.stdout = open('output.txt', 'w')
sys.setrecursionlimit(10 ** 6)
(MOD, MOD2, INF) = (10 ** 9 + 7, 998244353, 10 ** 18)

def solve():
    (n, k) = get_arr()
    a = [i % k for i in get_arr()]
    if 0 in a:
        print(0)
        return
    mx = max(a)
    ans = k - mx
    if k == 4:
        cnt2 = a.count(2)
        if cnt2 >= 2:
            ans = 0
        elif cnt2 == 1:
            ans = 1
        else:
            ans = min(ans, 2)
    print(ans)
tc = 1
tc = get_int()
for _ in range(tc):
    solve()
def divisible_2(c):
    for i in range(len(c)):
        if c[i] % 2 == 0:
            c[i] = c[i] / 2
            return 0
    return 1

def divisible_3(c):
    k = 2
    for i in c:
        if i % 3 == 0:
            return 0
        elif i % 3 == 2:
            k = 1
    return k

def divisible_4(c):
    if divisible_2(c) == 0:
        if divisible_2(c) == 0:
            return 0
        else:
            return 1
    else:
        for i in c:
            if i % 4 == 3:
                return 1
        return 2

def divisible_5(c):
    rem4 = 0
    rem3 = 0
    rem2 = 0
    rem1 = 0
    for i in c:
        if i % 5 == 0:
            return 0
        if i % 5 == 4:
            rem4 = 1
        if i % 5 == 3:
            rem3 = 1
        if i % 5 == 2:
            rem2 = 1
        if i % 5 == 1:
            rem1 = 1
    if rem4 != 0:
        return 1
    if rem3 != 0:
        return 2
    if rem2 != 0:
        return 3
    return 4

def func(k, c):
    if k == 2:
        return divisible_2(c)
    if k == 3:
        return divisible_3(c)
    if k == 4:
        return divisible_4(c)
    if k == 5:
        return divisible_5(c)
a = int(input())
out = []
for i in range(a):
    b = list(map(int, input().split()))
    c = list(map(int, input().split()))
    out.append(func(b[1], c))
for i in out:
    print(i)