#K46412. Taco: Subset Sum Multiple Problem

    ID: 27971 Type: Default 1000ms 256MiB

Taco: Subset Sum Multiple Problem

Taco: Subset Sum Multiple Problem

You are given several test cases. For each test case, you are provided with a deck of n cards, where each card contains an integer. You are also given an integer m. Your task is to determine if there exists a non-empty subset of these cards such that the sum of the numbers on the subset is a multiple of m. In other words, check if there exists a subset S (where S is not empty) satisfying

$\displaystyle \sum_{i \in S} a_i \equiv 0 \; (\bmod\; m)$

The input will be provided in a specific format from stdin and your output should be written to stdout.

inputFormat

The first line of input contains a single integer t, indicating the number of test cases.
For each test case, there are two lines:

  • The first line contains two integers n and m separated by a space, where n is the number of cards and m is the divisor.
  • The second line contains n integers representing the values on the cards.

outputFormat

For each test case, output a single line containing YES if such a non-empty subset exists, or NO otherwise.

## sample
3
5 3
1 2 3 4 5
4 5
5 10 15 20
3 11
1 2 3
YES

YES NO

</p>