You want to perform the combo on your opponent in one popular fighting game. The combo is the string $s$ consisting of $n$ lowercase Latin letters. To perform the combo, you have to press all buttons in the order they appear in $s$. I.e. if $s=$"abca" then you have to press 'a', then 'b', 'c' and 'a' again.

You know that you will spend $m$ wrong tries to perform the combo and during the $i$-th try you will make a mistake right after $p_i$-th button ($1 \le p_i < n$) (i.e. you will press first $p_i$ buttons right and start performing the combo from the beginning). It is guaranteed that during the $m+1$-th try you press all buttons right and finally perform the combo.

I.e. if $s=$"abca", $m=2$ and $p = [1, 3]$ then the sequence of pressed buttons will be 'a' (here you're making a mistake and start performing the combo from the beginning), 'a', 'b', 'c', (here you're making a mistake and start performing the combo from the beginning), 'a' (note that at this point you will not perform the combo because of the mistake), 'b', 'c', 'a'.

Your task is to calculate for each button (letter) the number of times you'll press it.

You have to answer $t$ independent test cases.


-----Input-----

The first line of the input contains one integer $t$ ($1 \le t \le 10^4$) — the number of test cases.

Then $t$ test cases follow.

The first line of each test case contains two integers $n$ and $m$ ($2 \le n \le 2 \cdot 10^5$, $1 \le m \le 2 \cdot 10^5$) — the length of $s$ and the number of tries correspondingly.

The second line of each test case contains the string $s$ consisting of $n$ lowercase Latin letters.

The third line of each test case contains $m$ integers $p_1, p_2, \dots, p_m$ ($1 \le p_i < n$) — the number of characters pressed right during the $i$-th try.

It is guaranteed that the sum of $n$ and the sum of $m$ both does not exceed $2 \cdot 10^5$ ($\sum n \le 2 \cdot 10^5$, $\sum m \le 2 \cdot 10^5$).

It is guaranteed that the answer for each letter does not exceed $2 \cdot 10^9$.


-----Output-----

For each test case, print the answer — $26$ integers: the number of times you press the button 'a', the number of times you press the button 'b', $\dots$, the number of times you press the button 'z'.


-----Example-----
Input
3
4 2
abca
1 3
10 5
codeforces
2 8 3 2 9
26 10
qwertyuioplkjhgfdsazxcvbnm
20 10 1 2 3 5 10 5 9 4

Output
4 2 2 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 
0 0 9 4 5 3 0 0 0 0 0 0 0 0 9 0 0 3 1 0 0 0 0 0 0 0 
2 1 1 2 9 2 2 2 5 2 2 2 1 1 5 4 11 8 2 7 5 1 10 1 5 2 



-----Note-----

The first test case is described in the problem statement. Wrong tries are "a", "abc" and the final try is "abca". The number of times you press 'a' is $4$, 'b' is $2$ and 'c' is $2$.

In the second test case, there are five wrong tries: "co", "codeforc", "cod", "co", "codeforce" and the final try is "codeforces". The number of times you press 'c' is $9$, 'd' is $4$, 'e' is $5$, 'f' is $3$, 'o' is $9$, 'r' is $3$ and 's' is $1$.

Difficulty: EASY
Tags: Complete search
Skill types: Complete search

Starter code:

Solutions:
from itertools import accumulate
from collections import defaultdict
for _ in range(int(input())):
	(a, b) = map(int, input().split())
	s = input()
	p = list(map(int, input().split()))
	k = [0] * a
	for x in p:
		if x >= a:
			k[0] += 1
		else:
			k[0] += 1
			k[x] -= 1
	k1 = list(accumulate(k))
	d = defaultdict(int)
	for x in range(a):
		d[s[x]] += k1[x] + 1
	qw = [0] * 26
	for x in range(97, 123):
		if chr(x) in d:
			qw[x - 97] = d[chr(x)]
	print(*qw)


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	s = input()
	p = list(map(int, input().split()))
	p.sort()
	p = [0] + p
	lst = [0] * 26
	for i in range(1, m + 1):
		cnt = m - i + 2
		for j in range(p[i - 1], p[i]):
			lst[ord(s[j]) - 97] += cnt
	if p[-1] < n:
		for c in range(p[-1], n):
			lst[ord(s[c]) - 97] += 1
	print(*lst)


t = int(input())
for i in range(t):
	(n, m) = map(int, input().split())
	s = input()
	M = [int(i) for i in input().split()]
	M.sort()
	A = [0] * 26
	j = 0
	for i in range(n):
		while j < m and M[j] < i + 1:
			j += 1
		A[ord(s[i]) - 97] += m + 1 - j
	print(*A)


for i in range(int(input())):
	(n, m) = map(int, input().split())
	f = input()
	p = list(map(int, input().split()))
	tt = [0] * (n + 2)
	for j in p:
		tt[0] += 1
		tt[j] -= 1
	tt[0] += 1
	tt[n] -= 1
	for j in range(1, len(tt)):
		tt[j] += tt[j - 1]
	r = {}
	u = 'abcdefghijklmnopqrstuvwxyz'
	for j in u:
		if j not in r:
			r[j] = 0
	for j in range(n):
		r[f[j]] += tt[j]
	print(*r.values())


import sys
t = int(sys.stdin.readline().rstrip())

def solve(p, s):
	a = [0] * 26
	p = [x - 1 for x in p]
	tracker = [0] * len(s)
	tracker[-1] = 1
	for i in p:
		tracker[i] += 1
	for i in range(len(tracker) - 2, -1, -1):
		tracker[i] += tracker[i + 1]
	for i in range(len(tracker)):
		a[ord(s[i]) - ord('a')] += tracker[i]
	print(' '.join([str(i) for i in a]))
for _ in range(t):
	sys.stdin.readline()
	s = sys.stdin.readline().rstrip()
	p = [int(i) for i in sys.stdin.readline().rstrip().split()]
	solve(p, s)


import sys
input = sys.stdin.readline
t = int(input())
for _ in range(t):
	(n, m) = map(int, input().split())
	s = input()[:-1]
	p = list(map(int, input().split())) + [n]
	acc = [[0] for _ in range(26)]
	for i in range(n):
		for j in range(26):
			if ord(s[i]) - ord('a') == j:
				acc[j].append(acc[j][-1] + 1)
			else:
				acc[j].append(acc[j][-1])
	ans = [0] * 26
	for i in range(26):
		for pi in p:
			ans[i] += acc[i][pi]
	print(*ans)


import sys
input = sys.stdin.readline
ins = lambda : input().rstrip()
ini = lambda : int(input().rstrip())
inm = lambda : map(int, input().rstrip().split())
inl = lambda : list(map(int, input().split()))
out = lambda x, s='\n': print(s.join(map(str, x)))
t = ini()
alpha = {}
for i in range(26):
	alpha[chr(i + 97)] = 0
for _ in range(t):
	(n, m) = inm()
	s = ins()
	p = sorted(inl())
	prev = 0
	b = alpha.copy()
	for i in s:
		b[i] += 1
	for i in range(m):
		for j in range(prev, p[i]):
			b[s[j]] += m - i
		prev = p[i]
	print(*b.values())


def add(arr, N, lo, hi, val):
	arr[lo] += val
	if hi != N - 1:
		arr[hi + 1] -= val

def updateArray(arr, N):
	for i in range(1, N):
		arr[i] += arr[i - 1]

def printArr(arr, N):
	updateArray(arr, N)
	return arr
for _ in range(int(input())):
	(n, m) = map(int, input().split())
	s = input()
	p = list(map(int, input().split()))
	f = {}
	for i in range(97, 123):
		f[i] = 0
	diff = [0 for i in range(n)]
	for i in p:
		add(diff, n, 0, i - 1, 1)
	diff = printArr(diff, n)
	for i in range(n):
		f[ord(s[i])] += diff[i] + 1
	for i in range(97, 123):
		if i in f:
			print(f[i], end=' ')
		else:
			print(0, end=' ')
	print()


from sys import stdin
t = int(stdin.readline())
for _ in range(t):
	(n, m) = list(map(int, stdin.readline().rstrip().split(' ')))
	s = stdin.readline().rstrip()
	p = list(map(int, stdin.readline().rstrip().split(' ')))
	prefixArr = [0] * (n + 1)
	prefixArr[0] = [0] * 26
	for i in range(n):
		prev = prefixArr[i].copy()
		prev[ord(s[i]) - 97] += 1
		prefixArr[i + 1] = prev
	output = prefixArr[-1].copy()
	for i in range(m):
		for j in range(26):
			output[j] += prefixArr[p[i]][j]
	print(*output)


def func(s):
	t = [0] * 26
	l = []
	for i in s:
		x = ord(i) - 97
		t[x] += 1
		l.append(tuple(t))
	return l

def sum(l, z):
	res = [0] * 26
	for i in range(26):
		res[i] = l[i] + z[i]
	return res

def domath(l, pl):
	res = [0] * 26
	for i in pl:
		res = sum(res, l[i - 1])
	res = sum(res, l[-1])
	for i in res:
		print(i, end=' ')
	print()
t = int(input())
for _ in range(t):
	s = list(map(int, input().split()))
	(n, m) = (s[0], s[1])
	s = input()
	pl = list(map(int, input().split()))
	l = func(s)
	domath(l, pl)


test = int(input())
for i in range(test):
	[s, k] = list(map(int, input().split()))
	arr = input()
	brr = list(map(int, input().split()))
	has = [0] * (max(brr) + 1)
	for j in range(k):
		has[brr[j]] += 1
	hold = 0
	for j in range(len(has) - 1, -1, -1):
		if has[j] != 0:
			has[j] += hold
			hold = has[j]
		else:
			has[j] = has[j + 1]
	del has[0]
	ans = [0] * 26
	for j in range(len(has)):
		ans[ord(arr[j]) - 97] += has[j]
	for j in range(s):
		ans[ord(arr[j]) - 97] += 1
	print(*ans)


def solve(n, m, s, p):
	s = list(s)
	tmp = [1] * n
	p.sort(key=lambda x: -x)
	p = [el - 1 for el in p]
	adder = 2
	for el in p:
		tmp[el] = adder
		adder += 1
	current = tmp[-1]
	for i in range(n - 1, -1, -1):
		current = max(current, tmp[i])
		tmp[i] = current
	alphabets = 'abcdefghijklmnopqrstuvwxyz'
	result = [0 for el in alphabets]
	for i in range(n):
		result[ord(s[i]) - 97] += tmp[i]
	return ' '.join(map(str, result))
t = int(input())
for _ in range(t):
	(n, m) = map(int, input().split())
	s = input()
	p = list(map(int, input().split()))
	result = solve(n, m, s, p)
	print(result)


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	s = input()
	m = list(map(int, input().split()))
	p = [0] * n
	for i in m:
		p[i - 1] += 1
	p[n - 1] += 1
	for i in range(n - 2, -1, -1):
		p[i] = p[i] + p[i + 1]
	ans = [0] * 26
	for i in range(n):
		ans[ord(s[i]) - 97] += p[i]
	print(*ans)


for _ in range(int(input())):
	(n, m) = list(map(int, input().split()))
	s = input()
	p = list(map(int, input().split()))
	count = [0] * 26
	scount = [0] * len(s)
	p.append(len(s))
	p.sort(reverse=True)
	pi = 0
	for i in range(len(s) - 1, -1, -1):
		while pi < len(p) and i == p[pi] - 1:
			pi += 1
		scount[i] += pi
	for i in range(len(s)):
		ch = s[i]
		count[ord(ch) - ord('a')] += scount[i]
	print(*count)


from sys import stdin

def solve(tc):
	(n, m) = map(int, stdin.readline().split())
	s = stdin.readline()
	plist = list(map(int, stdin.readline().split()))
	cum = [0 for i in range(n + 1)]
	ans = [0 for i in range(26)]
	for p in plist:
		cum[0] += 1
		cum[p] -= 1
	for i in range(1, n):
		cum[i] += cum[i - 1]
	for i in range(n):
		ans[ord(s[i]) - ord('a')] += cum[i] + 1
	for i in range(26):
		print(ans[i], end=' ')
	print('\n')
LOCAL_TEST = not __debug__
if LOCAL_TEST:
	infile = __file__.split('.')[0] + '-test.in'
	stdin = open(infile, 'r')
tcs = int(stdin.readline().strip())
tc = 1
while tc <= tcs:
	solve(tc)
	tc += 1


t = int(input())
while t:
	t += -1
	(n, m) = map(int, input().split())
	s = input()
	p = list(map(int, input().split()))
	ans = [0] * 26
	ss = ord('a') - 97
	arr = [0] * (n + 1)
	for i in p:
		arr[i] -= -1
	temp = 1
	for i in range(n, -1, -1):
		arr[i] += temp
		temp = arr[i]
	for i in range(n):
		ans[ord(s[i]) - 97] += arr[i + 1]
	print(*ans)


from bisect import bisect_right
t = int(input())
for x in range(t):
	(n, m) = map(int, input().split())
	s = str(input())
	p = list(map(int, input().split()))
	p = sorted(p)
	lett = [0] * 26
	ind = -1
	n_pos = -1
	for y in range(0, len(s)):
		ind = ord(s[y]) - 97
		n_pos = bisect_right(p, y)
		lett[ind] += len(p) - n_pos + 1
	print(' '.join((str(x) for x in lett)))


import math

class Read:

	@staticmethod
	def string():
		return input()

	@staticmethod
	def int():
		return int(input())

	@staticmethod
	def list(sep=' '):
		return input().split(sep)

	@staticmethod
	def list_int(sep=' '):
		return list(map(int, input().split(sep)))

def solve():
	alp = 'abcdefghijklmnopqrstuvwxyz'
	(n, m) = Read.list_int()
	s = Read.string()
	p = Read.list_int()
	p.sort()
	p.reverse()
	t = {}
	for i in p:
		i_lcl = i - 1
		if i_lcl in t:
			t[i_lcl] += 1
		else:
			t[i_lcl] = 1
	t[n - 1] = 1
	res = {}
	k = 0
	for i in range(n - 1, -1, -1):
		if i in t:
			k += t[i]
		if s[i] in res:
			res[s[i]] += k
		else:
			res[s[i]] = k
	res_s = []
	for i in alp:
		res_s.append(str(res[i]) if i in res else '0')
	print(' '.join(res_s))
query_count = Read.int()
while query_count:
	query_count -= 1
	solve()


t = int(input())
for test in range(t):
	(a, b) = map(int, input().split())
	s = input()
	arr = list(map(int, input().split()))
	warr = [[0 for i in range(26)] for i in range(len(s))]
	farr = [0 for i in range(26)]
	warr[0][ord(s[0]) - 97] = 1
	for i in range(1, len(s)):
		for j in range(26):
			warr[i][j] = warr[i - 1][j]
		warr[i][ord(s[i]) - 97] += 1
	for i in range(len(arr)):
		tarr = warr[arr[i] - 1]
		for i in range(26):
			farr[i] += tarr[i]
	for i in range(26):
		farr[i] += warr[len(s) - 1][i]
	print(*farr)


from bisect import bisect_right

def solve(s, P):
	P.sort()
	L = len(P)
	letters = [0] * 26
	for i in range(len(s)):
		letters[ord(s[i]) - ord('a')] += L - bisect_right(P, i) + 1
	return letters
t = int(input())
for _ in range(t):
	(n, m) = map(int, input().split())
	s = input()
	P = list(map(int, input().split()))
	r = solve(s, P)
	print(' '.join(map(str, r)))


import collections, math
local = False
if local:
	file = open('inputt.txt', 'r')

def inp():
	if local:
		return file.readline().rstrip()
	else:
		return input().rstrip()

def ints():
	return [int(_) for _ in inp().split()]
t = int(inp())
for _ in range(t):
	(n, m) = ints()
	arr = inp()
	parr = ints()
	vals = []
	latest = [0] * 26
	for a in arr:
		vals.append(list(latest))
		vals[-1][ord(a) - ord('a')] += 1
		latest = vals[-1]
	latest = [0] * 26
	for p in parr:
		for i in range(26):
			latest[i] += vals[p - 1][i]
	for i in range(26):
		latest[i] += vals[-1][i]
	print(' '.join([str(x) for x in latest]))


col = int(input())
for _ in range(col):
	(n, m) = input().split()
	n = int(n)
	m = int(m)
	s = input()
	ans = [0] * 26
	L = sorted(list(map(int, input().split())), reverse=True)
	temp = s
	m = 1
	k = 0
	for i in range(len(s) - 1, -1, -1):
		while k != len(L) and i + 1 == L[k]:
			m += 1
			k += 1
		ans[ord(s[i]) - 97] += m
	print(*ans)


import sys
from collections import defaultdict
from itertools import permutations, combinations
import string
from heapq import heapify, heappush, heappop

def solve():
	alphabets = string.ascii_lowercase
	digits = string.digits
	get_arr = lambda type_=int: list(map(type_, sys.stdin.readline().rstrip('\n').split()))
	inp = lambda type_=int: type_(sys.stdin.readline().rstrip('\n'))
	pair = lambda type_=int: map(type_, sys.stdin.readline().rstrip('\n').split(' '))
	t = inp()
	for _ in range(t):
		(n, m) = pair()
		string_ = inp(str)
		arr = get_arr()
		d = defaultdict(int)
		arr = sorted(arr)
		prev = 0
		for i in range(m):
			num = arr[i]
			for j in range(prev, num):
				char = string_[j]
				d[char] += m - i
			prev = num
		for i in range(n):
			d[string_[i]] += 1
		for alpha in alphabets:
			print(d[alpha], end=' ')
		print()
solve()


import sys
T = int(sys.stdin.readline())
for _ in range(T):
	(n, m) = map(int, sys.stdin.readline().split())
	s = sys.stdin.readline().strip()
	p = list(map(int, sys.stdin.readline().split()))
	p.sort()
	dict_alpha = {chr(97 + i): i for i in range(26)}
	list_count = [0] * 26
	list_result = [0] * 26
	j = 0
	for (i, letter) in enumerate(s):
		list_count[dict_alpha[letter]] += 1
		list_result[dict_alpha[letter]] += 1
		if j < m and i == p[j] - 1:
			gop = 0
			while j < m and i == p[j] - 1:
				gop += 1
				j += 1
			for k in range(26):
				list_result[k] += list_count[k] * gop
	print(*list_result)


import sys
input = sys.stdin.readline
for _ in range(int(input())):
	(n, m) = map(int, input().split())
	s = list(map(lambda x: ord(x) - 97, input().rstrip()))
	p = [n] + sorted(map(int, input().split()), reverse=True)
	ans = [0] * 26
	i = 0
	for i in range(n):
		while p and p[-1] == i:
			p.pop()
		ans[s[i]] += len(p)
	print(*ans)


t = int(input())
while t:
	t -= 1
	co = [0] * 26
	(n, m) = map(int, input().split())
	reco = [0] * n
	s = input()
	a = list(map(int, input().split()))
	for i in range(m):
		reco[0] += 1
		reco[a[i]] += -1
	reco[0] += 1
	for i in range(1, n):
		reco[i] = reco[i] + reco[i - 1]
	for i in range(n):
		z = ord(s[i]) - 97
		co[z] += reco[i]
	print(*co)


from math import sqrt
cnt_t = int(input())
for t in range(cnt_t):
	(n, m) = [int(x) for x in input().split(' ')]
	s = input()
	fails = [int(x) for x in input().split(' ')]
	answer = [0] * 26
	for ch in s:
		answer[ord(ch) - 97] += 1
	delta = len(fails)
	map_delta = [0] * n
	fails.sort(reverse=True)
	bound = fails.pop()
	for i in range(len(map_delta)):
		if i < bound - 1:
			map_delta[i] = delta
		elif i == bound - 1:
			map_delta[i] = delta
			delta -= 1
			prev_bound = bound
			if len(fails) == 0:
				continue
			bound = fails.pop()
			while len(fails) > 0 and prev_bound == bound:
				prev_bound = bound
				bound = fails.pop()
				delta -= 1
		else:
			map_delta[i] = 0
	for (i, val) in enumerate(map_delta):
		answer[ord(s[i]) - 97] += val
	for num in answer:
		print(num, end=' ')
	print('\n')


from sys import stdin

def inp():
	return next((ss.rstrip() for ss in stdin))

def itg():
	return int(inp())

def mpint():
	return map(int, inp().split())
for case in range(itg()):
	(n, m) = mpint()
	s = inp()
	data = [[0] * 26]
	for i in range(n):
		data[i][ord(s[i]) - 97] += 1
		data.append(data[i].copy())
	pp = (int(i) - 1 for i in inp().split())
	ans = data[-1]
	for p in pp:
		for i in range(26):
			ans[i] += data[p][i]
	print(*ans)


t = int(input())
alp = 'abcdefghijklmnopqrstuvwxyz'
dic = {}
for i in range(26):
	dic[alp[i]] = i
for loop in range(t):
	(n, m) = map(int, input().split())
	s = input()
	p = list(map(int, input().split()))
	p.sort()
	p.append(n)
	p.append(float('inf'))
	ind = 0
	ans = [0] * 26
	now = [0] * 26
	for i in range(n):
		now[dic[s[i]]] += 1
		while p[ind] == i + 1:
			ind += 1
			for j in range(26):
				ans[j] += now[j]
	print(' '.join(map(str, ans)))


testCases = int(input())
for _ in range(testCases):
	(n, m) = map(int, input().split())
	As = input()
	Ps = list(map(int, input().split()))
	Ps.append(n)
	frequency = [0] * n
	for mistakeIndex in Ps:
		frequency[mistakeIndex - 1] += 1
	for index in range(n - 2, -1, -1):
		frequency[index] = frequency[index] + frequency[index + 1]
	answer = [0] * 26
	for index in range(n):
		answer[ord(As[index]) - 97] += frequency[index]
	print(*answer)


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	s = input()
	p = sorted(list(map(int, input().split())) + [0] + [n], reverse=True)
	alphabet = {'a': 0, 'b': 0, 'c': 0, 'd': 0, 'e': 0, 'f': 0, 'g': 0, 'h': 0, 'i': 0, 'j': 0, 'k': 0, 'l': 0, 'm': 0, 'n': 0, 'o': 0, 'p': 0, 'q': 0, 'r': 0, 's': 0, 't': 0, 'u': 0, 'v': 0, 'w': 0, 'x': 0, 'y': 0, 'z': 0}
	c = 1
	for i in range(m + 1):
		if p[i] != 0:
			for j in s[p[i + 1]:p[i]]:
				alphabet[j] += c
			c += 1
	for i in alphabet.values():
		print(i, end=' ')
	print()


from sys import stdin

def inp():
	return stdin.readline().strip()
t = int(inp())
for _ in range(t):
	(n, m) = [int(x) for x in inp().split()]
	s = inp()
	p = [int(x) for x in inp().split()]
	pressed = [0] * n
	for i in range(len(p)):
		pressed[p[i] - 1] += 1
	for i in range(n - 1, 0, -1):
		pressed[i - 1] += pressed[i]
	ans = [0] * 26
	for i in range(n):
		asc = ord(s[i])
		ans[asc - 97] += pressed[i]
	for i in range(n):
		asc = ord(s[i])
		ans[asc - 97] += 1
	print(*ans)


t = int(input())
for i in range(t):
	(n, m) = map(int, input().split())
	s = input()
	chk = list(map(int, input().split()))
	ls = [0] * 26
	a = [0] * len(s)
	for i in chk:
		a[i - 1] += 1
	k = n - 1
	while k > 0:
		a[k - 1] += a[k]
		k -= 1
	str = 'abcdefghijklmnopqrstuvwxyz'
	for i in range(26):
		for j in range(len(s)):
			if str[i] == s[j]:
				ls[i] += a[j] + 1
		print(ls[i], end=' ')
	print()


n = int(input())
for x in range(n):
	(lengthA, lengthB) = [int(i) for i in input().split()]
	a = input()
	p = [int(i) for i in input().split()]
	p.append(len(a))
	alphabet = [0] * 26
	temp = [0] * len(a)
	for i in p:
		temp[i - 1] += 1
	for i in range(len(a) - 1, 0, -1):
		temp[i - 1] += temp[i]
	for i in range(len(temp)):
		alphabet[ord(a[i]) - 97] += temp[i]
	print(' '.join(map(str, alphabet)))


def solve(s, p):
	(n, m) = (len(s), len(p))
	cnt = [0] * n
	for i in range(m):
		cnt[p[i] - 1] += 1
	cnt[-1] += 1
	for i in range(n - 2, -1, -1):
		cnt[i] += cnt[i + 1]
	ans = [0] * 26
	for i in range(n):
		ans[ord(s[i]) - ord('a')] += cnt[i]
	print(*ans, end=' ')
	print()
	return
t = int(input())
for i in range(t):
	(n, m) = [int(x) for x in input().split()]
	s = input()
	p = [int(x) for x in input().split()]
	solve(s, p)


import math, sys
from collections import defaultdict, Counter, deque
INF = float('inf')
MOD = 10 ** 9 + 7

def gcd(a, b):
	while b:
		(a, b) = (b, a % b)
	return a

def isPrime(n):
	if n <= 1:
		return False
	i = 2
	while i ** 2 <= n:
		if n % i == 0:
			return False
		i += 1
	return True

def primeFactors(n):
	factors = defaultdict(int)
	i = 2
	while i ** 2 <= n:
		while n % i == 0:
			factors[i] += 1
			n //= i
		i += 1
	if n > 1:
		factors[n] += 1
	return factors

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

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

def main():
	(n, m) = vars()
	s = input()
	arr = array()
	count = {}
	for num in arr:
		if num not in count:
			count[num] = 1
		else:
			count[num]
	arr.sort()
	j = 0
	ans = [0 for i in range(26)]
	for i in range(n):
		while j < m and i == arr[j]:
			j += 1
		if j >= m:
			break
		if i < arr[j]:
			ans[ord(s[i]) % 97] += (m - j) * count[arr[j]]
	for i in range(n):
		ans[ord(s[i]) % 97] += 1
	print(*ans)
t = 1
t = int(input())
for _ in range(t):
	main()


for _ in range(int(input())):
	(n, m) = [int(i) for i in input().split()]
	(combs, reps) = ([0] * 26, [0] * n)
	s = input()
	p = [int(i) for i in input().split()]
	for i in range(m):
		reps[p[i] - 1] += 1
	reps[n - 1] = 1
	for i in range(n - 1, 0, -1):
		reps[i - 1] += reps[i]
	for i in range(n):
		combs[ord(s[i]) - 97] += reps[i]
	print(*combs, sep=' ')


def nLargerOrEqual(p, k):
	(low, high) = (-1, len(p))
	while high - low > 1:
		m = int((low + high) / 2)
		if p[m] < k:
			low = m
		else:
			high = m
	return len(p) - low - 1
t = int(input())
for _ in range(t):
	(m, n) = map(int, input().split())
	combo = input()
	p = list(map(int, input().split()))
	p.append(len(combo))
	p.sort()
	ans = [0] * 26
	for i in range(len(combo)):
		ans[ord(combo[i]) - ord('a')] += nLargerOrEqual(p, i + 1)
	print(*ans)


from collections import defaultdict as dc
import sys
import math
input = sys.stdin.readline
x = list('abcdefghijklmnopqrstuvwxyz')
for _ in range(int(input())):
	(n, m) = map(int, input().split())
	s = input()[:-1]
	l = list(map(int, input().split()))
	p = [0] * n
	for i in l:
		p[i - 1] += 1
	for i in range(n - 2, -1, -1):
		p[i] = p[i] + p[i + 1]
	p = [p[i] + 1 for i in range(n)]
	g = dc(int)
	for i in range(n):
		g[s[i]] += p[i]
	q = []
	for i in x:
		q.append(g[i])
	print(*q)


from collections import Counter
for ti in range(int(input())):
	(n, m) = [int(x) for x in input().split()]
	s = input()
	p = Counter([int(x) for x in input().split()])
	k = 0
	a = [0] * 26
	for i in range(len(s) - 1, -1, -1):
		k += p[i + 1]
		a[ord(s[i]) - ord('a')] += 1 + k
	print(*a)


t = int(input())
for _ in range(t):
	ans = [0] * 26
	(n, m) = map(int, input().split())
	combo = input()
	p = list(map(lambda x: int(x) - 1, input().split()))
	cnt = [0] * n
	for i in range(m):
		cnt[p[i]] += 1
	for i in range(n - 1, 0, -1):
		cnt[i - 1] += cnt[i]
	for (i, c) in enumerate(combo):
		ans[ord(c) - 97] += cnt[i] + 1
	for num in ans:
		print(num, end=' ')
	print()


from string import ascii_lowercase
for _ in range(int(input())):
	(n, m) = map(int, input().split())
	s = input()
	ans = [0 for i in range(26)]
	p = list(map(int, input().split()))
	dicts = {}
	for i in ascii_lowercase:
		dicts[i] = [0 for j in range(n + 1)]
	for i in range(n):
		curr = s[i]
		for character in ascii_lowercase:
			if curr == character:
				dicts[curr][i + 1] = dicts[curr][i] + 1
			else:
				dicts[character][i + 1] = dicts[character][i]
	for element in p:
		for character in ascii_lowercase:
			ans[ord(character) - ord('a')] += dicts[character][element]
	for e in s:
		ans[ord(e) - ord('a')] += 1
	print(*ans)


import sys
rl = sys.stdin.readline
t = int(input())
for _ in range(t):
	(n, m) = map(int, rl().rstrip().split(' '))
	inp = list(rl().rstrip())
	p = list(map(int, rl().rstrip().split(' ')))
	p.sort()
	answer = [0] * 26
	keyboards = []
	bef = 0
	for pp in p:
		keyboard = [0] * 26
		for i in range(bef, pp):
			keyboard[ord(inp[i]) - ord('a')] += 1
		bef = pp
		keyboards.append(keyboard)
	lenn = len(keyboards)
	kidx = 0
	while lenn > 0:
		curKeyboard = keyboards[kidx]
		for i in range(len(answer)):
			answer[i] += curKeyboard[i] * lenn
		lenn -= 1
		kidx += 1
	for inpp in inp:
		answer[ord(inpp) - ord('a')] += 1
	for a in answer:
		print(a, end=' ')
	print('')


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	s = input()
	p = list(map(int, input().split()))
	cnts = [0] * 26
	p.sort()
	index = 0
	for (i, char) in enumerate(s):
		while index < m and i > p[index] - 1:
			index += 1
		cnts[ord(char) - 97] += m - index + 1
	print(*cnts)


from bisect import bisect_left as left
t = int(input())
for _ in range(t):
	(n, m) = map(int, input().split())
	s = input()
	p = [int(i) for i in input().split()]
	p.sort()
	ans = [0] * 26
	for i in range(n):
		x = left(p, i + 1)
		ans[ord(s[i]) - 97] += m - x + 1
	print(*ans)


import copy
alphabet = ['abcdefghijklmnopqrstuvwxyz'][0]

def ai(ind):
	return alphabet.index(ind)

def solution(n, m, s, p):
	p = [pi - 1 for pi in p]
	p.append(n - 1)
	numbers = [[0] * 26]
	numbers[0][ai(s[0])] = 1
	for i in range(1, n):
		numbers.append(copy.copy(numbers[i - 1]))
		numbers[i][ai(s[i])] += 1
	ans = [0] * 26
	for i in range(m + 1):
		for j in range(26):
			ans[j] += numbers[p[i]][j]
	print(' '.join(map(str, ans)))
t = int(input())
for _ in range(t):
	(n, m) = map(int, input().split())
	s = input()
	p = list(map(int, input().split()))
	solution(n, m, s, p)


from copy import copy
t = int(input())

def addList(a, b):
	c = [0] * 26
	for i in range(26):
		c[i] = a[i] + b[i]
	return c
for _ in range(t):
	(n, m) = map(int, input().split())
	s = input()
	row = [0] * 26
	occ = []
	for c in s:
		row[ord(c) - ord('a')] += 1
		occ.append(copy(row))
	p = [int(x) - 1 for x in input().split()]
	total = [0] * 26
	for pi in p:
		total = addList(total, occ[pi])
	total = addList(total, occ[-1])
	print(*total)


t = int(input())
for T in range(t):
	(n, m) = map(int, input().strip().split())
	s = input().strip()
	q = [0] * n
	for i in map(int, input().strip().split()):
		q[i - 1] += 1
	q[-1] = 1
	p = {i: 0 for i in 'abcdefghijklmnopqrstuvwxyz'}
	o = {i: 0 for i in 'abcdefghijklmnopqrstuvwxyz'}
	for i in range(n):
		p[s[i]] += 1
		if q[i]:
			for j in p:
				o[j] += p[j] * q[i]
	for i in o:
		print(o[i])


from collections import Counter
sc = iter(open(0).read().split())
ni = lambda : int(next(sc))
ns = lambda : next(sc)
T = ni()
for _ in range(T):
	(N, M) = (ni(), ni())
	S = [ord(s) - ord('a') for s in ns()]
	P = [ni() - 1 for _ in range(M)]
	P.append(N - 1)
	C = Counter(P)
	K = sorted(C.keys(), reverse=True)
	ans = [0] * 26
	k = K.pop()
	cur = 0
	for (i, s) in enumerate(S):
		ans[s] += M + 1 - cur
		if i == k:
			cur += C[k]
			if K:
				k = K.pop()
	print(*ans)


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	s = input()
	p = map(int, input().split())
	(res, cnt, t) = ([0] * 26, [0] * n, 0)
	for x in p:
		cnt[x] += 1
	for i in range(n - 1, -1, -1):
		res[ord(s[i]) - ord('a')] += t
		t += cnt[i]
	for x in s:
		res[ord(x) - ord('a')] += 1
	print(' '.join(map(str, res)))


import bisect
testCases = int(input())
for _ in range(testCases):
	count = [0] * 26
	(length, tries) = list(map(int, input().split()))
	sequence = list(input())
	p = sorted(list(map(int, input().split())))
	for i1 in range(len(sequence)):
		index = bisect.bisect_left(p, i1 + 1)
		count[ord(sequence[i1]) - 97] += len(p) - index + 1
	print(*count)


from sys import stdin
from math import ceil
inp = lambda : stdin.readline().strip()
t = int(inp())
for _ in range(t):
	(n, m) = [int(x) for x in inp().split()]
	s = inp()
	p = [int(x) for x in inp().split()]
	p.append(n)
	ans = [0] * 26
	pos = [0] * n
	for i in p:
		pos[i - 1] += 1
	for i in range(n - 1, 0, -1):
		pos[i - 1] += pos[i]
	for i in range(n):
		ans[ord(s[i]) - 97] += pos[i]
	print(*ans)


import string
for _ in range(int(input())):
	(n, m) = map(int, input().split())
	s = input()
	p = list(map(int, input().split())) + [-1]
	d = {c: [0] for c in string.ascii_lowercase}
	for i in s:
		for c in string.ascii_lowercase:
			d[c].append(d[c][-1])
		d[i][-1] += 1
	ans = {c: 0 for c in string.ascii_lowercase}
	for i in p:
		for c in string.ascii_lowercase:
			ans[c] += d[c][i]
	print(*ans.values())


t = int(input())
for _ in range(t):
	(n, m) = map(int, input().split())
	s = input()
	p = list(map(int, input().split()))
	d = dict()
	k = ord(s[0]) - ord('a')
	q = [0 for i in range(26)]
	q[k] += 1
	d[0] = q
	for i in range(1, n):
		k = ord(s[i]) - ord('a')
		add = [j for j in d[i - 1]]
		add[k] += 1
		d[i] = add
	ans = [0 for _ in range(26)]
	for i in range(m):
		for j in range(26):
			ans[j] += d[p[i] - 1][j]
	for j in range(26):
		ans[j] += d[n - 1][j]
	for i in range(26):
		print('{} '.format(ans[i]), end='')
	print()


t = int(input())
for _ in range(t):
	(n, m) = map(int, input().split())
	s = input()
	p = list(map(int, input().split()))
	alpha = [0] * 26
	st = [0] * n
	for i in p:
		st[i - 1] += 1
	for j in range(n - 1, 0, -1):
		st[j - 1] += st[j]
	for k in range(n):
		alpha[ord(s[k]) - 97] += st[k]
		alpha[ord(s[k]) - 97] += 1
	print(*alpha)


import sys
input = sys.stdin.readline
LI = lambda : list(map(int, input().split()))
MI = lambda : map(int, input().split())
SI = lambda : input().strip('\n')
for _ in range(int(input())):
	(n, m) = MI()
	s = SI()
	a = sorted(list(map(lambda x: x - 1, LI())))
	num = [1] * n
	for i in range(n):
		l = 0
		r = m - 1
		ret = -1
		while l <= r:
			mid = (l + r) // 2
			if a[mid] >= i:
				ret = mid
				r = mid - 1
			else:
				l = mid + 1
		if ret != -1:
			num[i] = m - ret + 1
	cnt = {}
	for i in range(26):
		cnt[chr(i + ord('a'))] = 0
	for (i, c) in enumerate(s):
		cnt[c] += num[i]
	print(*cnt.values())


def nButtonPresses(nMispresses, combo, charactersLastPressedRight):
	storage = {'a': 0, 'b': 0, 'c': 0, 'd': 0, 'e': 0, 'f': 0, 'g': 0, 'h': 0, 'i': 0, 'j': 0, 'k': 0, 'l': 0, 'm': 0, 'n': 0, 'o': 0, 'p': 0, 'q': 0, 'r': 0, 's': 0, 't': 0, 'u': 0, 'v': 0, 'w': 0, 'x': 0, 'y': 0, 'z': 0}
	for i in range(nMispresses + 1):
		for j in range(charactersLastPressedRight[i], charactersLastPressedRight[i - 1]):
			storage[combo[j]] += 1 + i
	return ' '.join(map(str, storage.values()))

def testCase_1311c():
	(comboLength, nMispresses) = map(int, input().split(' '))
	combo = input()
	charactersLastPressedRight = list(map(int, input().split(' ')))
	charactersLastPressedRight.sort(reverse=True)
	print(nButtonPresses(nMispresses, combo, charactersLastPressedRight + [0, comboLength]))
for x in range(int(input())):
	testCase_1311c()


R = lambda : map(int, input().split())
(t,) = R()
for _ in [0] * t:
	(n, m) = R()
	s = input()
	p = sorted(R()) + [n, 0]
	r = [0] * 26
	i = j = 0
	for x in s:
		i += 1
		r[ord(x) - 97] += m + 1 - j
		while i == p[j]:
			j += 1
	print(*r)


from collections import Counter
from collections import defaultdict
import math
t = int(input())
for _ in range(0, t):
	(n, m) = list(map(int, input().split()))
	s = input()
	l = list(map(int, input().split()))
	d = dict()
	for i in range(0, n + 1):
		d[i] = [0] * 26
	for i in range(0, n):
		k = ord(s[i]) - ord('a')
		if i == 0:
			d[i][k] = 1
		else:
			for j in range(0, 26):
				if j == k:
					d[i][j] = d[i - 1][j] + 1
				else:
					d[i][j] = d[i - 1][j]
	pre = dict()
	ans = [0] * 26
	l.append(n - 1)
	for i in range(0, m):
		l[i] = l[i] - 1
	for i in range(0, len(l)):
		for j in range(0, 26):
			ans[j] = ans[j] + d[l[i]][j]
	print(*ans)


from operator import add
testcase = int(input())
for i in range(testcase):
	(n, m) = map(int, input().split())
	str1 = input()
	li = list(map(int, input().split()))
	li.sort()
	var = 0
	temp = [0 for i in range(27)]
	for q in range(n):
		temp[ord(str1[q]) - ord('a') + 1] += 1
	temp2 = temp[:]
	q = n - 1
	track = m - 1
	while q >= 0:
		if track < 0:
			break
		while q + 1 == li[track] and track >= 0:
			temp = list(map(add, temp, temp2))
			track -= 1
		else:
			temp2[ord(str1[q]) - ord('a') + 1] -= 1
		q -= 1
	print(*temp[1:])


t = int(input())
for _ in range(t):
	(n, m) = map(int, input().split())
	s = input()
	p = list(map(int, input().split()))
	p = sorted(p)
	vis = [1] * n
	last = p[0]
	mul = m
	for j in range(last):
		vis[j] += mul
	mul -= 1
	for i in range(1, m):
		for j in range(last, p[i]):
			vis[j] += mul
		last = p[i]
		mul -= 1
	res = [0] * 26
	for i in range(n):
		res[ord(s[i]) - 97] += vis[i]
	for i in res:
		print(i, end=' ')
	print()


from string import ascii_lowercase
from collections import Counter

def read_ints():
	return [int(x) for x in input().split()]
for _ in range(int(input())):
	(n, m) = read_ints()
	s = input()
	p = [x - 1 for x in read_ints()]
	p.sort()
	letter_counts = Counter()
	string_counts = [1] * n
	j = m - 1
	for i in range(n - 2, -1, -1):
		string_counts[i] = string_counts[i + 1]
		while j >= 0 and p[j] == i:
			string_counts[i] += 1
			j -= 1
	for (i, count) in enumerate(string_counts):
		letter_counts[s[i]] += count
	for ch in ascii_lowercase:
		print(letter_counts[ch], end=' ')
	print()


t = int(input())
for ts in range(t):
	(l1, l2) = [int(i) for i in input().split()]
	a = list(input())
	p = [int(i) for i in input().split()] + [l1 + 1]
	f = {}
	for i in 'qwertyuiopasdfghjklzxcvbnm':
		f[i] = 0
	p.sort()
	pp = 0
	for j in range(l1):
		while p[pp] - 1 < j:
			pp += 1
		f[a[j]] += l2 + 1 - pp
	for i in 'abcdefghijklmnopqrstuvwxyz':
		print(f[i], end=' ')
	print()


t = int(input())
for _ in range(t):
	(n, m) = map(int, input().split())
	s = input()
	arr = [int(x) for x in input().split()] + [n]
	h = [0] * 26
	L = []
	for i in range(0, len(s)):
		h[ord(s[i]) - 97] += 1
		d = []
		for j in range(26):
			d.append(h[j])
		L.append(d)
	pos = [0] * 26
	for i in range(0, len(arr)):
		h = L[arr[i] - 1]
		for j in range(0, len(h)):
			pos[j] += h[j]
	print(*pos)


input = __import__('sys').stdin.readline
print = __import__('sys').stdout.write
for _ in range(int(input())):
	(n, k) = map(int, input().split())
	alpha = [0 for _ in range(26)]
	word = input()
	word_ss = [1 for _ in range(n)]
	kk = [0] + sorted(list(map(int, input().split())))
	for (idx, idx2) in enumerate(range(k, 0, -1), 1):
		if word_ss[kk[idx] - 1] == 1:
			for j in range(kk[idx - 1], kk[idx]):
				word_ss[j] += idx2
	for i in range(n):
		alpha[ord(word[i]) - 97] += word_ss[i]
	for w in alpha:
		print(f'{w} ')
	print('\n')


for _ in range(int(input())):
	h = {'a': [], 'b': [], 'c': [], 'd': [], 'e': [], 'f': [], 'g': [], 'h': [], 'i': [], 'j': [], 'k': [], 'l': [], 'm': [], 'n': [], 'o': [], 'p': [], 'q': [], 'r': [], 's': [], 't': [], 'u': [], 'v': [], 'w': [], 'x': [], 'y': [], 'z': []}
	(n, m) = map(int, input().split())
	s = input()
	p = [int(x) for x in input().split()]
	for i in range(len(s)):
		if h[s[i]] != []:
			h[s[i]].append(h[s[i]][-1] + 1)
		else:
			h[s[i]].append(1)
		for x in h:
			if x != s[i]:
				if h[x] != []:
					h[x].append(h[x][-1])
				else:
					h[x].append(0)
	for x in h:
		s = 0
		for y in p:
			s += h[x][y - 1]
		print(s + h[x][-1], end=' ')
	print()


t = int(input())
for _ in range(t):
	a = [0 for i in range(26)]
	(n, m) = map(int, input().split())
	s = input()
	p = [int(i) for i in input().split()]
	p.append(n)
	p.sort()
	l = 0
	l2 = 0
	for i in range(m + 1):
		for j in s[l:p[i]]:
			a[ord(j) - 97] += m + 1 - l2
		l = p[i]
		l2 += 1
	print(*a)


import sys
input = sys.stdin.readline
for _ in range(int(input())):
	(n, m) = map(int, input().split())
	s = input()
	l = list(map(int, input().split()))
	c = [0] * n
	for i in l:
		c[i - 1] += 1
	c[n - 1] += 1
	for j in range(n - 2, -1, -1):
		c[j] += c[j + 1]
	d = [0] * 26
	for i in range(n):
		d[ord(s[i]) - 97] += c[i]
	print(*d)


t = int(input())
for ii in range(t):
	(n, m) = map(int, input().split())
	s = list(input())
	a = list(map(int, input().split()))
	e = [0] * n
	for i in range(m):
		e[a[i] - 1] += 1
	e[-1] += 1
	for i in range(n - 1):
		e[n - i - 2] += e[n - i - 1]
	bibl = 'abcdefghijklmnopqrstuvwxyz'
	b = [0] * 26
	for i in range(n):
		b[bibl.index(s[i])] += e[i]
	print(*b)


from sys import stdin
t = int(stdin.readline())

def alpha_add(cur_sum, string):
	for button in string:
		cur_sum[ord(button) - ord('a')] += 1

def add(a, b):
	for i in range(len(a)):
		b[i] += a[i]
for i in range(t):
	(n, m) = list(map(int, stdin.readline().split(' ')))
	a = stdin.readline()[:-1]
	p = list(map(int, stdin.readline().split(' ')))
	sum = [0 for i in range(26)]
	cur_sum = [0 for i in range(26)]
	p.sort()
	p.append(n)
	last_stop = 0
	for stop in p:
		alpha_add(cur_sum, a[last_stop:stop])
		add(cur_sum, sum)
		last_stop = stop
	for number in sum:
		print(str(number) + ' ', end='')
	print('')


def solution():
	from sys import stdout, stdin
	(_input, _print) = (stdin.readline, stdout.write)
	(_range, _int, _enumerate, _str) = (range, int, enumerate, str)
	for i in _range(_int(_input())):
		(m, n) = [_int(i) for i in _input().split()]
		arr = '#' + _input().replace('\n', '')
		from collections import defaultdict
		repeat = defaultdict(int)
		for i in _input().split():
			repeat[_int(i)] += 1
		ans = {v: i for (i, v) in _enumerate('abcdefghijklmnopqrstuvwxyz')}
		current = [0] * 26
		summary = [0] * 26
		for (i, v) in _enumerate(arr):
			if i == 0:
				continue
			current[ans[v]] += 1
			if i in repeat.keys():
				z = repeat[i]
				for j in _range(26):
					summary[j] += current[j] * z
		for i in _range(26):
			summary[i] += current[i]
		_print(''.join((_str(i) + ' ' for i in summary)) + '\n')
solution()


import sys
import math
get_string = lambda : sys.stdin.readline().strip()
get_int_list = lambda : list(map(int, sys.stdin.readline().strip().split()))
get_intList_from_str = lambda : list(map(int, list(sys.stdin.readline().strip())))
get_charList_from_str = lambda : list(sys.stdin.readline().strip())
get_char_list = lambda : sys.stdin.readline().strip().split()
get_int = lambda : int(sys.stdin.readline())
pt = lambda x: sys.stdout.write(str(x))

def removeall_replace(element, lst):
	t = [y for y in lst if y != element]
	del lst[:]
	lst.extend(t)
for _ in range(get_int()):
	(n, m) = get_int_list()
	string = get_string()
	index = get_int_list()
	d = {}
	for i in 'abcdefghijklmnopqrstuvwxyz':
		d[i] = 0
	arr = [0] * n
	for i in index:
		arr[i - 1] += 1
	for j in range(n - 2, -1, -1):
		arr[j] += arr[j + 1]
	for i in range(n):
		arr[i] += 1
	for (i, v) in enumerate(string):
		d[v] += arr[i]
	lst = d.values()
	print(' '.join(map(str, lst)))


kk = int(input())
for _ in range(kk):
	(n, k) = map(int, input().split())
	sss = input()
	cnt = [0] * n
	for x in [int(x) - 1 for x in input().split()]:
		cnt[x] += 1
	ans = [0] * 26
	carry = 0
	for (i, c) in enumerate(sss[::-1]):
		carry += cnt[n - 1 - i]
		ans[ord(c) - ord('a')] += carry + 1
	print(' '.join(map(str, ans)))


ax = ord('a')
ttt = int(input())
while ttt:
	ttt -= 1
	nm = [int(i) for i in input().split()]
	a = input()
	p = [int(i) for i in input().split()]
	x = [0] * 26
	lk = []
	for i in range(len(x)):
		lk.append([0] * len(a))
	for c in range(len(lk)):
		t = chr(c + ax)
		lkc = lk[c]
		if t == a[0]:
			lkc[0] = 1
		for i in range(1, len(lkc)):
			lkc[i] = lkc[i - 1] + 1 if a[i] == t else lkc[i - 1]
	for v in p:
		for j in range(len(lk)):
			x[j] += lk[j][v - 1]
	for i in range(len(x)):
		x[i] += lk[i][-1]
	print(' '.join([str(i) for i in x]))


import sys

def ric(x, a, b):
	global P
	print(x, a, b)
	if P[a] == x:
		return a
	if P[b] == x:
		return b
	if x < P[a] or x > P[b] or a == b:
		return -1
	c = (a + b) // 2
	if x == P[c]:
		return c
	if x < P[c]:
		return ric(x, a, c)
	else:
		return ric(x, c, b)
sys.setrecursionlimit(10000)
T = int(input())
for t in range(T):
	(N, M) = map(int, input().split())
	w = input()
	P = list(map(int, input().strip().split()))
	P.sort()
	R = [0] * N
	for m in range(M):
		R[P[m] - 1] += 1
	a = 'abcdefghijklmnopqrstuvwxyz'
	D = {}
	for c in a:
		D[c] = 0
	Passaggi = [0] * N
	for m in range(N - 2, -1, -1):
		Passaggi[m] = Passaggi[m + 1] + R[m]
	for x in range(N):
		c = w[x]
		D[c] += Passaggi[x]
	for c in w:
		D[c] += 1
	for c in a:
		print(D[c], end=' ')
	print()


import sys
input = sys.stdin.readline
xd = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z']
for j in range(int(input())):
	(n, m) = map(int, input().split(' '))
	s = input().rstrip()
	p = list(map(int, input().split(' ')))
	p.append(len(s))
	tr = []
	grow = [0 for k in range(26)]
	ans = [0 for k in range(26)]
	for m in range(len(s)):
		grow[ord(s[m]) - 97] = grow[ord(s[m]) - 97] + 1
		tr.append(grow)
		grow = grow.copy()
	for omg in p:
		for j in range(26):
			ans[j] = ans[j] + tr[omg - 1][j]
	for fk in range(len(ans)):
		ans[fk] = str(ans[fk])
	print(' '.join(ans))


p = int(input())
for j in range(p):
	res = [0] * 26
	(n, m) = map(int, input().split())
	s = input()
	k = list(map(int, input().split()))
	arr = [0] * len(s)
	for i in k:
		arr[i - 1] += 1
	arr[-1] += 1
	for i in range(len(s) - 2, -1, -1):
		arr[i] += arr[i + 1]
	for i in range(len(s)):
		res[ord(s[i]) - 97] += arr[i]
	print(*res)


TC = int(input())

def update_ch(precalc, last, i, ch):
	last_idx = last[ch]
	cur = 0 if last_idx == -1 else precalc[ch][last_idx]
	for j in range(last_idx + 1, i):
		precalc[ch][j] = cur
	precalc[ch][i] = cur + 1
	last[ch] = i

def solve(s, p):
	s = [ord(ch) - ord('a') for ch in s]
	p = [v - 1 for v in p]
	precalc = [[0] * len(s) for _ in range(26)]
	last = [-1] * 26
	for i in range(len(s)):
		update_ch(precalc, last, i, s[i])
	for ch in range(26):
		if last[ch] != -1:
			for j in range(last[ch] + 1, len(s)):
				precalc[ch][j] = precalc[ch][j - 1]
	res = [0] * 26
	for ch in range(26):
		for success in p:
			res[ch] += precalc[ch][success]
		res[ch] += precalc[ch][-1]
	return res
for _ in range(TC):
	(n, m) = map(int, input().split())
	s = input()
	p = [int(v) for v in input().split()]
	print(*solve(s, p))


t = int(input())
for _ in range(t):
	(n, m) = map(int, input().split())
	alpha = [0] * 26
	s = input()
	p = list(map(int, input().split()))
	freq = [0] * n
	for i in range(m):
		freq[p[i] - 1] += 1
	freq[n - 1] = 1
	for i in range(n - 1, 0, -1):
		freq[i - 1] += freq[i]
	for i in range(n):
		alpha[ord(s[i]) - 97] += freq[i]
	print(*alpha, sep=' ')


import io
import os
from collections import Counter, defaultdict, deque
from bisect import bisect

def solve(N, M, S, P):
	P.sort()
	counts = Counter()
	for (i, c) in enumerate(S):
		index = bisect(P, i)
		counts[c] += M - index
		counts[c] += 1
	return ' '.join([str(counts[chr(ord('a') + i)]) for i in range(26)])
input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline
T = int(input())
for t in range(T):
	(N, M) = [int(x) for x in input().split()]
	S = str(input().decode().rstrip())
	P = [int(x) for x in input().split()]
	ans = solve(N, M, S, P)
	print(ans)


t = int(input())
while t > 0:
	st = 'abcdefghijklmnopqrstuvwxyz'
	(n, m) = [int(x) for x in input().split()]
	s = input()
	p = [int(x) for x in input().split()]
	p.sort(reverse=True)
	lel = []
	for i in range(n + 1):
		lel.append(0)
	for i in range(m):
		lel[p[i]] += 1
	for i in range(n - 1, 0, -1):
		lel[i] += lel[i + 1]
		lel[i + 1] += 1
	lel[1] += 1
	d = {}
	for i in st:
		d[i] = 0
	for i in range(1, n + 1):
		d[s[i - 1]] += lel[i]
	for i in st:
		print(d[i], end=' ')
	print()
	t -= 1


import sys
import math
read = lambda : list(map(int, sys.stdin.readline().strip().split()))
for _ in range(int(input())):
	(n, m) = read()
	s = input()
	p = read()
	mark = [0] * (n + 1)
	for num in p:
		mark[num - 1] += 1
	temp = mark[-1]
	for i in range(n - 1, -1, -1):
		mark[i] += temp
		temp = mark[i]
	markk = [0] * 26
	for i in range(n):
		markk[ord(s[i]) - 97] += mark[i] + 1
	for num in markk:
		print(num, end=' ')
	print()


import math

def rints():
	return list(map(int, input().split()))
t = int(input())
for _ in range(t):
	(n, m) = rints()
	s = input()
	p = rints()
	occs = [0] * 26
	p.sort()
	ai = 0
	active = [1] * n
	rem = m + 1
	for pi in p:
		for i in range(ai, pi):
			active[i] = rem
		rem -= 1
		ai = pi
	for i in range(n):
		c = ord(s[i]) - ord('a')
		occs[c] += active[i]
	print(*occs)


def combo(str, p):
	dct = {}
	for i in range(ord('a'), ord('z') + 1):
		dct[chr(i)] = 0
	cnt = [0] * len(str)
	for i in range(len(p)):
		cnt[p[i] - 1] += 1
	for i in range(len(str) - 1, 0, -1):
		cnt[i - 1] += cnt[i]
	for i in range(len(str)):
		dct[str[i]] += cnt[i] + 1
	for i in range(ord('a'), ord('z') + 1):
		print(dct[chr(i)], end=' ')
	print()
for i in range(int(input())):
	(a, b) = map(int, input().split())
	str = input()
	p = [int(j) for j in input().split()]
	combo(str, p)


l3 = []
for i in range(ord('a'), ord('z') + 1):
	l3.append(chr(i))
for _ in range(int(input())):
	(n, m) = map(int, input().split())
	s = input()
	l1 = list(map(int, input().split()))
	l1.append(n)
	l2 = [0] * (n + 1)
	for i in range(m + 1):
		l2[l1[i]] += 1
	for i in range(n - 1, 0, -1):
		l2[i] += l2[i + 1]
	d = dict()
	for i in range(n):
		if s[i] in d.keys():
			d[s[i]] += l2[i + 1]
		else:
			d[s[i]] = l2[i + 1]
	for i in l3:
		if i in d.keys():
			print(d[i], end=' ')
		else:
			print(0, end=' ')
	print()


def func(x):
	return ord(x) - ord('a')
t = int(input())
while t:
	t -= 1
	(n, m) = list(map(int, input().split()))
	a = list(map(func, list(input())))
	p = sorted(list(map(int, input().split())))
	count = [0] * 26
	j = 0
	c = m + 1
	for i in range(n):
		while j < m and p[j] == i:
			c -= 1
			j += 1
		count[a[i]] += c
	print(*count)


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	s = input()
	arr = [[0] * (n + 1) for i in range(26)]
	ans = [0] * 26
	p = list(map(int, input().split()))
	for i in range(n):
		v = ord(s[i]) - 97
		arr[v][i + 1] = 1
	for i in range(26):
		for j in range(1, n + 1):
			arr[i][j] += arr[i][j - 1]
	for i in p:
		for j in range(26):
			ans[j] += arr[j][i]
	for j in range(26):
		ans[j] += arr[j][n]
	print(*ans)


for i in range(int(input())):
	(n, m) = map(int, input().split())
	s = input()
	l = list(map(int, input().split()))
	d = {}
	for i in range(97, 123):
		d[chr(i)] = 0
	l.append(n)
	l.sort(reverse=True)
	a = [0 for i in range(n)]
	x = 0
	y = 0
	for i in range(m + 1):
		x += 1
		a[l[i] - 1] = x
	k = -1
	for i in range(n - 1, -1, -1):
		if a[i] != 0:
			k = a[i]
		else:
			a[i] += k
	for i in range(n):
		d[s[i]] += a[i]
	for i in d:
		print(d[i], end=' ')
	print()


from string import ascii_lowercase
t = int(input())
for _ in range(t):
	(n, m) = [int(x) for x in input().split()]
	s = input()
	count = {x: 0 for x in ascii_lowercase}
	errors = [int(x) for x in input().split()]
	errors = sorted(errors)
	e_idx = 0
	for (j, c) in enumerate(s):
		while e_idx < m and errors[e_idx] <= j:
			e_idx += 1
		count[c] += m - e_idx + 1
	print(*[count[c] for c in ascii_lowercase])


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	a = [0] * 26
	s = input()
	valid = list(map(int, input().split()))
	valid.sort()
	count = [0] * n
	for i in valid:
		count[i - 1] += 1
	for i in range(n - 1, 0, -1):
		count[i - 1] += count[i]
	for i in range(n):
		a[ord(s[i]) - 97] += count[i] + 1
	print(*a)


t = int(input())
for _ in range(t):
	(n, m) = map(int, input().split())
	s = list(input())
	l = list(map(int, input().split()))
	l.append(n)
	arr = [0] * 26
	l.sort()
	p = 0
	z = m + 1
	for i in range(0, m + 1, 1):
		x = l[i]
		for j in range(p, x, 1):
			y = ord(s[j])
			arr[y - 97] += z
		p = x
		z -= 1
	print(*arr)


from sys import stdin
from collections import deque
mod = 10 ** 9 + 7
import sys
from queue import PriorityQueue
from bisect import bisect_right
from bisect import bisect_left
from collections import defaultdict
from math import sqrt, factorial, gcd, log2, inf, ceil
import heapq
input = lambda : sys.stdin.readline().rstrip()
from sys import stdin, stdout
from heapq import heapify, heappush, heappop
from itertools import permutations
from math import factorial as f

def ncr(x, y):
	return f(x) // (f(y) * f(x - y))
t = int(input())
for _ in range(t):
	(m, n) = map(int, input().split())
	s = list(input())
	l = list(map(int, input().split()))
	pref = []
	for i in range(26):
		pref.append([0] * (m + 1))
	for i in range(m):
		z = ord(s[i]) - 97
		i += 1
		pref[z][i] = 1
	for i in range(26):
		for j in range(1, m + 1):
			pref[i][j] += pref[i][j - 1]
	ans = [0] * 26
	l.append(m)
	for i in l:
		for j in range(26):
			ans[j] += pref[j][i]
	print(*ans)


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	s = input()
	ans = [0] * 26
	pref = [0] * n
	p = list(map(int, input().split()))
	for i in range(len(p)):
		pref[p[i] - 1] += 1
	for i in reversed(range(len(s) - 1)):
		if i > 0:
			pref[i - 1] += pref[i]
	for i in range(n):
		ans[ord(s[i]) - ord('a')] += pref[i] + 1
	print(*ans)


import sys
import string
input = sys.stdin.readline
for tt in range(int(input())):
	(n, m) = map(int, input().split())
	s = input()
	p = list(map(int, input().split()))
	p.sort()
	ans = [0] * n
	st = 0
	for i in range(m):
		for j in range(st, p[i]):
			ans[j] += m - i
		st = p[i]
	d = {c: 0 for c in string.ascii_lowercase}
	for i in range(n):
		d[s[i]] += ans[i] + 1
	print(*d.values(), sep=' ')


import sys, bisect
input = sys.stdin.readline
t = int(input())
for testcase in range(t):
	(n, m) = map(int, input().split())
	s = list(input())
	p = list(map(int, input().split()))
	res = [0] * 26
	imos = [0] * (n + 1)
	for e in p:
		imos[0] += 1
		imos[e] -= 1
	imos[0] += 1
	c = 0
	for i in range(n):
		c += imos[i]
		res[ord(s[i]) - 97] += c
	print(*res)


from itertools import accumulate
t = int(input())
for _ in range(t):
	(n, m) = map(int, input().split())
	s = [i for i in input()]
	p = list(map(int, input().split()))
	lst = [0] * n
	for i in p:
		lst[i - 1] += 1
	pf = list(accumulate(lst[::-1]))[::-1]
	mp = {chr(97 + i): 0 for i in range(26)}
	for i in range(n):
		mp[s[i]] += pf[i]
	for i in s:
		mp[i] += 1
	print(*mp.values())


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	s = list(input())
	p = list(map(int, input().split()))
	mul = [0] * (n + 1)
	for i in p:
		mul[0] += 1
		mul[i + 1] -= 1
	ans = [0] * 26
	m = mul[0]
	for x in range(1, n + 1):
		c = s[x - 1]
		m += mul[x]
		ans[ord(c) - ord('a')] += m
	for x in s:
		ans[ord(x) - ord('a')] += 1
	print(*ans)


import math
T = int(input())
for t in range(T):
	(N, M) = map(int, input().split())
	S = input()
	P = list(map(int, input().split()))
	out = ['0'] * 26
	pref = [0] * N
	for p in P:
		pref[p - 1] += 1
	pref[N - 1] = 1
	a = 0
	for n in range(N - 1, -1, -1):
		tmp = pref[n]
		pref[n] += a
		a += tmp
	for n in range(N):
		out[ord(S[n]) - 97] = str(int(out[ord(S[n]) - 97]) + pref[n])
	print(' '.join(out))


def mi():
	return map(int, input().split())
for _ in range(int(input())):
	(n, m) = mi()
	a = list(input())
	p = list(mi())
	p.sort()
	pref = [0] * 26
	ans = [0] * 26
	start = 0
	for i in range(n):
		pref[ord(a[i]) - 97] += 1
		while start < m and i == p[start] - 1:
			for j in range(26):
				ans[j] += pref[j]
			start += 1
	for j in range(26):
		ans[j] += pref[j]
	print(*ans)


t = int(input())
for _ in range(t):
	(n, m) = map(int, input().split())
	s = [i for i in input()]
	p = list(map(int, input().split()))
	if n == 1:
		print(1)
	else:
		mp = [1] * n
		p = sorted(p)[::-1]
		mp[p[0] - 1] = 2
		for i in range(1, m):
			mp[p[i] - 1] = mp[p[i - 1] - 1] + 1
		ls = mp[-1]
		for i in range(n - 1, -1, -1):
			if mp[i] != 1:
				ls = mp[i]
			else:
				mp[i] = ls
		d = {chr(97 + i): 0 for i in range(26)}
		for i in range(n):
			d[s[i]] += mp[i]
		print(*d.values())


MAX = 10 ** 6
tree = [0] * MAX
lazy = [0] * MAX

def updateRangeUtil(si, ss, se, us, ue, diff):
	if lazy[si] != 0:
		tree[si] += (se - ss + 1) * lazy[si]
		if ss != se:
			lazy[si * 2 + 1] += lazy[si]
			lazy[si * 2 + 2] += lazy[si]
		lazy[si] = 0
	if ss > se or ss > ue or se < us:
		return
	if ss >= us and se <= ue:
		tree[si] += (se - ss + 1) * diff
		if ss != se:
			lazy[si * 2 + 1] += diff
			lazy[si * 2 + 2] += diff
		return
	mid = (ss + se) // 2
	updateRangeUtil(si * 2 + 1, ss, mid, us, ue, diff)
	updateRangeUtil(si * 2 + 2, mid + 1, se, us, ue, diff)
	tree[si] = tree[si * 2 + 1] + tree[si * 2 + 2]

def updateRange(n, us, ue, diff):
	updateRangeUtil(0, 0, n - 1, us, ue, diff)

def getSumUtil(ss, se, qs, qe, si):
	if lazy[si] != 0:
		tree[si] += (se - ss + 1) * lazy[si]
		if ss != se:
			lazy[si * 2 + 1] += lazy[si]
			lazy[si * 2 + 2] += lazy[si]
		lazy[si] = 0
	if ss > se or ss > qe or se < qs:
		return 0
	if ss >= qs and se <= qe:
		return tree[si]
	mid = (ss + se) // 2
	return getSumUtil(ss, mid, qs, qe, 2 * si + 1) + getSumUtil(mid + 1, se, qs, qe, 2 * si + 2)

def getSum(n, qs, qe):
	if qs < 0 or qe > n - 1 or qs > qe:
		print('Invalid Input')
		return -1
	return getSumUtil(0, n - 1, qs, qe, 0)

def constructSTUtil(arr, ss, se, si):
	if ss > se:
		return
	if ss == se:
		tree[si] = arr[ss]
		return
	mid = (ss + se) // 2
	constructSTUtil(arr, ss, mid, si * 2 + 1)
	constructSTUtil(arr, mid + 1, se, si * 2 + 2)
	tree[si] = tree[si * 2 + 1] + tree[si * 2 + 2]

def constructST(arr, n):
	constructSTUtil(arr, 0, n - 1, 0)

def ip(s, p):
	arr = [0] * len(s)
	n = len(arr)
	constructST(arr, n)
	for r in p:
		updateRange(n, 0, r - 1, 1)
	updateRange(n, 0, n, 1)
	ll = [0] * 26
	for i in range(len(s)):
		val = getSum(n, i, i)
		ll[ord(s[i]) - ord('a')] += val
	print(*ll)
for _ in range(int(input())):
	(n, m) = map(int, input().split())
	s = input()
	p = list(map(int, input().split()))
	ip(s, p)


alpha = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z']
dic = {l: i for (i, l) in enumerate(alpha)}
t = int(input())
for o in range(t):
	lixo = input()
	s = list(input())
	v = list(map(int, input().split()))
	aux = [0] * len(s)
	out = [0] * 26
	for i in v:
		aux[i - 1] += 1
	aux2 = 0
	for i in range(len(aux) - 1, -1, -1):
		aux2 += aux[i]
		out[dic[s[i]]] += aux2
	for i in s:
		out[dic[i]] += 1
	for i in out:
		print(i, end=' ')
	print()


from collections import defaultdict
t = int(input())
while t:
	(n, m) = map(int, input().split())
	s = input()
	arr = list(map(int, input().split()))
	count = [0] * 26
	ans = [0] * 26
	d = {}
	strr = ''
	for i in range(len(s)):
		count[ord(s[i]) - 97] += 1
		d[str(i + 1)] = list(count)
	for i in arr:
		a = d[str(i)]
		for j in range(26):
			ans[j] += a[j]
	a = d[str(len(s))]
	for i in range(len(a)):
		ans[i] += a[i]
	print(*ans)
	t -= 1


t = int(input())
for w in range(t):
	(n, m) = (int(i) for i in input().split())
	s = input()
	p = [int(i) for i in input().split()]
	l = [0] * 26
	d = {}
	for i in range(n):
		l[ord(s[i]) - ord('a')] += 1
		d[i + 1] = l[:]
	l = [0] * 26
	for i in range(m):
		for j in range(26):
			l[j] += d[p[i]][j]
	for i in range(26):
		l[i] += d[n][i]
	print(*l)


import sys
sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep='\n')

def II():
	return int(sys.stdin.readline())

def MI():
	return map(int, sys.stdin.readline().split())

def LI():
	return list(map(int, sys.stdin.readline().split()))

def LI1():
	return list(map(int1, sys.stdin.readline().split()))

def LLI(rows_number):
	return [LI() for _ in range(rows_number)]

def SI():
	return sys.stdin.readline()[:-1]

def main():
	t = II()
	for _ in range(t):
		(n, m) = MI()
		s = SI()
		pp = LI1()
		pp.sort()
		ans = [0] * 26
		a = ord('a')
		cnt = 1
		for i in range(n - 1, -1, -1):
			while pp and i == pp[-1]:
				cnt += 1
				pp.pop()
			ans[ord(s[i]) - a] += cnt
		print(*ans)
main()


from collections import defaultdict
for _ in range(int(input())):
	(N, K) = map(int, input().split())
	L = list(input())
	M = list(map(int, input().split()))
	Hash = defaultdict(lambda : 0)
	for i in range(K):
		M[i] = M[i] - 1
		Hash[M[i]] += 1
	PrefixSum = defaultdict(lambda : 0)
	X = 'abcdefghijklmnopqrstuvwxyz'
	Ans = defaultdict(lambda : 0)
	for i in X:
		Ans[i] = 0
	for i in X:
		PrefixSum[i] = 0
	for i in range(N):
		PrefixSum[L[i]] += 1
		Ans[L[i]] = Ans[L[i]] + 1
		if Hash[i] > 0:
			for j in X:
				Ans[j] = Ans[j] + PrefixSum[j] * Hash[i]
	for i in Ans.values():
		print(i, end=' ')
	print()


t = int(input())
for i in range(t):
	(n, m) = [int(x) for x in input().split(' ')]
	s = input()
	p = [int(x) for x in input().split(' ')] + [n]
	letters = {key: [0, 0] for key in list('abcdefghijklmnopqrstuvwxyz')}
	p.sort()
	for x in range(m + 1):
		for j in letters:
			if letters[j][0] > 0:
				letters[j][1] += letters[j][0]
		if x == 0:
			a = 0
		else:
			a = p[x - 1]
		for j in range(a, p[x]):
			letters[s[j]][0] += 1
			letters[s[j]][1] += 1
	for x in letters.values():
		print(x[1], end=' ')
	print()


t = int(input())
import bisect
for _ in range(t):
	(n, m) = map(int, input().split())
	s = input()
	p = sorted(list(map(int, input().split())))
	counter = [0] * 26
	for i in range(1, n + 1):
		counter[ord(s[i - 1]) - ord('a')] += m - bisect.bisect_left(p, i) + 1
	print(*counter)


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	ss = list(input())
	pos = sorted(map(int, input().split())) + [n]
	fre = [0] * 26
	tot = [0] * 26
	ti = [0] * 26
	las = 0
	for i in range(m + 1):
		k = pos[i]
		for j in range(las, k):
			ti[ord(ss[j]) - ord('a')] += 1
		for j in range(26):
			tot[j] += ti[j]
		for j in range(26):
			fre[j] += tot[j]
		ti = [0] * 26
		las = pos[i]
	print(*fre)


from sys import stdin, stdout
for _ in range(int(stdin.readline())):
	(n, m) = map(int, stdin.readline().split())
	s = stdin.readline()[:-1]
	p = list(map(int, stdin.readline().split()))
	p.append(n)
	lst = [0] * 26
	p.sort()
	for j in range(p[0]):
		lst[ord(s[j]) - 97] += m + 1
	for i in range(1, m + 1):
		for j in range(p[i - 1], p[i]):
			lst[ord(s[j]) - 97] += m - i + 1
	for val in lst:
		stdout.write(str(val) + ' ')
	stdout.write('\n')


tests = int(input())
for te in range(tests):
	(n, m) = list(map(int, input().split()))
	stringa = input()
	arr = list(map(int, input().split()))
	lista = [0 for i in range(n)]
	for i in range(m):
		lista[0] += 1
		lista[arr[i]] -= 1
	lista[0] += 1
	for i in range(1, n):
		lista[i] += lista[i - 1]
	cnt = [0 for i in range(26)]
	for i in range(n):
		char = stringa[i]
		index = ord(char) - ord('a')
		cnt[index] += lista[i]
	print(*cnt)


from collections import deque as dd
for _ in range(int(input())):
	(n, m) = map(int, input().split())
	s = input()
	p = list(map(int, input().split()))
	p.sort()
	d = dd()
	pre = 0
	for i in range(m):
		if p[i] != pre:
			d.append((pre, p[i], m - i + 1))
			pre = p[i]
	d.append((pre, n, 1))
	ans = [0] * 26
	for i in range(len(d)):
		(x, y, v) = d.pop()
		for j in s[x:y]:
			ans[ord(j) - 97] += v
	print(' '.join((str(z) for z in ans)))


import sys
reader = (s.rstrip() for s in sys.stdin)
input = reader.__next__

def gift():
	for _ in range(cou):
		(n, p) = [int(x) for x in input().split()]
		combo = input()
		plst = [int(x) for x in input().split()]
		string = 'abcdefghijklmnopqrstuvwxyz'
		dic = {}
		for i in range(26):
			dic[string[i]] = i
		dp = [[0] * 26]
		for i in range(n):
			s = combo[i]
			pos = dic[s]
			if i == 0:
				dp[0][pos] += 1
			else:
				temp = dp[-1][:]
				temp[pos] += 1
				dp.append(temp)
		res = [0] * 26
		for i in range(p):
			arr = dp[plst[i] - 1]
			res = [x + y for (x, y) in zip(arr, res)]
		for s in combo:
			res[dic[s]] += 1
		yield ' '.join(map(str, res))
cou = int(input())
ans = gift()
print(*ans, sep='\n')


q = int(input())
for _ in range(q):
	(n, m) = map(int, input().split())
	s = input()
	p = list(map(int, input().split()))
	p.sort()
	p.append(n)
	m += 1
	code = ord('a')
	letters = [0 for i in range(26)]
	r = 0
	for i in range(m):
		if p[i] > r:
			while r < p[i]:
				letters[ord(s[r]) - code] += m - i
				r += 1
	print(*letters)


t = int(input())
for i in range(t):
	line = input()
	[n, m] = [int(x) for x in line.split(' ')]
	s = input()
	line = input()
	p = [int(x) for x in line.split(' ')]
	pressed = [0] * 26
	sums = [0] * n
	for pi in p:
		sums[pi - 1] += 1
	for i in range(n - 2, -1, -1):
		sums[i] = sums[i] + sums[i + 1]
	for (index, si) in enumerate(s):
		pressed[ord(si) - ord('a')] += sums[index]
	for (index, si) in enumerate(s):
		pressed[ord(si) - ord('a')] += 1
	for x in pressed:
		print(str(x) + ' ', end='')
	print()


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	s = input()
	a = list(map(int, input().split()))
	dp = [[0 for i in range(26)] for i in range(n + 1)]
	for i in range(1, n + 1):
		for j in range(26):
			if s[i - 1] == chr(ord('a') + j):
				dp[i][j] = dp[i - 1][j] + 1
			else:
				dp[i][j] = dp[i - 1][j]
	b = [0] * 26
	a.append(n)
	for i in a:
		for j in range(26):
			b[j] += dp[i][j]
	print(*b)


t = int(input())
for i in range(t):
	(n, m) = list(map(int, input().strip().split()))
	s = input()
	p = list(map(int, input().strip().split()))
	temp = []
	for j in s:
		temp.append(0)
	for j in range(m):
		temp[0] += 1
		if p[j] < n:
			temp[p[j]] -= 1
	ans = [0] * n
	for j in range(n):
		if j == 0:
			ans[j] = temp[j] + 1
		else:
			ans[j] = ans[j - 1] + temp[j]
	for k in 'abcdefghijklmnopqrstuvwxyz':
		if k in s:
			count = 0
			pos = s.find(k)
			while pos >= 0:
				count += ans[pos]
				pos = s.find(k, pos + 1)
			print(count, end=' ')
		else:
			print(0, end=' ')
	print()


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	s = input()
	l = list(map(int, input().split()))
	l.sort()
	a = [0] * n
	for i in l:
		a[i - 1] += 1
	a[-1] = 1
	for i in range(n - 2, -1, -1):
		a[i] = a[i] + a[i + 1]
	ans = [0] * 26
	for i in range(n):
		ans[ord(s[i]) - ord('a')] += a[i]
	print(*ans)


t = int(input())
import string
while t != 0:
	d = {'a': 0, 'b': 0, 'c': 0, 'd': 0, 'e': 0, 'f': 0, 'g': 0, 'h': 0, 'i': 0, 'j': 0, 'k': 0, 'l': 0, 'm': 0, 'n': 0, 'o': 0, 'p': 0, 'q': 0, 'r': 0, 's': 0, 't': 0, 'u': 0, 'v': 0, 'w': 0, 'x': 0, 'y': 0, 'z': 0}
	(n, m) = map(int, input().split())
	s = list(input())
	p = list(map(int, input().split()))
	a = [0] * n
	b = [0] * n
	for el in p:
		a[el - 1] = a[el - 1] + 1
	temp = sum(a)
	for i in range(n):
		if i != 0:
			b[i] = temp - a[i - 1]
			temp = b[i]
		else:
			b[i] = temp
	k = 0
	for ch in s:
		d[ch] = d[ch] + b[k] + 1
		k = k + 1
	print(*list(d.values()))
	t = t - 1


from collections import *
a = ord('a')
for i in range(int(input())):
	(n, m) = map(int, input().split())
	(s, p) = (input(), list(map(int, input().split())))
	(mem, ans) = (defaultdict(lambda : [0]), defaultdict(int))
	for k in s:
		for j in range(26):
			tem = mem[chr(a + j)][-1]
			if k == chr(a + j):
				tem += 1
			mem[chr(a + j)].append(tem)
	for k in range(m + 1):
		for j in range(26):
			if k < m:
				ans[chr(a + j)] += mem[chr(a + j)][p[k]]
			else:
				ans[chr(a + j)] += mem[chr(a + j)][-1]
				print(ans[chr(a + j)], end=' ')
	print(end='\n')


from bisect import bisect_left
for _ in range(int(input())):
	(n, m) = map(int, input().split())
	s = input()
	arr = sorted(list(map(int, input().split())))
	ans = [0 for i in range(26)]
	for i in s:
		ans[ord(i) - ord('a')] += 1
	t = n
	val = []
	for i in range(1, max(arr) + 1):
		ind = bisect_left(arr, i)
		val.append(len(arr) - ind)
	for i in range(n - len(val)):
		val.append(0)
	for i in range(len(s)):
		ans[ord(s[i]) - ord('a')] += val[i]
	for i in ans:
		print(i, end=' ')
	print()


from itertools import accumulate
for tin in range(int(input())):
	(n, m) = map(int, input().split())
	s = str(input())
	a = list(map(int, input().split()))
	h = [0] * n
	for _ in range(m):
		h[a[_] - 1] += 1
	h = h[::-1]
	h = list(accumulate(h))
	h = h[::-1]
	for _ in range(n):
		h[_] += 1
	v = [0] * 26
	for _ in range(n):
		v[ord(s[_]) - 97] += h[_]
	for _ in range(25):
		print(v[_], end=' ')
	print(v[-1])


for _ in range(int(input())):
	(n, p) = map(int, input().split())
	s = input()
	posi = sorted(map(int, input().split())) + [n]
	final = [0] * 26
	(last, idx) = (0, 0)
	for i in posi:
		for j in range(last, i):
			final[ord(s[j]) - 97] += p + 1
		last = i
		p -= 1
	print(*final)


import sys
input = sys.stdin.readline
t = int(input())

def bs(l, x, start, end):
	if start <= end:
		mid = (start + end) // 2
		if l[mid] < x:
			return bs(l, x, mid + 1, end)
		else:
			z = bs(l, x, start, mid - 1)
			if z == -1:
				return mid
			else:
				return z
	else:
		return -1
for i in range(t):
	arr = [0] * 26
	(n, m) = map(int, input().split(' '))
	s = input()
	l = list(map(int, input().split(' ')))
	l.sort()
	for j in range(n):
		x = bs(l, j + 1, 0, m - 1)
		if x != -1:
			arr[ord(s[j]) - 97] += m - x
	for j in range(n):
		arr[ord(s[j]) - 97] += 1
	s1 = ''
	for j in arr:
		s1 = s1 + str(j) + ' '
	s1 = s1[:-1]
	print(s1)


from math import factorial
from collections import Counter
from heapq import heapify, heappop, heappush
import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')

def RL():
	return map(int, sys.stdin.readline().rstrip().split())

def comb(n, m):
	return factorial(n) / (factorial(m) * factorial(n - m)) if n >= m else 0

def perm(n, m):
	return factorial(n) // factorial(n - m) if n >= m else 0

def mdis(x1, y1, x2, y2):
	return abs(x1 - x2) + abs(y1 - y2)
mod = 1000000007
INF = float('inf')
A = ord('a')
import bisect

def main():
	N = int(input())
	for _ in range(N):
		(n, m) = RL()
		s = input()
		arr = list(RL())
		arr.append(n)
		sm = [[0] * 26 for _ in range(n + 1)]
		for i in range(1, n + 1):
			for j in range(26):
				sm[i][j] += sm[i - 1][j]
			sm[i][ord(s[i - 1]) - A] += 1
		arr.sort()
		res = [0] * 26
		for i in arr:
			for j in range(26):
				res[j] += sm[i][j]
		print(*res)
main()


from collections import Counter
from itertools import accumulate
t = int(input())
for _ in range(t):
	(n, m) = map(int, input().split())
	s = input()
	nums = list(map(int, input().split()))
	prefix = [0] * (n + 1)
	for val in nums:
		prefix[0] += 1
		prefix[val] -= 1
	prefix = list(accumulate(prefix))
	ans = [0] * 26
	for idx in range(n):
		ans[ord(s[idx]) - 97] += prefix[idx] + 1
	print(*ans)


def combo(string, arr):
	arr = sorted(arr)
	j = 0
	lst = [0 for i in range(26)]
	for i in range(len(string)):
		while j < len(arr) and arr[j] < i + 1:
			j += 1
		lst[ord(string[i]) - 97] += len(arr) + 1 - j
	print(*lst)
	return ''
t = int(input())
for i in range(t):
	a = input()
	string = input()
	lst = list(map(int, input().strip().split()))
	print(combo(string, lst))


import string
import sys
input = lambda : sys.stdin.readline().rstrip()
for _ in range(int(input())):
	(n, m) = map(int, input().split())
	s = input()
	p = [int(x) - 1 for x in input().split()]
	arr = [[0 for _ in range(26)] for _ in range(n)]
	app = [0 for _ in range(26)]
	for i in range(n):
		app[ord(s[i]) - ord('a')] += 1
		for j in range(26):
			arr[i][j] = app[j]
	result = [0 for _ in range(26)]
	for i in p:
		for j in range(26):
			result[j] += arr[i][j]
	for j in range(26):
		result[j] += arr[n - 1][j]
	print(' '.join([str(s) for s in result]))


import string
t = int(input())
for tt in range(t):
	(n, m) = map(int, input().split())
	s = input()
	p = list(map(int, input().split()))
	se = set(p)
	dic = {}
	for i in p:
		if i - 1 in dic:
			dic[i - 1] += 1
		else:
			dic[i - 1] = 1
	alphs = dict.fromkeys(string.ascii_lowercase, 0)
	balphs = dict.fromkeys(string.ascii_lowercase, 0)
	for i in range(len(s)):
		balphs[s[i]] += 1
		if i in dic:
			for k in alphs:
				if balphs[k] != 0:
					alphs[k] += balphs[k] * dic[i]
	for i in range(len(s)):
		alphs[s[i]] += 1
	for i in alphs:
		print(alphs[i], end=' ')
	print()


t = int(input())
for i in range(t):
	dic = dict()
	for j in range(ord('a'), ord('z') + 1):
		dic[j] = 0
	(n, m) = map(int, input().split())
	s = input()
	dp = [[0 for m in range(n)] for p in range(ord('a'), ord('z') + 1)]
	dp[ord(s[0]) - ord('a')][0] = 1
	for j in range(1, n):
		dp[ord(s[j]) - ord('a')][j] = dp[ord(s[j]) - ord('a')][j - 1] + 1
		for k in range(ord('a'), ord('z') + 1):
			if k != ord(s[j]):
				dp[k - ord('a')][j] = dp[k - ord('a')][j - 1]
	for k in s:
		dic[ord(k)] += 1
	p = list(map(int, input().split(' ')))
	for k in p:
		for m in range(ord('a'), ord('z') + 1):
			dic[m] += dp[m - ord('a')][k - 1]
	for i in range(ord('a'), ord('z') + 1):
		print(dic[i], end=' ')


from collections import Counter
from sys import stdin
N = int(stdin.readline().rstrip())
for i in range(N):
	(n, m) = [int(x) for x in stdin.readline().rstrip().split()]
	s = stdin.readline().rstrip()
	p = [int(x) for x in stdin.readline().rstrip().split()]
	cumsum = [0] * (n + 1)
	cumsum[n] += 1
	for j in p:
		cumsum[j] += 1
	for k in range(n - 1, 0, -1):
		cumsum[k] += cumsum[k + 1]
	ans = [0] * 26
	for (ind, l) in enumerate(s):
		ans[ord(l) - ord('a')] += cumsum[ind + 1]
	for m in ans:
		print(m, end=' ')
	print('')


import collections

class Solution:

	def solve(self, n, m, string, p):
		counts = [0 for _ in range(26)]
		for num in p:
			for i in range(num):
				counts[ord(string[i]) - ord('a')] += 1
		for ch in string:
			counts[ord(ch) - ord('a')] += 1
		return ' '.join(map(str, counts))

	def solveWithPrefixSums(self, n, m, string, p):
		counts = [0 for _ in range(26)]
		prefixSums = [0 for _ in range(n)]
		prefixSums[n - 1] += 1
		for num in p:
			prefixSums[num - 1] += 1
		for i in range(n - 1, 0, -1):
			prefixSums[i - 1] += prefixSums[i]
		for i in range(n):
			counts[ord(string[i]) - ord('a')] += prefixSums[i]
		return ' '.join(map(str, counts))
sol = Solution()
t = int(input().strip())
for i in range(t):
	[n, m] = list(map(int, input().strip().split()))
	string = input().strip()
	p = list(map(int, input().strip().split()))
	print(sol.solveWithPrefixSums(n, m, string, p))


for _ in range(int(input())):
	d = {}
	for i in 'qwertyuioplkjhgfdsazxcvbnm':
		d[i] = 0
	(n, m) = map(int, input().split())
	s = input()
	a = [0] * (n + 1)
	a[0] = m + 1
	for i in list(map(int, input().split())):
		a[i] += 1
	for i in range(len(s)):
		d[s[i]] += a[0]
		a[0] -= a[i + 1]
	for i in 'abcdefghijklmnopqrstuvwxyz':
		print(d[i], end=' ')
	print()


from sys import stdin
t = int(stdin.readline())
z = [0] * t
for _ in range(t):
	(n, m) = map(int, stdin.readline().split())
	s = stdin.readline()[:n]
	p = list(map(int, stdin.readline().split()))
	d = {'a': 0, 'b': 0, 'c': 0, 'd': 0, 'e': 0, 'f': 0, 'g': 0, 'h': 0, 'i': 0, 'j': 0, 'k': 0, 'l': 0, 'm': 0, 'n': 0, 'o': 0, 'p': 0, 'q': 0, 'r': 0, 's': 0, 't': 0, 'u': 0, 'v': 0, 'w': 0, 'x': 0, 'y': 0, 'z': 0}
	y = [0] * n
	for i in range(m):
		y[p[i] - 1] += 1
	for i in range(n - 1, 0, -1):
		y[i - 1] += y[i]
	for i in range(n):
		d[s[i]] += y[i] + 1
	z[_] = ' '.join(map(str, d.values()))
print(*z, sep='\n')


dictt = {'a': 1, 'b': 2, 'c': 3, 'd': 4, 'e': 5, 'f': 6, 'g': 7, 'h': 8, 'i': 9, 'j': 10, 'k': 11, 'l': 12, 'm': 13, 'n': 14, 'o': 15, 'p': 16, 'q': 17, 'r': 18, 's': 19, 't': 20, 'u': 21, 'v': 22, 'w': 23, 'x': 24, 'y': 25, 'z': 26}
for _ in range(int(input())):
	(n, m) = map(int, input().split())
	s = str(input())
	pi = list(map(int, input().split()))
	pi.append(n)
	ans = [0] * 26
	li = [0] * n
	for i in pi:
		li[i - 1] += 1
	for i in range(len(li) - 2, -1, -1):
		li[i] = li[i] + li[i + 1]
	for i in range(len(li)):
		ans[dictt[s[i]] - 1] += li[i]
	print(*ans)


from collections import OrderedDict
t = int(input())
for _ in range(t):
	letters = OrderedDict(((l, 0) for l in 'abcdefghijklmnopqrstuvwxyz'))
	(n_s, n_err) = map(int, input().split())
	s = list(input())
	errors = sorted(list(map(int, input().split())))
	for (err_i, err) in enumerate(errors):
		if err_i > 0:
			for l in s[errors[err_i - 1]:err]:
				letters[l] += n_err - err_i
		else:
			for l in s[:err]:
				letters[l] += n_err
	for l in s:
		letters[l] += 1
	print(' '.join((str(v) for (_, v) in letters.items())))


t = int(input())

def solve(n, m, p, s):
	p += [n]
	a = [[0 for j in range(-1, n + 1)] for i in range(27)]
	a[ord(s[0]) - 97][0] = 1
	for i in range(1, n):
		for j in range(27):
			a[j][i] = a[j][i - 1]
		a[ord(s[i]) - 97][i] += 1
	for i in range(26):
		res = 0
		for j in range(m + 1):
			res += a[i][p[j] - 1]
		print(res, end=' ')
	print('\n')
while t > 0:
	t -= 1
	(n, m) = map(int, input().split())
	s = str(input())
	y = input()
	p = [int(i) for i in y.split()]
	solve(n, m, p, s)


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	s = list(map(lambda i: ord(i) - 97, input().rstrip()))
	p = sorted(list(map(int, input().split())), reverse=True) + [0]
	r = [0] * 26
	for i in s:
		r[i] += 1
	for (i, x) in enumerate(p):
		for j in range(x, n):
			r[s[j]] += i
		n = x
	print(*r)


import sys
input = sys.stdin.readline

def inp():
	return int(input())

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

def insr():
	s = input()
	return list(s[:len(s) - 1])

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

def pr_list(a):
	print(*a, sep=' ')
	return

def main():
	t = inp()
	for ti in range(t):
		[n, m] = inlt()
		in_str = insr()
		p = inlt()
		p.sort()
		out = [0 for i in range(26)]
		j = 0
		itr = 0
		while j < len(p):
			end = p[j]
			for i in range(itr, end):
				out[ord(in_str[i]) - ord('a')] = out[ord(in_str[i]) - ord('a')] + len(p) - j
			itr = end
			j = j + 1
		for i in in_str:
			out[ord(i) - ord('a')] = out[ord(i) - ord('a')] + 1
		pr_list(out)
	return
main()


from collections import Counter
for _ in range(int(input())):
	(n, m) = map(int, input().split())
	s = input()
	p = list(map(int, input().split()))
	p.append(len(s))
	count = Counter(p)
	freq = {x: 0 for x in range(ord('a'), ord('z') + 1)}
	multiplier = len(p)
	for i in range(len(s)):
		if i in count:
			multiplier -= count[i]
		freq[ord(s[i])] += multiplier
	for x in range(ord('a'), ord('z') + 1):
		print(freq[x], end=' ')
	print()


import sys
input = sys.stdin.readline
t = int(input())
for _ in range(t):
	(n, m) = map(int, input().split())
	raw = input()
	for i in range(n):
		if i == 0:
			dp = [[0 for _ in range(26)]]
			dp[0][ord(raw[i]) - 97] = 1
			continue
		tmp = dp[-1][:]
		tmp[ord(raw[i]) - 97] += 1
		dp.append(tmp)
	p = list(map(int, input().split()))
	ans = [0 for _ in range(26)]
	for x in p:
		x -= 1
		for d in range(26):
			ans[d] += dp[x][d]
	for d in range(26):
		ans[d] += dp[-1][d]
	print(' '.join(list(map(str, ans))))


t = int(input())
for _ in range(t):
	(n, m) = map(int, input().split())
	s = input()
	p = list(map(int, input().split()))
	dp = [0] * (n + 1)
	dp[-1] = 1
	for i in p:
		dp[i - 1] += 1
	for j in range(n - 1, -1, -1):
		dp[j] += dp[j + 1]
	ans = [0] * 26
	for i in range(n):
		ans[ord(s[i]) - 97] += dp[i]
	print(*ans)


from pprint import pprint
from copy import deepcopy
q = int(input())
for _ in range(q):
	(n, m) = map(int, input().split())
	s = input()
	datp = list(map(int, input().split()))
	kmap = [0] * 26
	totalkey = []
	for i in range(n):
		c = ord(s[i]) - ord('a')
		kmap[c] += 1
		totalkey.append(deepcopy(kmap))
	res = [0] * 26
	for i in range(m):
		for k in range(26):
			res[k] += totalkey[datp[i] - 1][k]
	for k in range(26):
		res[k] += totalkey[-1][k]
	print(' '.join(list(map(str, res))))


def solve():
	t = inp()
	for _ in range(t):
		(n, k) = mul()
		temp = k + 1
		s = strl()
		l = seq()
		arr = [[0 for z in range(n)] for y in range(26)]
		for j in range(n):
			val = ord(s[j]) - 97
			arr[val][j] = 1
		for j in range(26):
			for k in range(1, n):
				arr[j][k] += arr[j][k - 1]
		l.append(n)
		result = [0 for j in range(26)]
		for x in range(temp):
			val = l[x] - 1
			for index in range(26):
				result[index] += arr[index][val]
		print(*result)
import sys
import math
import bisect
from sys import stdin, stdout
from math import gcd, floor, sqrt, log
from collections import defaultdict as dd
from bisect import bisect_left as bl, bisect_right as br
inp = lambda : int(input())
strng = lambda : input().strip()
jn = lambda x, l: x.join(map(str, l))
strl = lambda : list(input().strip())
mul = lambda : map(int, input().strip().split())
mulf = lambda : map(float, input().strip().split())
seq = lambda : list(map(int, input().strip().split()))
ceil = lambda x: int(x) if x == int(x) else int(x) + 1
ceildiv = lambda x, d: x // d if x % d == 0 else x // d + 1
flush = lambda : stdout.flush()
stdstr = lambda : stdin.readline()
stdint = lambda : int(stdin.readline())
stdpr = lambda x: stdout.write(str(x))
solve()


exec('\nfor _ in range(int(input())):\n    n,m=[int(x) for x in input().split()];arr=list(input());arr=[ord(x)-97 for x in arr];p=[int(x) for x in input().split()];b=[0]*n;ans=[0]*26\n    for i in range(m):\n        b[p[i]-1]+=1\n    for i in range(max(p)-2,-1,-1):\n        b[i]=b[i]+b[i+1]\n    b=list(map(lambda x : x + 1, b))\n    for j in range(n):\n        ans[arr[j]]+=b[j]\n    print(*ans)\n')


T = int(input())
n = [0] * T
m = [0] * T
s = [0] * T
miss = [0] * T
lets = {'a': 0, 'b': 0, 'c': 0, 'd': 0, 'e': 0, 'f': 0, 'g': 0, 'h': 0, 'i': 0, 'j': 0, 'k': 0, 'l': 0, 'm': 0, 'n': 0, 'o': 0, 'p': 0, 'q': 0, 'r': 0, 's': 0, 't': 0, 'u': 0, 'v': 0, 'w': 0, 'x': 0, 'y': 0, 'z': 0}
for t in range(T):
	(n[t], m[t]) = [int(i) for i in input().split(' ')]
	s[t] = input()
	miss[t] = [int(i) for i in input().split(' ')]
for t in range(T):
	lets = {'a': 0, 'b': 0, 'c': 0, 'd': 0, 'e': 0, 'f': 0, 'g': 0, 'h': 0, 'i': 0, 'j': 0, 'k': 0, 'l': 0, 'm': 0, 'n': 0, 'o': 0, 'p': 0, 'q': 0, 'r': 0, 's': 0, 't': 0, 'u': 0, 'v': 0, 'w': 0, 'x': 0, 'y': 0, 'z': 0}
	miss[t].sort()
	strt = 0
	for i in s[t]:
		lets[i] += 1
	for i in range(m[t]):
		for j in s[t][strt:miss[t][i]]:
			lets[j] += m[t] - i
		strt = miss[t][i]
	for i in lets:
		print(lets[i], end=' ')
	print()


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	s = input()
	lis = list(map(int, input().split()))
	lis.append(n)
	x = []
	for i in range(n):
		x.append([0] * 26)
	x[0][ord(s[0]) - 97] += 1
	j = 1
	for i in range(1, n):
		x[j] = x[j - 1].copy()
		x[j][ord(s[i]) - 97] += 1
		j += 1
	res = [0] * 26
	for i in lis:
		for j in range(26):
			res[j] += x[i - 1][j]
	print(*res)


from math import *

def binarySearch(arr, x, i):
	l = i
	r = len(arr) - 1
	while l <= r:
		mid = (l + r) // 2
		if arr[mid] == x:
			return mid
		elif arr[mid] < x:
			l = mid + 1
		else:
			r = mid - 1
	return -1

def js(arr, x):
	l = 0
	r = len(arr) - 1
	ans = -1
	while l <= r:
		m = (l + r) // 2
		if arr[m] <= x:
			ans = m
			l = m + 1
		else:
			r = m - 1
	return ans

def jg(arr, x):
	l = 0
	r = len(arr) - 1
	ans = -1
	while l <= r:
		m = (l + r) // 2
		if arr[m] >= x:
			ans = m
			r = m - 1
		else:
			l = m + 1
	return ans

def ceil(a, b):
	if a % b == 0:
		return int(a / b)
	else:
		return a // b + 1
for __ in range(int(input())):
	(n, m) = map(int, input().split())
	s = input()
	ar = list(map(int, input().split()))
	d = []
	for i in range(n):
		d.append([0] * 26)
	for i in range(n):
		if i == 0:
			d[i][ord(s[i]) - 97] = 1
		else:
			for j in range(26):
				d[i][j] = d[i - 1][j]
			d[i][ord(s[i]) - 97] += 1
	ans = [0] * 26
	for i in range(m):
		for j in range(26):
			ans[j] += d[ar[i] - 1][j]
	for i in range(n):
		ans[ord(s[i]) - 97] += 1
	print(*ans)


t = int(input().strip())
result = []
for i in range(t):
	letters = [0] * 26
	x = list(map(int, input().strip().split()))
	(n, m) = (x[0], x[1])
	s = input().strip()
	positions = list(map(int, input().strip().split()))
	for k in s:
		letters[ord(k) - ord('a')] += 1
	helper = [0] * len(s)
	letters2 = [0] * len(s)
	for pos in positions:
		helper[pos - 1] += 1
	count = 0
	for index in range(len(s) - 1, -1, -1):
		count += helper[index]
		letters[ord(s[index]) - ord('a')] += count
	result.append(letters)
for i in result:
	res = ''
	for j in i:
		res += str(j) + ' '
	print(res[:-1])


from collections import Counter
letters = 'abcdefghijklmnopqrstuvwxyz'

def combo(m, s, p):
	cnt = Counter(s)
	ind = 0
	p.sort()
	l = len(p)
	for i in range(l):
		if p[i] == ind:
			continue
		presses = s[ind:p[i]]
		for press in presses:
			cnt[press] += l - i
		ind = p[i]
	sol = [str(cnt[l]) for l in letters]
	return ' '.join(sol)
t = int(input())
for case in range(t):
	nm = [int(x) for x in input().split(' ')]
	n = nm[0]
	m = nm[1]
	s = input()
	p = [int(x) for x in input().split(' ')]
	sol = combo(m, s, p)
	print(sol)


def solve():
	res = [0 for i in range(26)]
	(n, m) = map(int, input().split())
	s = input()
	p = list(map(int, input().split()))
	arr = [0 for i in range(n)]
	for pi in p:
		arr[pi - 1] += 1
	if arr[n - 1] == 0:
		arr[n - 1] += 1
	res[ord(s[n - 1]) - ord('a')] += arr[n - 1]
	for i in range(n - 2, -1, -1):
		arr[i] += arr[i + 1]
		res[ord(s[i]) - ord('a')] += arr[i]
	for i in range(26):
		if i == 25:
			print(res[i])
		else:
			print(res[i], end=' ')
	return
t = int(input())
for _ in range(t):
	solve()


q = int(input())
for i in range(q):
	(n, m) = [int(i) for i in input().split()]
	s = input()
	p = sorted([int(i) for i in input().split()])
	ans = [0 for i in range(26)]
	it = 0
	for i in range(len(s)):
		ans[ord(s[i]) - ord('a')] += len(p) - it + 1
		if it == len(p):
			continue
		if p[it] - 1 == i:
			it += 1
			if it == len(p):
				continue
			while p[it] == p[it - 1]:
				it += 1
				if it == len(p):
					break
	for i in range(len(ans)):
		print(ans[i], end=' ')
	print()


import atexit
import io
import sys
import math
from collections import defaultdict, Counter
t = int(input())
for i in range(t):
	(n, m) = map(int, input().split())
	s = input()
	l1 = [0] * n
	l = [0] * 26
	p = list(map(int, input().split()))
	p.append(n)
	for j in p:
		l1[j - 1] += 1
	for j in range(n - 2, -1, -1):
		l1[j] += l1[j + 1]
	for j in range(n):
		l[ord(s[j]) - 97] += l1[j]
	print(*l)


t = int(input())
for i in range(t):
	(n, m) = map(int, input().split())
	s = input()
	p = list(map(int, input().split()))
	d = [0] * 26
	a = [0] * (n + 1)
	res = [0] * 26
	for j in range(m):
		a[0] += 1
		a[p[j]] -= 1
	a[0] += 1
	a[n] -= 1
	p = 0
	for j in range(n):
		p += a[j]
		res[ord(s[j]) - 97] += p
	print(*res)


t = int(input())
alph = 'abcdefghijklmnopqrstuvwxyz'
a_symbol_code = 97
for i in range(t):
	(n, m) = map(int, input().split())
	combo = input()
	ans = {symbol: 0 for symbol in alph}
	tries = sorted([int(correct_num) for correct_num in input().split()])
	tries.append(len(combo))
	multiplier = len(tries)
	cur_letter = iter(combo)
	previous_try_stop = 0
	for current in tries:
		for letter_index in range(current - previous_try_stop):
			ans[next(cur_letter)] += multiplier
		previous_try_stop = current
		multiplier -= 1
	print(*ans.values())


for t in range(int(input())):
	(n, m) = map(int, input().split())
	s = input()
	p = list(map(int, input().split()))
	p.sort()
	a = []
	c = m + 1
	a.append(c)
	i = 1
	k = 0
	while i < n - 1:
		if k < m and i == p[k]:
			c -= 1
			k += 1
		else:
			a.append(c)
			i += 1
	b = [0 for j in range(26)]
	for i in range(n - 1):
		b[ord(s[i]) - 97] += a[i]
	b[ord(s[n - 1]) - 97] += 1
	u = list(map(str, b))
	print(' '.join(u))


t = int(input())
for i in range(t):
	(n, m) = map(int, input().split())
	q = m
	s = input()
	a = list(map(int, input().split()))
	res = [0 for x in range(26)]
	a.sort()
	j = 0
	for i in range(n):
		res[ord(s[i]) - 97] += m + 1
		if j < q:
			while a[j] <= i + 1 and j < q - 1:
				j += 1
				m -= 1
			if j == q - 1:
				if a[j] <= i + 1:
					m -= 1
					j = q
	print(*res)


import string

def combo(m, s):
	s1 = string.ascii_lowercase
	l = [0 for i in range(len(s))]
	for i in range(len(m)):
		l[m[i] - 1] += 1
	i = len(s) - 1
	while i > 0:
		l[i - 1] += l[i]
		i -= 1
	d = {}
	for i in range(len(s)):
		if not d.get(s[i]):
			d[s[i]] = l[i] + 1
		else:
			d[s[i]] += l[i] + 1
	l1 = []
	for e in s1:
		if d.get(e):
			l1.append(d[e])
		else:
			l1.append(0)
	return ' '.join(map(str, l1))
for i in range(int(input())):
	(a, b) = map(int, input().split())
	s = input()
	m = list(map(int, input().split()))
	print(combo(m, s))


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	a = [ord(i) - 97 for i in input()]
	p = [int(i) - 1 for i in input().split()]
	alp = [0] * 26
	st = [0] * 26
	d = []
	for i in range(n):
		st[a[i]] += 1
		d.append(st[:])
	for i in p:
		for j in range(len(d[i])):
			alp[j] += d[i][j]
	for i in range(n):
		alp[a[i]] += 1
	print(*alp)


import bisect
for _ in range(int(input())):
	(n, m) = map(int, input().split())
	s = input()
	l = [0] * 26
	p = sorted(list(map(int, input().split())))
	for i in range(1, n + 1):
		j = bisect.bisect_left(p, i)
		x = m - j + 1
		l[ord(s[i - 1]) - 97] += x
	print(*l)


import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
t = int(readline())
for _ in range(t):
	(n, m) = map(int, readline().split())
	s = readline().rstrip().decode('utf-8')
	p = list(map(int, readline().split()))
	lst = [0] * n
	for i in p:
		lst[i - 1] += 1
	lst[-1] += 1
	for i in range(n - 1, 0, -1):
		lst[i - 1] += lst[i]
	ans = [0] * 26
	kijun = ord('a')
	for i in range(n):
		ans[ord(s[i]) - kijun] += lst[i]
	print(*ans)


from collections import defaultdict as dd
t = int(input())
while t:
	ch = [0] * 26
	(n, m) = map(int, input().split())
	s = input()
	l = list(map(int, input().split()))
	arr = [0] * n
	for i in l:
		arr[0] += 1
		arr[i] -= 1
	for i in range(1, n):
		arr[i] = arr[i] + arr[i - 1]
	for i in range(n):
		a = ord(s[i]) - ord('a')
		ch[a] += arr[i] + 1
	print(*ch)
	t -= 1


def answer(s, mistakes):
	lettArr = [0] * 26
	comboCountArr = [1] * len(s)
	stack = 0
	for m in mistakes:
		comboCountArr[m - 1] += 1
	for i in range(len(comboCountArr) - 1, -1, -1):
		comboCountArr[i] += stack
		if comboCountArr[i] > 1:
			stack = comboCountArr[i] - 1
	dic = {'a': 0, 'b': 1, 'c': 2, 'd': 3, 'e': 4, 'f': 5, 'g': 6, 'h': 7, 'i': 8, 'j': 9, 'k': 10, 'l': 11, 'm': 12, 'n': 13, 'o': 14, 'p': 15, 'q': 16, 'r': 17, 's': 18, 't': 19, 'u': 20, 'v': 21, 'w': 22, 'x': 23, 'y': 24, 'z': 25}
	for i in range(len(s)):
		lettArr[dic[s[i]]] += comboCountArr[i]
	return ' '.join([str(c) for c in lettArr])
testCount = int(input())
for _ in range(testCount):
	(n, m) = map(int, input().split())
	s = input()
	p = list(map(int, input().split()))
	print(answer(s.rstrip(), p))


for i in range(int(input())):
	(a, b) = map(int, input().split())
	s = input()
	p = list(map(int, input().split()))
	p.sort()
	d = {0: 0, 1: 0, 2: 0, 3: 0, 4: 0, 5: 0, 6: 0, 7: 0, 8: 0, 9: 0, 10: 0, 11: 0, 12: 0, 13: 0, 14: 0, 15: 0, 16: 0, 17: 0, 18: 0, 19: 0, 20: 0, 21: 0, 22: 0, 23: 0, 24: 0, 25: 0}
	for i in range(len(s)):
		d[ord(s[i]) - 97] += 1
	k = 0
	for i in range(len(p)):
		w = s[k:p[i]]
		k = p[i]
		for j in w:
			d[ord(j) - 97] += b - i
	for i in range(26):
		print(d[i], end=' ')
	print()


t = int(input())
ans = []
for _ in range(t):
	(n, m) = map(int, input().split())
	s = str(input())
	p = list(map(int, input().split()))
	cnt = m + 1
	pp = [0 for _ in range(n)]
	for i in p:
		pp[i - 1] += 1
	out = [0 for _ in range(26)]
	for i in range(n):
		out[ord(s[i]) - ord('a')] += cnt
		cnt -= pp[i]
	ans.append(' '.join(list(map(str, out))))
print('\n'.join(ans))


t = int(input())
for _ in range(t):
	(n, m) = map(int, input().split())
	s = input()
	p = list(map(int, input().split()))
	b = [0] * 26
	p.sort()
	c = 0
	for i in range(m):
		r = p[i]
		for k in range(c, r):
			b[ord(s[k]) - ord('a')] += m - i
		c = r
	for i in range(n):
		b[ord(s[i]) - ord('a')] += 1
	for i in range(26):
		print(b[i], end=' ')
	print()


from collections import defaultdict
from string import ascii_lowercase

def res(n, m, s, l):
	d = defaultdict(lambda : 0)
	l = sorted(l)
	for z in s[:l[0]]:
		d[z] += 1 * m
	for v in range(1, m):
		x = s[l[v - 1]:l[v]]
		for z in x:
			d[z] += 1 * (m - v)
	for z in s:
		d[z] += 1
	return d
t = int(input())
for i in range(t):
	(n, m) = [int(x) for x in input().split()]
	s = input()
	l = [int(x) for x in input().split()]
	dic = res(n, m, s, l)
	for c in ascii_lowercase:
		print(dic[c], end=' ')
	print('\n')


t = int(input())
for _ in range(t):
	(n, m) = map(int, input().split())
	s = input()
	p = list(map(int, input().split()))
	mp = [0] * n
	for value in p:
		mp[value - 1] += 1
	for i in range(n - 1, 0, -1):
		mp[i - 1] += mp[i]
	occ = [0] * 26
	for i in range(len(s)):
		occ[ord(s[i]) - ord('a')] += mp[i]
		occ[ord(s[i]) - ord('a')] += 1
	print(' '.join(list(map(str, occ))))


for _ in range(int(input())):
	(z, y) = map(int, input().split())
	str1 = input()
	(*li,) = map(int, input().split())
	li.sort()
	li += [z]
	li1 = [0] * 26
	x = 0
	for i in range(y + 1):
		a = li[i]
		for j in str1[x:a]:
			li1[ord(j) - 97] += y - i + 1
		x = a
	print(*li1)


for _ in range(int(input())):
	(n, m) = list(map(int, input().split()))
	s = input()
	seq = list(map(int, input().split()))
	for c in range(0, 26, 1):
		pre = [0] * (n + 1)
		for i in range(0, n, 1):
			if ord(s[i]) - ord('a') == c:
				pre[i + 1] = 1
		for i in range(1, n + 1, 1):
			pre[i] += pre[i - 1]
		ans = pre[n]
		for x in seq:
			ans += pre[x]
		print(ans, end=' ')
	print('')


import sys
input = sys.stdin.readline
t = int(input())
for tests in range(t):
	(n, m) = map(int, input().split())
	S = input().strip()
	P = list(map(int, input().split()))
	SCORE = [[0] * 26 for i in range(n)]
	for i in range(n):
		for j in range(26):
			SCORE[i][j] = SCORE[i - 1][j]
		SCORE[i][ord(S[i]) - 97] += 1
	ANS = [0] * 26
	for p in P:
		for j in range(26):
			ANS[j] += SCORE[p - 1][j]
	for j in range(26):
		ANS[j] += SCORE[-1][j]
	print(*ANS)


import sys
import math
input = sys.stdin.readline
t = int(input())
for _ in range(t):
	(n, m) = map(int, input().split())
	s = input()
	p = list(map(int, input().split()))
	check = [0] * (n + 1)
	for i in range(m):
		check[p[i] - 1] += 1
	for i in range(n - 2, -1, -1):
		check[i] = check[i + 1] + check[i]
	ll = [0] * 26
	for i in range(n):
		ll[ord(s[i]) - ord('a')] += check[i] + 1
	for i in range(len(ll)):
		print(ll[i], end=' ')
	print()


from sys import stdin, stdout
rl = lambda : stdin.readline()
rll = lambda : stdin.readline().split()
cout = lambda s: stdout.write(s)
swrite = lambda s: cout(str(s))
nwrite = lambda s: cout(''.join([str(s), '\n']))

def nwrite2(s):
	cout(str(s))
	cout('\n')

def main():
	T = int(rl())
	numchar = lambda c: ord(c) - 97
	for _ in range(T):
		(n, m) = (int(x) for x in rll())
		s = rll()[0]
		P = [int(x) for x in rll()]
		freqs = [0] * 26
		for c in s:
			freqs[numchar(c)] += 1
		prefix = [0 for _ in range(len(s) + 1)]
		for x in P:
			prefix[x] -= 1
		curr_sum = 0
		for (i, char) in enumerate(s):
			curr_sum -= prefix[i]
			freqs[numchar(char)] += m - curr_sum
		ans = ' '.join((str(x) for x in freqs))
		nwrite(ans)
	stdout.close()
main()


import collections

def countLetters(S, tries):
	count = [0] * 26
	i = 0
	counter = collections.defaultdict(tuple)
	for (i, ch) in enumerate(S):
		count[ord(ch) - ord('a')] += 1
		counter[i] = tuple(count)
	for j in tries:
		for (i, c) in enumerate(counter[j - 1]):
			count[i] += c
	for val in count:
		print(val, end=' ')
	print()
testCases = int(input())
for _ in range(testCases):
	(n, m) = map(int, input().split())
	S = input()
	tries = [int(val) for val in input().split()]
	countLetters(S, tries)


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	s = input()
	p = list(map(int, input().split()))
	p.append(n)
	d = [0] * 26
	a = []
	for x in range(97, 97 + 26):
		t = []
		t.append(int(ord(s[0]) == x))
		for i in range(1, n):
			t.append(t[-1] + int(ord(s[i]) == x))
		a.append(t)
	for x in p:
		for y in range(26):
			d[y] += a[y][x - 1]
	print(*d)


t = int(input())
while t:
	(n, m) = map(int, input().split())
	s = input()
	l = list(map(int, input().split()))
	l.sort()
	a = []
	val = []
	a.append(m)
	val.append(l[0])
	for i in range(1, m):
		if l[i] != l[i - 1]:
			a.append(m - i)
			val.append(l[i])
	c = [0] * 26
	for i in s:
		c[ord(i) - 97] += 1
	pos = 0
	for i in range(len(val)):
		for j in range(pos, val[i]):
			c[ord(s[j]) - 97] = a[i] + c[ord(s[j]) - 97]
		pos = val[i]
	print(*c)
	t = t - 1


k = list('abcdefghijklmnopqrstuvwxyz')
for _ in range(int(input())):
	(n, m) = map(int, input().split())
	s = list(input())
	a = list(map(int, input().split())) + [n]
	data_all = []
	data = [0] * 26
	for i in range(n):
		data[k.index(s[i])] += 1
		data_all.append(data[:])
	ans = [0] * 26
	for i in range(m + 1):
		for j in range(26):
			ans[j] += data_all[a[i] - 1][j]
	print(' '.join([str(x) for x in ans]))


t = int(input())
while t != 0:
	t -= 1
	n = input().split(' ')
	n = list(map(int, n))
	(a, b) = n
	s = input()
	m = input().split(' ')
	m = list(map(int, m))
	dic = {chr(x): 0 for x in range(ord('a'), ord('{'))}
	mistake = []
	for x in range(a):
		mistake.append(0)
	for x in m:
		mistake[x - 1] += 1
	err = 1
	for x in range(1, a + 1):
		if mistake[-x] != 0:
			err += mistake[-x]
		mistake[-x] = max(err, mistake[-x])
	for x in range(a):
		dic[s[x]] += mistake[x]
	r = ''
	for d in dic:
		r += str(dic[d])
		r += ' '
	print(r)


import sys

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

def mint():
	return int(minp())

def mints():
	return map(int, minp().split())

def solve():
	(n, m) = mints()
	s = minp()
	p = list(mints())
	p.sort()
	cnt = [0] * 26
	A = ord('a')
	j = 0
	h = m + 1
	for i in range(n):
		while j < m and p[j] == i:
			j += 1
			h -= 1
		cnt[ord(s[i]) - A] += h
	print(' '.join(map(str, cnt)))
for i in range(mint()):
	solve()


t = int(input())
for i in range(t):
	(n, m) = list(map(int, input().split()))
	s = input()
	p = list(map(int, input().split()))
	zeroarray = [0] * 26
	aftereach = [[0] * 26] * n
	psorted = sorted(list(set(p)))
	x = 0
	final = [0] * 26
	arr = zeroarray[:]
	for j in range(n):
		arr[ord(s[j]) - 97] += 1
		pos = psorted[x]
		if pos == j + 1:
			aftereach[pos] = arr[:]
			if x + 1 < len(psorted):
				x += 1
			else:
				break
	for j in range(n):
		final[ord(s[j]) - 97] += 1
	ans = [0] * 26
	for j in p:
		for y in range(26):
			ans[y] = ans[y] + aftereach[j][y]
	for y in range(26):
		ans[y] = ans[y] + final[y]
	print(*ans)


import os
import sys
from math import *
from collections import *
from bisect import *
from io import BytesIO, IOBase

def vsInput():
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')

def value():
	return tuple(map(int, input().split()))

def array():
	return [int(i) for i in input().split()]

def Int():
	return int(input())

def Str():
	return input()

def arrayS():
	return [i for i in input().split()]
alpha = 'qwertyuiopasdfghjklzxcvbnm'

def disp(d):
	for i in sorted(alpha):
		print(d[i], end=' ')
	print()
for _ in range(Int()):
	(n, m) = value()
	s = input()
	a = sorted(array())
	d = Counter(s)
	temp = defaultdict(int)
	for i in range(n):
		temp[s[i]] += 1
		ind = bisect_left(a, i + 1)
		d[s[i]] += len(a) - ind
	disp(d)


from bisect import bisect_left as right
t = int(input())
for q in range(t):
	(n, m) = map(int, input().split())
	s = input()
	p = list(map(int, input().split()))
	p.sort()
	ans = [0 for i in range(26)]
	for i in range(n):
		x = right(p, i + 1)
		ans[ord(s[i]) - 97] += m - x + 1
	print(*ans)


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	s = input()
	pressed = []
	for i in range(26):
		cnt = 0
		keys = []
		for j in range(n):
			if ord(s[j]) - ord('a') == i:
				cnt += 1
			keys.append(cnt)
		pressed.append(keys)
	ps = list(map(lambda x: int(x) - 1, input().split()))
	counts = [0] * 26
	for p in ps:
		for i in range(26):
			counts[i] += pressed[i][p]
	for i in range(26):
		counts[i] += pressed[i][-1]
	print(*counts)


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	s = input()
	p = list(map(int, input().split()))
	p.sort()
	j = 0
	ans = [0] * 26
	for i in range(n):
		while j < m and p[j] < i + 1:
			j += 1
		ans[ord(s[i]) - 97] += m - j + 1
	print(*ans)


import sys
import math
import bisect
from sys import stdin, stdout
from math import gcd, floor, sqrt, log
from collections import defaultdict as dd
from bisect import bisect_left as bl, bisect_right as br
from collections import Counter
inp = lambda : int(input())
strng = lambda : input().strip()
jn = lambda x, l: x.join(map(str, l))
strl = lambda : list(input().strip())
mul = lambda : map(int, input().strip().split())
mulf = lambda : map(float, input().strip().split())
seq = lambda : list(map(int, input().strip().split()))
ceil = lambda x: int(x) if x == int(x) else int(x) + 1
ceildiv = lambda x, d: x // d if x % d == 0 else x // d + 1
flush = lambda : stdout.flush()
stdstr = lambda : stdin.readline().rstrip()
stdint = lambda : int(stdin.readline())
stdpr = lambda x: stdout.write(str(x))
stdarr = lambda : map(int, stdstr().split())
mod = 1000000007
for _ in range(stdint()):
	(n, m) = stdarr()
	s = stdstr()
	p = list(stdarr())
	c = Counter()
	pref = [0] * n
	for i in range(m):
		pref[p[i] - 1] += 1
	suffSum = [0] * n
	for i in range(n - 1, 0, -1):
		pref[i - 1] += pref[i]
	for i in range(n):
		c[s[i]] += pref[i] + 1
	for i in range(ord('a'), ord('z') + 1):
		print(c[chr(i)], end=' ')
	print()


t = int(input())
from collections import Counter
for _ in range(t):
	(n, m) = map(int, input().split())
	S = input()
	lengths = list(map(int, input().split()))
	l = [0 for i in range(26)]
	cnt = Counter(lengths)
	prev = 1
	times = []
	for i in range(len(S) - 1, -1, -1):
		prev += cnt[i + 1]
		times.append(prev)
	times = times[::-1]
	dic = {chr(i): 0 for i in range(97, 97 + 26)}
	for i in range(len(S)):
		dic[S[i]] += times[i]
	ans = []
	for i in range(97, 97 + 26):
		ans.append(str(dic[chr(i)]))
	print(' '.join(ans))


def i():
	return input()

def ii():
	return int(input())

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

def liis():
	return list(map(int, input().split()))
t = int(input())
for _ in range(t):
	(n, m) = iis()
	s = input()
	p = liis()
	p = sorted(p)
	ans = [0] * 26
	j = 0
	for i in range(len(p)):
		for c in s[j:p[i]]:
			ans[ord(c) - 97] += len(p) - i + 1
		j = p[i]
	for c in s[j:]:
		ans[ord(c) - 97] += 1
	print(' '.join(map(str, ans)))


for _ in range(int(input())):
	(n, m) = list(map(int, input().split()))
	word = [ord(x) - 97 for x in input()]
	p = [0] * n
	for i in list(map(int, input().split())):
		p[i - 1] += 1
	for i in range(n - 2, -1, -1):
		p[i] += p[i + 1]
	chars = [0] * 26
	for i in range(n):
		chars[word[i]] += p[i] + 1
	print(*chars)


import sys
import bisect

def ri():
	return int(input())

def rl():
	return list(map(int, input().split()))
import string
values = dict()
for (index, letter) in enumerate(string.ascii_lowercase):
	values[letter] = index
t = ri()
for _ in range(t):
	(n, m) = rl()
	s = input()
	p = rl()
	p.sort()
	ans = [0] * 26
	mot = [1] * n
	start = 0
	end = p[0]
	cum = len(p) + 1
	for k in range(len(p)):
		cum -= 1
		end = p[k]
		for j in range(start, end):
			mot[j] += cum
		start = p[k]
	for k in range(len(s)):
		letter = s[k]
		ans[values[letter]] += mot[k]
	print(*ans)


def process():
	(m, n) = input().split()
	li = input()
	m = [0] * len(li)
	mistakes = list(map(int, input().split()))
	mistakes = [i - 1 for i in mistakes]
	for i in mistakes:
		m[i] += 1
	s = 0
	for i in reversed(range(0, len(m))):
		s += m[i]
		m[i] = s
	for i in range(0, len(m)):
		m[i] += 1
	hashi = {}
	for i in range(0, len(li)):
		if li[i] in hashi:
			hashi[li[i]] += m[i]
		else:
			hashi[li[i]] = m[i]
	for i in range(0, 26):
		a = chr(ord('a') + i)
		if a in hashi:
			print(hashi[a], end=' ')
		else:
			print(0, end=' ')
	print('')
tests = int(input())
for i in range(0, tests):
	process()


t = int(input())
for _ in range(0, t):
	(n, m) = map(int, input().split())
	s = input()
	p = [int(i) for i in input().split()]
	ind = [[0] * 26]
	for i in s:
		o = ord(i) - 97
		k = ind[-1].copy()
		k[o] += 1
		ind.append(k)
	ans = [0] * 26
	for i in p:
		kk = ind[i]
		for ii in range(0, 26):
			ans[ii] += kk[ii]
	for i in s:
		ans[ord(i) - 97] += 1
	print(*ans)


t = int(input())
for ii in range(t):
	(n, m) = map(int, input().split())
	s = input()
	l = list(map(int, input().split()))
	suffix_sum = [0] * n
	res = [0] * 26
	for i in l:
		suffix_sum[i - 1] += 1
	i = n - 2
	while i >= 0:
		suffix_sum[i] += suffix_sum[i + 1]
		i -= 1
	i = 0
	while i < n:
		suffix_sum[i] += 1
		i += 1
	for i in range(n):
		c = ord(s[i]) - ord('a')
		res[c] += suffix_sum[i]
	print(*res)


import os
import sys
from io import BytesIO, IOBase
from collections import Counter

def solution(s, p_arr, n, m):
	res = [0] * 26
	arr = [0] * n
	for p in p_arr:
		arr[p - 1] += 1
	cur = 0
	suffix = [0] * n
	suffix[-1] = arr[-1]
	for i in range(n - 1, 0, -1):
		suffix[i - 1] += arr[i - 1] + suffix[i]
	for (i, c) in enumerate(s):
		res[ord(c) - ord('a')] += suffix[i]
	for c in s:
		res[ord(c) - ord('a')] += 1
	for c in res:
		print(c, end=' ')
	print()

def main():
	t = int(input())
	for _ in range(t):
		(n, m) = [int(x) for x in input().split()]
		s = input()
		p_arr = [int(x) for x in input().split()]
		solution(s, p_arr, n, m)
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))

def input():
	return sys.stdin.readline().rstrip('\r\n')
main()


import sys
from collections import Counter
input = sys.stdin.readline
for _ in range(int(input())):
	(n, m) = map(int, input().split())
	s = input().strip()
	L = list(map(int, input().split()))
	C = Counter(L)
	ans = [0] * 26
	count = 1
	for i in range(n - 1, -1, -1):
		count += C[i + 1]
		ans[ord(s[i]) - 97] += count
	print(*ans)


from collections import defaultdict

def binary(arr, ele):
	start = 0
	end = len(arr) - 1
	pos = 0
	while start <= end:
		mid = (start + end) // 2
		if arr[mid] < ele:
			pos = mid
			start = mid + 1
		elif arr[mid] > ele:
			pos = mid
			end = mid - 1
		else:
			return mid + 1
	if arr[pos] < ele:
		return pos + 1
	return pos

def result(d, ans, q):
	for i in d.keys():
		arr = d[i]
		ans[ord(i) - 97] += binary(arr, q)
for i in range(int(input())):
	(n, m) = map(int, input().split())
	ans = [0] * 26
	s = list(input())
	d = defaultdict(list)
	for i in range(n):
		ans[ord(s[i]) - 97] += 1
		d[s[i]].append(i)
	q = list(map(int, input().split()))
	for i in q:
		result(d, ans, i - 1)
	for i in ans:
		print(i, end=' ')
	print()


t = int(input())
for _ in range(t):
	(n, m) = map(int, input().split())
	s = str(input())
	P = list(map(int, input().split()))
	P = [p - 1 for p in P]
	C = [[0] * (n + 1) for i in range(26)]
	for i in range(n):
		for j in range(26):
			C[j][i + 1] = C[j][i]
		c = ord(s[i]) - ord('a')
		C[c][i + 1] += 1
	ans = [0] * 26
	for i in range(m):
		for c in range(26):
			ans[c] += C[c][P[i] + 1]
	for i in range(n):
		c = ord(s[i]) - ord('a')
		ans[c] += 1
	print(*ans)


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	a = input()
	b = list(map(int, input().split()))
	an = [0] * 26
	k = [0] * (n + 1)
	k[0] = m + 1
	for i in range(m):
		k[b[i]] -= 1
	an[ord(a[0]) - 97] = k[0]
	for i in range(1, n):
		k[i] += k[i - 1]
		an[ord(a[i]) - 97] += k[i]
	print(*an)


t = int(input())
while t > 0:
	(n, m) = [int(ele) for ele in input().split()]
	s = input()
	p = [int(ele) for ele in input().split()]
	count = []
	for i in range(26):
		count.append(0)
	lst = []
	for i in range(n):
		lst.append(0)
	for i in range(m):
		lst[p[i] - 1] += 1
	for i in range(n - 1, 0, -1):
		lst[i - 1] += lst[i]
	for i in range(n):
		count[ord(s[i]) - 97] += lst[i] + 1
	for ele in count:
		print(ele, end=' ')
	t -= 1


import sys
input = lambda : sys.stdin.readline().rstrip()
for _ in range(int(input())):
	(n, m) = map(int, input().split())
	a = [ord(i) - 97 for i in input()]
	p = [int(i) - 1 for i in input().split()]
	alp = [0] * 26
	st = [0] * 26
	d = []
	for i in range(n):
		st[a[i]] += 1
		d.append(tuple(st))
	for i in p:
		for j in range(len(d[i])):
			alp[j] += d[i][j]
	for i in range(n):
		alp[a[i]] += 1
	print(*alp)


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	l = [0] * n + [1]
	ans = [0] * 26
	s = list(input())
	for x in list(map(int, input().split())):
		l[x - 1] += 1
	for x in range(n - 1, -1, -1):
		l[x] += l[x + 1]
	for x in range(n):
		ans[ord(s[x]) - 97] += l[x]
	print(*ans)


for i in range(int(input())):
	(n, m) = map(int, input().split())
	s = list(input())
	p = list(map(int, input().split()))
	ans = [0] * 26
	calS = [0] * n
	calS[n - 1] = 1
	p.sort()
	for i in range(m - 1, -1, -1):
		calS[p[i] - 1] += 1
	add = 0
	for i in range(n - 1, -1, -1):
		add += calS[i]
		ans[ord(s[i]) - 97] += add
	print(*ans)


t = int(input())
for _ in range(t):
	(n, k) = input().split(' ')
	n = int(n)
	k = int(k)
	c = input()
	e = [int(x) for x in input().split(' ')]
	e.sort()
	d = [0 for _ in range(26)]
	p = 0
	for i in e:
		for j in range(p, i):
			d[ord(c[j]) - 97] += k
			p = j + 1
		k -= 1
	for i in c:
		d[ord(i) - 97] += 1
	for i in d:
		print(i)


t = int(input())
for q in range(t):
	ans = [0] * 26
	(n, m) = map(int, input().split())
	s = input()
	p = list(map(int, input().split()))
	p.sort(reverse=True)
	cnt = 0
	si = n - 1
	for elem in p:
		while si > elem - 1:
			ind = ord(s[si]) - ord('a')
			ans[ind] += cnt
			si -= 1
		cnt += 1
	while si >= 0:
		ind = ord(s[si]) - ord('a')
		ans[ind] += cnt
		si -= 1
	for c in s:
		ans[ord(c) - ord('a')] += 1
	print(*ans)


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	s = input()
	p = list(map(int, input().split()))
	a = {chr(i): 0 for i in range(97, 123)}
	S = [a]
	for i in s:
		t = S[-1].copy()
		t[i] += 1
		S.append(t)
	ans = S[-1]
	for i in p:
		for (j, k) in S[i].items():
			ans[j] += k
	print(*[ans[chr(i)] for i in range(97, 123)])


T = int(input())
for _ in range(T):
	(n, m) = map(int, input().split())
	s = input()
	p = list(map(int, input().split()))
	A = [0 for i in range(n)]
	Z = [0 for i in range(26)]
	for i in p:
		A[i - 1] = A[i - 1] + 1
	for i in range(n - 1, 0, -1):
		Z[ord(s[i]) - 97] = Z[ord(s[i]) - 97] + A[i] + 1
		A[i - 1] = A[i] + A[i - 1]
	Z[ord(s[0]) - 97] = Z[ord(s[0]) - 97] + A[0] + 1
	for i in range(len(Z) - 1):
		print(Z[i], end=' ')
	print(Z[len(Z) - 1])


import sys
input = lambda : sys.stdin.readline()
int_arr = lambda : list(map(int, input().split()))
str_arr = lambda : list(map(str, input().split()))
get_str = lambda : map(str, input().split())
get_int = lambda : map(int, input().split())
get_flo = lambda : map(float, input().split())
mod = 1000000007

def solve(n, m, s, p):
	dp = [0 for i in range(n + 1)]
	dp[n] = 1
	for i in range(m):
		dp[p[i] - 1] += 1
	for j in range(n - 1, -1, -1):
		dp[j] += dp[j + 1]
	ans = [0 for i in range(26)]
	for k in range(n):
		ans[ord(s[k]) - 97] += dp[k]
	print(*ans)
for _ in range(int(input())):
	(n, m) = get_int()
	s = str(input())[:-1]
	p = int_arr()
	solve(n, m, s, p)


def main():
	dec = {'a': 0, 'b': 1, 'c': 2, 'd': 3, 'e': 4, 'f': 5, 'g': 6, 'h': 7, 'i': 8, 'j': 9, 'k': 10, 'l': 11, 'm': 12, 'n': 13, 'o': 14, 'p': 15, 'q': 16, 'r': 17, 's': 18, 't': 19, 'u': 20, 'v': 21, 'w': 22, 'x': 23, 'y': 24, 'z': 25}
	for case in range(int(input())):
		(n, m) = map(int, input().split())
		st = input()
		ind = list(map(int, input().split()))
		op = [0] * 26
		g = [0] * 26
		dic = {}
		for i in ind:
			if i in dic.keys():
				dic[i] += 1
			else:
				dic[i] = 1
		for i in range(n):
			if i in dic.keys():
				x = dic[i]
				for k in range(26):
					op[k] = g[k] * x + op[k]
			g[dec[st[i]]] += 1
		for k in range(26):
			op[k] = g[k] + op[k]
		for i in op:
			print(i, end=' ')
		print()
main()


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

def I():
	return int(input())

def S():
	return str(input())

def L():
	return list(R())
from collections import Counter
import math
import sys
from itertools import permutations
import bisect
for _ in range(I()):
	(n, m) = R()
	s = S()
	p = L()
	p.append(n)
	p.sort()
	sump = [0] * (m + 2)
	more = [0] * (n + 2)
	for i in range(m + 1):
		more[p[i] - 1] += 1
	for i in range(n, -1, -1):
		more[i] = more[i + 1] + more[i]
	cnt = [0] * 26
	j = -1
	for a in s:
		j += 1
		cnt[ord(a) - ord('a')] += more[j]
	print(*cnt)


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	a = input()
	p = list(map(int, input().split()))
	p.sort()
	k = m - 1
	l = [0] * 26
	j = 1
	for i in range(n, 0, -1):
		while k >= 0 and i == p[k]:
			k -= 1
			j += 1
		l[ord(a[i - 1]) - ord('a')] += j
	print(*l)


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	s = input()
	d = [0 for _ in range(n)]
	c = [0 for _ in range(26)]
	d[n - 1] = 1
	for i in map(int, input().split()):
		d[i - 1] += 1
	for i in range(n - 1, 0, -1):
		d[i - 1] += d[i]
	for k in range(n):
		c[ord(s[k]) - 97] += d[k]
	print(*c)


import sys
import os
import math
import copy
from math import gcd
from bisect import bisect
from io import BytesIO, IOBase
from math import sqrt, floor, factorial, gcd, log, ceil
from collections import deque, Counter, defaultdict
from itertools import permutations, combinations
from itertools import accumulate

def Int():
	return int(sys.stdin.readline())

def Mint():
	return map(int, sys.stdin.readline().split())

def Lstr():
	return list(sys.stdin.readline().strip())

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

def Mstr():
	return map(str, sys.stdin.readline().strip().split())

def List():
	return list(map(int, sys.stdin.readline().split()))

def Hash():
	return dict()

def Mod():
	return 1000000007

def Ncr(n, r, p):
	return fact[n] * (ifact[r] * ifact[n - r] % p) % p

def Most_frequent(list):
	return max(set(list), key=list.count)

def Mat2x2(n):
	return [List() for _ in range(n)]

def Lcm(x, y):
	return x * y // gcd(x, y)

def dtob(n):
	return bin(n).replace('0b', '')

def btod(n):
	return int(n, 2)

def common(l1, l2):
	return set(l1).intersection(l2)

def solution():
	for _ in range(Int()):
		d = {}
		for i in range(97, 123):
			d[chr(i)] = 0
		(n, m) = Mint()
		a = Str()
		p = List()
		p.sort()
		x = 0
		for i in range(len(p)):
			for j in range(x, p[i]):
				d[a[j]] += len(p) - i
				x = p[i]
		for i in a:
			d[i] += 1
		print(*list(d.values()))
solution()


for _ in range(int(input())):
	(n, m) = list(map(int, input().strip().split()))
	string = input().strip()
	array = list(map(int, input().strip().split()))
	counts = []
	dick = {}
	for i in string:
		dick[i] = dick.get(i, 0) + 1
		counts.append(dick.copy())
	ans = {}
	for i in array:
		for j in counts[i - 1]:
			ans[j] = ans.get(j, 0) + counts[i - 1][j]
	this = [0] * 26
	for i in ans:
		this[ord(i) - ord('a')] = ans[i]
	for i in string:
		this[ord(i) - ord('a')] += 1
	print(*this)


testcases = int(input())
for j in range(testcases):
	values = list(map(int, input().split()))
	lengthofstring = values[0]
	numtries = values[1]
	string = [ord(q) - 97 for q in input()]
	listtries = list(map(int, input().split()))
	dummylist = [0 for alpha in range(26)]
	storedict = {}
	answerlist = [0 for alpha in range(26)]
	for k in range(lengthofstring):
		dummylist[string[k]] += 1
		storedict[k + 1] = dummylist + []
	listtries.append(lengthofstring)
	for l in range(numtries + 1):
		values2 = storedict[listtries[l]]
		for j in range(26):
			answerlist[j] += values2[j]
	print(' '.join(list(map(str, answerlist))))


def solve(s, n, m, arr, ans):
	counts = [0] * (n + 1)
	for i in arr:
		counts[1] += 1
		counts[i + 1] -= 1
	counts.pop(0)
	for i in range(1, n):
		counts[i] += counts[i - 1]
	for i in range(n):
		counts[i] += 1
	letters = [0] * 26
	for i in range(n):
		letters[ord(s[i]) - ord('a')] += counts[i]
	ans.append(letters[:])

def main():
	t = int(input())
	ans = []
	for i in range(t):
		(n, m) = map(int, input().split())
		s = input()
		arr = list(map(int, input().split()))
		solve(s, n, m, arr, ans)
	for i in ans:
		for j in i:
			print(j, end=' ')
		print()
main()


import sys
input = sys.stdin.readline

def main():
	t = int(input())
	for _ in range(t):
		(N, M) = [int(x) for x in input().split()]
		S = input().strip()
		P = [int(x) for x in input().split()]
		A = [[0] * 26 for j in range(N + 1)]
		for i in range(1, N + 1):
			for j in range(26):
				A[i][j] = A[i - 1][j]
			A[i][ord(S[i - 1]) - ord('a')] += 1
		ans = [0] * 26
		for p in P:
			for j in range(26):
				ans[j] += A[p][j]
		for j in range(26):
			ans[j] += A[N][j]
		print(*ans)
main()


import bisect
t = int(input())
for _ in range(t):
	(n, m) = map(int, input().split())
	s = input()
	arr = list(map(int, input().split()))
	arr = sorted(arr)
	ans = [0] * 26
	for i in range(n):
		pos = bisect.bisect_left(arr, i + 1)
		ans[ord(s[i]) - 97] += 1 + (m - pos)
	print(*ans)


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	s = input()
	p = [int(x) for x in input().split()]
	l = [0] * 26
	for i in range(n):
		l[ord(s[i]) - 97] += 1
	l1 = [0] * n
	for i in p:
		i -= 1
		l1[i] += 1
	for i in range(2, n + 1):
		l1[-i] += l1[-i + 1]
	for i in range(n):
		l[ord(s[i]) - 97] += l1[i]
	for i in l:
		print(i, end=' ')
	print()


t = int(input())
for _ in range(t):
	d = {}
	for i in range(97, 97 + 26):
		d[chr(i)] = 0
	(n, m) = map(int, input().split())
	s = input()
	b = list(map(int, input().split()))
	b.sort()
	x = 0
	for i in range(len(b)):
		for j in range(x, b[i]):
			d[s[j]] += len(b) - i
			x = b[i]
	for i in s:
		d[i] += 1
	for i in d.values():
		print(i, end=' ')
	print()


from collections import defaultdict
t = int(input())
for j in range(t):
	(n, m) = map(int, input().split())
	l1 = list(input())
	l2 = list(map(int, input().split()))
	d = defaultdict(int)
	for i in l2:
		d[i] += 1
	sum = m
	All = [0] * 26
	for i in range(len(l1)):
		count = sum
		if d.get(i + 1):
			sum = sum - d.get(i + 1)
		All[ord(l1[i]) - 97] = All[ord(l1[i]) - 97] + count + 1
	print(*All)


from collections import Counter
alphabet = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z']

def get_buttons_pressed_stat(combo_length, combo, failed_times, failed_data):
	failed_data_sorted = sorted(failed_data, reverse=True)
	button_pressed = Counter()
	latest_failed_amount = failed_times
	latest_failed_button = None
	if failed_times != 0:
		latest_failed_button = failed_data_sorted.pop()
	for i in range(combo_length):
		increment_amount = 1
		while latest_failed_button is not None and latest_failed_button - 1 < i:
			latest_failed_amount -= 1
			if len(failed_data_sorted) == 0:
				latest_failed_button = None
			else:
				latest_failed_button = failed_data_sorted.pop()
		button_pressed[combo[i]] += increment_amount + latest_failed_amount
	return button_pressed
number_of_tests = int(input())
for _ in range(number_of_tests):
	(n, m) = tuple(map(int, input().split()))
	s = input()
	p = list(map(int, input().split()))
	buttons_pressed_stat = get_buttons_pressed_stat(n, s, m, p)
	for button in alphabet:
		if button == 'z':
			print(buttons_pressed_stat[button])
		else:
			print(buttons_pressed_stat[button], end=' ')


t = int(input())
for _ in range(t):
	(n, m) = map(int, input().split())
	s = input()
	p = [int(x) for x in input().split()]
	a = [[0] for x in range(26)]
	a[ord(s[0]) - 97][0] = 1
	for i in range(1, n):
		temp = ord(s[i]) - 97
		for j in range(26):
			a[j].append(a[j][i - 1])
			if j == temp:
				a[j][i] = a[j][i - 1] + 1
	ans = [0] * 26
	p.append(n)
	for x in p:
		for i in range(26):
			ans[i] += a[i][x - 1]
	for x in ans:
		print(x, end=' ')
	print()


alphabet = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z']
t = int(input())

def binsearch(nums, target):
	left = 0
	right = len(nums) - 1
	while left <= right:
		mid = (left + right) // 2
		if nums[mid] == target:
			return mid
		elif nums[mid] > target:
			right = mid - 1
		elif nums[mid] < target:
			left = mid + 1
	return left
for tc in range(t):
	(n, m) = map(int, input().split())
	s = input()
	fails = [int(z) - 1 for z in input().split()]
	occ = {}
	fails.sort()
	for i in alphabet:
		occ[i] = 0
	for i in range(n):
		pl = binsearch(fails, i - 0.1)
		occ[s[i]] += m - pl
	for i in range(n):
		occ[s[i]] += 1
	res = []
	for i in range(26):
		res.append(occ[alphabet[i]])
	print(*res)


for _ in ' ' * int(input()):
	(a, b) = map(int, input().split())
	z = input()
	s = sorted(map(int, input().split()))
	ans = [0] * 26
	p = 0
	i = 0
	b1 = b
	while i < b:
		k = [0] * 26
		r = s[i]
		for j in range(p, s[i]):
			o = ord(z[j]) - 97
			k[o] += 1
		temp = 0
		while i < b and r == s[i]:
			i += 1
			temp += 1
		for t in range(26):
			ans[t] += k[t] * b1
		p = s[i - 1]
		b1 -= temp
	for i in range(a):
		ans[ord(z[i]) - 97] += 1
	print(*ans)


from sys import stdin
input = lambda : stdin.readline().rstrip('\r\n')

def read():
	(n, m) = map(int, input().split())
	s = input()
	p = list(map(int, input().split()))
	return (n, m, s, p)

def solve(n, m, s, p):
	a = [[0] * (n + 1) for i in range(26)]
	ord_a = ord('a')
	for i in range(n):
		for j in range(26):
			a[j][i + 1] = a[j][i]
		a[ord(s[i]) - ord_a][i + 1] += 1
	res = [0] * 26
	p.append(n)
	for pi in p:
		for i in range(26):
			res[i] += a[i][pi]
	return res
for t in range(int(input())):
	result = solve(*read())
	print(*result)


from collections import defaultdict
from time import time
alphabet = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z']
N = int(input())
for _ in range(N):
	(n, m) = map(int, input().split())
	ss = input()
	ps = list(map(int, input().split()))
	count = defaultdict(int)
	p_count = [0] * n
	for p in ps:
		p_count[p - 1] += 1
	for i in range(n - 1, 0, -1):
		p_count[i - 1] += p_count[i]
	ans = [0] * 26
	for i in range(n):
		ans[alphabet.index(ss[i])] += p_count[i] + 1
	print(*ans)


I = input
for _ in range(int(I())):
	(n, m) = map(int, I().split())
	s = list(I())
	p = list(map(int, I().split(' ')))
	ds = []
	t = []
	c = []
	ans = [0 for i in range(26)]
	for i in range(n):
		c1 = c.copy()
		t1 = t.copy()
		try:
			ind = t.index(s[i])
		except ValueError:
			ind = -1
		if ind == -1:
			t.append(s[i])
			t1.append(s[i])
			c.append(1)
			c1.append(1)
		else:
			c1[ind] += 1
			c[ind] += 1
		ds.append([t1, c1, 0])
	for i in p:
		ds[i - 1][2] += 1
	ds[n - 1][2] = 1
	p.append(n)
	for i in set(p):
		for j in range(len(ds[i - 1][0])):
			asc = ord(ds[i - 1][0][j]) - 97
			v = ds[i - 1][1][j]
			ans[asc] += v * ds[i - 1][2]
	for i in ans:
		print(i, end=' ')


import sys
from bisect import bisect_left as bs
input = sys.stdin.readline
for _ in range(int(input().strip())):
	(n, m) = list(map(int, input().strip().split()))
	st = input().strip()
	arr = list(map(int, input().strip().split()))
	arr.sort()
	dic = {}
	cur = 0
	last = 0
	for i in range(len(st)):
		if cur > len(arr) - 1:
			break
		last = i
		while cur < len(arr) and i + 1 > arr[cur]:
			cur += 1
		if st[i] in dic:
			dic[st[i]] += m - cur + 1
		else:
			dic[st[i]] = m - cur + 1
	for i in range(last + 1, n):
		if st[i] in dic:
			dic[st[i]] += 1
		else:
			dic[st[i]] = 1
	out = []
	for i in range(26):
		cur_ch = chr(ord('a') + i)
		if cur_ch in dic:
			out.append(dic[cur_ch])
		else:
			out.append(0)
	print(' '.join(map(str, out)))


def print_a(a):
	for i in a:
		print(i, end=' ')
	print()

def solve(n, m, s, p):
	p.sort(reverse=True)
	ans = [1] * n
	i = 0
	while i < len(p):
		j = i
		while j < len(p) and p[j] == p[i]:
			j += 1
		if j == len(p):
			(l, r) = (0, p[i])
		else:
			(l, r) = (p[j], p[i])
		inc = j
		for it in range(l + 1, r + 1):
			ans[it - 1] += inc
		i = j
	res = [0] * 26
	for i in range(n):
		c = ord(s[i]) - ord('a')
		res[c] += ans[i]
	print_a(res)

def main():
	inp = lambda : [int(x) for x in input().split()]
	tc = int(input())
	for _ in range(tc):
		(n, m) = inp()
		s = input()
		p = inp()
		solve(n, m, s, p)
main()


t = int(input())
for _ in range(t):
	(n, m) = [int(p) for p in input().split()]
	s = input()
	arr = sorted([int(p) for p in input().split()])
	freq = [0] * len(s)
	for i in range(len(arr)):
		freq[arr[i]] += 1
	for i in range(1, len(freq)):
		freq[i] += freq[i - 1]
	for i in range(len(freq)):
		freq[i] = len(arr) - freq[i] + 1
	ans = [0] * 26
	for i in range(len(s)):
		f = freq[i]
		ans[ord(s[i]) - 97] += f
	print(*ans)


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	s = input()
	pl = list(map(int, input().split())) + [n + 1]
	pl.sort()
	d = [0] * 26
	j = 0
	i = 0
	for x in s:
		i += 1
		d[ord(x) - 97] += m + 1 - j
		while i == pl[j]:
			j += 1
	print(*d)


def solution(s, l):
	a = [0 for i in range(26)]
	num = 1
	for i in range(len(s)):
		q = len(s) - 1 - i
		if num <= len(l):
			while l[num - 1] == q + 1:
				num += 1
				if num > len(l):
					break
		a[ord(s[q]) - 97] += num
	return a
a = int(input())
for i in range(a):
	b = input()
	s = input()
	l = input().split(' ')
	for i in range(len(l)):
		l[i] = int(l[i])
	l.sort(reverse=True)
	q = solution(s, l)
	p = ''
	for i in q:
		p += str(i) + ' '
	print(p[:-1])


from __future__ import division, print_function
import os, sys
from io import BytesIO, IOBase
if sys.version_info[0] < 3:
	from __builtin__ import xrange as range
	from future_builtins import ascii, filter, hex, map, oct, zip

def ii():
	return int(input())

def si():
	return input()

def mi():
	return map(int, input().strip().split(' '))

def msi():
	return map(str, input().strip().split(' '))

def li():
	return list(mi())

def dmain():
	sys.setrecursionlimit(100000000)
	threading.stack_size(40960000)
	thread = threading.Thread(target=main)
	thread.start()
abc = 'abcdefghijklmnopqrstuvwxyz'
abd = {'a': 0, 'b': 1, 'c': 2, 'd': 3, 'e': 4, 'f': 5, 'g': 6, 'h': 7, 'i': 8, 'j': 9, 'k': 10, 'l': 11, 'm': 12, 'n': 13, 'o': 14, 'p': 15, 'q': 16, 'r': 17, 's': 18, 't': 19, 'u': 20, 'v': 21, 'w': 22, 'x': 23, 'y': 24, 'z': 25}
mod = 1000000007
inf = float('inf')
vow = ['a', 'e', 'i', 'o', 'u']
(dx, dy) = ([-1, 1, 0, 0], [0, 0, 1, -1])

def getKey(item):
	return item[1]

def sort2(l):
	return sorted(l, key=getKey, reverse=True)

def d2(n, m, num):
	return [[num for x in range(m)] for y in range(n)]

def isPowerOfTwo(x):
	return x and (not x & x - 1)

def decimalToBinary(n):
	return bin(n).replace('0b', '')

def ntl(n):
	return [int(i) for i in str(n)]

def ncr(n, r):
	return factorial(n) // (factorial(r) * factorial(n - r))

def powerMod(x, y, p):
	res = 1
	x %= p
	while y > 0:
		if y & 1:
			res = res * x % p
		y = y >> 1
		x = x * x % p
	return res

def gcd(x, y):
	while y:
		(x, y) = (y, x % y)
	return x

def isPrime(n):
	if n <= 1:
		return False
	if n <= 3:
		return True
	if n % 2 == 0 or n % 3 == 0:
		return False
	i = 5
	while i * i <= n:
		if n % i == 0 or n % (i + 2) == 0:
			return False
		i = i + 6
	return True

def read():
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')

def main():
	for _ in range(ii()):
		(n, m) = mi()
		s = si()
		p = li()
		ans = [0] * 26
		s = '.' + s
		f = [0] * (n + 5)
		for i in range(m):
			f[1] += 1
			f[p[i] + 1] -= 1
		for i in range(1, n + 5):
			f[i] += f[i - 1]
		for i in range(1, n + 1):
			ans[abd[s[i]]] += f[i] + 1
		print(*ans)
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')

def print(*args, **kwargs):
	(sep, file) = (kwargs.pop('sep', ' '), kwargs.pop('file', sys.stdout))
	at_start = True
	for x in args:
		if not at_start:
			file.write(sep)
		file.write(str(x))
		at_start = False
	file.write(kwargs.pop('end', '\n'))
	if kwargs.pop('flush', False):
		file.flush()
if sys.version_info[0] < 3:
	(sys.stdin, sys.stdout) = (FastIO(sys.stdin), FastIO(sys.stdout))
else:
	(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
main()


for _ in range(int(input())):
	d = {}
	for i in range(97, 123):
		d[chr(i)] = 0
	(n, m) = map(int, input().split())
	a = input()
	p = list(map(int, input().split()))
	l1 = []
	for i in range(n):
		l1.append(0)
	for i in p:
		l1[0] += 1
		l1[i] -= 1
	for i in range(1, len(l1)):
		l1[i] = l1[i] + l1[i - 1]
	for i in range(len(l1)):
		l1[i] += 1
	for i in range(len(l1)):
		d[a[i]] += l1[i]
	for i in d:
		print(d[i], end=' ')
	print()


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	s = input()
	a = [[0] * 26]
	for el in s:
		temp = a[-1].copy()
		temp[ord(el) - 97] += 1
		a.append(temp)
	ans = [0] * 26
	for el in map(int, input().split()):
		for i in range(26):
			ans[i] += a[el][i]
	for el in s:
		ans[ord(el) - 97] += 1
	print(*ans)


import sys
t = int(sys.stdin.readline())
for _ in range(t):
	(n, m) = map(int, sys.stdin.readline().split())
	s = sys.stdin.readline()[:-1]
	temp = [0] * 26
	dic = [temp]
	for i in range(n):
		temp = [i for i in dic[-1]]
		temp[ord(s[i]) - 97] += 1
		dic.append(temp)
	p = list(map(int, sys.stdin.readline().split()))
	ans = [0] * 26
	for i in range(len(p)):
		for j in range(26):
			ans[j] += dic[p[i]][j]
	for i in range(26):
		ans[i] += dic[-1][i]
	print(*ans)


from collections import Counter
from string import ascii_lowercase as al
for _ in range(int(input())):
	(n, m) = [int(x) for x in input().split()]
	has = input()
	pos = [int(x) for x in input().split()]
	freq = Counter(has)
	pref = [0] * (n + 1)
	for i in range(m):
		pref[0] += 1
		pref[pos[i]] -= 1
	for i in range(n):
		pref[i] += pref[i - 1]
		freq[has[i]] += pref[i]
	ans = [freq[i] if i in freq else 0 for i in al]
	print(*ans)


def main():
	t = int(input())
	for _ in range(t):
		(n, m) = list(map(int, input().strip().split()))
		s = input()
		p = list(map(int, input().strip().split()))
		p.append(n)
		cnt = [[0 for _ in range(26)] for _ in range(n)]
		cnt[0][ord(s[0]) - 97] = 1
		for i in range(1, n):
			for j in range(26):
				cnt[i][j] = cnt[i - 1][j]
			cnt[i][ord(s[i]) - 97] += 1
		ret = [0 for _ in range(26)]
		for pos in p:
			for i in range(26):
				ret[i] += cnt[pos - 1][i]
		print(' '.join(list(map(str, ret))))
main()


t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	arr = input()
	mis = list(map(int, input().strip().split()))[:k]
	ans = [0] * n
	for num in mis:
		ans[num] -= 1
	ans[0] += k
	for i in range(1, n):
		ans[i] += ans[i - 1]
	res = [0] * 26
	for i in range(n):
		res[ord(arr[i]) - 97] += ans[i] + 1
	for num in res:
		print(num, end=' ')
	print()


from itertools import accumulate
sc = iter(open(0).read().split())
ni = lambda : int(next(sc))
ns = lambda : next(sc)
T = ni()
for _ in range(T):
	(N, M) = (ni(), ni())
	S = [ord(s) - ord('a') for s in ns()]
	P = [ni() for _ in range(M)]
	imos = [0] * N
	imos[0] = M + 1
	for p in P:
		imos[p] -= 1
	A = accumulate(imos)
	ans = [0] * 26
	for (s, a) in zip(S, A):
		ans[s] += a
	print(*ans)


import sys
t = int(sys.stdin.readline())
for query in range(t):
	pressed = {chr(code): 0 for code in range(ord('a'), ord('z') + 1)}
	(n, m) = map(int, sys.stdin.readline().strip().split())
	s = sys.stdin.readline().strip()
	p = [int(x) for x in sys.stdin.readline().strip().split()]
	p.sort()
	addTimes = m
	for pos in range(n):
		while addTimes > 0 and p[m - addTimes] <= pos:
			addTimes -= 1
		pressed[s[pos]] += addTimes + 1
	print(' '.join([str(pressed[sym]) for sym in pressed]))


t = int(input().strip())
for _ in range(t):
	(n, m) = map(int, input().strip().split())
	s = input().strip()
	ps = [int(i) - 1 for i in input().strip().split()]
	cnts = [0 for i in range(26)]
	pre = 0
	ps.sort()
	for (cnt, i) in enumerate(ps):
		for j in range(pre, i + 1):
			cnts[ord(s[j]) - ord('a')] += m - cnt + 1
		pre = i + 1
	if pre < n:
		for j in range(pre, n):
			cnts[ord(s[j]) - ord('a')] += 1
	print(' '.join((str(i) for i in cnts)))


for t in range(int(input())):
	(n, m) = map(int, input().split())
	a = input().rstrip()
	d = [0] * n
	for i in input().split():
		d[int(i) - 1] += 1
	for i in range(n - 2, -1, -1):
		d[i] += d[i + 1]
	z = [0] * 26
	for (i, v) in enumerate(a):
		z[ord(v) - 97] += d[i] + 1
	print(*z)


t = int(input())
for _ in range(t):
	(n, m) = list(map(int, input().split()))
	s = str(input())
	p = list(map(int, input().split()))
	ans = [0] * 26
	arr = [0] * n
	for i in range(m):
		arr[p[i] - 1] += 1
	arr[-1] += 1
	pref = [-1] * n
	pref[-1] = arr[-1]
	for i in range(2, n + 1):
		pref[-i] = pref[-i + 1] + arr[-i]
	for i in range(n):
		ans[ord(s[i]) - 97] += pref[i]
	print(' '.join((str(x) for x in ans)))


from collections import defaultdict
t = int(input())
res = []
for k in range(t):
	(n, m) = map(int, input().split())
	s = input()
	P = [int(x) for x in input().split()]
	counters = defaultdict(int)
	P = sorted(P)
	old_curr = 0
	for i in range(m):
		curr = P[i]
		for j in range(old_curr, curr):
			counters[s[j]] += m - i
		old_curr = curr
	for char in s:
		counters[char] += 1
	for char in 'abcdefghijklmnopqrstuvwxyz':
		print(counters[char], end=' ')
	print()


t = int(input())
for i in range(t):
	(a, b) = map(int, input().split())
	s = input()
	l = list(map(int, input().split()))
	dic = dict()
	for j in range(a):
		dic[s[j]] = 0
	arr = [0] * a
	for j in range(len(l)):
		arr[l[j] - 1] += 1
	for k in range(len(arr) - 2, -1, -1):
		arr[k] = arr[k] + arr[k + 1]
	for k in range(len(arr)):
		arr[k] += 1
	for y in range(len(s)):
		dic[s[y]] += arr[y]
	for e in range(26):
		if chr(97 + e) in dic:
			print(dic[chr(97 + e)], end=' ')
		else:
			print(0, end=' ')
	print()


from sys import stdin
from collections import deque
from math import sqrt, floor, ceil, log, log2, log10, pi, gcd, sin, cos, asin, tan

def ii():
	return int(stdin.readline())

def fi():
	return float(stdin.readline())

def mi():
	return map(int, stdin.readline().split())

def fmi():
	return map(float, stdin.readline().split())

def li():
	return list(mi())

def lsi():
	x = list(stdin.readline())
	x.pop()
	return x

def si():
	return stdin.readline()

def sieve(x):
	a = [True] * (x + 1)
	sq = floor(sqrt(x))
	for i in range(3, sq + 1, 2):
		if a[i]:
			for j in range(i * i, x + 1, i):
				a[j] = False
	if x > 1:
		p = [2]
	else:
		p = []
	for i in range(3, x + 1, 2):
		if a[i]:
			p.append(i)
	return p

def prime_factor(x):
	c = 1
	i = 0
	while p[i] * p[i] <= x:
		if not x % p[i]:
			c += 1
			while not x % p[i]:
				x //= p[i]
		i += 1
	if x > 1:
		c += 1
	return c
res = ['YES', 'NO']
for _ in range(ii()):
	ans = [0] * 26
	(n, m) = mi()
	a = lsi()
	s = li()
	s.sort(reverse=True)
	s += [0]
	(i, j, c) = (0, n - 1, 1)
	while j >= 0:
		while s[i] == j + 1:
			c += 1
			i += 1
		ans[ord(a[j]) - 97] += c
		j -= 1
	print(*ans)


from os import path
from sys import stdin, stdout
maxn = 200005
count = [[0 for j in range(26)] for i in range(maxn)]
if path.exists('inp.txt'):
	stdin = open('inp.txt', 'r')
q = int(stdin.readline())
for _ in range(q):
	(n, m) = map(int, stdin.readline().split())
	inp = stdin.readline().split()
	s = inp[0]
	a = list(map(int, stdin.readline().split()))
	ans = [0 for i in range(26)]
	for i in range(len(s)):
		for j in range(26):
			count[i][j] = 0
	for i in range(len(s)):
		for j in range(26):
			count[i][j] = count[i - 1][j]
			if ord(s[i]) - ord('a') == j:
				count[i][j] += 1
	for i in a:
		for j in range(26):
			ans[j] += count[i - 1][j]
	for i in range(26):
		ans[i] += count[n - 1][i]
	print(*ans)


def solve():
	(n, m) = map(int, input().split())
	s = input()
	mistakes = list(sorted(map(int, input().split())))
	res = [0] * 26
	left = 0
	for i in range(m):
		for letter in s[left:mistakes[i]]:
			res[ord(letter) - ord('a')] += m - i
		left = mistakes[i]
	for letter in s:
		res[ord(letter) - ord('a')] += 1
	print(*res)
for _ in range(int(input())):
	solve()


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	s = input()
	p = sorted(list(map(int, input().split())))
	r = [0] * 26
	for i in s:
		r[ord(i) - 97] += 1
	prv = 0
	for (i, nxt) in enumerate(p):
		for j in range(prv, nxt):
			r[ord(s[j]) - 97] += m - i
		prv = nxt
	print(' '.join(map(str, r)))


import sys
from collections import Counter
from itertools import accumulate

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

def list2d(a, b, c):
	return [[c] * b for i in range(a)]

def list3d(a, b, c, d):
	return [[[d] * c for j in range(b)] for i in range(a)]

def list4d(a, b, c, d, e):
	return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]

def ceil(x, y=1):
	return int(-(-x // y))

def INT():
	return int(input())

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

def LIST(N=None):
	return list(MAP()) if N is None else [INT() for i in range(N)]

def Yes():
	print('Yes')

def No():
	print('No')

def YES():
	print('YES')

def NO():
	print('NO')
INF = 10 ** 18
MOD = 10 ** 9 + 7
for _ in range(INT()):
	(N, M) = MAP()
	S = [ord(s) - 97 for s in input()]
	A = LIST()
	imos = [0] * (N + 1)
	imos[0] += 1
	imos[N] -= 1
	for a in A:
		imos[0] += 1
		imos[a] -= 1
	imos = list(accumulate(imos))
	ans = [0] * 26
	for (i, s) in enumerate(S):
		ans[s] += imos[i]
	print(*ans)


for x in range(int(input())):
	(n, m) = list(map(int, input().split()))
	s = input()
	h = list(map(int, input().split()))
	k = [0] * 26
	h.sort()
	prev = 0
	for i in range(m):
		step = h[i]
		for j in range(prev, step):
			k[ord(s[j]) - 97] += m - i
		prev = h[i]
	for i in range(n):
		k[ord(s[i]) - 97] += 1
	print(*k)


def main():
	(n, m) = map(int, input().split())
	string = str(input())
	a = list(map(int, input().split()))
	dp = [0 for _ in range(26)]
	arr = [0 for _ in range(n)]
	for i in range(len(a)):
		arr[0] += 1
		arr[a[i]] -= 1
	arr[0] += 1
	for i in range(len(arr) - 1):
		arr[i + 1] += arr[i]
	for i in range(n):
		dp[ord(string[i]) - ord('a')] += arr[i]
	for x in dp:
		print(x, end=' ')
	print()
	return

def test():
	t = int(input())
	while t:
		main()
		t -= 1
test()


import sys

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

def data_input():
	return [int(x) for x in fast_input().split()]

def binary_search(array, x):
	(left, right) = (-1, len(array))
	while left + 1 != right:
		middle = (left + right) // 2
		if array[middle] >= x:
			right = middle
		elif array[middle] < x:
			left = middle
	return right

def solve_of_problem():
	(n, m) = data_input()
	s = fast_input()
	p = sorted(data_input()) + [n]
	alp = {}
	m += 1
	for i in range(97, 123):
		alp[chr(i)] = (0, 0)
	count = 0
	for i in range(n):
		while i == p[count]:
			count += 1
			for j in range(97, 123):
				alp[chr(j)] = (alp[chr(j)][0] + alp[chr(j)][1], alp[chr(j)][1])
		alp[s[i]] = (alp[s[i]][0] + 1, alp[s[i]][1] + 1)
	ans = []
	for i in range(97, 123):
		ans.append(str(alp[chr(i)][0]))
	print(' '.join(ans))
	return
for ______ in range(int(fast_input())):
	solve_of_problem()


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	a = input()
	b = [int(i) for i in input().split()]
	b.append(n)
	c = [0] * 26
	f = [0] * (n + 1)
	for i in range(m + 1):
		f[b[i] - 1] += 1
	x = f[n]
	for i in range(n - 1, -1, -1):
		x += f[i]
		c[ord(a[i]) - 97] += x
	print(*c)


q = int(input())
for _ in range(q):
	(n, m) = map(int, input().split())
	s = str(input())
	a = list(map(int, input().split()))
	a.append(n)
	step = []
	temp = [0] * 26
	for i in range(len(s)):
		num = ord(s[i]) - 97
		temp[num] += 1
		step.append(temp.copy())
	ans = [0] * 26
	for i in range(m + 1):
		for j in range(26):
			ans[j] += step[a[i] - 1][j]
	print(' '.join((str(x) for x in ans)))


import sys
for _ in range(int(sys.stdin.readline().rstrip())):
	(n, m) = list(map(int, sys.stdin.readline().rstrip().split()))
	s = sys.stdin.readline().rstrip()
	p = list(map(int, sys.stdin.readline().rstrip().split()))
	chk = []
	for i in range(n):
		if i == 0:
			chk.append([0] * 26)
		else:
			chk.append(chk[i - 1].copy())
		chk[i][ord(s[i]) - ord('a')] += 1
	re = [0] * 26
	for i in p:
		for j in range(26):
			re[j] += chk[i - 1][j]
	for (idx, i) in enumerate(re):
		print(i + chk[n - 1][idx], end=' ')
	print('')


import sys
input = sys.stdin.readline
t = int(input())
for i in range(t):
	(n, m) = map(int, input().split())
	string = input()
	p = [int(i) for i in input().split()]
	p.append(n)
	p.insert(0, 0)
	p.sort()
	char1 = [0] * 26
	char = [0] * 26
	for i in range(1, m + 2):
		for j in range(p[i - 1], p[i]):
			char[ord(string[j]) - 97] += 1
		for ij in range(26):
			char1[ij] += char[ij]
	print(' '.join(map(str, char1)))


from sys import maxsize, stdout, stdin, stderr
mod = int(1000000000.0 + 7)

def I():
	return int(stdin.readline())

def lint():
	return [int(x) for x in stdin.readline().split()]

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

def grid(r, c):
	return [lint() for i in range(r)]
from collections import defaultdict, Counter
import math
import heapq
from heapq import heappop, heappush
import bisect
from itertools import groupby

def gcd(a, b):
	while b:
		a %= b
		tmp = a
		a = b
		b = tmp
	return a

def lcm(a, b):
	return a / gcd(a, b) * b

def check_prime(n):
	for i in range(2, int(n ** (1 / 2)) + 1):
		if not n % i:
			return False
	return True

def Bs(a, x):
	i = 0
	j = 0
	left = 0
	right = len(a)
	flag = False
	while left < right:
		mi = (left + right) // 2
		if a[mi] <= x:
			left = mi + 1
			i += 1
		else:
			right = mi
			j += 1
	if left > 0 and a[left - 1] == x:
		return (i - 1, j)
	else:
		return (-1, -1)

def nCr(n, r):
	return fact(n) / (fact(r) * fact(n - r))

def fact(n):
	res = 1
	for i in range(2, n + 1):
		res = res * i
	return res
t = I()
for _ in range(t):
	(n, m) = lint()
	s = input()
	p = lint()
	p.sort()
	a = []
	d = defaultdict(lambda : 0)
	c = defaultdict(lambda : 0)
	ls = 0
	for i in p:
		d[i] += 1
		a.append(i - ls)
		ls = i
	q = 0
	tmp = a[q]
	for i in range(1, n + 1):
		if tmp == 0:
			q += 1
			while q < len(a) and a[q] == 0:
				q += 1
			if q >= len(a):
				break
			tmp = a[q]
		c[s[i - 1]] += len(a) - q
		tmp -= 1
	for i in range(n):
		c[s[i]] += 1
	for i in range(97, 123):
		print(c[chr(i)], end=' ')
	print()


t = int(input())
for _ in range(t):
	(n, m2) = map(int, input().split())
	a = list(input())
	m1 = list(map(int, input().split()))
	dm = {m1[i]: 0 for i in range(m2)}
	for i in range(m2):
		dm[m1[i]] += 1
	m = set(m1)
	d = {chr(i): 0 for i in range(97, 123)}
	d2 = {chr(i): 0 for i in range(97, 123)}
	for i in range(n):
		if i + 1 not in m:
			d2[a[i]] += 1
			d[a[i]] += 1
		else:
			d[a[i]] += 1
			for j in d:
				d2[j] += dm[i + 1] * d[j]
			d2[a[i]] += 1
	for k in d2:
		print(d2[k], end=' ')
	print()


from collections import defaultdict
from sys import stdin

def convert(char):
	return ord(char) - 97
for _ in range(int(stdin.readline())):
	ans = [0 for i in range(26)]
	(n, m) = map(int, stdin.readline().split())
	s = input()
	p = list(map(int, stdin.readline().split()))
	strings = defaultdict(list)
	temp = [0 for i in range(26)]
	for i in range(n):
		temp[convert(s[i])] += 1
		strings[i] = tuple(temp)
	for i in p:
		for j in range(26):
			ans[j] += strings[i - 1][j]
	for i in range(26):
		ans[i] += strings[n - 1][i]
	print(*ans)


def main(n, m, s, p):
	count = [0] * 26
	p.append(n)
	log = [0] * n
	c = 0
	m = m + 1
	for i in range(m):
		log[p[i] - 1] += 1
	for i in range(n):
		if log[i] > 0:
			c += log[i]
			temp = m - c + log[i]
			log[i] = temp
			continue
		log[i] = m - c
	for i in range(n):
		count[ord(s[i]) - 97] += log[i]
	return count
k = int(input())
for _ in range(k):
	(n, m) = map(int, input().split())
	s = input()
	p = list(map(int, input().split()))
	res = main(n, m, s, p)
	print(*res, sep=' ')


from bisect import bisect_right as br
I = lambda : map(int, input().split())
k = {}
for i in range(97, 123):
	k[chr(i)] = 0
for i in range(int(input())):
	z = dict(k)
	(n, m) = I()
	s = input()
	p = list(I())
	p.sort()
	r = ''
	m += 1
	for j in range(n):
		z[s[j]] += m - br(p, j)
	for i in z:
		r += str(z[i]) + ' '
	print(r)


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	s = input()
	p = list(map(int, input().split()))
	ans = [0 for i in range(26)]
	for i in s:
		ans[ord(i) - ord('a')] += 1
	freq = [[0 for i in range(n + 1)] for j in range(26)]
	for i in range(1, n + 1):
		freq[ord(s[i - 1]) - ord('a')][i] += 1
		for j in range(26):
			freq[j][i] += freq[j][i - 1]
	for i in p:
		for j in range(26):
			ans[j] += freq[j][i]
	print(*ans)


from typing import List
import collections
import bisect
import itertools
import functools
from collections import defaultdict
import collections
from fractions import gcd
import heapq
from math import ceil, sqrt
import sys
sys.setrecursionlimit(50000)
from collections import defaultdict
t = int(input())
for _ in range(t):
	(n, m) = list(map(int, input().split()))
	s = input()
	p = list(map(int, input().split()))
	sub_sum = [[0] * 26 for j in range(n + 1)]
	for (i, c) in enumerate(s):
		for j in range(26):
			sub_sum[i + 1][j] = sub_sum[i][j]
		sub_sum[i + 1][ord(c) - ord('a')] += 1
	total_sum = [0] * 26
	for pos in p:
		for j in range(26):
			total_sum[j] += sub_sum[pos][j]
	for c in s:
		total_sum[ord(c) - ord('a')] += 1
	print(' '.join([str(t) for t in total_sum]))


from sys import stdin
t = int(stdin.readline())
while t:
	t -= 1
	(n, m) = map(int, stdin.readline().split())
	s = input()
	p = list(map(int, stdin.readline().split()))
	pref = [0] * n
	for e in p:
		pref[e - 1] += 1
	for i in range(n - 2, -1, -1):
		pref[i] += pref[i + 1]
	r = [0] * 26
	for i in range(n):
		r[ord(s[i]) - 97] += pref[i] + 1
	print(*r)


from sys import stdin

def solve():
	(n, m) = map(int, input().split())
	s = input()
	ml = list(map(int, input().split()))
	ml.append(n)
	ml.sort(reverse=True)
	prev = 0
	ans = [0] * 26
	for i in range(m, -1, -1):
		for j in range(prev, ml[i]):
			ans[ord(s[j]) - ord('a')] += i + 1
		prev = ml[i]
	print(*ans)
for i in range(int(input())):
	solve()


import string
t = int(input())
for i in range(t):
	(n, m) = map(int, input().split())
	s = input()
	p = list(map(int, input().split()))
	p.sort()
	j = 0
	a = 0
	d = dict.fromkeys(string.ascii_lowercase, 0)
	for j in range(m):
		if a == p[j]:
			pass
		else:
			for k in range(a, p[j]):
				d[s[k]] += m + 1 - j
		a = p[j]
	if p[m - 1] == n:
		pass
	else:
		for k in range(p[m - 1], n):
			d[s[k]] += 1
	ans = list(d.values())
	print(*ans)


from collections import Counter
for _ in range(0, int(input())):
	(n, m) = map(int, input().split())
	L = input()
	arr = list(map(int, input().split()))
	arr.sort()
	Seq = list(map(chr, range(ord('a'), ord('z') + 1)))
	Dict = {}
	Dict = Dict.fromkeys(Seq, 0)
	k = 0
	for j in L:
		Dict[j] = Dict[j] + 1
	for i in range(0, m):
		for j in range(k, arr[i]):
			Dict[L[j]] = Dict[L[j]] + m - i
		k = arr[i]
	res = Dict.values()
	for i in res:
		print(i, end=' ')
	print()


t = int(input())
for i in range(t):
	a = input().split()
	for i in range(len(a)):
		a[i] = int(a[i])
	arr = input()
	p = input().split()
	for i in range(len(p)):
		p[i] = int(p[i])
	final = [0 for i in range(26)]
	arr1 = [0 for i in range(len(arr) + 1)]
	for i in range(len(p)):
		arr1[p[i] + 1] = arr1[p[i] + 1] - 1
	arr1[0] = len(p)
	for i in range(1, len(arr1)):
		arr1[i] = arr1[i - 1] + arr1[i]
	j = 0
	for i in range(len(arr)):
		final[ord(arr[j]) - 97] += arr1[i + 1]
		j += 1
	for i in arr:
		final[ord(i) - 97] += 1
	for i in range(26):
		print(final[i], end=' ')
	print()


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	s = input()
	a = [0 for i in range(26)]
	p = list(map(int, input().split()))
	p.append(len(s))
	l = [0 for i in range(len(s))]
	for i in range(len(p)):
		l[p[i] - 1] += 1
	m = 0
	for i in range(len(l) - 1, -1, -1):
		m += l[i]
		l[i] = m
	for i in range(len(s)):
		c = ord(s[i]) - 97
		a[c] += l[i]
	print(*a)


import os
from io import BytesIO, IOBase
import sys
from collections import defaultdict, deque, Counter
from bisect import *
from math import sqrt, pi
import math
from itertools import permutations
from copy import deepcopy

def main():
	for t in range(int(input())):
		(n, m) = map(int, input().split())
		a = input().rstrip()
		d = [0] * n
		for i in input().split():
			d[int(i) - 1] += 1
		for i in range(n - 2, -1, -1):
			d[i] += d[i + 1]
		z = [0] * 26
		for (i, v) in enumerate(a):
			z[ord(v) - 97] += d[i] + 1
		print(*z)
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
main()


from collections import defaultdict
for _ in range(int(input())):
	(n, m) = map(int, input().split())
	(s, p) = (input(), list(map(lambda x: int(x) - 1, input().split())))
	p.sort()
	p += [n - 1]
	(j, cc) = (0, defaultdict(int))
	for i in range(len(s)):
		while j < len(p) and p[j] < i:
			j += 1
		cc[s[i]] += m - j + 1
	res = [cc[chr(ord('a') + i)] for i in range(26)]
	print(*res)


import sys
input = sys.stdin.readline
read = lambda : map(int, input().split())
read_float = lambda : map(float, input().split())

def ceil(x):
	if x != int(x):
		x = int(x) + 1
	return x

def factorial(x, m):
	val = 1
	while x > 0:
		val = val * x % m
		x -= 1
	return val

def fact(x):
	val = 1
	while x > 0:
		val *= x
		x -= 1
	return val

def swaparr(arr, a, b):
	temp = arr[a]
	arr[a] = arr[b]
	arr[b] = temp

def gcd(a, b):
	if b == 0:
		return a
	return gcd(b, a % b)

def lcm(a, b):
	return a * b // math.gcd(a, b)

def nCr(n, k):
	if k > n:
		return 0
	if k > n - k:
		k = n - k
	res = 1
	for i in range(k):
		res = res * (n - i)
		res = res / (i + 1)
	return int(res)

def primefs(n):
	primes = {}
	while n % 2 == 0 and n > 0:
		primes[2] = primes.get(2, 0) + 1
		n = n // 2
	for i in range(3, int(n ** 0.5) + 2, 2):
		while n % i == 0 and n > 0:
			primes[i] = primes.get(i, 0) + 1
			n = n // i
	if n > 2:
		primes[n] = primes.get(n, 0) + 1
	return primes

def power(x, y, p):
	res = 1
	x = x % p
	if x == 0:
		return 0
	while y > 0:
		if y & 1 == 1:
			res = res * x % p
		y = y >> 1
		x = x * x % p
	return res

def swap(a, b):
	temp = a
	a = b
	b = temp
	return (a, b)

def find(x, link):
	p = x
	while p != link[p]:
		p = link[p]
	while x != p:
		nex = link[x]
		link[x] = p
		x = nex
	return p

def union(x, y, link, size):
	x = find(x, link)
	y = find(y, link)
	if size[x] < size[y]:
		(x, y) = swap(x, y)
	if x != y:
		size[x] += size[y]
		link[y] = x

def sieve(n):
	prime = [True for i in range(n + 1)]
	(prime[0], prime[1]) = (False, False)
	p = 2
	while p * p <= n:
		if prime[p] == True:
			for i in range(p * p, n + 1, p):
				prime[i] = False
		p += 1
	return prime

def phi(n):
	result = n
	p = 2
	while p * p <= n:
		if n % p == 0:
			while n % p == 0:
				n = n // p
			result = result * (1.0 - 1.0 / float(p))
		p = p + 1
	if n > 1:
		result = result * (1.0 - 1.0 / float(n))
	return int(result)

def is_prime(n):
	if n == 0:
		return False
	if n == 1:
		return True
	for i in range(2, int(n ** (1 / 2)) + 1):
		if not n % i:
			return False
	return True
MAXN = int(100000.0 + 5)

def spf_sieve():
	spf[1] = 1
	for i in range(2, MAXN):
		spf[i] = i
	for i in range(4, MAXN, 2):
		spf[i] = 2
	for i in range(3, ceil(MAXN ** 0.5), 2):
		if spf[i] == i:
			for j in range(i * i, MAXN, i):
				if spf[j] == j:
					spf[j] = i
spf = [0 for i in range(MAXN)]

def factoriazation(x):
	res = []
	for i in range(2, int(x ** 0.5) + 1):
		while x % i == 0:
			res.append(i)
			x //= i
	if x != 1:
		res.append(x)
	return res

def factors(n):
	res = []
	for i in range(1, int(n ** 0.5) + 1):
		if n % i == 0:
			res.append(i)
			res.append(n // i)
	return list(set(res))

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

def float_array():
	return list(map(float, input().strip().split()))

def str_array():
	return input().strip().split()

def binary_search(low, high, w, h, n):
	while low < high:
		mid = low + (high - low) // 2
		if check(mid, w, h, n):
			low = mid + 1
		else:
			high = mid
	return low

def check(l, ps, n, t):
	for i in range(n - l + 1):
		if ps[i + l] - ps[i] <= t:
			return True
	return False
MOD = int(1000000000.0) + 7
CMOD = 998244353
INF = float('inf')
NINF = -float('inf')
from itertools import permutations
import math
import bisect as bis
import random
import sys

def solve():
	(n, m) = read()
	s = input().rstrip()
	p = list(read())
	p.sort()
	char = [0] * 26
	for i in range(n):
		j = bis.bisect_left(p, i + 1)
		char[ord(s[i]) - ord('a')] += len(p) - j
	for x in s:
		char[ord(x) - ord('a')] += 1
	print(*char)
for _ in range(int(input())):
	solve()


from sys import stdin, stdout
for _ in range(int(stdin.readline())):
	(n, m) = list(map(int, stdin.readline().split()))
	s = input()
	d = [0] * (n + 1)
	a = list(map(int, stdin.readline().split()))
	for v in a:
		d[0] += 1
		d[v] -= 1
	for i in range(1, n):
		d[i] += d[i - 1]
	freq = {}
	for i in range(n):
		freq[s[i]] = freq.get(s[i], 0) + d[i] + 1
	for ch in range(97, 123):
		f = freq.get(chr(ch), 0)
		stdout.write(str(f) + ' ')
	print()


T = int(input())
for case in range(T):
	(n, m) = map(int, input().strip().split())
	s = input().strip()
	p = list(map(int, input().strip().split()))
	pre = [0] * (n + 2)
	for x in p:
		pre[1] += 1
		pre[x + 1] -= 1
	pre[1] += 1
	pre[n + 1] -= 1
	for i in range(1, n + 1):
		pre[i] += pre[i - 1]
	cnt = [0] * 26
	for i in range(1, n + 1):
		id = ord(s[i - 1]) - ord('a')
		cnt[id] += pre[i]
	for x in cnt:
		print(x, end=' ')
	print()


from bisect import *
t = int(input())
for i in range(t):
	d = {}
	a = []
	for i in range(26):
		a.append(0)
	(n, m) = map(int, input().split(' '))
	s = input()
	l = list(map(int, input().split(' ')))
	l.append(n)
	l.sort()
	for i in range(len(s)):
		x = bisect_left(l, i + 1, 0, len(l))
		if l[x - 1] != i + 1:
			x += 1
		a[ord(s[i]) - 97] += len(l) - x + 1
	print(*a)


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	s = input()
	a = [0 for i in range(26)]
	p = list(map(int, input().split()))
	d = [0 for i in range(n)]
	for i in range(n):
		a[ord(s[i]) - 97] += 1
	for i in range(m):
		d[p[i] - 1] += 1
	c = 0
	for i in range(n - 1, -1, -1):
		if c == 0 and d[i] == 0:
			d[i] = 0
		elif c == 0 and d[i] != 0:
			c = d[i]
		elif c != 0 and d[i] == 0:
			d[i] = c
		else:
			d[i] = d[i] + c
			c = d[i]
	for i in range(n):
		a[ord(s[i]) - 97] += d[i]
	print(' '.join(map(str, a)))


t = int(input())
for _ in range(t):
	(n, m) = list(map(int, input().split()))
	s = input()
	pref = [0] * n
	p = list(map(int, input().split()))
	for i in p:
		pref[i - 1] += 1
	for i in reversed(range(1, n)):
		pref[i - 1] += pref[i]
	a = [0] * 26
	for i in range(n):
		a[ord(s[i]) - 97] += pref[i]
		a[ord(s[i]) - 97] += 1
	for i in a:
		print(i, end=' ')
	print()


t = int(input())
for T in range(t):
	(n, m) = list(map(int, input().split()))
	s = input()
	charsright = list(map(int, input().split()))
	char_dict = dict()
	test_list = []
	alpha = 'a'
	for i in range(0, 26):
		test_list.append(alpha)
		alpha = chr(ord(alpha) + 1)
	for i in test_list:
		char_dict[i] = [0] * n
	count_dict = dict()
	for i in test_list:
		count_dict[i] = 0
	for i in range(len(s)):
		count_dict[s[i]] += 1
		char_dict[s[i]][i] = count_dict[s[i]]
		for j in test_list:
			if j != s[i] and i > 0:
				char_dict[j][i] = char_dict[j][i - 1]
	ans_dict = dict()
	for i in test_list:
		ans_dict[i] = 0
	for i in range(m):
		index = charsright[i] - 1
		for j in range(26):
			ans_dict[test_list[j]] += char_dict[test_list[j]][index]
	for i in range(len(s)):
		ans_dict[s[i]] += 1
	ans = []
	for i in ans_dict:
		ans.append(ans_dict[i])
	print(*ans)


for _ in range(int(input())):
	(n, m) = [int(i) for i in input().split()]
	(alpha, frequencies) = ([0] * 26, [0] * n)
	s = input()
	p = [int(i) for i in input().split()]
	for i in range(m):
		frequencies[p[i] - 1] += 1
	frequencies[n - 1] = 1
	for i in range(n - 1, 0, -1):
		frequencies[i - 1] += frequencies[i]
	for i in range(n):
		alpha[ord(s[i]) - 97] += frequencies[i]
	print(*alpha, sep=' ')


def fact(x):
	if x == 0:
		return 1
	else:
		return x * fact(x - 1)

def lower_bound(li, num):
	answer = -1
	start = 0
	end = len(li) - 1
	while start <= end:
		middle = (end + start) // 2
		if li[middle] >= num:
			answer = middle
			end = middle - 1
		else:
			start = middle + 1
	return answer

def upper_bound(li, num):
	answer = -1
	start = 0
	end = len(li) - 1
	while start <= end:
		middle = (end + start) // 2
		if li[middle] <= num:
			answer = middle
			start = middle + 1
		else:
			end = middle - 1
	return answer

def abs(x):
	return x if x >= 0 else -x

def binary_search(li, val, lb, ub):
	ans = 0
	while lb <= ub:
		mid = (lb + ub) // 2
		if li[mid] > val:
			ub = mid - 1
		elif val > li[mid]:
			lb = mid + 1
		else:
			ans = 1
			break
	return ans

def sieve_of_eratosthenes(n):
	ans = []
	arr = [1] * (n + 1)
	(arr[0], arr[1], i) = (0, 0, 2)
	while i * i <= n:
		if arr[i] == 1:
			j = i + i
			while j <= n:
				arr[j] = 0
				j += i
		i += 1
	for k in range(n):
		if arr[k] == 1:
			ans.append(k)
	return ans

def nc2(x):
	if x == 1:
		return 0
	else:
		return x * (x - 1) // 2

def kadane(x):
	sum_so_far = 0
	current_sum = 0
	for i in x:
		current_sum += i
		if current_sum < 0:
			current_sum = 0
		else:
			sum_so_far = max(sum_so_far, current_sum)
	return sum_so_far

def mex(li):
	check = [0] * 1001
	for i in li:
		check[i] += 1
	for i in range(len(check)):
		if check[i] == 0:
			return i

def sumdigits(n):
	ans = 0
	while n != 0:
		ans += n % 10
		n //= 10
	return ans
from math import *
from collections import deque
max_steps = 100005
for _ in range(int(input())):
	(n, m) = map(int, input().split())
	st = input()
	a = list(map(int, input().split()))
	li = [0] * (len(st) + 1)
	li[0] = m + 1
	for i in a:
		li[i] -= 1
	for i in range(1, len(li)):
		li[i] += li[i - 1]
	char = [0] * 26
	for i in range(len(st)):
		char[ord(st[i]) - 97] += li[i]
	print(*char)


from collections import Counter
import bisect
for _ in range(int(input())):
	count = {chr(ord('a') + i): 0 for i in range(26)}
	summ = {chr(ord('a') + i): 0 for i in range(26)}
	(n, m) = map(int, input().split())
	s = input()
	p = list(map(int, input().split()))
	p.sort()
	for i in range(n):
		ind = bisect.bisect_right(p, i)
		if m - ind > 0:
			summ[s[i]] += m - ind
		count[s[i]] += 1
	for j in summ:
		print(summ[j] + count[j], end=' ')
	print()


import string
n = int(input())
d = dict()
d_reverse = dict()
d_ans = dict()
lst = string.ascii_lowercase
for i in range(n):
	for u in range(len(lst)):
		d[lst[u]] = u
		d_reverse[u] = lst[u]
		d_ans[lst[u]] = 0
	str_ans = ''
	ans = 0
	(a, b) = map(int, input().split())
	s = input()
	str_ = []
	for sd in s:
		str_.append(0)
	tries = list(map(int, input().split()))
	for h in tries:
		if h != 0:
			str_[h - 1] += 1
	str_[len(str_) - 1] = 1
	for j in range(1, len(str_)):
		str_[len(str_) - 1 - j] = str_[len(str_) - j] + str_[len(str_) - 1 - j]
	for k in range(len(str_)):
		charac = s[k]
		d_ans[charac] += str_[k]
	for h in list(string.ascii_lowercase):
		str_ans += str(d_ans[h]) + ' '
	print(str_ans)


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	s = input()
	p = list(map(int, input().split()))
	chars = 'abcdefghijklmnopqrstuvwxyz'
	ans = {}
	for c in chars:
		ans[c] = 0
	dp = [ans.copy()]
	for i in range(n):
		new = dp[-1].copy()
		new[s[i]] += 1
		dp.append(new)
	for i in p:
		for (c, v) in dp[i].items():
			ans[c] += v
	for (c, v) in dp[-1].items():
		ans[c] += v
	print(' '.join(map(str, ans.values())))


for _ in range(int(input())):
	(a, b) = map(int, input().split())
	l = list(input())
	a = list(map(int, input().split()))
	alpha = [0] * 26
	a = sorted(a)
	prev = 0
	for i in range(len(l)):
		flag = 0
		for j in range(prev, len(a)):
			if i <= a[j] - 1:
				prev = j
				flag = 1
				break
		if flag == 1:
			alpha[ord(str(l[i])) - 97] += len(a) - j
	for i in range(len(l)):
		alpha[ord(str(l[i])) - 97] += 1
	for i in alpha:
		print(i, end=' ')
	print(' ')


from math import *
from collections import *
from functools import *
from bisect import *
from itertools import *
from heapq import *
inf = float('inf')
ninf = -float('inf')
ip = input
alphal = 'abcdefghijklmnopqrstuvwxyz'
alphau = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
mod = 10 ** 9 + 7

def ipl():
	return list(map(int, ip().split()))

def ipn():
	return int(ip())

def ipf():
	return float(ip())

def solve():
	(n, m) = ipl()
	s = ip()
	p = ipl()
	h = [0] * n
	for i in p:
		if i < n:
			h[i] -= 1
	r = [0] * 26
	c = m
	for (e, i) in enumerate(s):
		c += h[e]
		r[alphal.index(i)] += 1 + c
	for i in r:
		print(i, end=' ')
	print()
t = ipn()
for _ in range(t):
	solve()


ans = []
empt = [0 for i in range(26)]
s = 'abcdefghijklmnopqrstuvwxyz'
pos = {s[i]: i for i in range(26)}
for t in range(int(input())):
	[n, m] = [int(i) for i in input().split()]
	seq = input()
	err = [int(i) - 1 for i in input().split()]
	freq = {}
	for i in err:
		if i in freq:
			freq[i] += 1
		else:
			freq[i] = 1
	dp = [0 for i in range(n)]
	dp[n - 1] = 1
	for i in range(n - 2, -1, -1):
		dp[i] = dp[i + 1]
		if i in freq:
			dp[i] += freq[i]
	a = empt + []
	for i in range(n):
		a[pos[seq[i]]] += dp[i]
	ans.append(' '.join([str(i) for i in a]))
print('\n'.join(ans))


t = int(input())
for _ in range(t):
	(n, m) = tuple((int(i) for i in input().split(' ')))
	s = [ord(i) for i in input()]
	p = [int(i) for i in input().split(' ')]
	numbers = [0 for i in range(n)]
	max = 0
	for i in range(m):
		numbers[p[i] - 1] += 1
		if p[i] > max:
			max = p[i]
	p = []
	for i in range(max):
		if numbers[i] > 0:
			p += [i + 1]
	letters = [0] * 26
	l = 0
	for i in range(n):
		letters[s[i] - 97] += m + 1
		if l < len(p) and i + 1 == p[l]:
			m -= numbers[p[l] - 1]
			l += 1
	ans = []
	for i in letters:
		ans.append(str(i))
	print(' '.join(ans))


t = int(input())
for i in range(t):
	(n, m) = map(int, input().split())
	ans = []
	a = input()
	l = list(map(int, input().split()))
	a = list(a)
	for j in range(26):
		ans.append(0)
	di = {}
	for j in range(26):
		ma = 0
		di[chr(j + 97)] = []
		for k in range(n):
			if a[k] == chr(97 + j):
				ma += 1
			di[chr(j + 97)].append(ma)
	for j in range(m):
		for k in range(26):
			ans[k] += di[chr(k + 97)][l[j] - 1]
	for j in range(26):
		if j < 25:
			print(ans[j] + di[chr(j + 97)][n - 1], end=' ')
		else:
			print(ans[j] + di[chr(j + 97)][n - 1])


import math
import sys
from collections import defaultdict, Counter
from itertools import groupby
rt = lambda : map(int, input().split())
ri = lambda : int(input())
rl = lambda : list(map(int, input().split()))

def main():
	t = ri()
	for _ in range(t):
		(n, m) = rt()
		s = input()
		p = rl()
		pref = [[0] * 26 for _ in range(n)]
		for i in range(n):
			if i > 0:
				for j in range(26):
					pref[i][j] += pref[i - 1][j]
			pref[i][ord(s[i]) - ord('a')] += 1
		all = pref[-1].copy()
		for i in range(m):
			for j in range(26):
				all[j] += pref[p[i] - 1][j]
		print(*all)
main()


numTest = int(input())
for test in range(numTest):
	(n, m) = map(int, input().split())
	s = input()
	p = list(map(int, input().split()))
	cnt = [0] * (n + 2)
	cnt[n] += 1
	for x in p:
		cnt[x] += 1
	for x in range(n, 0, -1):
		cnt[x] += cnt[x + 1]
	res = [0] * 27
	for i in range(n):
		res[ord(s[i]) - ord('a')] += cnt[i + 1]
	for i in range(26):
		print(res[i], end=' ')
	print('')


t = int(input())
for k in range(t):
	(n, m) = list(map(int, input().split(' ')))
	s = input()
	a = list(map(int, input().split(' ')))
	a.append(n)
	r = [0] * 26
	s = list(s)
	z = m + 1
	p = 0
	a.sort()
	for i in range(0, m + 1, 1):
		x = a[i]
		for j in range(p, x, 1):
			y = ord(s[j])
			r[y - 97] += z
		p = x
		z -= 1
	for i in range(0, len(r) - 1, 1):
		print(r[i], end=' ')
	print(r[25])


def bin_s(el, m, a):
	if a[0] > el:
		return 0
	if a[m - 1] <= el:
		return m
	left = 0
	right = m
	while left + 1 != right:
		mid = (left + right) // 2
		if a[mid] > el:
			right = mid
		if a[mid] <= el:
			left = mid
	return right
t = int(input())
st = 'abcdefghijklmnopqrstuvwxyz'
for q in range(t):
	(n, m) = map(int, input().split())
	s = input()
	p = [int(s) for s in input().split()]
	ABC = [0] * 27
	p.sort()
	for i in range(0, n):
		ABC[ord(s[i]) % 26] += m - bin_s(i, m, p) + 1
	for i in st:
		print(ABC[ord(i) % 26], end=' ')
	print()


t = int(input())
for i in range(t):
	(n, m) = map(int, input().split())
	s = input()
	swa = list(map(int, input().split()))
	swa.sort()
	ret = [0] * 26
	the = (n + 1) * [0]
	for j in range(m):
		the[swa[j]] += 1
	for j in range(n):
		c = ord(s[j]) - 97
		a = m - the[j] + 1
		ret[c] += a
		the[j + 1] += the[j]
	print(*ret)


from collections import Counter
from collections import defaultdict
import math
import random
import heapq as hq
from math import sqrt
import sys
from functools import reduce

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

def iinput():
	return int(input())

def tinput():
	return input().split()

def rinput():
	return map(int, tinput())

def rlinput():
	return list(rinput())
mod = int(1000000000.0) + 7

def factors(n):
	return set(reduce(list.__add__, ([i, n // i] for i in range(1, int(n ** 0.5) + 1) if n % i == 0)))
for _ in range(iinput()):
	(n, m) = rinput()
	s = input()
	p = rlinput()
	dp = [[0 for i in range(26)] for i in range(n)]
	dp[0][ord(s[0]) - 97] += 1
	for i in range(1, n):
		for j in range(26):
			dp[i][j] = dp[i - 1][j]
		dp[i][ord(s[i]) - 97] += 1
	ans = [0] * 26
	for i in range(m):
		for j in range(26):
			ans[j] += dp[p[i] - 1][j]
	for i in range(26):
		ans[i] += dp[n - 1][i]
	print(' '.join(map(str, ans)))


import math
q = int(input())
for _ in range(q):
	(n, m) = map(int, input().split())
	s = input()
	p = list(map(int, input().split()))
	count = [0] * n
	for i in range(m):
		count[p[i] - 1] += 1
	for i in range(n - 1, 0, -1):
		count[i - 1] += count[i]
	ans = [0] * 26
	for i in range(n):
		ans[ord(s[i]) - 97] += count[i] + 1
	print(*ans)


for t in range(int(input())):
	D = dict()
	cnt = dict()
	(n, m) = map(int, input().split())
	s = input()
	L = list(map(int, input().split()))
	L.sort()
	if L[-1] != n:
		L.append(n)
	for i in range(L[0]):
		try:
			cnt[ord(s[i]) - ord('a')] += 1
		except:
			cnt[ord(s[i]) - ord('a')] = 1
	for i in cnt:
		try:
			D[i] += cnt[i]
		except:
			D[i] = cnt[i]
	last = L[0]
	for j in range(1, len(L)):
		if last < L[j]:
			for i in range(last, L[j]):
				try:
					cnt[ord(s[i]) - ord('a')] += 1
				except:
					cnt[ord(s[i]) - ord('a')] = 1
		for i in cnt:
			try:
				D[i] += cnt[i]
			except:
				D[i] = cnt[i]
		last = L[j]
	for i in range(26):
		try:
			print(D[i], end=' ')
		except:
			print(0, end=' ')
	print()


T = int(input())

def solve():
	[N, M] = list(map(int, input().split()))
	S = input()
	P = list(map(int, input().split()))
	P = sorted(P)
	count = {}
	for i in range(26):
		count[chr(ord('a') + i)] = 0
	p_index = 0
	for i in range(N):
		while p_index < len(P) and P[p_index] <= i:
			p_index += 1
		count[S[i]] += 1 + (M - p_index)
	ans = []
	for i in range(26):
		ans.append(str(count[chr(ord('a') + i)]))
	return ' '.join(ans)
for _ in range(T):
	print(solve())


from sys import stdin, stdout
import traceback
from collections import Counter
read = stdin.readline
write = stdout.write
writeln = lambda x: write(str(x) + '\n')

def reads(typ=int):
	return list(map(typ, read().split()))

class Sol:

	def __init__(self, s, pp):
		self.s = s
		self.pp = pp
		self.n = len(self.s)

	@classmethod
	def input(cls):
		(n, m) = reads()
		s = read().strip()
		pp = reads()
		return cls(s, pp)

	def cum_count(self, counter):
		vsum = 0
		counts = sorted(counter.items())
		for (k, v) in reversed(counts):
			vsum += v
			counter[k] = vsum
		return counter

	def solve(self):
		self.pp.append(len(self.s))
		count_p = Counter(self.pp)
		count_p = self.cum_count(count_p)
		ret = [0] * 26
		last = 0
		for (p, times) in sorted(count_p.items()):
			for c in self.s[last:p]:
				ret[ord(c) - ord('a')] += times
			last = p
		return ret
try:
	for _ in range(int(read())):
		res = Sol.input().solve()
		writeln(' '.join([str(r) for r in res]))
except Exception as e:
	print('Got exception:', repr(e))
	print(traceback.format_exc())


t = int(input())
test_cases = [[input() for j in range(3)] for i in range(t)]
P = []

def binary_search(ok, ng, func):
	while abs(ok - ng) > 1:
		mid = (ok + ng) // 2
		if func(mid):
			ok = mid
		else:
			ng = mid
	return ok

def solve(test_case):
	(n, m) = map(int, test_case[0].split())
	s = test_case[1]
	P = list(map(int, test_case[2].split()))
	P.sort(reverse=True)
	P.append(-1)
	s_arr = [ord(c) - ord('a') for c in s]
	ans = [0 for i in range(26)]
	for i in range(n):
		k = binary_search(-1, m, lambda x: P[x] >= i + 1)
		ans[s_arr[i]] += k + 2
	print(' '.join(map(str, ans)))
for test_case in test_cases:
	solve(test_case)


from collections import *
for _ in range(int(input())):
	(n, m) = map(int, input().split())
	s = input()
	p = list(map(int, input().split()))
	d = {}
	for i in range(26):
		d[i] = [0]
	for i in range(n):
		o = int(ord(s[i]) - 97)
		for j in range(26):
			if j == o:
				d[j].append(d[j][-1] + 1)
			else:
				d[j].append(d[j][-1])
	sn = [0] * 26
	for i in range(m):
		k = p[i]
		for j in range(26):
			sn[j] += d[j][k]
	for j in range(26):
		sn[j] += d[j][n]
	print(*sn)


target = 'abcdefghijklmnopqrstuvwxyz'
for _ in range(int(input())):
	(n, m) = map(int, input().split())
	s = input()
	l = list(map(int, input().split()))
	p = [0] * n
	for i in l:
		p[i] -= 1
	p[0] = m
	for i in range(1, n):
		p[i] += p[i - 1]
	for i in range(n):
		p[i] += 1
	d = dict()
	for i in range(n):
		if s[i] not in d:
			d[s[i]] = 0
		d[s[i]] += p[i]
	for i in target:
		if i not in d:
			d[i] = 0
		print(d[i], end=' ')
	print()


def getIn():
	return input().strip()
t = int(getIn())
for _ in range(t):
	(n, m) = list(map(int, getIn().split(' ')))
	s = getIn()
	marr = list(map(int, getIn().split(' ')))
	abcd = [0 for i in range(26)]
	bigshit = [[0 for j in range(n)] for i in range(26)]
	for i in range(len(s)):
		c = ord(s[i]) - 97
		for j in range(26):
			if i > 0:
				bigshit[j][i] = bigshit[j][i - 1]
		bigshit[c][i] += 1
	for ind in marr:
		for i in range(26):
			abcd[i] += bigshit[i][ind - 1]
	for i in range(26):
		abcd[i] += bigshit[i][n - 1]
	for ii in abcd:
		print(ii, end=' ')
	print()


from collections import Counter

def go():
	(n, m) = map(int, input().split())
	s = input()
	p = sorted(map(int, input().split()))
	p.append(n + 1)
	count = Counter(s)
	j = -1
	for (i, k) in enumerate(s):
		while p[j + 1] <= i:
			j += 1
		count[k] += m - j - 1
	result = ' '.join([str(count[let]) for let in 'abcdefghijklmnopqrstuvwxyz'])
	return result
t = int(input())
ans = []
for _ in range(t):
	ans.append(str(go()))
print('\n'.join(ans))


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	s = input()
	l = list(map(int, input().split()))
	c = {}
	d = [0 for _ in range(26)]
	for i in l:
		if i in c:
			c[i] += 1
		else:
			c[i] = 1
	su = [0 for _ in s]
	su[-1] = 1
	for i in range(1, len(s)):
		if len(s) - i in c:
			su[len(s) - i - 1] += su[len(s) - i] + c[len(s) - i]
		else:
			su[len(s) - i - 1] += su[len(s) - i]
	for i in range(len(su)):
		d[ord(s[i]) - ord('a')] += su[i]
	print(*d)


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	s = input()
	l = [int(x) for x in input().split()]
	l.sort()
	d = {'a': 0, 'b': 0, 'c': 0, 'd': 0, 'e': 0, 'f': 0, 'g': 0, 'h': 0, 'i': 0, 'j': 0, 'k': 0, 'l': 0, 'm': 0, 'n': 0, 'o': 0, 'p': 0, 'q': 0, 'r': 0, 's': 0, 't': 0, 'u': 0, 'v': 0, 'w': 0, 'x': 0, 'y': 0, 'z': 0}
	value = m
	index = 0
	for i in range(n):
		while index < m - 1 and i > l[index] - 1:
			index += 1
			value -= 1
		d[s[i]] += value
	for i in range(0, l[m - 1]):
		d[s[i]] += 1
	print(d['a'], end=' ')
	print(d['b'], end=' ')
	print(d['c'], end=' ')
	print(d['d'], end=' ')
	print(d['e'], end=' ')
	print(d['f'], end=' ')
	print(d['g'], end=' ')
	print(d['h'], end=' ')
	print(d['i'], end=' ')
	print(d['j'], end=' ')
	print(d['k'], end=' ')
	print(d['l'], end=' ')
	print(d['m'], end=' ')
	print(d['n'], end=' ')
	print(d['o'], end=' ')
	print(d['p'], end=' ')
	print(d['q'], end=' ')
	print(d['r'], end=' ')
	print(d['s'], end=' ')
	print(d['t'], end=' ')
	print(d['u'], end=' ')
	print(d['v'], end=' ')
	print(d['w'], end=' ')
	print(d['x'], end=' ')
	print(d['y'], end=' ')
	print(d['z'], end=' ')
	print()


t = int(input())
while t:
	(n, m) = map(int, input().split())
	s = input()
	wrong = sorted(list(map(int, input().split())))
	(ans, prv) = ([0] * 26, 0)
	for (i, nxt) in enumerate(wrong):
		for j in range(prv, nxt):
			ans[ord(s[j]) - 97] += m - i
		prv = nxt
	for i in s:
		ans[ord(i) - 97] += 1
	print(*ans, sep=' ')
	t -= 1


import sys
input = sys.stdin.readline
alph = 'abcdefghijklmnopqrstuvwxyz'
to_int = {v: i for (i, v) in enumerate(alph)}
t = int(input())
for _ in range(t):
	(n, m) = list(map(int, input().split()))
	s = input()
	p = list(map(int, input().split()))
	num = [[0] * (n + 1) for i in range(26)]
	for i in range(n):
		tmp = to_int[s[i]]
		for j in range(26):
			if tmp == j:
				num[j][i + 1] = num[j][i] + 1
			else:
				num[j][i + 1] = num[j][i]
	ans = [0] * 26
	for i in range(len(ans)):
		for j in p:
			ans[i] += num[i][j]
		ans[i] += num[i][-1]
	print(*ans)


t = int(input())
dic = dict()
r = 'abcdefghijklmnopqrstuvwxyz'
for _ in range(t):
	dic = dict()
	for i in r:
		dic[i] = 0
	dicp = dict()
	ans = dict(dic)
	(n, m) = map(int, input().split())
	s = input()
	l = list(map(int, input().split()))
	for i in range(n):
		dic[s[i]] += 1
		dicp[i + 1] = dict(dic)
	for i in l:
		ch = dicp[i]
		for j in r:
			ans[j] += ch[j]
	ch = dicp[n]
	for i in r:
		ans[i] += ch[i]
	for i in r:
		print(ans[i], end=' ')
	print()


for _ in range(int(input())):
	(sl, pl) = map(int, input().split())
	s = input()
	p = map(int, input().split())
	pref = [0] * sl
	for i in p:
		pref[i - 1] += 1
	for i in range(sl - 1, 0, -1):
		pref[i - 1] += pref[i]
	ans = [0] * 26
	for i in range(sl):
		ans[ord(s[i]) - ord('a')] += pref[i] + 1
	print(*ans)


t = int(input())
while t:
	t -= 1
	(n, m) = map(int, input().split())
	a = [ord(i) - 97 for i in input()]
	p = sorted([int(i) - 1 for i in input().split()])
	k = m
	ans = [0] * 26
	ind = 0
	for i in range(n):
		ans[a[i]] += k
		if p[ind] == i:
			try:
				while p[ind] == i:
					ind += 1
					k -= 1
			except:
				break
	for i in a:
		ans[i] += 1
	print(*ans)


import sys
for _ in range(int(input())):
	(n, m) = map(int, input().split())
	s = input()
	p = list(map(int, input().split()))
	check = [0 for i in range(n + 1)]
	for i in range(m):
		check[0] += 1
		check[p[i]] -= 1
	check[0] += 1
	check[n] -= 1
	for i in range(1, n):
		check[i] = check[i] + check[i - 1]
	ans = [0 for _ in range(26)]
	for i in range(n):
		ans[ord(s[i]) - ord('a')] += check[i]
	for i in range(26):
		print(ans[i], end=' ')
	print()


def initializeDiffArray(A):
	n = len(A)
	D = [0 for i in range(0, n + 1)]
	D[0] = A[0]
	D[n] = 0
	for i in range(1, n):
		D[i] = A[i] - A[i - 1]
	return D

def update(D, l, r, x):
	D[l] += x
	D[r + 1] -= x

def printArray(A, D):
	for i in range(0, len(A)):
		if i == 0:
			A[i] = D[i]
		else:
			A[i] = D[i] + A[i - 1]
for _ in range(int(input())):
	(n, m) = map(int, input().split())
	s = input()
	a = list(map(int, input().split()))
	freq = [0] * 26
	for elem in s:
		freq[ord(elem) - ord('a')] += 1
	A = [0] * n
	D = initializeDiffArray(A)
	for elem in a:
		update(D, 0, elem - 1, 1)
	printArray(A, D)
	for i in range(n):
		freq[ord(s[i]) - ord('a')] += A[i]
	print(*freq)


T = int(input())
while T > 0:
	T -= 1
	(n, m) = map(int, input().split())
	s = input()
	d = [0 for i in range(n)]
	d[n - 1] = 1
	for i in map(int, input().split()):
		d[i - 1] += 1
	for i in range(n - 1, 0, -1):
		d[i - 1] += d[i]
	c = [0 for i in range(26)]
	for i in range(n):
		c[ord(s[i]) - 97] += d[i]
	print(*c)


a = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z']
cases = int(input())
while cases > 0:
	cases -= 1
	(n, m) = map(int, input().split())
	combo = input()
	mis = list(map(int, input().split()))
	mis.sort()
	alpha = {}
	freq = {}
	for i in range(n + 1):
		freq[i] = 0
	for mistake in mis:
		freq[mistake] += 1
	for letter in a:
		alpha[letter] = 0
	value = 1
	index = n - 1
	while index >= 0:
		value += freq[index + 1]
		alpha[combo[index]] += value
		index -= 1
	answer = ''
	for letter in a:
		answer += str(alpha[letter])
		answer += ' '
	print(answer)


def binary_search(arr, val):
	l = -1
	r = len(arr)
	while r - l > 1:
		m = l + r >> 1
		if arr[m] == val:
			return m + 1
		if arr[m] > val:
			r = m
		if arr[m] < val:
			l = m
	return -1
t = int(input())
answers = []
for ti in range(t):
	(n, m) = list(map(int, input().split()))
	s = input()
	p = list(map(int, input().split()))
	ans = [0] * 26
	a = [0] * len(s)
	for pi in p:
		a[pi - 1] += 1
	a.reverse()
	non_zero = a[0]
	for i in range(len(a)):
		a[i] += non_zero
		non_zero = a[i]
	a.reverse()
	for i in range(len(s)):
		order = ord(s[i]) - ord('a')
		ans[order] += a[i]
	for c in s:
		order = ord(c) - ord('a')
		ans[order] += 1
	answers.append(ans)
for a in answers:
	print(*a)


t = int(input())
while t:
	(n, m) = map(int, input().split())
	a = input()
	l = list(map(int, input().split()))
	p = [0] * n
	pp = [0] * 26
	for j in range(m):
		p[l[j] - 1] += 1
	x = p[n - 1]
	for j in range(n - 2, -1, -1):
		p[j] += x
		x = p[j]
	for j in range(n):
		pp[ord(a[j]) - 97] += 1 + p[j]
	print(*pp)
	t -= 1


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	s = input()
	l = list(map(int, input().split()))
	l1 = [0] * n
	temp = [0] * 26
	for i in range(m):
		l1[l[i] - 1] += 1
	for i in range(n - 2, -1, -1):
		l1[i] = l1[i + 1] + l1[i]
	for i in range(n):
		temp[ord(s[i]) - 97] += l1[i] + 1
	print(*temp)


from bisect import bisect_left as bl
from bisect import bisect_right as br
import heapq
import math
from collections import *
from functools import reduce, cmp_to_key
import sys
input = sys.stdin.readline
M = mod = 10 ** 9 + 7

def factors(n):
	return sorted(set(reduce(list.__add__, ([i, n // i] for i in range(1, int(n ** 0.5) + 1) if n % i == 0))))

def inv_mod(n):
	return pow(n, mod - 2, mod)

def li():
	return [int(i) for i in input().rstrip('\n').split(' ')]

def st():
	return input().rstrip('\n')

def val():
	return int(input().rstrip('\n'))

def li2():
	return [i for i in input().rstrip('\n').split(' ')]

def li3():
	return [int(i) for i in input().rstrip('\n')]
for _ in range(val()):
	(n, m) = li()
	s = st()
	p = li()
	l = []
	cnt = Counter()
	for i in range(n):
		cnt[s[i]] += 1
		l.append(cnt.copy())
	currcnt = Counter()
	for i in range(m):
		for j in 'abcdefghijklmnopqrstuvwxyz':
			currcnt[j] += l[p[i] - 1][j]
	for i in s:
		currcnt[i] += 1
	print(*currcnt.values())


t = int(input())
while t:
	t -= 1
	(n, m) = map(int, input().split())
	s = input().strip()
	p = list(map(int, input().split()))
	pref = [[0] * 26 for _ in range(n)]
	pref[0][ord(s[0]) - ord('a')] = 1
	for i in range(1, n):
		pref[i][ord(s[i]) - ord('a')] += 1
		for j in range(26):
			pref[i][j] += pref[i - 1][j]
	ans = [0] * 26
	for i in range(m):
		for j in range(26):
			ans[j] += pref[p[i] - 1][j]
	for j in range(26):
		ans[j] += pref[n - 1][j]
	print(' '.join(map(str, ans)))


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	s = list(input())
	p = list(map(int, input().split()))
	u = [0] * n
	t = [0] * 26
	for i in range(m):
		u[p[i] - 1] += 1
	for j in range(n - 2, -1, -1):
		u[j] += u[j + 1]
	for j in range(n):
		u[j] += 1
	for j in range(n):
		t[ord(s[j]) - ord('a')] += u[j]
	print(*t)


from sys import stdin, stdout
import math
from itertools import permutations, combinations
from collections import defaultdict

def L():
	return list(map(int, stdin.readline().split()))

def In():
	return map(int, stdin.readline().split())

def I():
	return int(stdin.readline())
P = 1000000007
for t in range(I()):
	arr = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
	(n, m) = In()
	s = input()
	lis = L()
	lis.append(n)
	lis.sort()
	arr1 = [0 for i in range(n)]
	lis = [0] + lis
	m += 2
	for i in range(1, m):
		for j in range(lis[i - 1], lis[i]):
			arr1[j] += m - i
	for i in range(n):
		arr[ord(s[i]) - 97] += arr1[i]
	print(*arr)


t = int(input())
for ii in range(t):
	(n, m) = map(int, input().split())
	l = list(input())
	p = list(map(int, input().split()))
	d = [0] * n
	for i in range(m):
		d[p[i] - 1] += 1
	d[-1] += 1
	for i in range(n - 1):
		d[n - i - 2] += d[n - i - 1]
	al = list('abcdefghijklmnopqrstuvwxyz')
	ans = [0] * 26
	for i in range(n):
		ans[al.index(l[i])] += d[i]
	print(*ans)


t = int(input())
while t > 0:
	(n, m) = map(int, input().split())
	s = input()
	p = list(map(int, input().split()))
	p.append(n)
	answer = [0] * 26
	intermediate = [0] * (n + 1)
	for x in p:
		intermediate[0] += 1
		intermediate[x] -= 1
	for i in range(1, n):
		intermediate[i] += intermediate[i - 1]
		answer[ord(s[i]) - 97] += intermediate[i]
	answer[ord(s[0]) - 97] += intermediate[0]
	for ans in answer:
		print(ans, end=' ')
	t -= 1


import string

def main():
	letters = string.ascii_lowercase
	(n, m) = map(int, input().split())
	line = input()
	p = list(map(int, input().split()))
	dct = dict()
	for i in range(1, len(line) + 1):
		dct[i] = 0
	for i in p:
		if i in dct:
			dct[i] += 1
		else:
			dct[i] = 1
	rng = sorted(dct)
	to_add = 0
	letdct = dict()
	for i in letters:
		letdct[i] = 0
	for i in range(len(rng) - 1, -1, -1):
		to_add += dct[rng[i]]
		letdct[line[rng[i] - 1]] += to_add
	for i in line:
		letdct[i] += 1
	for i in letters:
		print(letdct[i], end=' ')
	print()
t = int(input())
for i in range(t):
	main()


t = int(input())
while t:
	t -= 1
	(n, m) = map(int, input().split())
	s = input()
	where = [0] * n
	ans = [0] * 128
	for x in map(int, input().split()):
		where[x - 1] += 1
	frq = 1
	for i in range(n - 1, -1, -1):
		frq += where[i]
		ans[ord(s[i])] += frq
	for i in range(ord('a'), ord('z') + 1):
		print(ans[i], end=' ')
	print()


for _ in range(int(input())):
	d = {chr(i): 0 for i in range(97, 123)}
	(n, m) = map(int, input().split())
	s = list(input())
	l = list(map(lambda x: int(x) - 1, input().split()))
	z = [0 for i in range(n)]
	x = 0
	for i in range(m):
		z[l[i]] += 1
	x = 0
	for i in range(n - 1, -1, -1):
		if z[i] > 0:
			x += z[i]
		z[i] = x
	for i in range(n):
		d[s[i]] += z[i] + 1
	for i in d:
		print(str(d[i]) + ' ', end='')
	print()


t = int(input())
for _ in range(t):
	(n, m) = map(int, input().split())
	s = input()
	l = list(map(int, input().split()))
	ans = [0 for _ in range(n)]
	ans[n - 1] += 1
	for i in l:
		ans[i - 1] += 1
	for i in range(n - 1, 0, -1):
		ans[i - 1] += ans[i]
	res = [0 for _ in range(26)]
	c = 0
	for char in s:
		res[ord(char) - ord('a')] += ans[c]
		c += 1
	print(*res)


import string
from bisect import bisect
t = int(input())
for i in range(t):
	(n, m) = map(int, input().split())
	s = str(input())
	l = list(map(int, input().split()))
	l.sort()
	d = {}
	le = 0
	d = dict.fromkeys(string.ascii_lowercase, 0)
	for j in range(n):
		count = m - bisect(l, j)
		d[s[j]] += count
	for k in range(0, n):
		d[s[k]] += 1
	for q in range(97, 123):
		print(d[chr(q)], end=' ')
	print()


import sys

def input():
	return sys.stdin.readline().rstrip('\n')
for _ in range(int(input())):
	(n, m) = map(int, input().split())
	s = input()
	p = list(map(int, input().split()))
	p_array = [0] * n
	ans = [0] * 26
	for i in p:
		p_array[i - 1] += 1
	for i in range(n - 1, 0, -1):
		p_array[i - 1] += p_array[i]
	for i in range(n):
		ans[ord(s[i]) - ord('a')] += p_array[i]
		ans[ord(s[i]) - ord('a')] += 1
	print(*ans)


import collections

def solve(n, m, s, p):
	prefixSums = [0 for _ in range(n)]
	for elem in p:
		prefixSums[elem - 1] += 1
	prefixSums[n - 1] = 1
	for i in range(n - 2, -1, -1):
		prefixSums[i] += prefixSums[i + 1]
	counts = [0 for _ in range(26)]
	for (i, sum) in enumerate(prefixSums):
		counts[ord(s[i]) - ord('a')] += sum
	return ' '.join(map(str, counts))
t = int(input().strip())
for i in range(t):
	[n, m] = list(map(int, input().strip().split()))
	s = input().strip()
	p = list(map(int, input().strip().split()))
	print(solve(n, m, s, p))


from collections import Counter
for _ in range(int(input())):
	(n, m) = map(int, input().split())
	s = input()
	l = list(map(int, input().split()))
	cc = Counter(l)
	d = [0] * 26
	c = 1
	for i in range(n - 1, -1, -1):
		c += cc[i + 1]
		d[ord(s[i]) - 97] += c
	print(*d)


t = int(input())
for _ in range(t):
	Dict = {'a': 0, 'b': 0, 'c': 0, 'd': 0, 'e': 0, 'f': 0, 'g': 0, 'h': 0, 'i': 0, 'j': 0, 'k': 0, 'l': 0, 'm': 0, 'n': 0, 'o': 0, 'p': 0, 'q': 0, 'r': 0, 's': 0, 't': 0, 'u': 0, 'v': 0, 'w': 0, 'x': 0, 'y': 0, 'z': 0}
	(n, m) = [int(i) for i in input().split()]
	s = input()
	p = [int(i) for i in input().split()]
	m1 = max(p)
	d = [0] * n
	for i in p:
		d[i - 1] += 1
	for i in range(len(d) - 2, -1, -1):
		d[i] += d[i + 1]
	for i in range(n):
		Dict[s[i]] += d[i] + 1
	keys = list(Dict.keys())
	for i in range(len(keys) - 1):
		print(Dict[keys[i]], end=' ')
	print(Dict[keys[-1]])


import bisect
for _ in range(int(input())):
	(n, m) = map(int, input().split())
	s = input()
	p = list(map(int, input().split()))
	p.sort()
	count = {'a': 0, 'b': 0, 'c': 0, 'd': 0, 'e': 0, 'f': 0, 'g': 0, 'h': 0, 'i': 0, 'j': 0, 'k': 0, 'l': 0, 'm': 0, 'n': 0, 'o': 0, 'p': 0, 'q': 0, 'r': 0, 's': 0, 't': 0, 'u': 0, 'v': 0, 'w': 0, 'x': 0, 'y': 0, 'z': 0}
	summ = {'a': 0, 'b': 0, 'c': 0, 'd': 0, 'e': 0, 'f': 0, 'g': 0, 'h': 0, 'i': 0, 'j': 0, 'k': 0, 'l': 0, 'm': 0, 'n': 0, 'o': 0, 'p': 0, 'q': 0, 'r': 0, 's': 0, 't': 0, 'u': 0, 'v': 0, 'w': 0, 'x': 0, 'y': 0, 'z': 0}
	for i in range(n):
		ind = bisect.bisect_right(p, i)
		if m - ind > 0:
			summ[s[i]] += m - ind
		count[s[i]] += 1
	for i in list(count.keys()):
		summ[i] += count[i]
	for j in list(summ.values()):
		print(j, end=' ')
	print()


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	s = list(input())
	p = list(map(int, input().split()))
	matrix = [[0 for i in range(26)] for i in range(n)]
	for i in range(n):
		for j in range(26):
			matrix[i][j] = matrix[i - 1][j]
		matrix[i][ord(s[i]) - 97] += 1
	ans = [0 for i in range(26)]
	for i in range(m):
		pos = p[i] - 1
		for j in range(26):
			ans[j] += matrix[pos][j]
	for j in range(26):
		ans[j] += matrix[n - 1][j]
	for i in ans:
		print(i, end=' ')
	print('')


def combo(string, arr):
	cnt = [0] * len(string)
	lst = [0 for i in range(26)]
	for i in arr:
		cnt[i - 1] += 1
	for i in range(len(cnt) - 1, 0, -1):
		cnt[i - 1] += cnt[i]
	for i in range(len(string)):
		lst[ord(string[i]) - ord('a')] += cnt[i] + 1
	print(*lst)
	return ''
t = int(input())
for i in range(t):
	a = input()
	string = input()
	lst = list(map(int, input().strip().split()))
	print(combo(string, lst))


t = int(input())
for _ in range(t):
	(n, m) = list(map(int, input().split()))
	s = input()
	r = ''
	p = list(map(int, input().split()))
	l = [0] * 26
	count = [0] * n
	for i in range(m):
		count[p[i] - 1] += 1
	for i in range(n - 1, 0, -1):
		count[i - 1] += count[i]
	for i in range(n):
		l[ord(s[i]) - 97] += count[i] + 1
	for a in l:
		r += str(a) + ' '
	print(r)


for n in range(int(input())):
	entry = input()
	s = input()
	m = input().split(' ')
	si = []
	for i in range(len(s)):
		si.append(0)
	for i in m:
		si[int(i) - 1] += 1
	si[len(si) - 1] += 1
	for i in range(len(si) - 2, -1, -1):
		si[i] += si[i + 1]
	letters = []
	for i in range(26):
		letters.append(0)
	for i in range(len(s)):
		letters[ord(s[i]) - 97] += si[i]
	output = ''
	for i in letters:
		output += str(i) + ' '
	print(output)


t = int(input())
for x in range(t):
	(n, m) = map(int, input().split())
	a = input()
	p = list(map(int, input().split()))
	al = [0 for x in range(26)]
	s = [[0 for x in range(26)]]
	for x in a:
		g = s[-1].copy()
		g[ord(x) - 97] += 1
		s.append(g)
	for x in p + [n]:
		for y in range(26):
			al[y] += s[x][y]
	print(' '.join(map(str, al)))


letters = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z']
T = int(input())
for t in range(T):
	res = {l: 0 for l in letters}
	(n, m) = list(map(int, input().split()))
	s = input()
	p = list(map(int, input().split()))
	error_dict = {}
	nb_times = len(p) + 1
	for pi in p:
		r = error_dict.get(pi, 0)
		error_dict[pi] = r + 1
	for (i, letter) in enumerate(s):
		nb_times -= error_dict.get(i, 0)
		res[letter] += nb_times
	r = [res[l] for l in letters]
	p = ' '.join(map(str, r))
	print(p)


def solve2(a, b):
	b.sort()
	n = len(a)
	b.append(n)
	arr = [0 for i in range(n)]
	ans = [0 for i in range(26)]
	for i in b:
		arr[i - 1] += 1
	for j in range(n - 2, -1, -1):
		arr[j] += arr[j + 1]
	for i in range(len(arr)):
		ans[ord(a[i]) - ord('a')] += arr[i]
	return ans
line = int(input())
for _ in range(line):
	input()
	a = input()
	b = [int(i) for i in input().split(' ')]
	print(*solve2(a, b))


for i in range(int(input())):
	d = {chr(i): 0 for i in range(97, 97 + 26)}
	(n, m) = map(int, input().split())
	s = input()
	p = sorted([int(i) - 1 for i in input().split()])
	l = m - 1
	cnt = 1
	for i in range(n - 1, -1, -1):
		if i == p[l]:
			while i == p[l] and l >= 0:
				l -= 1
				cnt += 1
		d[s[i]] += cnt
	for i in d:
		print(d[i], end=' ')
	print('', end='\n')


t = int(input())
for _ in range(t):
	(n, m) = map(int, input().split())
	s = input()
	p = sorted(list(map(int, input().split())))
	r = [0] * 26
	end = 0
	for i in range(m, 0, -1):
		st = end
		end = p[m - i]
		for j in range(st, end):
			r[ord(s[j]) - 97] += i + 1
	for j in range(end, n):
		r[ord(s[j]) - 97] += 1
	print(' '.join(map(str, r)))


import math
t = int(input())
for tt in range(t):
	(n, m) = map(int, input().split())
	s = input().strip()
	p = list(map(int, input().split()))
	freq = [0] * n
	for i in range(len(p)):
		freq[p[i] - 1] += 1
	for i in range(n - 1, 0, -1):
		freq[i - 1] += freq[i]
	ans = [0] * 26
	cc = 0
	for i in range(len(s)):
		ans[ord(s[i]) - ord('a')] += freq[i] + 1
	for i in ans:
		print(i, end=' ')
	print()


t = int(input().strip())
for _ in range(t):
	(n, m) = list(map(int, input().strip().split()))
	s = input().strip().lower()
	arr = list(map(int, input().strip().split()))
	arr.append(n)
	s_arr = [[0 for i in range(26)] for j in range(n)]
	for i in range(n):
		index = ord(s[i]) - 97
		if i == 0:
			s_arr[i][index] = 1
			continue
		s_arr[i] = s_arr[i - 1].copy()
		s_arr[i][index] += 1
	ans = [0 for i in range(26)]
	for i in arr:
		for j in range(26):
			ans[j] += s_arr[i - 1][j]
	print(*ans)


from string import ascii_lowercase
for _ in range(int(input())):
	(n, m) = map(int, input().split())
	s = input()
	p = list(sorted(map(int, input().split())))
	d = {c: s.count(c) for c in ascii_lowercase}
	j = 0
	for i in range(n):
		while j < m and i >= p[j]:
			j += 1
		c = s[i]
		y = m - j
		d[c] += y
	print(*(d[c] for c in ascii_lowercase))


for ii in range(int(input())):
	(n, m) = map(int, input().split())
	s = input()
	p = list(map(int, input().split()))
	p.append(0)
	a = list(map(chr, range(97, 123)))
	d = {key: 0 for key in a}
	for i in s:
		d[i] += 1
	p.sort()
	for i in range(m):
		for j in range(p[i], p[i + 1]):
			d[s[j]] += m - i
	for keys in d:
		print(d[keys], end=' ')
	print()


from math import *
t = int(input())
for zz in range(t):
	(n, m) = map(int, input().split())
	s = input()
	p = [int(i) for i in input().split()]
	ts = 'abcdefghijklmnopqrstuvwxyz'
	p.append(n)
	d = {}
	for i in ts:
		d[i] = []
	for k in sorted(d.keys()):
		c = 0
		for i in range(n):
			if s[i] == k:
				c += 1
			d[k].append(c)
	ans = {}
	for i in ts:
		ans[i] = 0
	for ti in p:
		for k in d.keys():
			ans[k] += d[k][ti - 1]
	for i in sorted(ans.keys()):
		print(ans[i], end=' ')
	print()


t = int(input())
for _ in range(t):
	(n, m) = map(int, input().split())
	s = input()
	p = list(map(int, input().split()))
	a = [0] * n
	for i in p:
		a[i - 1] += 1
	k = 1
	result = [0] * 26
	for i in range(n - 1, -1, -1):
		k += a[i]
		result[ord(s[i]) - ord('a')] += k
	print(*result)


for _ in range(int(input())):
	(x, y) = map(int, input().split())
	thing = input()
	mylist = list(map(int, input().split()))
	cnt = [0] * x
	for i in range(y):
		cnt[mylist[i] - 1] += 1
	for i in range(x - 1, 0, -1):
		cnt[i - 1] += cnt[i]
	ans = [0] * 26
	for i in range(x):
		ans[ord(thing[i]) - 97] += cnt[i] + 1
	print(*ans)


for eps in range(int(input())):
	(n, m) = map(int, input().split())
	s = input()
	a = list(map(int, input().split()))
	a.sort()
	ans = [0] * 26
	j = 0
	for i in range(n):
		while j < m and i >= a[j]:
			j += 1
		ans[ord(s[i]) - ord('a')] += m - j + 1
	for elem in ans:
		print(elem, end=' ')
	print()


t = int(input())
for _ in range(t):
	(n, m) = [*map(int, input().split())]
	s = input()
	p = [*map(int, input().split())]
	p.sort()
	p.append(n)
	res = [0] * 26
	tmp = [0] * 26

	def addTmp():
		for i in range(26):
			res[i] += tmp[i]
	pos = 0
	for e in p:
		while pos <= e - 1:
			x = ord(s[pos]) - ord('a')
			tmp[x] += 1
			pos += 1
		addTmp()
	print(' '.join(map(str, res)))


t = int(input())
for i in range(t):
	(n, m) = map(int, input().split())
	nlist = list(input())
	mlist = list(map(int, input().split()))
	ans = []
	for j in range(n):
		ans.append([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0])
	ans[0][ord(nlist[0]) - 97] += 1
	for j in range(1, n):
		for k in range(26):
			if k == ord(nlist[j]) - 97:
				ans[j][k] = ans[j - 1][k] + 1
			else:
				ans[j][k] = ans[j - 1][k]
	finalans = [0] * 26
	for j in mlist:
		for k in range(26):
			finalans[k] += ans[j - 1][k]
	for k in range(26):
		finalans[k] += ans[n - 1][k]
	for j in finalans:
		print(j, end=' ')
	print()


for t in range(int(input())):
	(n, m) = map(int, input().split())
	ar = [ord(x) - 97 for x in input()]
	mis = sorted([int(x) - 1 for x in input().split()])
	mis.append(n - 1)
	ans = [0] * 26
	temp = [0] * 26
	temp[ar[0]] = 1
	ptr = 0
	for k in mis:
		while ptr != k:
			ptr += 1
			temp[ar[ptr]] += 1
		for p in range(26):
			ans[p] += temp[p]
	for k in ans:
		print(k, end=' ')
	print()


def printFreq(arr, string):
	freqArray = list()
	suffixSum = list()
	n = len(string)
	for i in range(n):
		freqArray.append(0)
		suffixSum.append(0)
	for i in arr:
		freqArray[i] += 1
	freqArray[n - 1] += 1
	suffixSum[n - 1] = freqArray[n - 1]
	i = n - 2
	while i >= 0:
		suffixSum[i] = suffixSum[i + 1] + freqArray[i]
		i -= 1
	freqArray = list()
	for i in range(26):
		freqArray.append(0)
	for i in range(len(string)):
		count = suffixSum[i]
		freqArray[ord(string[i]) - 97] += count
	ans = ''
	for i in range(26):
		ans += str(freqArray[i]) + ' '
	print(ans)
numTestCases = int(input(''))
while numTestCases > 0:
	inputArray = input('').strip().split()
	n = int(inputArray[0])
	m = int(inputArray[1])
	string = input('')
	arr = list()
	inputArray = input('').strip().split()
	for i in inputArray:
		arr.append(int(i) - 1)
	printFreq(arr, string)
	numTestCases -= 1


t = int(input())
for _ in range(t):
	(n, m) = map(int, input().split())
	s = input()
	p = list(map(int, input().split()))
	count = [0 for i in range(n)]
	for i in range(m):
		count[p[i] - 1] += 1
	for i in range(n - 1, 0, -1):
		count[i - 1] += count[i]
	alpha = [0 for i in range(26)]
	for i in range(n):
		alpha[ord(s[i]) - ord('a')] += count[i] + 1
	print(' '.join(map(str, alpha)))


def combo(n, m, s, p):
	l = [chr(i) for i in range(ord('a'), ord('z') + 1)]
	d = {}
	for i in range(len(l)):
		d[l[i]] = 0
	p.sort()
	i = 0
	j = 0
	for i in range(m):
		while j < p[i]:
			d[s[j]] += m - i
			j += 1
	for i in range(n):
		d[s[i]] += 1
	print(*d.values())
t = int(input())
for i in range(t):
	(n, m) = map(int, input().split())
	s = input()
	p = list(map(int, input().split()))
	combo(n, m, s, p)


from collections import defaultdict
for _ in range(int(input())):
	(n, m) = map(int, input().split())
	s = str(input())
	pos = list(map(int, input().split()))
	pos.sort()
	(ansdic, curdic) = (defaultdict(int), defaultdict(int))
	j = -1
	for i in pos:
		if i - 1 != j:
			for k in range(j + 1, i):
				curdic[s[k]] += 1
		for (c, d) in curdic.items():
			ansdic[c] += d
		j = i - 1
	for i in s:
		ansdic[i] += 1
	ans = ['0'] * 26
	for (i, j) in ansdic.items():
		ans[ord(i) - 97] = str(j)
	print(' '.join(ans))


num_cases = int(input())
for case in range(num_cases):
	ans = [0] * 26
	init_ascii = 97
	line = input().split()
	n = int(line[0])
	m = int(line[1])
	s = input()
	tries = input().split()
	for i in range(len(tries)):
		tries[i] = int(tries[i])
	tries.sort()
	tries.reverse()
	acc_list = [1] * n
	acc_list_index = n - 2
	for i in range(m):
		for j in range(acc_list_index, tries[i] - 2, -1):
			acc_list[j] = acc_list[acc_list_index]
		acc_list_index = tries[i] - 1
		acc_list[acc_list_index] += 1
	for i in range(acc_list_index):
		acc_list[i] = acc_list[acc_list_index]
	for i in range(len(acc_list)):
		ans[ord(s[i]) - 97] += acc_list[i]
	for result in ans:
		print(result, end=' ')
	print()


for _ in range(int(input())):
	(wL, am) = list(map(int, input().split()))
	w = list(input())
	fails = list(map(int, input().split()))
	ans = [0] * 26
	preAns = [0] * wL
	for i in range(am):
		preAns[fails[i] - 1] += 1
	prePreAns = [0] * wL
	prePreAns[-1] = 1
	for i in range(wL - 2, -1, -1):
		prePreAns[i] = prePreAns[i + 1] + preAns[i]
	for i in range(wL):
		ans[ord(w[i]) - 97] += prePreAns[i]
	print(*ans)


letters = [chr(97 + i) for i in range(26)]
for _ in range(int(input())):
	(n, m) = (int(x) for x in input().split())
	s = input()
	p = sorted([int(x) for x in input().split()]) + [len(s)]
	ans = [0] * 26
	cnt = [0] * 26
	from_id = 0
	for val in p:
		for (i, l) in enumerate(letters):
			cnt[i] += s[from_id:val].count(l)
			ans[i] += cnt[i]
		from_id = val
	print(' '.join([str(x) for x in ans]))


a = int(input())
from collections import defaultdict
from bisect import bisect_left
for i in range(a):
	(x, y) = map(int, input().split())
	s = input()
	z = list(map(int, input().split()))
	z.sort()
	al = defaultdict(int)
	for i in range(len(s)):
		al[s[i]] += len(z) - bisect_left(z, i + 1)
	for i in range(len(s)):
		al[s[i]] += 1
	ans = []
	for i in range(26):
		ans.append(al[chr(ord('a') + i)])
	print(' '.join(map(str, ans)))


for _ in ' ' * int(input()):
	(a, b) = map(int, input().split())
	z = input()
	k = [0] * a
	for i in map(int, input().split()):
		k[i - 1] += 1
	for i in range(a - 1, 0, -1):
		k[i - 1] += k[i]
	ans = [0] * 26
	for i in z:
		ans[ord(i) - 97] += 1
	for i in range(a):
		ans[ord(z[i]) - 97] += k[i]
	print(*ans)


import sys

def alele():
	return list(map(int, sys.stdin.readline().strip().split()))

def ilele():
	return map(int, sys.stdin.readline().strip().split())

def input():
	return sys.stdin.readline().strip()
for _ in range(int(input())):
	(n, m) = map(int, input().split(' '))
	S = input()
	A = list(map(int, input().split(' ')))
	Ans = {}
	for i in range(97, 123):
		Ans[chr(i)] = 0
	mark = Ans.copy()
	dp = {}
	for i in range(len(S)):
		mark[S[i]] += 1
		dp[i + 1] = mark.copy()
	A.append(n)
	for i in A:
		for (j, k) in dp[i].items():
			Ans[j] += k
	for (i, j) in sorted(Ans.items()):
		print(j, end=' ')
	print()


import sys

def rint():
	return map(int, sys.stdin.readline().split())

def input():
	return sys.stdin.readline().rstrip('\n')

def oint():
	return int(input())
t = oint()
for _ in range(t):
	(n, m) = rint()
	ss = input()
	p = list(rint())
	p.sort()
	s = []
	for i in range(n):
		s.append(ord(ss[i]) - ord('a'))
	cnt = [0] * 26
	ans = [0] * 26
	i0 = 0
	for i in range(m):
		for ii in range(i0, p[i]):
			cnt[s[ii]] += 1
		i0 = p[i]
		for ii in range(26):
			ans[ii] += cnt[ii]
	for i in range(i0, n):
		cnt[s[i]] += 1
	for i in range(26):
		ans[i] += cnt[i]
	print(*ans)


import sys
input = sys.stdin.readline

def main():
	for _ in range(int(input())):
		(n, m) = map(int, input().split())
		s = input()
		p = list(map(int, input().split()))
		ans = {}
		cnt = {}
		ch = {}
		for i in range(n):
			if s[i] in ch:
				ch[s[i]] += 1
			else:
				ch[s[i]] = 1
			cnt[i] = ch.copy()
		for i in range(m):
			for el in cnt[p[i] - 1]:
				if el in ans:
					ans[el] += cnt[p[i] - 1][el]
				else:
					ans[el] = cnt[p[i] - 1][el]
		for el in cnt[n - 1]:
			if el in ans:
				ans[el] += cnt[n - 1][el]
			else:
				ans[el] = cnt[n - 1][el]
		for i in range(97, 97 + 26):
			if chr(i) in ans:
				print(ans[chr(i)], end=' ')
			else:
				print(0, end=' ')
		print()
main()


from collections import defaultdict as dd
for _ in range(int(input())):
	(a, b) = map(int, input().split())
	s = input()
	l = list(map(int, input().split()))
	t = [0 for i in range(a + 1)]
	t[0] = b + 1
	d = dd(lambda : 0)
	for i in range(len(l)):
		t[l[i]] -= 1
	q = 0
	for i in range(len(s)):
		q += t[i]
		d[s[i]] += q
	for i in range(26):
		print(d[chr(97 + i)], end=' ')
	print()


import string

def foo():
	(lens, lenp) = list(map(int, input().split()))
	s = input()
	p = list(map(int, input().split()))
	p.sort()
	ans = [0] * 26
	d = {}
	for (i, v) in enumerate(string.ascii_lowercase):
		d[v] = i
	ptrp = 0
	ptrs = 0
	suma = lenp + 1
	while ptrp < lenp:
		while ptrs < p[ptrp]:
			ans[d[s[ptrs]]] += suma
			ptrs += 1
		ptrp += 1
		suma -= 1
	while ptrs < lens:
		ans[d[s[ptrs]]] += 1
		ptrs += 1
	print(*ans)
t = int(input())
for i in range(t):
	foo()


for _ in range(int(input())):
	(n, m) = list(map(int, input().split()))
	combo = input()
	arr = list(map(int, input().split()))
	x = 'abcdefghijklmnopqrstuvwxyz'
	mat = []
	temp = [0 for i in range(26)]
	temp[ord(combo[0]) - 97] = 1
	mat.append(temp)
	for i in range(1, n):
		temp = mat[-1][:]
		temp[ord(combo[i]) - 97] += 1
		mat.append(temp)
	d = {}
	cnt = 0
	for i in x:
		d[cnt] = 0
		cnt += 1
	for i in arr:
		ind = i - 1
		temp = mat[ind]
		cnt = 0
		for j in temp:
			d[cnt] += j
			cnt += 1
	for i in combo:
		d[ord(i) - 97] += 1
	x = ''
	for i in range(26):
		x += str(d[i]) + ' '
	print(x)


from sys import stdin
r = stdin.readline

def ascii(c):
	return ord(c) - 97

def solve(t, p, n, m):
	(ac, cnt) = (dict(), [])
	for i in range(n):
		if t[i] not in ac:
			ac[t[i]] = 1
		else:
			ac[t[i]] += 1
		cnt.append(ac.copy())
	ans = [0 for _ in range(26)]
	p.append(n)
	for i in range(m + 1):
		x = p[i] - 1
		count = cnt[x]
		for c in count:
			ans[ascii(c)] += count[c]
	return ans

def main():
	cases = int(r())
	for case in range(cases):
		(n, m) = map(int, r().strip().split())
		t = r().strip()
		p = list(map(int, r().strip().split()))
		print(*solve(t, p, n, m))
main()


import sys
import bisect
import heapq
from math import *
from collections import defaultdict as dd
from collections import deque
from collections import Counter
from itertools import combinations as comb
mod = pow(10, 9) + 7
mod2 = 998244353

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

def out(var):
	sys.stdout.write(var)

def l():
	return list(map(int, data().split()))

def sl():
	return list(map(str, data().split()))

def sp():
	return map(int, data().split())

def ssp():
	return map(str, data().split())

def l1d(n, val=0):
	return [val for i in range(n)]

def l2d(n, m, val=0):
	return [[val for i in range(n)] for j in range(m)]
for _ in range(int(data())):
	(n, m) = sp()
	s = data()
	arr = l()
	dp = dict()
	faltu = [0 for i in range(26)]
	for i in range(len(s)):
		faltu[ord(s[i]) - 97] += 1
		dp[i] = tuple(faltu)
	answer = [0 for i in range(26)]
	for i in s:
		answer[ord(i) - 97] += 1
	for i in arr:
		for j in range(len(dp[i - 1])):
			answer[j] += dp[i - 1][j]
	print(*answer)


for _ in range(int(input())):
	(n, m) = [int(x) for x in input().split()]
	s = input()
	p = [int(x) for x in input().split()]
	p.sort()
	alpha = [0] * 26
	pre = m
	j = 0
	for i in range(0, m):
		while j < n and j < p[i]:
			alpha[ord(s[j]) - ord('a')] += pre
			j += 1
		pre -= 1
	j = 0
	while j < n:
		alpha[ord(s[j]) - ord('a')] += 1
		j += 1
	for i in range(26):
		if i == 25:
			print(alpha[i])
		else:
			print(alpha[i], end=' ')


t = int(input())
for _ in range(t):
	(n, m) = map(int, input().split())
	s = input()
	a = list(map(int, input().split()))
	d = [0] * n
	for i in range(m):
		d[a[i] - 1] += 1
	k = d[-1]
	for i in range(n - 2, -1, -1):
		k1 = d[i]
		d[i] += k
		k += k1
	for i in range(n):
		d[i] += 1
	f = [0] * 26
	for i in range(n - 1, -1, -1):
		f[ord(s[i]) - 97] += d[i]
	print(*f)


from operator import add
for t in range(int(input())):
	(n, m) = [int(j) for j in input().split()]
	s = input()
	tries = [int(j) - 1 for j in input().split()]
	x = [0] * 26
	ls = []
	for i in range(n):
		x_ = [q for q in x]
		x_[ord(s[i]) - 97] += 1
		ls.append(x_)
		x = [q for q in x_]
	tries.sort()
	x = [0] * 26
	for i in range(m):
		x = list(map(add, ls[tries[i]], x))
	x = list(map(add, x, ls[-1]))
	print(' '.join([str(j) for j in x]))


dict = {}
abc = 'abcdefghijklmnopqrstuvwxyz'
for i in range(26):
	dict[abc[i]] = i
t = int(input())
for _ in range(t):
	(n, m) = map(int, input().split())
	s = input()
	p = sorted(list(map(int, input().split())))
	p = [p[i] - 1 for i in range(m)] + [n - 1]
	idx = 0
	count = []
	for i in range(n):
		while i > p[idx]:
			idx += 1
		count.append(m + 1 - idx)
	Ans = [0 for _ in range(26)]
	for i in range(n):
		Ans[dict[s[i]]] += count[i]
	print(*Ans)


t = int(input())

def add(a, b):
	ret = []
	for i in range(len(a)):
		ret.append(a[i] + b[i])
	return ret

def get_list(s):
	ret = [0 for i in range(26)]
	for i in s:
		ret[ord(i) - ord('a')] += 1
	return ret
for _ in range(t):
	(n, m) = [int(x) for x in input().split()]
	s = input()
	ret = [0 for i in range(26)]
	prefix = [0 for i in range(n)]
	for i in input().split():
		prefix[int(i) - 1] += 1
	for i in range(n - 1, 0, -1):
		prefix[i - 1] += prefix[i]
	for i in range(n):
		ret[ord(s[i]) - ord('a')] += prefix[i]
		ret[ord(s[i]) - ord('a')] += 1
	for i in ret:
		print(i, end=' ')
	print()


from functools import reduce
import os
import sys
from math import *
from collections import *
from fractions import *
from bisect import *
from heapq import *
from io import BytesIO, IOBase
input = lambda : sys.stdin.readline().rstrip('\r\n')

def value():
	return tuple(map(int, input().split()))

def arr():
	return [int(i) for i in input().split()]

def sarr():
	return [int(i) for i in input()]

def starr():
	return [str(x) for x in input().split()]

def inn():
	return int(input())

def svalue():
	return tuple(map(str, input().split()))
mo = 1000000007
for _ in range(inn()):
	(n, m) = value()
	s = input()
	a = arr()
	d = defaultdict(list)
	ans = {chr(i): 0 for i in range(97, 123)}
	for i in range(97, 123):
		d[chr(i)] = [0] * n
	d[s[0]][0] += 1
	ans[s[0]] += 1
	for i in range(1, n):
		ans[s[i]] += 1
		for j in range(97, 123):
			if chr(j) == s[i]:
				d[chr(j)][i] = d[chr(j)][i - 1] + 1
			else:
				d[chr(j)][i] = d[chr(j)][i - 1]
	for i in range(m):
		k = a[i] - 1
		for j in range(97, 123):
			ans[chr(j)] += d[chr(j)][k]
	for i in ans:
		print(ans[i], end=' ')
	print()


for _ in range(int(input())):
	res = [0] * 26
	(n, m) = list(map(int, input().split()))
	s = input()
	a = sorted(list(map(int, input().split())))
	a.append(n)
	j = 0
	for (i, v) in enumerate(s):
		while j <= m and a[j] - 1 < i:
			j += 1
		res[ord(v) - 97] += m - j + 1
	print(*res)


from collections import OrderedDict
for _ in range(int(input())):
	(l, o) = map(int, input().split())
	s = input()
	opr = list(map(int, input().split()))
	d = OrderedDict()
	d1 = OrderedDict()
	for i in range(97, 123):
		d[chr(i)] = 0
		d1[chr(i)] = 0
	dp = [d]
	for i in s:
		t = dp[-1]
		t[i] += 1
		dp.append(t.copy())
	for i in opr:
		t = dp[i - 1]
		for j in range(97, 123):
			d1[chr(j)] += t[chr(j)]
	for i in s:
		d1[i] += 1
	for i in d1.values():
		print(i, end=' ')
	print()


import sys
input = sys.stdin.readline

def getInt():
	return int(input())

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

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

def getStr():
	return input().strip()
t = getInt()
for _ in range(t):
	(n, m) = getVars()
	s = getStr()
	p = getList()
	p.sort()
	res = {}
	res1 = {}
	for i in range(ord('a'), ord('z') + 1):
		res[chr(i)] = 0
		res1[chr(i)] = 0
	for i in range(p[0]):
		res[s[i]] += 1
		res1[s[i]] += 1
	for i in range(1, m):
		for j in res:
			res[j] += res1[j]
		for j in range(p[i - 1], p[i]):
			res[s[j]] += 1
			res1[s[j]] += 1
	for i in range(p[-1], n):
		res1[s[i]] += 1
	for i in res:
		res[i] += res1[i]
	print(*list(res.values()))


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	s = input()
	arr = list(map(int, input().split()))
	arr.sort()
	dd = [0] * 26
	j = 0
	for i in range(m):
		while j < arr[i]:
			dd[ord(s[j]) - ord('a')] += len(arr) - i
			j += 1
	for i in s:
		dd[ord(i) - ord('a')] += 1
	print(*dd)


import sys
Ri = lambda : [int(x) for x in sys.stdin.readline().split()]
ri = lambda : sys.stdin.readline().strip()

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

def list2d(a, b, c):
	return [[c] * b for i in range(a)]

def list3d(a, b, c, d):
	return [[[d] * c for j in range(b)] for i in range(a)]

def list4d(a, b, c, d, e):
	return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]

def ceil(x, y=1):
	return int(-(-x // y))

def INT():
	return int(input())

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

def LIST(N=None):
	return list(MAP()) if N is None else [INT() for i in range(N)]

def Yes():
	print('Yes')

def No():
	print('No')

def YES():
	print('YES')

def NO():
	print('NO')
INF = 10 ** 18
MOD = 998244353
for _ in range(int(ri())):
	(n, m) = Ri()
	s = ri()
	p = Ri()
	p = [i - 1 for i in p]
	se = {}
	for i in p:
		if i in se:
			se[i] += 1
		else:
			se[i] = 1
	dic = {}
	summ = 0
	for i in range(n - 1, -1, -1):
		if i in se:
			summ += se[i]
		if s[i] in dic:
			dic[s[i]] += summ
		else:
			dic[s[i]] = summ
	for i in s:
		dic[i] += 1
	for i in range(26):
		if chr(ord('a') + i) in dic:
			print(dic[chr(ord('a') + i)], end=' ')
		else:
			print(0, end=' ')
	print()


t = int(input())
while t:
	t = t - 1
	(n, m) = [int(s) for s in input().split()]
	s = [ord(s) for s in input()]
	p = [int(s) for s in input().split()]
	f = [1 for i in range(n)]
	for i in range(m):
		f[p[i] - 1] += 1
	inc = 0
	for i in range(n - 1, -1, -1):
		x = f[i]
		f[i] = f[i] + inc
		if x != 1:
			inc = inc + (x - 1)
	d = {}
	for i in range(26):
		d[97 + i] = 0
	for i in range(n):
		d[s[i]] = d[s[i]] + f[i]
	for i in sorted(d.keys()):
		print(d[i], end=' ')
	print()


import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
testcases = int(input())
for j in range(testcases):
	values = list(map(int, input().split()))
	lengthofstring = values[0]
	numtries = values[1]
	string = [ord(q) - 97 for q in input()]
	listtries = list(map(int, input().split()))
	dummylist = [0 for alpha in range(26)]
	storedict = {}
	answerlist = [0 for alpha in range(26)]
	for k in range(lengthofstring):
		dummylist[string[k]] += 1
		storedict[k + 1] = dummylist + []
	listtries.append(lengthofstring)
	for l in range(numtries + 1):
		values2 = storedict[listtries[l]]
		for j in range(26):
			answerlist[j] += values2[j]
	print(' '.join(list(map(str, answerlist))))


t = int(input())
for i in range(t):
	numberOfTimes = [0 for x in range(26)]
	(n, m) = [int(x) for x in input().split()]
	s = input()
	mPs = [int(x) for x in input().split()]
	mPs.append(len(s))
	mPs = sorted(mPs)
	m += 1
	minimum = 0
	for p in mPs:
		maximum = p
		for letter in s[minimum:maximum]:
			numberOfTimes[ord(letter) - 97] += m
		minimum = maximum
		m -= 1
	for num in numberOfTimes:
		print(num, end=' ')
	print()


from sys import stdin
input = stdin.readline
q = int(input())
for _ in range(q):
	(n, m) = map(int, input().split())
	s = input()
	pyk = [[0] * 26]
	for i in range(1, n + 1):
		cyk = pyk[-1].copy()
		cyk[ord(s[i - 1]) - 97] += 1
		pyk.append(cyk)
	l = list(map(int, input().split()))
	l.append(n)
	wyn = [0] * 26
	for i in range(m + 1):
		for j in range(26):
			wyn[j] += pyk[l[i]][j]
	print(*wyn)


t = int(input())
for i in range(t):
	a = input()
	string = input()
	arr = list(map(int, input().strip().split()))
	arr.sort()
	j = 0
	lst = [0 for i in range(26)]
	for i in range(len(string)):
		while j < len(arr) and arr[j] < i + 1:
			j += 1
		lst[ord(string[i]) - 97] += len(arr) + 1 - j
	print(*lst)


from sys import stdin
from bisect import bisect_left
from collections import Counter
for k in range(int(stdin.readline())):
	(n, m) = [int(x) for x in stdin.readline().split()]
	s = input()
	d = Counter(s)
	l = list(map(int, stdin.readline().split()))
	l.sort()
	ans = [0 for j in range(0, 26)]
	for j in range(0, len(s)):
		n = len(l) - bisect_left(l, j + 1)
		ans[ord(s[j]) - 97] += n
	e = list(d.keys())
	try:
		for i in range(0, len(e)):
			ans[ord(e[i]) - 97] += d[e[i]]
	except Exception:
		pass
	print(*ans)


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	string = input()
	arr = [int(k) for k in input().split()]
	freq1 = [0] * 26
	freq2 = [0] * n
	for j in range(m):
		freq2[arr[j]] += 1
	for i in range(n):
		m = m - freq2[i]
		freq2[i] = m
	for i in range(n):
		freq2[i] += 1
	for i in range(n):
		freq1[ord(string[i]) - 97] += freq2[i]
	print(*freq1)


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	napis = input()
	bledy = [int(x) for x in input().split()]
	litery = [0 for _ in range(26)]
	prefix = [0 for _ in range(n)]
	for x in bledy:
		prefix[x - 1] += 1
	for x in range(n - 1, 0, -1):
		prefix[x - 1] += prefix[x]
	for x in range(n):
		litery[ord(napis[x]) - 97] += prefix[x] + 1
	print(*litery)


t = int(input())
q = 'abcdefghijklmnopqrstuvwxyz'
for _ in range(t):
	(n, m) = list(map(int, input().split()))
	s = input()
	p = list(map(int, input().split()))
	l = [0 for i in range(n)]
	for i in p:
		l[i - 1] = l[i - 1] + 1
	for i in range(n - 2, -1, -1):
		l[i] = l[i] + l[i + 1]
	d = {}
	for i in q:
		d[i] = 0
	for i in s:
		d[i] += 1
	for i in range(n):
		d[s[i]] = l[i] + d[s[i]]
	l = []
	for i in q:
		l.append(d[i])
	print(*l)


t = int(input())
from collections import defaultdict
for _ in range(t):
	(n, m) = list(map(int, input().split()))
	dict = {}
	for i in range(26):
		dict[chr(i + 97)] = 0
	s = input()
	for x in s:
		dict[x] += 1
	p = list(map(int, input().split()))
	p.sort()
	val = len(p)
	dt = defaultdict(int)
	for x in p:
		dt[x] += 1
	for i in range(n):
		if dt[i + 1] != 0:
			dict[s[i]] += val
			val -= dt[i + 1]
		else:
			dict[s[i]] += val
	print(*list(dict.values()))


t = int(input())
while t > 0:
	(n, m) = map(int, input().split())
	a = input()
	b = list(map(int, input().split()))
	mark = [0] * n
	flag = 0
	ans = [0] * 26
	for i in a:
		ans[ord(i) - 97] += 1
	for i in range(0, m):
		mark[b[i]] -= 1
	mark[0] = m
	for i in range(1, n):
		mark[i] = mark[i] + mark[i - 1]
	for j in range(0, n):
		ans[ord(a[j]) - 97] += mark[j]
	for i in ans:
		print(i, end=' ')
	print()
	t -= 1


def countGreater(arr, n, k):
	l = 0
	r = n - 1
	leftGreater = n
	while l <= r:
		m = int(l + (r - l) / 2)
		if arr[m] > k:
			leftGreater = m
			r = m - 1
		else:
			l = m + 1
	return n - leftGreater

def char_position(letter):
	return ord(letter) - 97
t = int(input())
for i in range(t):
	counter = [0] * 26
	(n, m) = map(int, input().split())
	s = input()
	p = list(map(int, input().split()))
	p.sort()
	for i in range(len(s)):
		gr = countGreater(p, len(p), i)
		ta = char_position(s[i])
		counter[ta] += gr + 1
	print(*counter)


for _ in ' ' * int(input()):
	(n, m) = map(int, input().split())
	s = input()
	a = list(map(int, input().split())) + [n]
	s = [ord(i) - 97 for i in s]
	r = []
	l = [0] * 26
	for i in range(n):
		l[s[i]] += 1
		r.append(list(l))
	y = [0] * 26
	for i in a:
		for j in range(26):
			y[j] += r[i - 1][j]
	print(*y)


import os
import sys
from io import BytesIO, IOBase
import threading
from math import cos, sin, pi
mod = 998244353

def main():
	for _ in range(int(input())):
		(n, m) = map(int, input().split())
		s = input()
		ans = [0] * 26
		for i in s:
			ans[ord(i) - 97] += 1
		cnt = [0] * n
		cnt[0] = m
		q = list(map(int, input().split()))
		for i in q:
			cnt[i] -= 1
		c = 0
		for i in range(n):
			c += cnt[i]
			ans[ord(s[i]) - 97] += c
		print(*ans)
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
main()


def char_position(letter):
	return ord(letter) - 97
t = int(input())
for i in range(t):
	(n, m) = [int(x) for x in input().split()]
	s = input()
	p = [int(x) for x in input().split()]
	result = [0] * 26
	count = [0] * n
	for pos in p:
		count[pos - 1] += 1
	for j in range(n - 1, 0, -1):
		count[j - 1] += count[j]
	for j in range(n):
		charPos = char_position(s[j])
		result[charPos] += count[j] + 1
	print(*result, sep=' ')


t = int(input())
while t:
	(n, m) = map(int, input().split())
	s = input()
	p = input().split()
	for i in range(m):
		p[i] = int(p[i])
	p.sort()
	ls = []
	count = 0
	for i in range(m):
		if i == 0:
			count += 1
			if i == m - 1:
				ls.append([p[i], count])
		elif p[i] == p[i - 1]:
			count += 1
			if i == m - 1:
				ls.append([p[i], count])
		else:
			ls.append([p[i - 1], count])
			count = 1
			if i == m - 1:
				ls.append([p[i], count])
	ls.append([n, 0])
	visited = [1 for i in range(n)]
	count = m
	j = 0
	for i in range(n):
		if i < ls[j][0]:
			visited[i] += count
		else:
			count -= ls[j][1]
			j += 1
			visited[i] += count
	ans = [0 for i in range(26)]
	for i in range(n):
		ans[ord(s[i]) - 97] += visited[i]
	print(*ans)
	t -= 1


test = int(input())
while test:
	test -= 1
	(n, m) = map(int, input().split())
	s = input()
	ls = list(map(int, input().split()))
	ls.sort()
	ans = [0] * 26
	l = 0
	a = 1
	kk = [0] * (n + 1)
	for i in range(m):
		kk[ls[i]] += 1
	for i in range(n):
		ch = ord(s[i]) - 97
		k = m - kk[i] + 1
		ans[ch] += k
		kk[i + 1] += kk[i]
	print(*ans)


t = int(input())
for tt in range(t):
	(n, m) = map(int, input().split())
	s = input()
	l = list(map(int, input().split()))
	l.sort()
	ans = [0] * 26
	suffix = [0] * (n + 1)
	for i in range(m):
		suffix[l[i]] += 1
	for j in range(n):
		c = ord(s[j]) - 97
		r = m - suffix[j] + 1
		ans[c] += r
		suffix[j + 1] += suffix[j]
	print(*ans)


from bisect import bisect_left

def solve(s, p):
	p.sort()
	sinds = [[] for _ in range(26)]
	counts = [0 for _ in range(26)]
	for i in range(len(s)):
		sinds[ord(s[i]) - 97].append(i + 1)
	for i in range(26):
		counts[i] = sum((len(p) + 1 - bisect_left(p, ind) for ind in sinds[i]))
	return counts
t = int(input())
for _ in range(t):
	(n, m) = map(int, input().split())
	s = input()
	p = list(map(int, input().split()))
	print(' '.join(map(str, solve(s, p))))


caseNum = int(input())

def arrayAdd(a, b):
	for i in range(len(a)):
		a[i] = a[i] + b[i]
	return a
for i in range(caseNum):
	(n, m) = map(int, input().split())
	combo = input()
	p = list(map(int, input().split(' ')))
	ans = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
	posValueBase = ans
	posValue = [] * len(combo)
	cnt = 0
	for char in combo:
		posValueBase[ord(char) - ord('a')] = posValueBase[ord(char) - ord('a')] + 1
		posValue.append(posValueBase.copy())
	for pi in p:
		ans = arrayAdd(ans, posValue[pi - 1])
	for ansi in ans:
		print(ansi, end=' ')
	print()


import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
for _ in range(int(input())):
	(n, m) = map(int, input().split())
	s = input()
	p = list(map(int, input().split()))
	ans = []
	ans.append([])
	a = [0] * 26
	for i in s:
		a[ord(i) - 97] += 1
		ans.append(list(a))
	pressed = [0] * 26
	for i in p:
		for j in range(26):
			pressed[j] += ans[i][j]
	for i in range(26):
		pressed[i] += ans[len(s)][i]
	print(' '.join((str(k) for k in pressed)))


for q in range(int(input())):
	(n, m) = map(int, input().split())
	s = input()
	p = sorted(list(map(int, input().split())))
	res = [0] * 26
	di = dict()
	iter = 0
	for i in range(m):
		if di.get(p[i], -1) == -1:
			di[p[i]] = 1
			yy = m - i + 1
			for j in range(iter, p[i]):
				ww = ord(s[j]) - 97
				res[ww] += yy
			iter = p[i]
	for i in range(iter, n):
		ww = ord(s[i]) - 97
		res[ww] += 1
	print(*res)


t = int(input())
while t:
	(n, m) = map(int, input().split())
	s = input()
	arr = [int(i) for i in input().split()]
	c = [0] * n
	ans = [0] * 26
	for i in arr:
		c[i - 1] += 1
	c[n - 1] += 1
	for i in range(n - 2, -1, -1):
		c[i] += c[i + 1]
	for i in range(n):
		ans[ord(s[i]) - ord('a')] += c[i]
	print(*ans)
	t -= 1


def st(sol, c):
	for i in range(len(sol)):
		sol[i] += c[i]
	return sol
num = int(input())
for i in range(num):
	(n, m) = map(int, input().split())
	s = input()
	p = sorted(list(map(int, input().split())))
	p.append(len(s))
	count = [0 for t in range(ord('z') - ord('a') + 1)]
	sol = [0 for t in range(ord('z') - ord('a') + 1)]
	id = 0
	for j in range(len(p)):
		while id != p[j]:
			count[ord(s[id]) - ord('a')] += 1
			id += 1
		sol = st(sol, count)
	print(*sol)


import copy

def main():
	t = int(input())
	while t:
		(n, m) = list(map(int, input().split()))
		s = input()
		p = list(map(int, input().split()))
		count = {}
		count[0] = [0] * 26
		count[0][ord(s[0]) - ord('a')] = 1
		for i in range(1, n):
			tmp = copy.copy(count[i - 1])
			tmp[ord(s[i]) - ord('a')] += 1
			count[i] = tmp
		ans = [0] * 26
		for i in p:
			for j in range(26):
				ans[j] += count[i - 1][j]
		for j in range(26):
			ans[j] += count[n - 1][j]
		for i in ans:
			print(i, end=' ')
		print()
		t -= 1
main()


t = int(input())
for test in range(t):
	(n, m) = [int(x) for x in input().split()]
	s = list(input())
	p = [int(x) for x in input().split()]
	d = [0] * n
	a = [0] * n
	for i in range(m):
		d[0] += 1
		d[p[i]] -= 1
	a[0] = d[0]
	for i in range(1, n):
		a[i] = a[i - 1] + d[i]
	c = [0] * 26
	for i in range(n):
		x = ord(s[i]) - 97
		c[x] += a[i]
	for i in s:
		x = ord(i) - 97
		c[x] += 1
	for i in range(len(c)):
		print(c[i], end=' ')
	print()


import sys, math

def input():
	return sys.stdin.readline()[:-1]

def main():
	q = int(input())
	for _ in range(q):
		(n, m) = map(int, input().split())
		s = input()
		p = list(map(int, input().split()))
		t = [[0 for k in range(26)] for l in range(n)]
		for k in range(n):
			t[k][ord(s[k]) - 97] += 1
		for k in range(1, n):
			for l in range(26):
				t[k][l] += t[k - 1][l]
		ans = [0 for k in range(26)]
		for k in range(m):
			for l in range(26):
				ans[l] += t[p[k] - 1][l]
		for l in range(26):
			ans[l] += t[n - 1][l]
		print(*ans)
main()


import sys
import math
import itertools
import functools
import collections
import operator
import fileinput
import copy

def ii():
	return int(input())

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

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

def lcm(a, b):
	return abs(a * b) // math.gcd(a, b)

def revn(n):
	return str(n)[::-1]

def dd():
	return collections.defaultdict(int)

def ddl():
	return collections.defaultdict(list)

def sieve(n):
	if n < 2:
		return list()
	prime = [True for _ in range(n + 1)]
	p = 3
	while p * p <= n:
		if prime[p]:
			for i in range(p * 2, n + 1, p):
				prime[i] = False
		p += 2
	r = [2]
	for p in range(3, n + 1, 2):
		if prime[p]:
			r.append(p)
	return r

def divs(n, start=2):
	r = []
	for i in range(start, int(math.sqrt(n) + 1)):
		if n % i == 0:
			if n / i == i:
				r.append(i)
			else:
				r.extend([i, n // i])
	return r

def divn(n, primes):
	divs_number = 1
	for i in primes:
		if n == 1:
			return divs_number
		t = 1
		while n % i == 0:
			t += 1
			n //= i
		divs_number *= t

def prime(n):
	if n == 2:
		return True
	if n % 2 == 0 or n <= 1:
		return False
	sqr = int(math.sqrt(n)) + 1
	for d in range(3, sqr, 2):
		if n % d == 0:
			return False
	return True

def convn(number, base):
	newnumber = 0
	while number > 0:
		newnumber += number % base
		number //= base
	return newnumber

def cdiv(n, k):
	return n // k + (n % k != 0)
for _ in range(ii()):
	(n, m) = mi()
	s = input()
	p = li()
	orda = ord('a')
	ans = [0] * 26
	arr = [0] * 26
	t = {0: dict.fromkeys(range(26), 0)}
	c = ord(s[0]) - orda
	ans[c] += 1
	t[0][c] += 1
	for i in range(1, n):
		c = ord(s[i]) - orda
		ans[c] += 1
		t[i] = {}
		for j in range(26):
			t[i][j] = t[i - 1][j]
		t[i][c] += 1
	for i in range(m):
		for j in range(26):
			arr[j] += t[p[i] - 1][j]
	for i in range(26):
		ans[i] += arr[i]
	print(*ans)


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	s = input()
	nums = [int(x) for x in input().split(' ')]
	answer = [0] * 26
	for ch in s:
		answer[ord(ch) - 97] += 1
	nums.sort()
	for i in range(m):
		if i == 0:
			for j in range(0, nums[0]):
				answer[ord(s[j]) - 97] += m - i
		else:
			for j in range(nums[i - 1], nums[i]):
				answer[ord(s[j]) - 97] += m - i
	for num in answer:
		print(num, end=' ')
	print('\n')


for _ in range(int(input())):
	(n, m) = list(map(int, input().split()))
	s = input()
	p = list(map(int, input().split()))
	ans = [0] * 26
	cnt = [0] * n
	for i in range(m):
		cnt[p[i] - 1] += 1
	x = 0
	for i in range(n - 1, -1, -1):
		if cnt[i] != 0:
			x += cnt[i]
		cnt[i] = x
	for i in range(n):
		ans[ord(s[i]) - 97] += cnt[i] + 1
	print(*ans)


(t, res) = (int(input()), '')
while t > 0:
	t -= 1
	(n, m) = map(int, input().split())
	s = input()
	suf = [0] * (n - 1) + [1]
	for i in map(int, input().split()):
		suf[i - 1] += 1
	for i in range(n - 2, -1, -1):
		suf[i] += suf[i + 1]
	ans = [0] * 26
	for i in range(n):
		ans[ord(s[i]) - ord('a')] += suf[i]
	for i in ans:
		res += str(i) + ' '
	res += '\n'
print(res)


t = int(input())
for q in range(0, t):
	(n, m) = map(int, input().split())
	a = input()
	p = [int(i) for i in input().split()]
	p.sort()
	p.append(n)
	b = [0] * n
	for i in range(0, m):
		b[p[i] - 1] += 1
	b[n - 1] = 1
	s = sum(b)
	ans = [0] * 26
	x = b[0]
	ans[ord(a[0]) - 97] += s
	for i in range(1, n):
		l = s - x
		x += b[i]
		ans[ord(a[i]) - 97] += l
	print(*ans)


t = int(input())
for _ in range(t):
	(n, m) = map(int, input().split())
	s = input()
	p = list(map(int, input().split()))
	arr = [0] * n
	arr[n - 1] = 1
	for i in range(m):
		arr[p[i] - 1] += 1
	prefix_sum = 0
	res = [0] * 26
	for i in range(n - 1, -1, -1):
		prefix_sum += arr[i]
		res[ord(s[i]) - 97] += prefix_sum
	for i in res:
		print(i, end=' ')
	print()


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	a = input()
	b = list(map(int, input().split()))
	b.append(n)
	count = []
	al = [0 for i in range(26)]
	for i in range(n):
		al[ord(a[i]) - 97] += 1
		alll = list(al)
		count.append(alll)
	ans = [0 for i in range(26)]
	for i in range(m + 1):
		an = [count[b[i] - 1][j] + ans[j] for j in range(26)]
		ans = list(an)
	print(*ans)


def get_step_counts(combo):
	step_counts = []
	step_count = [0] * 26
	step_counts.append(step_count[:])
	for letter in combo:
		idx_in_array = ord(letter) - ord('a')
		step_count[idx_in_array] += 1
		step_counts.append(step_count[:])
	return step_counts

def combo_count(combo, mistakes):
	step_counts = get_step_counts(combo)
	counts = [0] * 26
	for mistake in mistakes + [len(combo)]:
		for (idx, item) in enumerate(step_counts[mistake]):
			counts[idx] += item
	return counts
test_number = int(input())
for _ in range(test_number):
	input()
	combo = input()
	mistakes = [int(x) for x in input().split()]
	result = combo_count(combo, mistakes)
	print(' '.join([str(x) for x in result]))


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	s = input()
	a = list(map(int, input().split()))
	count = [0] * n
	for i in a:
		count[i - 1] += 1
	for i in range(n - 1, 0, -1):
		count[i - 1] += count[i]
	ans = [0] * 26
	for i in range(n):
		ans[ord(s[i]) - ord('a')] += count[i] + 1
	print(*ans)


import math
from collections import defaultdict
ml = lambda : map(int, input().split())
ll = lambda : list(map(int, input().split()))
ii = lambda : int(input())
ip = lambda : input()
t = ii()
for _ in range(t):
	(n, m) = ml()
	s = ip()
	yo = [0] * (n + 1)
	lol = [0] * 26
	a = ll()
	for i in a:
		yo[i] -= 1
	ans = m + 1
	for i in range(n):
		ans += yo[i]
		idx = ord(s[i]) - ord('a')
		lol[idx] += ans
	print(*lol)


import sys
input = sys.stdin.readline
t = int(input())
for _ in range(t):
	(n, m) = map(int, input().split())
	s = input()
	p = [int(i) - 1 for i in input().split()] + [n - 1]
	cnt = [[0] * 26 for i in range(n)]
	for i in range(n):
		if i > 0:
			for j in range(26):
				cnt[i][j] = cnt[i - 1][j]
		cur = ord(s[i]) - ord('a')
		cnt[i][cur] += 1
	ans = [0] * 26
	for i in p:
		for j in range(26):
			ans[j] += cnt[i][j]
	print(*ans)


import sys
from functools import lru_cache, cmp_to_key
from heapq import merge, heapify, heappop, heappush
from math import *
from collections import defaultdict as dd, deque, Counter as C
from itertools import combinations as comb, permutations as perm
from bisect import bisect_left as bl, bisect_right as br, bisect
from time import perf_counter
from fractions import Fraction
mod = int(pow(10, 9) + 7)
mod2 = 998244353

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

def out(*var, end='\n'):
	sys.stdout.write(' '.join(map(str, var)) + end)

def L():
	return list(sp())

def sl():
	return list(ssp())

def sp():
	return map(int, data().split())

def ssp():
	return map(str, data().split())

def l1d(n, val=0):
	return [val for i in range(n)]

def l2d(n, m, val=0):
	return [l1d(n, val) for j in range(m)]
try:
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('../output.txt', 'w')
except:
	pass
for _ in range(L()[0]):
	(n, m) = L()
	s = input()
	p = L()
	pref = [0 for i in range(n + 2)]
	for ele in p:
		pref[1] += 1
		pref[ele + 1] -= 1
	for i in range(1, n + 1):
		pref[i] += pref[i - 1]
	pref = pref[1:n + 2]
	for i in range(n):
		pref[i] += 1
	d = [0 for i in range(26)]
	for i in range(n):
		d[ord(s[i]) - ord('a')] += pref[i]
	print(*d)


import sys
import math
import heapq
import collections
fast_reader = sys.stdin.readline
fast_writer = sys.stdout.write

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

def print(*argv):
	fast_writer(' '.join((str(i) for i in argv)))
	fast_writer('\n')

def printspace(*argv):
	fast_writer(' '.join((str(i) for i in argv)))
	fast_writer(' ')

def inputnum():
	return int(input())

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

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

def inputstring():
	return [x for x in input()]

def inputstringnum():
	return [ord(x) - ord('a') for x in input()]

def inputmatrixchar(rows):
	arr2d = [[j for j in input().strip()] for i in range(rows)]
	return arr2d

def inputmatrixint(rows):
	arr2d = []
	for _ in range(rows):
		arr2d.append([int(i) for i in input().split()])
	return arr2d
t = int(input())
for q in range(t):
	(n, m) = inputnums()
	s = inputstringnum()
	p = inputlist()
	alphabet = [0] * 26
	twod = [[0 for j in range(26)] for i in range(n)]
	twod[0][s[0]] += 1
	for i in range(1, n):
		for j in range(26):
			twod[i][j] = twod[i - 1][j]
		twod[i][s[i]] += 1
	for i in p:
		for j in range(26):
			alphabet[j] += twod[i - 1][j]
	for i in s:
		alphabet[i] += 1
	print(*alphabet)


for _ in range(int(input())):
	(n, m) = [int(i) for i in input().split()]
	s = [ord(i) - 97 for i in input()]
	a = [int(i) for i in input().split()]
	cnt = [0] * n
	for i in range(m):
		cnt[a[i] - 1] += 1
	cur = 0
	for i in range(n - 1, -1, -1):
		cnt[i] += cur
		cur = cnt[i]
	al = [0] * 26
	for i in range(n):
		al[s[i]] += cnt[i]
	for i in s:
		al[i] += 1
	print(*al)


import math, sys
from collections import Counter, defaultdict, deque
from sys import stdin, stdout
input = stdin.readline
li = lambda : list(map(int, input().split()))

def solve():
	(n, m) = li()
	s = input()
	a = li()
	c = Counter(a)
	j = 0
	count = [0] * 26
	ans = [0] * 26
	for i in range(n):
		count[ord(s[i]) - 97] += 1
		ans[ord(s[i]) - 97] += 1
		if i + 1 in c:
			for j in range(26):
				ans[j] += count[j] * c[i + 1]
	print(*ans)
for _ in range(int(input())):
	solve()


def o7(x):
	return ord(x) - 97
for _ in range(int(input())):
	(n, m) = map(int, input().split())
	s = input()
	p = list(map(int, input().split()))
	pr = []
	cnt = [0 for i in range(26)]
	for i in range(len(s)):
		cnt[o7(s[i])] += 1
		pr.append(cnt.copy())
	ans = [0 for i in range(26)]
	for i in p:
		pri = pr[i - 1]
		for j in range(26):
			ans[j] += pri[j]
	pri = pr[-1]
	for j in range(26):
		ans[j] += pri[j]
	print(' '.join(map(str, ans)))


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	s = input()
	mark = [0] * (n + 10)
	l = [*map(int, input().split())]
	for i in range(m):
		mark[l[i]] += 1
	k = []
	count = [0] * 128
	v = [0] * 128
	for i in range(n):
		if count[ord(s[i])] == 0:
			k.append(ord(s[i]))
		count[ord(s[i])] += 1
		while mark[i + 1] > 0:
			for j in k:
				v[j] += count[j]
			mark[i + 1] -= 1
	for i in range(n):
		v[ord(s[i])] += 1
	for i in range(ord('a'), ord('z') + 1, 1):
		print(v[i], end=' ')
	print()


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	k = input()
	l = sorted(map(int, input().split()))
	l.append(n)
	h = [0 for i in range(n)]
	for i in range(m + 1):
		h[l[i] - 1] += 1
	for j in range(1, n):
		h[n - j - 1] += h[n - j]
	q = 'abcdefghijklmnopqrstuvwxyz'
	w = {q[i]: 0 for i in range(26)}
	for r in range(n):
		w[k[r]] += h[r]
	for r1 in w:
		print(w[r1], end=' ')
	print()


import sys
import math

def read_line():
	return sys.stdin.readline()[:-1]

def read_int():
	return int(sys.stdin.readline())

def read_int_line():
	return [int(v) for v in sys.stdin.readline().split()]
t = read_int()
for i in range(t):
	(n, m) = read_int_line()
	s = read_line()
	p = read_int_line()
	c = [0] * n
	for i in range(len(p)):
		c[0] += 1
		c[p[i]] -= 1
	for i in range(1, n):
		c[i] += c[i - 1]
	for i in range(n):
		c[i] += 1
	d = [0] * 26
	for i in range(len(c)):
		d[ord(s[i]) - ord('a')] += c[i]
	print(*d)


def main():
	t = int(input())
	for query in range(t):
		(N, M) = (int(i) for i in input().split())
		T = input()
		P = [int(i) for i in input().split()]
		al = {chr(ord('a') + i): 0 for i in range(26)}
		s = [0] * N
		for p in P:
			s[0] += 1
			s[p] -= 1
		S = [0] * (N + 1)
		for i in range(N):
			S[i + 1] = S[i] + s[i]
		for i in range(1, N + 1):
			al[T[i - 1]] += S[i]
		for st in T:
			al[st] += 1
		print(*al.values())
main()


t = int(input())
for i in range(t):
	(n, m) = input().split()
	m = int(m)
	n = int(n)
	s = input()
	p = list(map(int, input().split()))
	ans = {'a': 0}
	abjad = 'bcdefghijklmnopqrstuvwxyz'
	for letter in abjad:
		ans[letter] = 0
	number = [0] * n
	for pmem in p:
		number[pmem - 1] += 1
	number[-1] = 1
	number_sum = sum(number)
	for index in range(n):
		ans[s[index]] += number_sum
		number_sum -= number[index]
	abjad = 'a' + abjad
	answer = []
	for letter in abjad:
		answer.append(ans[letter])
	answer = list(map(str, answer))
	print(' '.join(answer))


from sys import stdin, stdout
from collections import *
from math import gcd, floor, ceil

def st():
	return list(stdin.readline().strip())

def li():
	return list(map(int, stdin.readline().split()))

def mp():
	return map(int, stdin.readline().split())

def inp():
	return int(stdin.readline())

def pr(n):
	return stdout.write(str(n) + '\n')
mod = 1000000007
INF = float('inf')

def solve():
	(n, m) = mp()
	s = st()
	k = li()
	l = [0] * (n + 1)
	d = {chr(i): i - 97 for i in range(97, 123)}
	for i in k:
		l[i] -= 1
		l[0] += 1
	for i in range(1, n + 1):
		l[i] += l[i - 1]
	ans = [0] * 26
	for i in range(n):
		ans[d[s[i]]] += l[i] + 1
	pr(' '.join(map(str, ans)))
for _ in range(inp()):
	solve()


import math
from collections import *

def solve():
	(n, m) = map(int, input().split())
	s = input()
	a = [int(i) for i in input().split()]
	ans = [0 for i in range(n)]
	for i in range(len(a)):
		ans[a[i] - 1] += 1
	for i in range(n - 1, 0, -1):
		ans[i - 1] += ans[i]
	d = defaultdict(int)
	for i in range(len(s)):
		d[s[i]] += ans[i] + 1
	for i in range(ord('a'), ord('z') + 1):
		if d.get(chr(i), 0) != 0:
			print(d.get(chr(i), 0), end=' ')
		else:
			print(0, end=' ')
	print()
t = int(input())
for _ in range(t):
	solve()


import string
for _ in [0] * int(input()):
	(n, m) = map(int, input().split())
	s = list(input())
	t = sorted(list(map(int, input().split())))
	ind = len(t)
	k = 0
	c = 0
	ret = dict()
	for i in string.ascii_lowercase:
		ret[i] = 0
	for i in t:
		if k == 0 or t[k] != t[k - 1]:
			for l in range(c, i):
				ret[s[l]] += ind
				c = i
		k += 1
		ind -= 1
	else:
		for i in s:
			ret[i] += 1
	for q in ret.values():
		print(q, end=' ')
	print()


for _ in range(int(input())):
	cnt = [0] * 26
	(n, m) = map(int, input().split())
	res = [0] * n
	k = input()
	pi = [*map(int, input().split())]
	for i in pi:
		res[i - 1] += 1
	t = 1
	for j in range(n - 1, -1, -1):
		t += res[j]
		cnt[ord(k[j]) - ord('a')] += t
	print(*cnt)


for _ in range(int(input())):
	(n, m) = list(map(int, input().split()))
	word = [ord(x) - 97 for x in input()]
	p = list(map(int, input().split()))
	p.sort()
	p.append(n)
	p.reverse()
	chars = [0] * 26
	l = len(p)
	for i in range(n):
		while p[-1] - 1 < i:
			p.pop(-1)
		l = len(p)
		chars[word[i]] += l
	print(*chars)


from collections import defaultdict

def sol():
	T = int(input())
	for i in range(T):
		(n, m) = map(int, input().split(' '))
		letter = input()
		p = list(map(int, input().split(' ')))
		for i in range(len(p)):
			p[i] -= 1
		p.sort()
		count_list = [0] * n
		idx = n - 1
		count = 0
		for i in range(m - 1, -1, -1):
			while idx > p[i]:
				count_list[idx] = count
				idx -= 1
			count += 1
		for i in range(idx + 1):
			count_list[i] = count
		count_by_char_dict = defaultdict(int)
		for i in range(n):
			count_by_char_dict[letter[i]] += count_list[i] + 1
		ans = [0] * 26
		for i in range(26):
			if chr(i + 97) in count_by_char_dict:
				ans[i] = count_by_char_dict[chr(i + 97)]
		for val in ans:
			print(val, end=' ')
		print()
sol()


t = int(input())
for i in range(t):
	(n, m) = map(int, input().split())
	letters = list(input())
	pressed = list(map(int, input().split()))
	alphabet = [0 for t in range(26)]
	numbers = [0 for t in range(n)]
	numbers[-1] = 1
	for number in pressed:
		numbers[number - 1] += 1
	mcopy = m + 1
	last = 0
	for j in range(n):
		if numbers[j]:
			for t in range(last, j + 1):
				alphabet[ord(letters[t]) % 97] += mcopy
			last = j + 1
			mcopy -= numbers[j]
	print(*alphabet)


import string
for _ in range(int(input())):
	(n, m) = map(int, input().split())
	s = input()
	p = list(map(int, input().split()))
	freq = {letter: 0 for letter in string.ascii_lowercase}
	d = [0] * (n + 1)
	for i in range(m):
		d[p[i]] -= 1
	c = m - 1
	for i in range(n):
		m += d[i]
		freq[s[i]] += m
	for letter in s:
		freq[letter] += 1
	for val in freq.values():
		print(val, end=' ')
	print()


import copy
t = int(input())
for ti in range(t):
	(n, m) = (int(i) for i in input().split(' '))
	s = input()
	li = [int(i) for i in input().split(' ')]
	od = [0 for i in range(26)]
	sta = []
	for i in s:
		od[ord(i) - 97] += 1
		sta.append(copy.deepcopy(od))
	for j in li:
		for k in range(26):
			od[k] += sta[j - 1][k]
	print(*od, sep=' ')


import string
alph = list(string.ascii_lowercase)
from bisect import bisect_right

def find_gt(a, x):
	i = bisect_right(a, x)
	return i
t = int(input())
for _ in range(t):
	d = {each: 0 for each in alph}
	(n, m) = list(map(int, input().split()))
	s = input()
	p = sorted(list(map(int, input().split())))
	for (i, ch) in enumerate(s):
		temp = find_gt(p, i)
		d[ch] += m + 1 - temp
	print(' '.join(map(str, d.values())))


t = int(input())
while t:
	t -= 1
	(n, m) = map(int, input().split())
	s = list(input())
	ar = list(map(int, input().split()))
	alpha = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z']
	visited = [0] * n
	for i in ar:
		visited[i - 1] += 1
	curr = 0
	for i in range(len(visited) - 1, -1, -1):
		visited[i] += curr
		curr = max(curr, visited[i])
	d = {}
	for i in range(len(s)):
		try:
			d[s[i]] += visited[i] + 1
		except:
			d[s[i]] = visited[i] + 1
	for i in alpha:
		try:
			print(d[i], end=' ')
		except:
			print(0, end=' ')
	print()


for _ in range(int(input())):
	dic = {'a': 0, 'b': 0, 'c': 0, 'd': 0, 'e': 0, 'f': 0, 'g': 0, 'h': 0, 'i': 0, 'j': 0, 'k': 0, 'l': 0, 'm': 0, 'n': 0, 'o': 0, 'p': 0, 'q': 0, 'u': 0, 'r': 0, 's': 0, 't': 0, 'u': 0, 'v': 0, 'w': 0, 'x': 0, 'y': 0, 'z': 0}
	(n, m) = map(int, input().split())
	s = input()
	l = [int(x) for x in input().split()]
	l.sort()
	j = 0
	for i in range(len(l)):
		while j < l[i]:
			dic[s[j]] += m + 1
			j += 1
		m -= 1
	while j < n:
		dic[s[j]] += m + 1
		j += 1
	l = sorted(dic.items(), key=lambda x: x[0])
	for i in l:
		print(i[1], end=' ')
	print()


def solve():
	ans = [0 for _ in range(26)]
	(n, m) = [int(x) for x in input().split()]
	c = [ord(x) - ord('a') for x in input()]
	ile = [0 for _ in range(n)]
	ile[n - 1] += 1
	for x in input().split():
		ile[int(x) - 1] += 1
	curr = 0
	suf = []
	for x in ile[::-1]:
		curr += x
		suf.append(curr)
	suf = suf[::-1]
	for (i, x) in enumerate(suf):
		ans[c[i]] += x
	print(*ans)
t = int(input())
for _ in range(t):
	solve()


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	s = input()
	p = list(map(int, input().split()))
	a = [0] * 26
	b = [0] * n
	for i in p:
		b[i - 1] += 1
	c = 1
	for i in range(n - 1, -1, -1):
		c += b[i]
		a[ord(s[i]) - 97] += c
	print(*a)


get_int = lambda : int(input())
get_mul_int = lambda : map(int, input().rstrip().split())
get_list = lambda : list(map(int, input().rstrip().split()))
TEST_CASES = True

def main():
	(n, m) = get_mul_int()
	s = input()
	indices = get_list()
	a = [0] * 26
	b = [0] * n
	for i in indices:
		b[i - 1] += 1
	cdf_count = 1
	for i in range(n - 1, -1, -1):
		cdf_count += b[i]
		a[ord(s[i]) - 97] += cdf_count
	print(*a)
if not TEST_CASES:
	main()
else:
	[main() for _ in range(int(input()))]


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

def li():
	return list(mi())

def ii():
	return int(input())

def si():
	return input()
t = ii()
while t:
	t -= 1
	(n, m) = mi()
	s = si()
	ans = [0] * 26
	a = li()
	b = [0] * (n + 1)
	for i in a:
		b[0] += 1
		b[i] -= 1
	ans[ord(s[0]) - ord('a')] += b[0]
	for i in range(1, n):
		b[i] = b[i] + b[i - 1]
		ans[ord(s[i]) - ord('a')] += b[i]
	for i in range(n):
		ans[ord(s[i]) - ord('a')] += 1
	print(*ans)


for i in range(int(input())):
	(n, m) = map(int, input().split())
	s = input()
	p = list(map(int, input().split()))
	l = [[0] * n for i in range(26)]
	l1 = [0] * 26
	for i in range(n):
		k = ord(s[i]) - 97
		l1[k] += 1
		for j in range(26):
			l[j][i] = l1[j]
	l1 = [0] * 26
	for i in range(m):
		for j in range(26):
			l1[j] += l[j][p[i] - 1]
	for j in range(26):
		l1[j] += l[j][n - 1]
	print(*l1)


import math, string, itertools, fractions, heapq, collections, re, array, bisect, sys, copy, functools
sys.setrecursionlimit(10 ** 7)
inf = 10 ** 20
eps = 1.0 / 10 ** 10
mod = 10 ** 9 + 7
mod2 = 998244353
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)]

def LI():
	return list(map(int, sys.stdin.readline().split()))

def LLI():
	return [list(map(int, l.split())) for l in sys.stdin.readlines()]

def LI_():
	return [int(x) - 1 for x in sys.stdin.readline().split()]

def LF():
	return [float(x) for x in sys.stdin.readline().split()]

def LS():
	return sys.stdin.readline().split()

def I():
	return int(sys.stdin.readline())

def F():
	return float(sys.stdin.readline())

def S():
	return input()

def pf(s):
	return print(s, flush=True)

def pe(s):
	return print(str(s), file=sys.stderr)

def JA(a, sep):
	return sep.join(map(str, a))

def JAA(a, s, t):
	return s.join((t.join(map(str, b)) for b in a))

def IF(c, t, f):
	return t if c else f

def YES(c):
	return IF(c, 'YES', 'NO')

def Yes(c):
	return IF(c, 'Yes', 'No')

def main():
	t = I()
	rr = []
	for _ in range(t):
		(n, m) = LI()
		s = S()
		p = LI_()
		r = [0] * 26
		t = [0] * 26
		pc = collections.Counter(p)
		pc[n - 1] += 1
		for i in range(n):
			c = ord(s[i]) - ord('a')
			t[c] += 1
			pt = pc[i]
			if pt > 0:
				for j in range(26):
					r[j] += t[j] * pt
		rr.append(JA(r, ' '))
	return JA(rr, '\n')
print(main())


from sys import stdin
t = int(input())
for _ in range(t):
	(n, m) = map(int, input().split())
	s = [ord(x) - ord('a') for x in input().rstrip()]
	p = map(int, input().split())
	alphabet = [0] * 26
	twod = [[0 for j in range(26)] for i in range(n)]
	twod[0][s[0]] += 1
	for i in range(1, n):
		for j in range(26):
			twod[i][j] = twod[i - 1][j]
		twod[i][s[i]] += 1
	for i in p:
		for j in range(26):
			alphabet[j] += twod[i - 1][j]
	for i in s:
		alphabet[i] += 1
	print(*alphabet)


import os
import sys
from io import BytesIO, IOBase
input = sys.stdin.readline

def inp():
	return int(input())

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

def insr():
	s = input()
	return list(s[:len(s) - 1])

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

def main():
	try:
		for _ in range(inp()):
			(n, m) = invr()
			s = input()
			p = inlt()
			pref = [0] * n
			for i in range(m):
				pref[p[i] - 1] += 1
			for i in range(n - 1, 0, -1):
				pref[i - 1] += pref[i]
			alpha = [0] * 26
			for i in range(n):
				alpha[ord(s[i]) - 97] += pref[i] + 1
			print(*alpha, sep=' ')
	except Exception as e:
		print(e)
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
main()


import sys
d = {}
cnt = 0
for i in 'abcdefghijklmnopqrstuvwxyz':
	d[i] = cnt
	cnt += 1
for _ in range(int(sys.stdin.readline())):
	(n, m) = map(int, sys.stdin.readline().split())
	s = sys.stdin.readline()
	p = list(map(int, sys.stdin.readline().split()))
	p.sort()
	p.append(n)
	ans = [0] * 26
	crrans = [0] * 26
	curr = 0
	for i in range(m + 1):
		val = p[i]
		for j in range(curr, val):
			crrans[d[s[j]]] += 1
		for j in range(26):
			ans[j] += crrans[j]
		curr = val
	for i in range(26):
		sys.stdout.write(str(ans[i]))
		sys.stdout.write(' ')
	sys.stdout.write('\n')


from sys import stdin
for _ in range(int(stdin.readline().rstrip())):
	(n, m) = map(int, stdin.readline().rstrip().split(' '))
	s = list(stdin.readline().rstrip())
	l = list(map(int, stdin.readline().rstrip().split(' ')))
	r = [[0] * 26 for i in range(n)]
	for i in range(1, n):
		z = i - 1
		for j in range(26):
			r[i][j] += r[i - 1][j]
		r[i][ord(s[z]) - 97] += 1
	res = [0] * 26
	for i in range(n):
		res[ord(s[i]) - 97] += 1
	for i in l:
		res = [sum(i) for i in zip(res, r[i])]
	print(*res)


t = int(input())
a_symbol_code = 97
for i in range(t):
	(n, m) = map(int, input().split())
	combo = input()
	ans = [0 for symbol in range(26)]
	tries = sorted([int(correct_num) for correct_num in input().split()])
	tries.append(len(combo))
	multiplier = len(tries)
	previous_try_stop = 0
	for current in tries:
		for letter_index in range(previous_try_stop, current):
			ans[ord(combo[letter_index]) - a_symbol_code] += multiplier
		previous_try_stop = current
		multiplier -= 1
	print(*ans)


import sys
t = int(sys.stdin.readline())
for _ in range(t):
	(n, m) = map(int, sys.stdin.readline().split())
	combo = sys.stdin.readline()
	ps = list(map(int, sys.stdin.readline().split()))
	arr1 = []
	sumVal = [0] * 126
	for i in range(n):
		if i == 0:
			temp = [0] * 126
			temp[ord(combo[i])] += 1
			arr1.append(temp)
		else:
			temp = []
			for j in range(len(arr1[-1])):
				temp.append(arr1[-1][j])
			arr1.append(temp)
			arr1[-1][ord(combo[i])] += 1
	for p in ps:
		for i in range(26):
			sumVal[i] += arr1[p - 1][ord('a') + i]
	for j in range(26):
		sumVal[j] += arr1[-1][ord('a') + j]
	sumVal = sumVal[:26]
	for k in range(len(sumVal)):
		if k == len(sumVal) - 1:
			print(sumVal[k])
		else:
			print(sumVal[k], end=' ')


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	s = input()
	p = list(map(int, input().split()))
	p.append(0)
	p = sorted(p)
	ans = {}
	for i in range(ord('a'), ord('z') + 1):
		ans[chr(i)] = 0
	for x in s:
		ans[x] += 1
	for i in range(m):
		for j in range(p[i], p[i + 1]):
			ans[s[j]] += m - i
	print(' '.join([str(ans[x]) for x in ans]))


from sys import stdin, stdout
int_in = lambda : int(stdin.readline())
arr_in = lambda : [int(x) for x in stdin.readline().split()]
mat_in = lambda rows: [arr_in() for y in range(rows)]
str_in = lambda : stdin.readline().strip()
out = lambda o: stdout.write('{}\n'.format(o))
arr_out = lambda o: out(' '.join(map(str, o)))
bool_out = lambda o: out('YES' if o else 'NO')

def solve(n, m, s, p):
	mistake_at = [0] * n
	for item in p:
		mistake_at[item - 1] += 1
	result = [0] * 26
	alphabet = 'abcdefghijklmnopqrstuvwxyz'
	count = len(p) + 1
	for i in range(n):
		result[alphabet.index(s[i])] += count
		count -= mistake_at[i]
	return result
for i in range(int_in()):
	(n, m) = arr_in()
	s = str_in()
	p = arr_in()
	arr_out(solve(n, m, s, p))


from heapq import heappush, heappop, heapify
from collections import deque, defaultdict, Counter
import itertools
from itertools import permutations, combinations, accumulate
import sys
import bisect
import string
import math
import time

def I():
	return int(input())

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

def S():
	return input()

def MS():
	return map(str, input().split())

def LI():
	return [int(i) for i in input().split()]

def LI_():
	return [int(i) - 1 for i in input().split()]

def StoI():
	return [ord(i) - 97 for i in input()]

def ItoS(nn):
	return chr(nn + 97)

def input():
	return sys.stdin.readline().rstrip()

def show(*inp, end='\n'):
	if show_flg:
		print(*inp, end=end)
YN = {False: 'No', True: 'Yes'}
MOD = 10 ** 9 + 7
inf = float('inf')
IINF = 10 ** 10
l_alp = string.ascii_lowercase
u_alp = string.ascii_uppercase
nums = ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10']
show_flg = False

def solve(T):
	(n, m) = MI()
	s = S()
	p = LI()
	ans = [0 for i in range(26)]
	dic = {}
	for k in p:
		if k not in dic:
			dic[k] = 0
		dic[k] += 1
	dp = [0] * (n + 1)
	keys = list(sorted(dic.keys(), reverse=True))
	cur = 0
	v = keys[cur]
	dp[n] = 1
	last = False
	for i in range(n, 0, -1):
		if i > v:
			dp[i - 1] = dp[i]
		elif cur + 1 < len(keys):
			dp[i - 1] = dp[i] + dic[v]
			cur += 1
			v = keys[cur]
		elif last is False:
			last = True
			dp[i - 1] = dp[i] + dic[v]
		else:
			dp[i - 1] = dp[i]
	for i in range(n):
		ch = ord(s[i]) - ord('a')
		ans[ch] += dp[i]
	print(*ans)

def main():
	T = I()
	for i in range(T):
		solve(T)
main()


t = int(input())
import bisect
for qwe in range(t):
	alf = {'a': 0, 'b': 0, 'c': 0, 'd': 0, 'e': 0, 'f': 0, 'g': 0, 'h': 0, 'i': 0, 'j': 0, 'k': 0, 'l': 0, 'm': 0, 'n': 0, 'o': 0, 'p': 0, 'q': 0, 'r': 0, 's': 0, 't': 0, 'u': 0, 'v': 0, 'w': 0, 'x': 0, 'y': 0, 'z': 0}
	(n, m) = map(int, input().split())
	s = input()
	p = list(map(int, input().split()))
	p.sort()
	for i in range(n):
		ind = bisect.bisect_left(p, i + 1)
		alf[s[i]] += m - ind + 1
	for i in alf.values():
		print(i, end=' ')
	print()


for __ in range(int(input())):
	(n, m) = [int(x) for x in input().split()]
	s = input()
	b = [int(x) for x in input().split()]
	a = [0] * n
	for x in b:
		a[x - 1] += 1
	i = n - 2
	while i >= 0:
		a[i] += a[i + 1]
		i -= 1
	i = 0
	while i < n:
		a[i] += 1
		i += 1
	k = [0] * 26
	i = 0
	while i < n:
		k[ord(s[i]) - ord('a')] += a[i]
		i += 1
	for x in k:
		print(x, end=' ')
	print()


import math
from decimal import Decimal
import heapq
import copy
import heapq
from collections import deque
from collections import defaultdict

def na():
	n = int(input())
	b = [int(x) for x in input().split()]
	return (n, b)

def nab():
	n = int(input())
	b = [int(x) for x in input().split()]
	c = [int(x) for x in input().split()]
	return (n, b, c)

def dv():
	(n, m) = map(int, input().split())
	return (n, m)

def da():
	(n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	return (n, m, a)

def dva():
	(n, m) = map(int, input().split())
	a = [int(x) for x in input().split()]
	b = [int(x) for x in input().split()]
	return (n, m, b)

def prost(x):
	d = math.sqrt(x)
	d = int(d) + 1
	for i in range(2, d):
		if x % i == 0:
			return False
	return True

def eratosthenes(n):
	sieve = list(range(n + 1))
	for i in sieve:
		if i > 1:
			for j in range(i + i, len(sieve), i):
				sieve[j] = 0
	return sorted(set(sieve))

def lol(lst, k):
	k = k % len(lst)
	ret = [0] * len(lst)
	for i in range(len(lst)):
		if i + k < len(lst) and i + k >= 0:
			ret[i] = lst[i + k]
		if i + k >= len(lst):
			ret[i] = lst[i + k - len(lst)]
		if i + k < 0:
			ret[i] = lst[i + k + len(lst)]
	return ret

def nm():
	n = int(input())
	b = [int(x) for x in input().split()]
	m = int(input())
	c = [int(x) for x in input().split()]
	return (n, b, m, c)

def dvs():
	n = int(input())
	m = int(input())
	return (n, m)
ddd = 'abcdefghijklmnopqrstuvwxyz'
for _ in range(int(input())):
	(n, m) = map(int, input().split())
	s = input()
	p = list(map(int, input().split()))
	d = defaultdict(int)
	pref = []
	for j in range(n):
		if j == 0:
			tc = defaultdict(int)
			tc[s[0]] += 1
		else:
			tc = defaultdict(int)
			for i in pref[-1]:
				tc[i] = pref[-1][i]
			tc[s[j]] += 1
		pref.append(tc)
	p.append(n)
	for i in p:
		dd = i - 1
		for j in pref[dd]:
			d[j] += pref[dd][j]
	for i in ddd:
		print(d[i], end=' ')
	print()


t = int(input())
a = [chr(ord('a') + i) for i in range(26)]
integer = [i for i in range(1, 27)]
for _ in range(t):
	(n, m) = map(int, input().split())
	s = list(input())
	p = list(map(int, input().split()))
	p.sort()
	p.append(n)
	for i in range(len(s)):
		for j in range(len(integer)):
			if s[i] == a[j]:
				s[i] = integer[j]
	cnt = [0] * 26
	cnt_now = [0] * 26
	here = p[0]
	for i in range(0, here):
		cnt[s[i] - 1] += 1
		cnt_now[s[i] - 1] += 1
	for j in range(m):
		for i in range(26):
			cnt[i] += cnt_now[i]
		for i in range(here, p[j + 1]):
			cnt_now[s[i] - 1] += 1
			cnt[s[i] - 1] += 1
			here = p[j + 1]
	print(*cnt)


import string, sys

def bin_search(i, mas):
	left = -1
	right = len(mas)
	while right - left > 1:
		mid = (right + left) // 2
		if mas[mid] > i:
			right = mid
		else:
			left = mid
	return right
t = int(input())
for _ in range(t):
	num = dict(((string.ascii_lowercase[i], 0) for i in range(26)))
	(n, m) = map(int, sys.stdin.readline().split())
	a = str(sys.stdin.readline())
	p = [int(i) for i in sys.stdin.readline().split()]
	p.sort()
	for i in range(n):
		num[a[i]] += m - bin_search(i, p) + 1
	for i in string.ascii_lowercase:
		sys.stdout.write(str(num[i]) + ' ')
	sys.stdout.write('\n')


T = int(input())
for tt in range(T):
	[n, m] = [int(i) for i in input().split()]
	s = input()
	p = [int(i) for i in input().split()]
	alphabet = 'abcdefghijklmnopqrstuvwxyz'
	p.sort()
	dic = {i: 0 for i in alphabet}
	lst = [0 for i in range(n)]
	j = 0
	i = 0
	while 1:
		if i >= m or j >= n:
			break
		if j < p[i]:
			lst[j] = m - i
			j += 1
		elif j >= p[i]:
			i += 1
	for i in range(n):
		dic[s[i]] += lst[i]
		dic[s[i]] += 1
	for i in dic:
		print(dic[i], end=' ')
	print()


import string
data = input().rstrip().split()
t = int(data[0])
letters = list(string.ascii_lowercase)
all_vars = []
for u in range(t):
	data = input().rstrip().split()
	(m, n) = (int(data[0]), int(data[1]))
	data = input().rstrip().split()
	s = data[0]
	data = input().rstrip().split()
	ps = [int(p) for p in data]
	all_vars.append((m, n, s, ps))

def to_str(list):
	return ' '.join([str(l) for l in list]) + ' '
for (m, n, s, ps) in all_vars:
	ps.sort(reverse=True)
	rr = [1] * m
	counter = 0
	p_prev = ps[0]
	for i in range(n):
		if i != n - 1:
			p_next = ps[i + 1]
			if p_next == p_prev:
				continue
			for j in range(p_next, p_prev):
				rr[j] += i + 1
			p_prev = p_next
		else:
			for j in range(0, p_prev):
				rr[j] += i + 1
	result = {l: 0 for l in letters}
	for (l, c) in zip(s, rr):
		result[l] += c
	counts = [result[l] for l in letters]
	print(to_str(counts))


import sys
input = sys.stdin.readline

def update(res, h):
	for i in h.keys():
		res[ord(i) - 97] += h[i]

def solve():
	(n, m) = map(int, input().split())
	s = input().strip()
	q = sorted(list(map(int, input().split())), reverse=True)
	h = {}
	for i in s:
		if i not in h:
			h[i] = 1
		else:
			h[i] = h[i] + 1
	res = [0 for _ in range(26)]
	last = len(s)
	update(res, h)
	for qu in q:
		for x in range(qu, last):
			h[s[x]] -= 1
		update(res, h)
		last = qu
	print(*res)
for _ in range(int(input())):
	solve()


t = int(input())
for i in range(t):
	(n, m) = map(int, input().split())
	s = input()
	fails = [int(j) for j in input().split()]
	pre = [0 for j in range(n)]
	ans = [0 for j in range(26)]
	for f in fails:
		pre[0] += 1
		pre[f] -= 1
	for j in range(1, n):
		pre[j] += pre[j - 1]
	for j in range(n):
		ans[ord(s[j]) - 97] += pre[j] + 1
	print(*ans)


from collections import defaultdict as dd
t = int(input())
for _ in range(t):
	(n, m) = map(int, input().split())
	s = input()
	p = list(map(int, input().split()))
	d = dd(int)
	for i in p:
		d[i] += 1
	a = [0 for x in range(26)]
	p = list(set(p))
	p.sort()
	arr = [0 for x in range(n)]
	m += 1
	ptr = 0
	for i in range(n):
		arr[i] = m
		if m > 1 and p[ptr] - 1 == i:
			m -= d[p[ptr]]
			ptr += 1
	for i in range(n):
		a[ord(s[i]) - 97] += arr[i]
	print(' '.join(map(str, a)))


def solve(n, m, S, P):
	temp = [0] * 26
	np_list = []
	for (itr, s) in enumerate(S):
		idx = ord(s) - 97
		temp[idx] += 1
		temp_copy = temp[:]
		if itr < n - 1:
			np_list.append(temp_copy)
	ans = temp
	for p in P:
		for (i, num) in enumerate(np_list[p - 1]):
			ans[i] += num
	return ans
t = int(input())
for _ in range(t):
	(n, m) = map(int, input().split())
	S = input()
	P = list(map(int, input().split()))
	ans = solve(n, m, S, P)
	print(*ans)


for test in range(int(input())):
	(n, m) = map(int, input().split())
	s = input()
	p = list(map(int, input().split()))
	cnt = [[0 for i in range(26)] for j in range(n)]
	res = [0] * 26
	for i in range(n):
		cnt[i][ord(s[i]) - ord('a')] += 1
	for i in range(1, n):
		for c in range(26):
			cnt[i][c] += cnt[i - 1][c]
	for i in range(m):
		for c in range(26):
			res[c] += cnt[p[i] - 1][c]
	for c in range(26):
		res[c] += cnt[-1][c]
	print(*res)


from sys import *
from collections import Counter
input = lambda : stdin.readline()
int_arr = lambda : list(map(int, stdin.readline().strip().split()))
str_arr = lambda : list(map(str, stdin.readline().split()))
get_str = lambda : map(str, stdin.readline().strip().split())
get_int = lambda : map(int, stdin.readline().strip().split())
get_float = lambda : map(float, stdin.readline().strip().split())
mod = 1000000007
setrecursionlimit(1000)
for _ in range(int(input())):
	(n, m) = get_int()
	s = str(input())[:-1]
	arr = int_arr()
	lst = [0] * (n + 1)
	lst[n] = 1
	for i in range(m):
		lst[arr[i] - 1] += 1
	for i in range(n - 1, -1, -1):
		lst[i] += lst[i + 1]
	res = [0] * 26
	for i in range(len(s)):
		res[ord(s[i]) - 97] += lst[i]
	print(*res)


def read():
	(n, m) = map(int, input().split())
	s = input()
	p = list(map(int, input().split()))
	return (n, m, s, p)

def solve(n, m, s, p):
	a = [[0] * (n + 1) for i in range(26)]
	ord_a = ord('a')
	for i in range(n):
		for j in range(26):
			a[j][i + 1] = a[j][i]
		a[ord(s[i]) - ord_a][i + 1] += 1
	res = [0] * 26
	p.append(n)
	for pi in p:
		for i in range(26):
			res[i] += a[i][pi]
	return res
for t in range(int(input())):
	result = solve(*read())
	print(*result)


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	s = input()
	s = s.rstrip()
	dp = [0] * n
	p = list(map(int, input().split()))
	for i in p:
		dp[i] += 1
	for i in range(1, n):
		dp[i] += dp[i - 1]
	ans = [0] * 26
	for i in range(0, n):
		dp[i] = m + 1 - dp[i]
	for i in range(0, n):
		b = ord(s[i]) - 97
		ans[b] += dp[i]
	for i in range(0, 26):
		print(ans[i], end=' ')
	print()


for _ in range(int(input())):
	(n, m) = [int(x) for x in input().split()]
	given = input()
	pos = [int(x) for x in input().split()]
	pref = [0] * (n + 1)
	for it in pos:
		pref[0] += 1
		pref[it] -= 1
	cnt = [0] * 26
	for i in range(n):
		if i > 0:
			pref[i] += pref[i - 1]
		cnt[ord(given[i]) - 97] += pref[i] + 1
	print(*cnt)


t = int(input())
for _ in range(t):
	(n, m) = map(int, input().split())
	s = input()
	a = [0] * n
	b = [0] * 26
	p = list(map(int, input().split()))
	d = [0] * n
	for i in p:
		d[i - 1] += 1
	a[n - 1] = d[n - 1]
	for i in range(n - 2, -1, -1):
		a[i] = a[i + 1] + d[i]
	for i in range(n):
		b[ord(s[i]) - ord('a')] += a[i]
	for i in range(n):
		b[ord(s[i]) - ord('a')] += 1
	print(*b)


t = int(input())
for _ in range(t):
	(n, m) = tuple(map(int, input().split()))
	s = input()
	p = list(map(int, input().split()))
	histogram = [0 for i in range(n)]
	for pp in p:
		histogram[pp - 1] += 1
	histogram[-1] = 1
	sum = 0
	for i in range(n - 1, -1, -1):
		sum += histogram[i]
		histogram[i] = sum
	result = [0 for i in range(ord('z') - ord('a') + 1)]
	for i in range(n):
		result[ord(s[i]) - ord('a')] += histogram[i]
	print(' '.join(map(str, result)))


from sys import stdin, gettrace
if not gettrace():

	def input():
		return next(stdin)[:-1]

def main():

	def solve():
		(n, m) = map(int, input().split())
		ss = [ord(s) - ord('a') for s in input()]
		pp = [int(a) for a in input().split()]
		pp.sort()
		ppi = iter(pp)
		counts = [0] * 26
		p = next(ppi)
		mult = m + 1
		for i in range(n):
			while i == p:
				mult -= 1
				if mult > 1:
					p = next(ppi)
				else:
					p = -1
			counts[ss[i]] += mult
		print(' '.join(map(str, counts)))
	q = int(input())
	for _ in range(q):
		solve()
main()


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	s = input()
	p = list(map(int, input().split()))
	alpha = list('abcdefghijklmnopqrstuvwxyz')
	count = dict(zip(alpha, [0 for _ in range(26)]))
	sum = [0 for _ in range(n)]
	for i in range(m):
		if p[i] >= n:
			break
		sum[0] += 1
		sum[p[i]] -= 1
	else:
		sum[0] += 1
	su = 0
	for i in range(n):
		su += sum[i]
		count[s[i]] += su
	ans = []
	for key in alpha:
		ans.append(count[key])
	print(*ans)


import sys
input = sys.stdin.readline
t = int(input())
for _ in range(t):
	(n, m) = [int(item) for item in input().split()]
	command = input().rstrip()
	tries = [int(item) for item in input().split()] + [n]
	cumsum = [0] * (n + 1)
	for item in tries:
		cumsum[0] += 1
		cumsum[item] -= 1
	for i in range(n):
		cumsum[i + 1] += cumsum[i]
	ans = [0] * 26
	orda = ord('a')
	for (ch, cnt) in zip(command, cumsum):
		ans[ord(ch) - orda] += cnt
	print(*ans)


t = int(input())
for i in range(t):
	(n, m) = map(int, input().split())
	s = input()
	p = list(map(int, input().split()))
	p.append(n)
	a = [0] * 26
	l = [0] * n
	for j in range(m + 1):
		l[p[j] - 1] += 1
	for j in range(n - 2, -1, -1):
		l[j] += l[j + 1]
	for j in range(n):
		a[ord(s[j]) - ord('a')] += l[j]
	print(*a)


for _ in range(int(input())):
	(n, m) = [int(i) for i in input().split()]
	g = input()
	pos = [int(i) for i in input().split()]
	pref = [0] * (n + 1)
	for i in pos:
		pref[0] += 1
		pref[i] -= 1
	ct = [0] * 26
	for i in range(n):
		if i > 0:
			pref[i] += pref[i - 1]
		ct[ord(g[i]) - 97] += pref[i] + 1
	print(*ct)


import sys, os, io

def rs():
	return sys.stdin.readline().rstrip()

def ri():
	return int(sys.stdin.readline())

def ria():
	return list(map(int, sys.stdin.readline().split()))

def ws(s):
	sys.stdout.write(s + '\n')

def wi(n):
	sys.stdout.write(str(n) + '\n')

def wia(a):
	sys.stdout.write(' '.join([str(x) for x in a]) + '\n')
import math, datetime, functools
from collections import deque, defaultdict, OrderedDict
import collections

def main():
	starttime = datetime.datetime.now()
	if os.path.exists('input.txt'):
		sys.stdin = open('input.txt', 'r')
		sys.stdout = open('output.txt', 'w')
	mod = 998244353
	for _ in range(ri()):
		(n, m) = ria()
		t = m
		s = rs()
		p = ria()
		d = {}
		a = [0] * (n + 1)
		s += '.'
		for i in range(26):
			d[chr(i + 97)] = 0
		d['.'] = 0
		for i in range(m):
			a[0] += 1
			a[p[i]] -= 1
		a[0] += 1
		a[-1] -= 1
		k = a[0]
		for i in range(1, n + 1):
			k += a[i]
			a[i] = k
		for i in range(n):
			d[s[i]] += a[i]
		for i in range(26):
			print(d[chr(i + 97)], end=' ')
		print()
	endtime = datetime.datetime.now()
	time = (endtime - starttime).total_seconds() * 1000
	if os.path.exists('input.txt'):
		print('Time:', time, 'ms')

class FastReader(io.IOBase):
	newlines = 0

	def __init__(self, fd, chunk_size=1024 * 8):
		self._fd = fd
		self._chunk_size = chunk_size
		self.buffer = io.BytesIO()

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, self._chunk_size))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self, size=-1):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, self._chunk_size if size == -1 else size))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

class FastWriter(io.IOBase):

	def __init__(self, fd):
		self._fd = fd
		self.buffer = io.BytesIO()
		self.write = self.buffer.write

	def flush(self):
		os.write(self._fd, self.buffer.getvalue())
		(self.buffer.truncate(0), self.buffer.seek(0))

class FastStdin(io.IOBase):

	def __init__(self, fd=0):
		self.buffer = FastReader(fd)
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')

class FastStdout(io.IOBase):

	def __init__(self, fd=1):
		self.buffer = FastWriter(fd)
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.flush = self.buffer.flush
sys.stdin = FastStdin()
sys.stdout = FastStdout()
main()


t = int(input())
for _ in range(t):
	(n, m) = map(int, input().split())
	s = input()
	p = list(map(int, input().split()))
	cnt = []
	line = [0] * 26
	for i in range(n):
		c = s[i]
		line[ord(c) - 97] += 1
		cnt.append(list(line))
	ans = cnt[n - 1]
	for e in p:
		ans = list(map(lambda x, y: x + y, ans, cnt[e - 1]))
	print(*ans)


def prefix(arr):
	for i in range(1, len(arr)):
		arr[i] += arr[i - 1]
	return arr
t = int(input())
for q in range(t):
	(l, m) = map(int, input().split())
	s = input()
	ar = list(map(int, input().split()))
	arr = [0] * len(s)
	for i in range(len(ar)):
		arr[0] += 1
		arr[min(ar[i], len(arr) - 1)] += -1
	arr[0] += 1
	prefix(arr)
	hash = [0] * 26
	for i in range(len(s)):
		hash[ord(s[i]) - ord('a')] += arr[i]
	for i in range(len(hash)):
		print(hash[i], end=' ')
	print()


s = 'abcdefghijklmnopqrstuvwxyz'
t = int(input())
for i in range(t):
	(n, m) = map(int, input().split())
	combo = input()
	qs = [0] * n
	p = [int(x) for x in input().split()]
	for i in p:
		qs[0] += 1
		qs[i] -= 1
	qs[0] += 1
	for i in range(1, n):
		qs[i] += qs[i - 1]
	alpha = [0] * 26
	for i in range(n):
		alpha[s.find(combo[i])] += qs[i]
	for i in alpha:
		print(i, end=' ')


from bisect import bisect_left as bl
from bisect import bisect_right as br
rr = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z']
ss = []
for jjij in range(int(input())):
	q = {}
	(n, m) = map(int, input().split())
	s = input()
	p = sorted(list(map(int, input().split())))
	for i in range(n):
		q[s[i]] = q.get(s[i], 0) + (m - bl(p, i + 1))
	for i in q:
		q[i] += s.count(i)
	f = []
	for i in rr:
		f.append(q.get(i, 0))
	ss.append(f)
for i in ss:
	for j in i:
		print(j, end=' ')
	print()


ls = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z']
t = int(input())
for ___ in range(t):
	dc = {'a': 0, 'c': 0, 'b': 0, 'e': 0, 'd': 0, 'g': 0, 'f': 0, 'i': 0, 'h': 0, 'k': 0, 'j': 0, 'm': 0, 'l': 0, 'o': 0, 'n': 0, 'q': 0, 'p': 0, 's': 0, 'r': 0, 'u': 0, 't': 0, 'w': 0, 'v': 0, 'y': 0, 'x': 0, 'z': 0}
	(a, b) = map(int, input().split())
	s = input()
	p = list(map(int, input().split()))
	p = sorted(p)
	k = 1
	b -= 1
	for j in range(b, 0, -1):
		for i in range(p[j - 1], p[j]):
			dc[s[i]] += k
		k += 1
	for i in range(0, p[0]):
		dc[s[i]] += k
	for i in range(a):
		dc[s[i]] += 1
	ss = str()
	for el in ls:
		ss += str(dc[el]) + ' '
	print(ss)


t = int(input())
for _ in range(t):
	(n, m) = [int(x) for x in input().split()]
	s = input()
	p = [int(x) for x in input().split()]
	prefixSums = [[0 for _ in range(n)] for __ in range(26)]
	for k in range(n):
		if k > 0:
			for i in range(26):
				prefixSums[i][k] = prefixSums[i][k - 1]
		prefixSums[ord(s[k]) - ord('a')][k] += 1
	res = [0 for _ in range(26)]
	for l in p:
		for i in range(26):
			res[i] += prefixSums[i][l - 1]
	for i in range(26):
		res[i] += prefixSums[i][n - 1]
	print(' '.join([str(x) for x in res]))


from collections import Counter
cases = int(input())
for t in range(cases):
	(n, m) = list(map(int, input().split()))
	s = input()
	p = list(map(int, input().split()))
	p.append(n)
	c = [0] * n
	for i in p:
		c[i - 1] += 1
	for i in range(n - 1, 0, -1):
		c[i - 1] += c[i]
	d = {i: 0 for i in 'abcdefghijklmnopqrstuvwxyz'}
	for i in range(n):
		d[s[i]] += c[i]
	d = [d[i] for i in 'abcdefghijklmnopqrstuvwxyz']
	print(*d)


t = int(input())
for _ in range(t):
	(n, m) = map(int, input().split())
	s = input()
	alph = [0 for _ in range(26)]
	ps = list(map(lambda x: int(x) - 1, input().split()))
	ps.sort()
	st = 0
	for i in range(n):
		alph[ord(s[i]) - ord('a')] += m - st
		while st < m and i >= ps[st]:
			st += 1
	for i in range(n):
		alph[ord(s[i]) - ord('a')] += 1
	print(*alph)


def ii():
	return map(int, input().split())
for _ in range(int(input())):
	(n, m) = ii()
	s = input()
	p = ii()
	marked = [0 for _ in range(n + 3)]
	for ele in p:
		marked[ele] += 1
	marked[n] = 1
	ans = [0 for _ in range(26)]
	for i in range(n + 1, 0, -1):
		marked[i] += marked[i + 1]
	for i in range(1, n + 1):
		ans[ord(s[i - 1]) - 97] += marked[i]
	print(*ans, sep=' ')


from sys import stdin, stdout
input = stdin.readline
t = int(input())
for _ in range(t):
	(n, m) = map(int, input().split())
	s = input().strip()
	vals = [int(x) for x in input().split()]
	ans = [0 for i in range(26)]
	pre = [[0 for i in range(n)] for j in range(26)]
	for i in range(n):
		for j in range(26):
			if i:
				pre[j][i] = pre[j][i - 1]
			if ord(s[i]) - 97 == j:
				pre[j][i] += 1
		ans[ord(s[i]) - 97] += 1
	d = {}
	for i in vals:
		d[i] = d.get(i, 0) + 1
	for i in d:
		for j in range(26):
			ans[j] += d[i] * pre[j][i - 1]
	print(*ans)


import sys
import math
import collections
import bisect
import string

def get_ints():
	return map(int, sys.stdin.readline().strip().split())

def get_list():
	return list(map(int, sys.stdin.readline().strip().split()))

def get_string():
	return sys.stdin.readline().strip()
for t in range(int(input())):
	(n, m) = get_ints()
	s = list(get_string())
	pos = get_list()
	lower = string.ascii_lowercase
	counter = dict()
	for i in lower:
		counter[i] = 0
	pos.sort()
	index = dict()
	for i in range(n):
		if s[i] in index:
			index[s[i]].append(i + 1)
		else:
			index[s[i]] = [i + 1]
	for i in index:
		row = index[i]
		for j in row:
			index_of_alpha = j
			val = m - bisect.bisect_left(pos, index_of_alpha)
			counter[i] += val
	for j in s:
		counter[j] += 1
	print(*counter.values())


import sys
import os
import time
import collections
from collections import Counter, deque
import itertools
import math
import timeit
import random
from io import BytesIO, IOBase
from bisect import bisect_left

def sieve(n):
	if n < 2:
		return list()
	prime = [True for _ in range(n + 1)]
	p = 3
	while p * p <= n:
		if prime[p]:
			for i in range(p * 2, n + 1, p):
				prime[i] = False
		p += 2
	r = [2]
	for p in range(3, n + 1, 2):
		if prime[p]:
			r.append(p)
	return r

def divs(n, start=1):
	divisors = []
	for i in range(start, int(math.sqrt(n) + 1)):
		if n % i == 0:
			if n / i == i:
				divisors.append(i)
			else:
				divisors.extend([i, n // i])
	return divisors

def divn(n, primes):
	divs_number = 1
	for i in primes:
		if n == 1:
			return divs_number
		t = 1
		while n % i == 0:
			t += 1
			n //= i
		divs_number *= t

def flin(d, x, default=-1):
	left = right = -1
	for i in range(len(d)):
		if d[i] == x:
			if left == -1:
				left = i
			right = i
	if left == -1:
		return (default, default)
	else:
		return (left, right)

def ceil(n, k):
	return n // k + (n % k != 0)

def ii():
	return int(input())

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

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

def lcm(a, b):
	return abs(a * b) // math.gcd(a, b)

def prr(a, sep=' '):
	print(sep.join(map(str, a)))

def dd():
	return collections.defaultdict(int)

def ddl():
	return collections.defaultdict(list)
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
for _ in range(ii()):
	(n, m) = mi()
	s = input()
	p = li()
	res = [0 for i in range(26)]
	for i in range(n):
		res[ord(s[i]) - 97] += 1
	p.sort()
	for i in range(n):
		idx = bisect_left(p, i + 1)
		res[ord(s[i]) - 97] += m - idx
	print(*res)


t = int(input())
while t > 0:
	t = t - 1
	(n, m) = map(int, input().split())
	s = [i for i in input()]
	p = list(map(int, input().split()))
	b = [0 for i in range(n)]
	for i in p:
		b[i - 1] += 1
	temp = [0 for i in range(n)]
	val = m + 1
	i = 0
	while i < n:
		if b[i] == 0:
			temp[i] = val
		elif b[i] > 0:
			temp[i] = val
			val -= b[i]
		i += 1
	a = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z']
	for i in range(len(a)):
		letter = a[i]
		c = 0
		count = 0
		for j in range(n):
			if s[j] == letter:
				count += temp[j]
		print(count, end=' ')
	print()


from math import *
from collections import *
t = int(input())
for y in range(t):
	(n, m) = map(int, input().split())
	s = input()
	a = list(map(int, input().split()))
	pre = [0 for i in range(n)]
	al = [0 for i in range(26)]
	pre[0] = m + 1
	for i in a:
		pre[i] -= 1
	for i in range(1, n):
		pre[i] += pre[i - 1]
	for i in range(n):
		ind = ord(s[i]) - ord('a')
		al[ind] += pre[i]
	for i in al:
		print(i, end=' ')
	print()


t = int(input())
for i in range(t):
	(a, b) = map(int, input().split())
	s = input()
	ans = [0] * 26
	arr = [[0 for i in range(a)] for j in range(26)]
	l = list(map(int, input().split()))
	e = set()
	r = []
	rt = [0] * 26
	for j in range(a):
		d = ord(s[j]) - 97
		if d not in e:
			e.add(d)
			r.append(chr(d + 97))
		rt[d] += 1
		arr[d][j] = rt[d]
	for i in range(26):
		for j in range(1, a):
			if arr[i][j] == 0:
				arr[i][j] += arr[i][j - 1]
	for i in range(len(r)):
		j = ord(r[i]) - 97
		for k in range(b):
			ans[j] += arr[j][l[k] - 1]
		ans[j] += arr[j][a - 1]
	print(*ans, sep=' ')


import string
for _ in range(int(input())):
	(n, m) = map(int, input().split())
	s = input()
	l = list(map(int, input().split()))
	d = dict(((key, 0) for key in string.ascii_lowercase))
	l.sort()
	j = 0
	for i in range(m):
		l1 = s[j:l[i]]
		for k in l1:
			d[k] = d[k] + (m - i)
		j = l[i]
	for i in s:
		d[i] = d[i] + 1
	for i in d.values():
		print(i, end=' ')
	print(end='\n')


def bs(left, right, pos, p):
	while right - left > 1:
		middle = (left + right) // 2
		if p[middle] < pos:
			left = middle
		else:
			right = middle
	return right
t = int(input())
for i in range(t):
	count = dict()
	for j in 'abcdefghijklmnopqrstuvwxyz':
		count[j] = 0
	(n, m) = map(int, input().split())
	s = input()
	p = list(map(int, input().split()))
	p.sort()
	m += 1
	p.append(n)
	for j in range(n):
		pos = bs(-1, m, j + 1, p)
		count[s[j]] += m - pos
	for k in 'abcdefghijklmnopqrstuvwxyz':
		print(count[k], end=' ')
	print()


def modinv(n, p):
	return pow(n, p - 2, p)

def main():
	for case in range(int(input())):
		(n, m) = [int(x) for x in input().split()]
		s = input()
		series = [int(x) - 1 for x in input().split()]
		mistake_count = [1] * n
		for x in series:
			mistake_count[x] += 1
		for i in range(n - 2, -1, -1):
			mistake_count[i] += mistake_count[i + 1] - 1
		letters = 'abcdefghijklmnopqrstuvwxyz'
		letter_count = {}
		for c in letters:
			letter_count[c] = 0
		for i in range(n):
			letter_count[s[i]] += mistake_count[i]
		for l in letter_count:
			print(letter_count[l], end=' ')
		print()
py2 = round(0.5)
if py2:
	from future_builtins import ascii, filter, hex, map, oct, zip
	range = xrange
import os, sys
from io import IOBase, BytesIO
BUFSIZE = 8192

class FastIO(BytesIO):
	newlines = 0

	def __init__(self, file):
		self._file = file
		self._fd = file.fileno()
		self.writable = 'x' in file.mode or 'w' in file.mode
		self.write = super(FastIO, self).write if self.writable else None

	def _fill(self):
		s = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
		self.seek((self.tell(), self.seek(0, 2), super(FastIO, self).write(s))[0])
		return s

	def read(self):
		while self._fill():
			pass
		return super(FastIO, self).read()

	def readline(self):
		while self.newlines == 0:
			s = self._fill()
			self.newlines = s.count(b'\n') + (not s)
		self.newlines -= 1
		return super(FastIO, self).readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.getvalue())
			(self.truncate(0), self.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		if py2:
			self.write = self.buffer.write
			self.read = self.buffer.read
			self.readline = self.buffer.readline
		else:
			self.write = lambda s: self.buffer.write(s.encode('ascii'))
			self.read = lambda : self.buffer.read().decode('ascii')
			self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
main()


t = int(input())
for i in range(t):
	al = dict()
	for i in range(ord('a'), ord('z') + 1):
		al.update({chr(i): 0})
	(n, m) = map(int, input().split())
	s = input()
	pts = list(map(int, input().split()))
	pts.sort()
	pts.append(n)
	pp = 0
	count = 0
	for p in pts:
		if p == pp:
			count += 1
			continue
		else:
			for q in s[pp:p]:
				al[q] += m - count + 1
			pp = p
			count += 1
	print(*al.values())


from collections import Counter
t = int(input())
for _ in range(t):
	(n, m) = map(int, input().split())
	s = input()
	l = []
	p = [int(x) - 1 for x in input().split()]
	d = {x: 0 for x in 'abcdefghijklmnopqrstuvwxyz'}
	c = [0 for i in range(n)]
	for i in range(m):
		c[p[i]] += 1
	for i in range(n - 1, 0, -1):
		c[i - 1] += c[i]
	for i in range(n):
		d[s[i]] += c[i] + 1
	for x in 'abcdefghijklmnopqrstuvwxyz':
		if x in d:
			print(d[x], end=' ')
		else:
			print(0, end=' ')
	print()


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	s = input()
	mist = list(map(int, input().split()))
	sums = [[0] * n for _ in range(26)]
	sums[ord(s[0]) - ord('a')][0] += 1
	for i in range(1, n):
		for c in range(26):
			sums[c][i] = sums[c][i - 1]
		sums[ord(s[i]) - ord('a')][i] += 1
	dp = [0] * 26
	mist.append(n)
	for tr in mist:
		for c in range(26):
			dp[c] += sums[c][tr - 1]
	print(*dp)


t = int(input())
for i in range(t):
	(n, m) = list(map(int, input().split()))
	s = input()
	p = list(map(int, input().split()))
	prefix = [[0] * 26 for i in range(n)]
	prefix[0][ord(s[0]) - 97] = 1
	for i in range(1, n):
		prefix[i] = prefix[i - 1][:]
		prefix[i][ord(s[i]) - 97] += 1
	ans = [0] * 26
	for i in range(m):
		c = prefix[p[i] - 1]
		for j in range(26):
			ans[j] += c[j]
	for j in range(26):
		ans[j] += prefix[-1][j]
	print(' '.join(list(map(str, ans))))


t = int(input())
for _ in range(t):
	(n, m) = map(int, input().split())
	s = input()
	x = map(int, input().split())
	l = []
	r = []
	res = []
	for i in range(26):
		r.append(0)
		res.append(0)
	l.append(r)
	for c in s:
		copy = l[-1].copy()
		copy[ord(c) - ord('a')] += 1
		l.append(copy)
	for v in x:
		for i in range(26):
			res[i] += l[v][i]
	for i in range(26):
		res[i] += l[-1][i]
	for i in range(26):
		print(res[i], end=' ')


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	s = list(input())
	nums = list(map(int, input().split()))
	prefix = [[0 for i in range(26)] for j in range(n)]
	prefix[0][ord(s[0]) - 97] = 1
	for i in range(1, n):
		prefix[i] = list(prefix[i - 1])
		prefix[i][ord(s[i]) - 97] += 1
	ans = [0 for i in range(26)]
	nums.append(n)
	for e in nums:
		for x in range(26):
			ans[x] += prefix[e - 1][x]
	print(' '.join(list(map(str, ans))))


import sys, string

def convert(ch):
	return ord(ch) - ord('a')
tc = int(sys.stdin.readline())
for _ in range(tc):
	(n, m) = map(int, sys.stdin.readline().split())
	arr = list(sys.stdin.readline().rstrip())
	res = [[0] * 26 for _ in range(n)]
	temp = list(map(int, sys.stdin.readline().split()))
	ans = [0] * 26
	res[0][convert(arr[0])] = 1
	for i in range(1, n):
		for j in range(26):
			res[i][j] = res[i - 1][j]
		res[i][convert(arr[i])] += 1
	for i in temp:
		for j in range(26):
			ans[j] += res[i - 1][j]
	for i in arr:
		ans[convert(i)] += 1
	print(' '.join(map(str, ans)))


for _ in range(int(input())):
	(a, b) = map(int, input().split())
	(a1, b1) = (input(), list(map(int, input().split())))
	d = {}
	for i in range(97, 97 + 26):
		d[chr(i)] = 0
	b1.sort()
	n = b
	k = 0
	for i in b1:
		for j in range(k, i):
			d[a1[j]] += n
		n -= 1
		k = i
	for j in a1:
		d[j] += 1
	for (key, value) in d.items():
		print(value, end=' ')
	print(end='\n')


from sys import stdin, stdout
from math import floor, gcd, fabs, factorial, fmod, sqrt, inf, log
from collections import defaultdict as dd, deque
from heapq import merge, heapify, heappop, heappush, nsmallest
from bisect import bisect_left as bl, bisect_right as br, bisect
mod = pow(10, 9) + 7
mod2 = 998244353

def inp():
	return stdin.readline().strip()

def out(var, end='\n'):
	stdout.write(str(var) + '\n')

def outa(*var, end='\n'):
	stdout.write(' '.join(map(str, var)) + end)

def lmp():
	return list(mp())

def mp():
	return map(int, inp().split())

def smp():
	return map(str, inp().split())

def l1d(n, val=0):
	return [val for i in range(n)]

def l2d(n, m, val=0):
	return [l1d(m, val) for j in range(n)]

def remadd(x, y):
	return 1 if x % y else 0

def ceil(a, b):
	return (a + b - 1) // b

def isprime(x):
	if x <= 1:
		return False
	if x in (2, 3):
		return True
	if x % 2 == 0:
		return False
	for i in range(3, int(sqrt(x)) + 1, 2):
		if x % i == 0:
			return False
	return True
for _ in range(int(inp())):
	(n, m) = mp()
	s = inp()
	arr = lmp()
	md = {}
	for i in 'abcdefghijklmnopqrstuvwxyz':
		md[i] = 0
	ml = [0 for i in range(n)]
	for i in arr:
		ml[i - 1] -= 1
	ansl = [m + 1]
	for i in range(n - 1):
		ansl.append(ansl[-1] + ml[i])
	for i in range(n):
		md[s[i]] += ansl[i]
	for i in md.values():
		print(i, end=' ')
	print()


t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	s = input()
	c = list(map(int, input().split()))
	cnt = [0 for i in range(n)]
	ans = [0 for i in range(26)]
	dp = [0 for i in range(n)]
	for i in c:
		cnt[i - 1] += 1
	dp[-1] = cnt[-1] + 1
	for i in range(n - 2, -1, -1):
		dp[i] = dp[i + 1] + cnt[i]
	for i in range(0, n):
		ans[ord(s[i]) - 97] += dp[i]
	print(*ans, sep=' ')


def _ord(c):
	return ord(c) - 97

def solve():
	(n, m) = map(int, input().split())
	s = str(input())
	err = list(map(int, input().split()))
	Press = [0] * (n + 1)
	for e in err:
		Press[e - 1] += 1
	Press[n] = 1
	for i in range(n - 1, -1, -1):
		Press[i] += Press[i + 1]
	alphastroke = [0] * 26
	for i in range(0, n):
		alphastroke[_ord(s[i])] += Press[i]
	print(*alphastroke)
T = int(input())
while T > 0:
	T -= 1
	solve()


import bisect
t = int(input())
for i in range(t):
	(n, m) = map(int, input().split())
	s = input()
	p = [int(i) for i in input().split()]
	p.sort()
	ans = {}
	al = 'abcdefghijklmnopqrstuvwxyz'
	for i in al:
		ans[i] = 0
	for i in range(len(s)):
		ans[s[i]] += 1
		x = bisect.bisect_left(p, i + 1)
		ans[s[i]] += len(p) - x
	for i in al:
		print(ans[i], end=' ')
	print()


t = int(input())
for i in range(t):
	(n, m) = map(int, input().split())
	s = input()
	A = list(map(int, input().split()))
	B = [0] * 26
	C = {}
	D = {}
	for i in range(m):
		if A[i] not in D:
			D[A[i]] = 0
		D[A[i]] += 1
	for i in range(n):
		B[ord(s[i]) - 97] += 1
		if i + 1 in D:
			C[i + 1] = []
			for j in range(26):
				C[i + 1].append(B[j])
	for i in D:
		for j in range(26):
			B[j] += D[i] * C[i][j]
	print(*B)


import sys
alphabet = 'abcdefghijklmnopqrstuvwxyz'
t = int(sys.stdin.readline().strip())
for i in range(t):
	(n, m) = map(int, sys.stdin.readline().strip().split())
	s = sys.stdin.readline().strip()
	p = sorted(list(map(int, sys.stdin.readline().strip().split())))
	korrad = {}
	for j in p:
		if j not in korrad.keys():
			korrad[j] = 1
		else:
			korrad[j] += 1
	for letter in alphabet:
		if letter != 'a':
			sys.stdout.write(' ')
		amount = [0]
		count = 0
		for j in range(n):
			if s[j] == letter:
				count += 1
			amount.append(count)
		if count > 0:
			count = 0
			for j in korrad.keys():
				count += amount[j] * korrad[j]
			count += amount[n]
			sys.stdout.write(str(count))
		else:
			sys.stdout.write('0')
	sys.stdout.write('\n')


for i in range(int(input())):
	ans = [0 for i in range(26)]
	(n, m) = map(int, input().split())
	s = input()
	p = sorted(list(map(int, input().split())))
	p.append(n)
	l = 0
	for j in range(m + 1):
		if j == 0 or p[j] != p[j - 1]:
			for g in range(l, p[j]):
				ans[ord(s[g]) - ord('a')] += m - j + 1
			l = p[j]
	print(*ans)


from sys import stdin, stdout
get = stdin.readline
for _ in range(int(input())):
	(n, m) = map(int, get().split())
	m += 1
	a = [0] * 26
	v = 0
	s = input()
	p = sorted(map(int, get().split())) + [0]
	for i in range(n):
		a[ord(s[i]) - 97] += m
		while i == p[v] - 1:
			m -= 1
			v += 1
	print(*a)


import string
T = int(input())
for _ in range(T):
	(n, m) = map(int, input().split())
	combo = input()
	p = list(map(int, input().split())) + [n + 1]
	p.sort()
	c_d = [0] * 26
	j = 0
	i = 0
	for x in combo:
		i += 1
		c_d[ord(x) - 97] += m + 1 - j
		while i == p[j]:
			j += 1
	print(*c_d)


from copy import copy
for nt in range(int(input())):
	(n, m) = map(int, input().split())
	s = input()
	p = list(map(int, input().split()))
	d = {0: {s[0]: 1}}
	for i in range(1, n):
		d[i] = copy(d[i - 1])
		if s[i] not in d[i]:
			d[i][s[i]] = 1
		else:
			d[i][s[i]] += 1
	ans = [0] * 26
	for i in p:
		for j in range(26):
			if chr(j + 97) in d[i - 1]:
				ans[j] += d[i - 1][chr(j + 97)]
	for i in s:
		ans[ord(i) - 97] += 1
	print(*ans)


import math
import collections
import functools
import sys
import os

def solve():
	(n, _) = map(int, input().split())
	s = input()
	table = list(map(int, input().split()))
	tt = {}
	table.append(n)
	for i in table:
		if i in tt:
			tt[i] += 1
		else:
			tt[i] = 1
	dp = [0] * 26
	res = [0] * 26
	for i in range(n):
		dp[ord(s[i]) - ord('a')] += 1
		if i + 1 not in tt:
			continue
		for j in range(26):
			res[j] += dp[j] * tt[i + 1]
	for i in range(26):
		if i:
			print(' ', end='')
		print(res[i], end='')
	print()
	return

def main():
	T = 1
	T = int(input())
	while T:
		solve()
		T -= 1
main()


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	s = input()
	_p = list(map(int, input().split()))
	a = ''
	let = [0] * 26
	p = [i - 1 for i in _p]
	pref = [0] * len(s)
	for i in range(len(p)):
		pref[p[i]] += 1
	for i in range(len(s) - 1, 0, -1):
		pref[i - 1] += pref[i]
	for i in range(len(s)):
		let[ord(s[i]) - ord('a')] += pref[i]
		let[ord(s[i]) - ord('a')] += 1
	print(*let)


import sys
input = sys.stdin.readline
Alp = [chr(i) for i in range(97, 97 + 26)]
Q = int(input())
Query = []
for _ in range(Q):
	(N, M) = map(int, input().split())
	S = list(input().rstrip())
	A = list(map(int, input().split()))
	Query.append((N, M, S, A))
for (N, M, S, A) in Query:
	dic = {}
	ans = {}
	for a in Alp:
		dic[a] = [0]
		ans[a] = 0
	for s in S:
		for a in Alp:
			if a == s:
				dic[a].append(dic[a][-1] + 1)
			else:
				dic[a].append(dic[a][-1])
	A.append(N)
	for n in A:
		for a in Alp:
			ans[a] += dic[a][n]
	for a in Alp:
		print(ans[a], end=' ')
	print()