Mystic Subarray Sums

Time limit: 2 secMemory limit: 256 MBMath, Dynamic Programming

Problem Statement

Deep in the ancient lands of Numeria, the wizards discovered a magical array forged by celestial architects. According to legend, every contiguous segment (or subarray) of this array hides a secret power. The scrolls state that a subarray is truly mystical if the sum of its elements is divisible by a given divine number KK. Your quest is to help the wizards count the number of such mystical subarrays in the given array.

Given an array of NN integers and an integer KK, determine how many subarrays have a sum that is a multiple of KK (i.e., the sum is divisible by KK).

Input Format

  • The first line contains a single integer TT, representing the number of test cases.
  • For each test case, the first line contains two space-separated integers NN and KK, where:
    • NN is the number of elements in the array.
    • KK is the mystical divisor.
  • The second line of each test case contains NN space-separated integers representing the elements of the array.

Output Format

For each test case, print a single integer on a new line — the number of subarrays whose sum is divisible by KK.

Examples

Input

1
5 3
1 2 3 4 1

Output

4

Input

2
4 2
1 2 3 4
3 5
5 5 5

Output

4
6

Code Editor

Submit a solution. Authentication is required to create submissions.

Language
Theme
Source code is submitted to the judge for testing.