#!/usr/bin/python
import sys;
import math;
import numpy as np
from scipy.fftpack import fft

SAMPLE_RATE = 22050 #44100
# MAGIC VALUES BELOW
VOLUME_SAMPLE = (int) (SAMPLE_RATE * 0.05)
VOLUME_THRESHOLD = 1200
TONE_SAMPLE = 2048*2

def getFreq(i):
    return 220 * math.exp(math.log(2) / 12 * i)

tones = [
    ("A" , getFreq( 0)),
    ("A#", getFreq( 1)),
    ("B" , getFreq( 2)),
    ("C" , getFreq( 3)),
    ("C#", getFreq( 4)),
    ("D" , getFreq( 5)),
    ("D#", getFreq( 6)),
    ("E" , getFreq( 7)),
    ("F" , getFreq( 8)),
    ("F#", getFreq( 9)),
    ("G" , getFreq(10)),
    ("G#", getFreq(11)),
    ("A" , getFreq(12)),
    ("A#", getFreq(13)),
    ("B" , getFreq(14)),
    ("C" , getFreq(15)),
    ("C#", getFreq(16)),
    ("D" , getFreq(17)),
    ("D#", getFreq(18)),
    ("E" , getFreq(19)),
    ("F" , getFreq(20)),
    ("F#", getFreq(21)),
    ("G" , getFreq(22)),
    ("G#", getFreq(23)),
    ("A" , getFreq(24)),
    ("A#", getFreq(25)),
    ("B" , getFreq(26)),
    ("C" , getFreq(27)),
    ("C#", getFreq(28)),
    ("D" , getFreq(29)),
    ("D#", getFreq(30)),
];

# First method: get the correlation of sequence with its offset
def analyze_tone(data):
    best = 1e10;
    bestTone = ("XX", 0)

    for tone in tones:
        offset = int(SAMPLE_RATE / tone[1]);
        tmp = zip(data, data[offset:])
        diff = sum(map(lambda x:abs(x[0]-x[1]), tmp)) / len(tmp)
        # This is ugly weighting hack!
        # We need it because if something has frequency 660Hz (high E), 
        # then 220Hz (low A) is also matching. The weighting will discourage
        # picking lower harmonics if there is good enough match for high ones.
        match = diff / tone[1]
        if (best > match):
            best = match
            bestTone = tone
    return bestTone;

# Second method: use FFT
def analyze_tone_fourier(data):
    tmp = fft(data)

    bestTone = ("YY", 0);
    best = 0;
    for tone in tones:
        f = tone[1] * len(data) / SAMPLE_RATE
        match = abs(tmp[int(f)])
        if (best < match):
            best = match;
            bestTone = tone;

    return bestTone;

TESTCASES = int(sys.stdin.readline())
for testcase in range(TESTCASES):
	values = []
	volumes = []
	if (testcase>0):
		print
	sys.stdin.readline()
	n = int(sys.stdin.readline())
	for x in range(n):
		values.append(int(sys.stdin.readline()))

	for x in range(int(n/VOLUME_SAMPLE)):
		samples = values[x*VOLUME_SAMPLE:(x+1)*VOLUME_SAMPLE]
		avg = (sum(map(lambda x:x**2, samples)) / VOLUME_SAMPLE)**0.5
		volumes.append(avg)

	note_starts = 0;
	low = 0;
	output = []
	for q in range(1, len(volumes)):
		if note_starts and (volumes[q-1] > volumes[q]):
			note_starts = 0
			low = volumes[q]
			base = q * VOLUME_SAMPLE
			data = values[base: base + TONE_SAMPLE]
			tone = analyze_tone(data)
			tone2 = analyze_tone_fourier(data)
			#check only tone name, octave could be different
			if (tone[0] != tone2[0]):
				print tone, tone2
				assert False
			output.append(tone[0])

		if (low > volumes[q]):
		  low = volumes[q]
		elif (volumes[q] - low > VOLUME_THRESHOLD):
		  note_starts = 1

	print len(output)
	for x in output:
		print x,
	print
