// Arup Guha
// 3/8/2016
// Solution to 2016 UCF HS Contest Problem: Chomp Chomp!

import java.util.*;

public class chomp {

	public static int mod;
	public static int n;
	public static int[] nums;
	public static int[] cumfreq;

	public static void main(String[] args) {

		Scanner stdin = new Scanner(System.in);
		int numCases = stdin.nextInt();

		// Process each case.
		for (int loop=1; loop<=numCases; loop++) {

			// Read in all of the data.
			n = stdin.nextInt();
			mod = stdin.nextInt();
			nums = new int[n];
			for (int i=0; i<n; i++)
				nums[i] = stdin.nextInt();

			// Calculate a cumulative frequency array.
			cumfreq = new int[n+1];
			for (int i=1; i<=n; i++)
				cumfreq[i] = (cumfreq[i-1] + nums[i-1])%mod;;

			// Output the result.
			System.out.println("Plate #"+loop+": "+solve());
		}
	}

	public static long solve() {

		// Will store how many sublists are a particular mod.
		int[] modFreq = new int[mod];

		// See the modFreq list with all sublists starting at index 2 or greater.
		for (int i=2; i<n; i++)
			for (int j=i; j<n; j++)
				modFreq[getRangeMod(i,j)]++;

		long res = 0;

		// Loop through all possible endings of the first range.
		for (int lowEnd=0; lowEnd<n-2; lowEnd++) {

			// Iterate through all possible starting locations of the first chomp.
			for (int lowStart=0; lowStart<=lowEnd; lowStart++) {

				// Find this single ranges mod sum, and the desired matching mod sum of the second chomp.
				int cur = getRangeMod(lowStart, lowEnd);
				int need = (mod-cur)%mod;

				// Add in all of these solutions.
				res = res + modFreq[need];
			}

			// Now, we must subtract out all ranges that start with lowEnd+2. This won't be valid next time around.
			for (int highEnd=lowEnd+2; highEnd<n; highEnd++)
				modFreq[getRangeMod(lowEnd+2, highEnd)]--;
		}

		// Ta da!
		return res;
	}

	// Returns the sum nums[low..high] mod the mod value for the problem.
	public static int getRangeMod(int low, int high) {
		int res = cumfreq[high+1] - cumfreq[low];
		if (res < 0) res += mod;
		return res;
	}
}