Chef wants to serve mankind by making people immortal by preparing a dish, a dish of life - a dish with the best taste in the universe, one with the smell and splash of fresh water flowing down the springs of the mountain, one with the smell of the best lily flowers of the garden, one that has contained the very essence of life in a real sense. 
This dish will contain K ingredients that are found only in remote islands amid mountains. For sake of convenience, we enumerate the ingredients by the integers from 1 to K, both inclusive. There are N islands and each of them offers some ingredients. Chef being a little child did not know how to collect the ingredients for the recipe. He went to all the islands and bought all the ingredients offered in each island. Could he possibly have saved some time by skipping some island? If it was not possible for Chef to collect the required ingredients (i.e. all the K ingredients), output "sad". If it was possible for him to skip some islands, output "some", otherwise output "all".

-----Input-----
First line of the input contains an integer T denoting number of test cases. The description of T test cases follow.
The first line of each test case contains two space separated integers N, K.
The i-th of the next lines will contain first an integer Pi, denoting the number of ingredients grown in the i-th island, followed by Pi distinct integers in the range [1, K]. All the integers are space separated. 

-----Output-----
For each test case, output a single line containing one of the strings "sad", "all" or "some" (without quotes) according to the situation. 

-----Constraints-----
- 1 ≤ T  ≤ 10
- 1 ≤ N, K ≤ 105
- 1 ≤ Pi ≤ K
- Sum of Pi over all test cases ≤ 106

-----Subtasks-----
Subtask #1 (30 points)
- 1 ≤ N, K ≤ 50

Subtask #2 (30 points)
- 1 ≤ K ≤ 50

Subtask #3 (40 points)
- original constraints

-----Example-----
Input
3
3 4
3 1 2 3
2 1 3
2 1 2
2 3
3 1 2 3
2 1 3
2 3
2 1 2
2 1 3

Output
sad
some
all

-----Explanation-----
Example 1. The ingredient 4 is not available in any island, so Chef can't make the dish of life. Hence, the answer is "sad".
Example 2. Chef can just go to the first island and collect all the three ingredients required. He does not need to visit the second island. So, the answer is "some".
Example 3. Chef has to visit both the islands in order to obtain all the three ingredients. So, the answer is "all".

Difficulty: MEDIUM

Solutions:
t = int(input())
for i in range(t):
	(n, k) = [int(j) for j in input().split()]
	b = set()
	flag = 0
	cout = 0
	for m in range(n):
		a = [int(j) for j in input().split()]
		a1 = a[1:]
		cout += 1
		if flag == 1:
			continue
		b.update(a1)
		if len(b) == k:
			flag = 1
			if cout == n:
				print('all')
			else:
				print('some')
	if flag == 0:
		print('sad')


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	l = []
	for i in range(n):
		l.append(list(map(int, input().split())))
	c = set({})
	bl = ''
	for i in range(n):
		for j in l[i][1:]:
			if j not in c:
				c.add(j)
		if len(c) == k:
			if i == n - 1:
				bl = 'all'
			else:
				bl = 'some'
			break
	else:
		bl = 'sad'
	c = set({})
	bl1 = ''
	for i in range(n - 1, -1, -1):
		for j in l[i][1:]:
			if j not in c:
				c.add(j)
		if len(c) == k:
			if i == 0:
				bl1 = 'all'
			else:
				bl1 = 'some'
			break
	else:
		bl1 = 'sad'
	if bl1 == bl:
		print(bl)
	else:
		print('some')


t = int(input())
for i in range(t):
	(n, k) = input().strip().split(' ')
	(n, k) = (int(n), int(k))
	a = list(range(1, k + 1))
	e = []
	flag = 'sad'
	for j in range(n - 1):
		for x in input().strip().split(' '):
			e.append(int(x))
	e1 = [x for x in e]
	for x in input().strip().split(' '):
		e.append(int(x))
	if set(a) == set(e):
		if set(e) == set(e1):
			flag = 'some'
		if set(e) != set(e1):
			flag = 'all'
	print(flag)


import sys
t = int(input())
for ti in range(t):
	ans = ''
	(n, k) = map(int, input().split())
	for_set = []
	vp = [[-1, -1]] * (k + 1)
	for i in range(n):
		ls = list(map(int, input().split()))
		for j in range(1, ls[0] + 1):
			temp = [ls[0], i + 1]
			if vp[ls[j]][0] < temp[0]:
				vp[ls[j]] = temp
	for i in range(1, k + 1):
		if vp[i] == [-1, -1]:
			ans = 'sad'
			break
		else:
			for_set.append(vp[i][1])
	if ans == 'sad':
		print(ans)
	elif len(set(for_set)) == n:
		print('all')
	else:
		print('some')


from math import gcd, sqrt, ceil, floor, log10, log2
from heapq import heapify, heappop, heappush, nsmallest, nlargest
from collections import Counter, deque, OrderedDict, defaultdict
from itertools import combinations, permutations, zip_longest
from bisect import bisect_left, bisect_right
from functools import lru_cache, reduce
import sys
import time
import string
import operator
RECURSION_LIMIT = int(10000000.0)
INT_MAX = float('inf')
INT_MIN = float('-inf')
MOD = int(1000000000.0) + 7
NEWLINE = '\n'
SPACE = ' '
sys.setrecursionlimit(RECURSION_LIMIT)
inp = lambda fn: fn(input())
inp_vars = lambda fn, delim, convert_to=list: convert_to(map(fn, input().split(delim)))
enum = lambda itr: enumerate(itr)

def toposort(graph, n):
	degree = [0] * n
	for node in graph:
		for adj in graph[node]:
			degree[adj] += 1
	bfs_queue = [node for node in range(n) if not degree[node]]
	for node in bfs_queue:
		for adj in graph[node]:
			degree[adj] -= 1
			if not degree[adj]:
				bfs_queue.append(adj)
	return (bfs_queue, degree)

def dfs(graph, node, visited):
	visited.add(node)
	for adj in graph[node]:
		if adj in visited:
			continue
		dfs(graph, adj, visited)

def solve(*args, **kwargs):
	(n, k, arr) = args
	(cnt, mp) = (0, Counter())
	for ingredients in arr:
		for i in ingredients:
			mp[i] += 1
	for ingredients in arr:
		visit = False
		for i in ingredients:
			if mp[i] == 1:
				visit = True
				break
		cnt += visit
	return 'some' if len(mp) == k and cnt != n else 'all' if len(mp) == k and cnt == n else 'sad'

def main(*args, **kwargs):
	for _ in range(int(input())):
		(arg1, arg2) = inp_vars(int, SPACE)
		arg3 = [inp_vars(int, SPACE)[1:] for _ in range(arg1)]
		res = solve(*(arg1, arg2, arg3))
		if type(res) in {list, tuple, set}:
			print(*res, sep=' ')
		else:
			print(res)
main()


for a1 in range(int(input())):
	(n, k) = [int(i) for i in input().split(' ')]
	ans = set()
	(flag, c) = (0, 0)
	for i in range(n):
		b = set(input().split())
		if c != 1:
			ans.update(b)
		if len(ans) == k and i + 1 != n:
			c = 1
	l = len(ans)
	if c == 1 and l == k:
		print('some')
	elif l == k:
		print('all')
	elif l != k:
		print('sad')


for i in range(int(input())):
	(n, k) = map(int, input().split())
	ans = set()
	count = 0
	done = True
	li = []
	for i in range(n):
		l = tuple(map(int, input().split()))
		ll = set(l[1:])
		k1 = ans.intersection(ll)
		if k1 == ll:
			done = False
		if k1 == ans and ans != set():
			done = False
		ans.update(ll)
	if len(ans) != k:
		print('sad')
		continue
	elif done:
		print('all')
	else:
		print('some')


t = int(input())
for m in range(t):
	l = input()
	flag = False
	pk = set([])
	a = l.split()
	for i in range(len(a)):
		a[i] = int(a[i])
	for j in range(a[0]):
		l = input()
		b = l.split()
		for i in range(0, len(b)):
			b[i] = int(b[i])
		gs = len(pk)
		for z in range(1, len(b)):
			pk.add(b[z])
		if gs == len(pk):
			flag = True
		for i in b:
			del i
	if len(pk) != a[1]:
		print('sad')
	elif flag == True:
		print('some')
	else:
		print('all')
	for i in a:
		del i


T = int(input())
for i in range(T):
	line = input()
	split = line.split(' ')
	N = int(split[0])
	K = int(split[1])
	arrB = []
	presence = {}
	for j in range(N):
		b = input().split()[1:]
		for k in b:
			if k in presence:
				presence[k] += 1
			else:
				presence[k] = 1
		arrB.append(b)
	if len(presence) < K:
		print('sad')
		continue
	printed = False
	for j in range(N):
		d = True
		for k in arrB[j]:
			if presence[k] == 1:
				d = False
				break
		if d:
			print('some')
			printed = True
			break
	if not printed:
		print('all')


for _ in range(int(input())):
	(n, k) = list(map(int, input().split()))
	array = []
	tot = []
	for _ in range(n):
		temp = list(map(int, input().split()))
		aa = temp[0]
		del temp[0]
		temp.sort()
		temp.insert(0, aa)
		array.append(temp)
	dic = {}
	array.sort(reverse=True)
	for i in array:
		del i[0]
	for i in range(1, k + 1):
		tot.append(i)
		dic[i] = False
	count = 0
	for i in array:
		count += 1
		for j in i:
			if dic[j] == True:
				pass
			else:
				tot.remove(j)
				dic[j] = True
		if len(tot) == 0:
			break
	if len(tot) != 0:
		print('sad')
	elif count != n:
		print('some')
	else:
		print('all')


T = int(input())
while T > 0:
	(N, K) = map(int, input().split())
	C = []
	G = [0]
	l = 0
	c = 0
	for i in range(1, K + 1):
		w = 0
		G.append(w)
	for i in range(0, N):
		e = 0
		c1 = input()
		C = c1.split(' ')
		p = int(C[0])
		for j in range(1, p + 1):
			s = int(C[j])
			if G[s] == 0:
				G[s] = 1
				c = c + 1
				e = 1
		if e == 1:
			l = l + 1
	if l == N and c == K:
		print('all')
	if l < N and c == K:
		print('some')
	if c != K:
		print('sad')
	T = T - 1


n = int(input())
while n:
	(islands, ingredients) = map(int, input().split())
	some = 0
	foundIngredients = [x for x in range(1, ingredients + 1)]
	while islands:
		caught = 0
		currentIngredients = []
		currentIngredients = list(map(int, input().split()))
		for x in range(1, currentIngredients[0] + 1):
			if foundIngredients[currentIngredients[x] - 1] != 0:
				foundIngredients[currentIngredients[x] - 1] = 0
			else:
				caught += 1
		if caught == currentIngredients[0]:
			some = 1
		islands -= 1
	if not all((x == 0 for x in foundIngredients)):
		print('sad')
	elif all((x == 0 for x in foundIngredients)) and some == 0:
		print('all')
	elif all((x == 0 for x in foundIngredients)) and some == 1:
		print('some')
	n -= 1


from collections import Counter
T = int(input())
for test in range(T):
	(N, K) = map(int, input().split(' '))
	islands = []
	counter = Counter()
	for i in range(N):
		islands.append(list(map(int, input().split(' '))))
		islands[i].pop(0)
		for x in islands[i]:
			counter[x] += 1
	solution = 'all'
	for e in range(1, K + 1):
		if counter[e] == 0:
			solution = 'sad'
	if solution == 'all':
		for island in islands:
			valid = True
			for x in island:
				counter[x] -= 1
				if counter[x] == 0:
					valid = False
			for x in island:
				counter[x] += 1
			if valid:
				solution = 'some'
				break
	print(solution)


t = int(input())
while t > 0:
	t -= 1
	(n, k) = list(map(int, input().split()))
	ing = {i: 0 for i in range(1, k + 1)}
	islands = []
	for i in range(n):
		vals = list(map(int, input().split()))[1:]
		islands.append(vals)
		for val in vals:
			ing[val] += 1
	flag = False
	for i in range(1, k + 1):
		if ing[i] == 0:
			print('sad')
			flag = True
			break
	if flag:
		continue
	k = 0
	for i in range(1, n + 1):
		for j in islands[i - 1]:
			if ing[j] == 1:
				k += 1
				break
	if k == n:
		print('all')
	else:
		print('some')


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	f = [False] * (k + 1)
	l = []
	res = 0
	for i in range(n):
		x = [int(x) for x in input().split()]
		l.append(x[1:])
		for ing in l[i]:
			if f[ing] == 0:
				res += 1
			f[ing] += 1
	if res != k:
		print('sad')
	else:
		for i in range(n):
			flag = True
			for ing in l[i]:
				if f[ing] == 1:
					flag = False
					break
			if flag:
				break
		if flag:
			print('some')
		else:
			print('all')


tests = int(input())
for i in range(tests):
	(n, r) = map(int, input().split())
	all_ingridients = []
	for j in range(n):
		arr = list(map(int, input().split()))
		all_ingridients.append(arr)
	ans1 = 'sad'
	ingridients = set()
	for j in range(n):
		arr = all_ingridients[j]
		if arr[0] == r:
			ans1 = 'some'
			break
		if ans1 == 'sad':
			ingridients.update(arr[1:])
			if len(ingridients) == r:
				if j + 1 == n:
					ans1 = 'all'
				else:
					ans1 = 'some'
				break
	ans2 = 'sad'
	ingridients = set()
	for j in range(n - 1, -1, -1):
		arr = all_ingridients[j]
		if arr[0] == r:
			ans2 = 'some'
			break
		if ans2 == 'sad':
			ingridients.update(arr[1:])
			if len(ingridients) == r:
				if j == 0:
					ans2 = 'all'
				else:
					ans2 = 'some'
				break
	if ans1 == 'all' and ans2 == 'all':
		print(ans1)
	elif ans1 == 'some' or ans2 == 'some':
		print('some')
	else:
		print('sad')


import heapq
tc = int(input())
for etc in range(tc):
	(n, k) = map(int, input().split())
	used_food = [False for i in range(k + 1)]
	input_q = []
	final_q = []
	used_food[0] = True
	some = False
	for i in range(n):
		input_list = list(map(int, input().strip().split()))
		count = input_list[0]
		values = input_list[1:]
		heapq.heappush(input_q, (count, values))
	for i in range(n):
		final_q.append(heapq.heappop(input_q))
	for i in range(n):
		current = final_q[n - i - 1]
		some_temp = False
		for item in current[1]:
			if not used_food[item]:
				some_temp = True
				used_food[item] = True
		if some_temp == False:
			some = True
	if False in used_food:
		print('sad')
	elif some:
		print('some')
	else:
		print('all')


class GetOutOfLoop(Exception):
	pass
t = int(input().strip())
while t:
	t -= 1
	inputs = list(map(int, input().strip().split()))
	n = inputs[0]
	k = inputs[1]
	islands = []
	total = {}
	try:
		for i in range(n):
			inputs = list(map(int, input().strip().split()))
			if inputs[0] == k:
				if n == 1:
					print('all')
				else:
					print('some')
				for j in range(n - 1 - i):
					input()
				raise GetOutOfLoop
			island = {}
			for inp in inputs[1:]:
				if island.get(inp):
					island[inp] += 1
					total[inp] += 1
				else:
					island[inp] = 1
					if total.get(inp):
						total[inp] += 1
					else:
						total[inp] = 1
			islands.append(island)
		if len(total.keys()) < k:
			print('sad')
			continue
		for island in islands:
			is_extra = True
			for inp in island:
				if total[inp] <= island[inp]:
					is_extra = False
					break
			if is_extra:
				print('some')
				raise GetOutOfLoop
		print('all')
	except GetOutOfLoop:
		continue


def main():
	t = int(input())
	for _ in range(t):
		(n, k) = [int(i) for i in input().split()]
		k = set(range(1, k + 1))
		islands = []
		for i in range(n):
			islands.append({int(i) for i in input().split()[1:]})
		islands.sort(key=lambda x: len(x), reverse=True)
		temp = set()
		considered = 0
		for i in islands:
			if i - temp:
				considered += 1
				temp |= i
		if temp != k:
			print('sad')
		elif considered < n:
			print('some')
		elif considered == n:
			print('all')
main()


for i in range(int(input())):
	(n, k) = map(int, input().split())
	s = set()
	l = set()
	cnt = 0
	for j in range(n):
		p = tuple(map(int, input().split()))
		l.add(p)
	l = list(l)
	l.sort(reverse=True)
	f = 0
	for j in range(len(l)):
		x = len(s)
		for p in range(1, l[j][0] + 1):
			s.add(l[j][p])
			y = len(s)
			if y == k:
				f = 1
				break
		if f == 1:
			break
	if len(s) < k:
		print('sad')
	elif f == 1 and j < n - 1:
		print('some')
	else:
		print('all')


t = int(input())
for r in range(t):
	(n, k) = map(int, input().strip().split(' '))
	kset = []
	sm = [0] * k
	for i in range(n):
		it = list(map(int, input().split(' ')))
		ks = it[0]
		sp = it[1:]
		rset = set()
		for j in range(ks):
			rset.add(sp[j] - 1)
			sm[sp[j] - 1] += 1
		kset.append(rset)
	ans = min(sm)
	if ans == 0:
		print('sad')
	elif ans > 1:
		print('some')
	else:
		onc = []
		for i in range(k):
			if sm[i] == 1:
				onc.append(i)
		if len(onc) == k:
			print('all')
		else:
			flag = False
			for i in range(n):
				f2 = True
				for j in onc:
					if kset[i].__contains__(j):
						f2 = False
						break
				if f2 == True:
					flag = True
					break
			if flag:
				print('some')
			else:
				print('all')


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	s = set()
	flag = False
	for i in range(n):
		s.update(input().split()[1:])
		if i < n - 1 and s.__len__() == k:
			flag = True
	if flag:
		print('some')
	elif s.__len__() == k:
		print('all')
	else:
		print('sad')


t = int(input())
while t > 0:
	t -= 1
	(n, k) = map(int, input().split(' '))
	arr_n = []
	arr_k = [0] * k
	for i in range(n):
		arr_n.append([int(x) for x in input().split(' ')])
		for j in range(1, arr_n[i][0] + 1):
			arr_k[arr_n[i][j] - 1] += 1
	flag = 0
	if 0 in arr_k:
		print('sad')
	else:
		for i in range(n):
			count = 0
			for j in range(1, arr_n[i][0] + 1):
				if arr_k[arr_n[i][j] - 1] > 1:
					count += 1
			if count == arr_n[i][0]:
				flag = 1
				break
		if flag == 1:
			print('some')
		else:
			print('all')


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	l = set(range(1, k + 1))
	label = 0
	for i in range(n):
		s = set(map(int, input().split()))
		for j in s:
			l.discard(j)
		if l == set():
			label = 1
			x = i + 1
			break
	for j in range(i + 1, n):
		input()
	if label and x < n:
		print('some')
	elif label == 0:
		print('sad')
	else:
		print('all')


t = int(input())
for i in range(t):
	(n, k) = list(map(int, input().strip().split()))
	a = []
	d = {}
	for i in range(1, k + 1):
		d[i] = 0
	for i in range(n):
		p = list(map(int, input().strip().split()))[1:]
		for j in p:
			d[j] += 1
		a.append(p)
	flag = 0
	for i in range(1, k + 1):
		if d[i] == 0:
			flag = 1
			break
	if flag == 0:
		for i in range(n):
			flag2 = 0
			for j in a[i]:
				if d[j] == 1:
					flag2 = 1
					break
			if flag2 == 0:
				flag = 2
				break
	if flag == 0:
		print('all')
	elif flag == 1:
		print('sad')
	else:
		print('some')


t = int(input())
for i in range(t):
	(islands, ingredients) = map(int, input().split())
	test = [0] * ingredients
	zero = 0
	skip_this = False
	islands_ingredients = [[] for x in range(islands)]
	for j in range(islands):
		islands_ingredients[j] = list(map(int, input().split()))[1:]
	for j in range(islands):
		for k in islands_ingredients[j]:
			test[k - 1] += 1
	for j in test:
		if j == 0:
			zero += 1
	if zero:
		print('sad')
	else:
		for j in range(islands):
			not_necessary = True
			for k in islands_ingredients[j]:
				if test[k - 1] == 1:
					not_necessary = False
			if not_necessary:
				skip_this = True
				break
		if skip_this:
			print('some')
		else:
			print('all')


t = int(input())
for test in range(t):
	skip = 0
	(n, k) = map(int, input().split())
	m = {}
	his = []
	for i in range(n):
		lst = input().split()
		p = lst[0]
		ing = lst[1:]
		ing = list(map(int, ing))
		his.append(ing)
		for j in ing:
			try:
				m[j] += 1
			except:
				m[j] = 1
	for i in range(1, k + 1):
		if not i in m or m[i] == 0:
			print('sad')
			skip = 1
			break
	if skip:
		continue
	for x in his:
		flag = 1
		for num in x:
			if m[num] == 1:
				flag = 0
		if flag:
			print('some')
			skip = 1
			break
	if skip:
		continue
	print('all')


def main():
	from sys import stdin, stdout
	t = int(stdin.readline())
	for i in range(t):
		(islands, ingredients) = map(int, stdin.readline().split())
		test = [0] * ingredients
		zero = 0
		skip_this = False
		islands_ingredients = [[] for x in range(islands)]
		for j in range(islands):
			islands_ingredients[j] = list(map(int, stdin.readline().split()))[1:]
		for j in range(islands):
			for k in islands_ingredients[j]:
				test[k - 1] += 1
		for j in test:
			if j == 0:
				zero += 1
		if zero:
			stdout.write('sad\n')
		else:
			for j in range(islands):
				not_necessary = True
				for k in islands_ingredients[j]:
					if test[k - 1] == 1:
						not_necessary = False
				if not_necessary:
					skip_this = True
					break
			if skip_this:
				stdout.write('some\n')
			else:
				stdout.write('all\n')
main()


t = int(input())
while t:
	t -= 1
	(n, k) = map(int, input().split())
	flag = 0
	m = [0] * (k + 1)
	m[0] = 1
	co = 0
	while n:
		n -= 1
		l = list(map(int, input().split()))
		if l[0] == k:
			flag = 1
		if flag != 1:
			i = 1
			while i < l[0] + 1:
				if m[l[i]] == 0:
					m[l[i]] = 1
					co += 1
				i += 1
			if n != 0 and co == k:
				flag = 1
	if flag == 1:
		print('some')
	elif 0 in m:
		print('sad')
	else:
		print('all')


T = int(input())
for t in range(T):
	(N, k) = list(map(int, input().split()))
	recipe = set([])
	for n in range(N - 1):
		ingredients = input().split()
		for i in range(1, len(ingredients)):
			if ingredients[i] not in recipe:
				recipe.add(ingredients[i])
	ingredients = input().split()
	if len(recipe) == k or len(ingredients) - 1 == k:
		print('some')
	else:
		for i in range(1, len(ingredients)):
			if ingredients[i] not in recipe:
				recipe.add(ingredients[i])
		if len(recipe) == k:
			print('all')
		else:
			print('sad')


for _ in range(int(input())):
	island = []
	(n, k) = map(int, input().split())
	for i in range(n):
		l = [int(i) for i in input().split()]
		l = l[1:]
		island.append(l)
	cnt = [0] * (k + 1)
	for i in range(n):
		for indigrient in island[i]:
			cnt[indigrient] += 1
	f = 1
	for i in range(1, k + 1):
		if cnt[i] == 0:
			f = 0
			break
	if not f:
		print('sad')
		continue
	f1 = 0
	for i in range(n):
		f2 = 1
		for j in island[i]:
			if cnt[j] == 1:
				f2 = 0
		if f2:
			f1 = 1
			break
	if f1:
		print('some')
	else:
		print('all')


def main():
	T = int(input())
	results = [''] * T
	for t in range(T):
		sad = 1
		(N, K) = input().split(' ')
		case = [0] * int(K)
		lastIslandVisted = 0
		for n in range(int(N)):
			P = input().split(' ')
			P.pop(0)
			P = list(map(int, P))
			for i in P:
				if case[i - 1] == 0:
					case[i - 1] = 1
					lastIslandVisted = n
		for c in case:
			if c == 0:
				results[t] = 'sad'
				sad = 0
				break
		if sad != 0:
			if lastIslandVisted == int(N) - 1:
				results[t] = 'all'
			else:
				results[t] = 'some'
	for i in results:
		print(i)
main()


t = int(input())
for e in range(t):
	(n, k) = map(int, input().split())
	(a, b, s) = ([], [], set())
	flag = False
	for ee in range(n):
		y = []
		y = list(map(int, input().split()))
		b.append(y[0])
		y.pop(0)
		a.append(y)
		if len(y) == k:
			flag = True
		s |= set(y)
	if len(s) != k:
		print('sad')
		continue
	if flag:
		print('some')
		continue
	l = set()
	for i in range(len(a)):
		for j in a[i]:
			l.add(j)
			if len(l) == k:
				break
		if len(l) == k:
			if i < len(a) - 1:
				flag = True
			break
	if flag:
		print('some')
	else:
		print('all')


t = int(input())
for i in range(t):
	(N, K) = list(map(int, input().split(' ')))
	d = dict()
	lst = []
	a = set({})
	f = ''
	for i in range(N):
		s = list(map(int, input().split(' ')))
		lst.append(s)
	for i in range(N):
		for ele in lst[i][1:]:
			if ele not in a:
				a.add(ele)
		if len(a) == K:
			if i == N - 1:
				f = 'all'
			else:
				f = 'some'
			break
	else:
		f = 'sad'
	a = set({})
	b = ''
	for i in range(N - 1, -1, -1):
		for ele in lst[i][1:]:
			if ele not in a:
				a.add(ele)
		if len(a) == K:
			if i == 0:
				b = 'all'
			else:
				b = 'some'
			break
	else:
		b = 'sad'
	if f == b:
		print(f)
	else:
		print('some')


for _ in range(int(input())):
	(n, k) = [int(x) for x in input().split()]
	it = []
	occ = [0] * (k + 1)
	end = False
	res = ''
	for i in range(n):
		items = [int(x) for x in input().split()]
		it.append(items)
		for ii in range(1, len(items)):
			occ[items[ii]] += 1
	for i in range(1, len(occ)):
		if occ[i] == 0:
			end = True
	visit_all = True
	for i in range(n):
		city_not_needed = True
		for j in range(1, len(it[i])):
			if occ[it[i][j]] == 1:
				city_not_needed = False
		if city_not_needed == True:
			visit_all = False
	if end == True:
		print('sad')
	elif visit_all == False:
		print('some')
	else:
		print('all')


for q in range(int(input())):
	(n, k) = list(map(int, input().split()))
	test = []
	z = []
	f = 0
	for i in range(n):
		l = [int(i) for i in input().split()]
		l = l[1:]
		z.append(l)
	c = [0] * (k + 1)
	for i in range(n):
		for j in z[i]:
			c[j] += 1
	for i in range(1, k + 1):
		if c[i] == 0:
			print('sad')
			f = 1
			break
	if f == 1:
		continue
	for i in range(n):
		cnt = 0
		for j in z[i]:
			if c[j] != 1:
				cnt += 1
		if cnt == len(z[i]):
			print('some')
			break
	else:
		print('all')


for _ in range(int(input())):
	a = input().split()
	(n, k) = [int(a[0]), int(a[1])]
	answer = set()
	cer = 0
	po = 0
	for i in range(n):
		box = set(input().split())
		if cer != 1:
			answer.update(box)
		if len(answer) == k and i + 1 != n:
			cer = 1
		for lk in range(2):
			po += 1
	for lk in range(2):
		po += 1
	for de in range(2):
		if de != 0:
			po += 1
	l = len(answer)
	if cer == 1 and l == k:
		print('some')
	elif l == k:
		print('all')
	elif l != k:
		print('sad')


for _ in range(int(input())):
	(islands, collects) = map(int, input().split())
	data = [0] * collects
	idata = []
	for i in range(islands):
		arr = list(map(int, input().split()))
		idata.append(arr[1:])
	for i in range(islands):
		for item in idata[i]:
			data[item - 1] += 1
	if 0 in data:
		print('sad')
		continue
	skip = False
	for i in range(islands):
		need = False
		for j in idata[i]:
			if data[j - 1] == 1:
				need = True
		if not need:
			skip = True
			break
	if skip:
		print('some')
	else:
		print('all')


def soln(n, k, arr):
	cur = arr[0]
	flag = True
	for i in range(1, n):
		inter = cur.intersection(arr[i])
		if inter == cur or inter == arr[i]:
			flag = False
		cur.update(arr[i])
	if len(cur) < k:
		return 'sad'
	if flag:
		return 'all'
	return 'some'
for _ in range(int(input())):
	(n, k) = map(int, input().split())
	arr = []
	for i in range(n):
		arr.append(set(list(map(int, input().split()))[1:]))
	print(soln(n, k, arr))


for testCases in range(int(input())):
	(n, k) = map(int, input().split())
	s = set()
	some = False
	for islands in range(n):
		s.update(input().split()[1:])
		if islands < n - 1 and s.__len__() == k:
			some = True
	if some:
		print('some')
	elif s.__len__() == k:
		print('all')
	else:
		print('sad')


for _ in range(int(input())):
	(n, k) = [int(i) for i in input().split()]
	a = set()
	q = set(range(1, k + 1))
	c = z = 0
	global r
	r = 1
	for _1 in range(n):
		a.update([int(i) for i in input().split()][1:])
		z += 1
		c += 1
		if q.issubset(a):
			if c < n:
				print('some')
				for i in range(n - z):
					input()
			elif c == n:
				print('all')
				r = 0
			break
	if c == n and r:
		print('sad')


T = int(input())
for t in range(T):
	(N, K) = [int(num) for num in input().split()]
	allIsles = set()
	someIsles = [set() for n in range(N)]
	possSome = False
	allIsles = {}
	for n in range(N):
		(P, *ingrds) = [int(num) for num in input().split()]
		numSame = 0
		for ing in ingrds:
			if ing in allIsles:
				numSame += 1
			else:
				allIsles[ing] = True
		if numSame == P:
			possSome = True
		if len(allIsles) == K:
			if n < N - 1:
				possSome = True
				for n in range(n + 1, N):
					input()
			break
	if len(allIsles) == K:
		if possSome:
			print('some')
		else:
			print('all')
	else:
		print('sad')


for i in range(int(input())):
	(n, k) = input().split()
	n = int(n)
	k = int(k)
	h = []
	c = 0
	for x in range(k):
		h.append(0)
	s = ''
	for j in range(n):
		l = input().split()
		for m in range(1, len(l)):
			if h[int(l[m]) - 1] == 0:
				h[int(l[m]) - 1] = 1
				c = c + 1
			if s == '':
				if k == c:
					if j == n - 1:
						s = 'all'
					else:
						s = 'some'
	if s == '':
		if k != c:
			s = 'sad'
	print(s)


t = int(input())
for test in range(t):
	(n, k) = map(int, input().split())
	l = [0] * k
	extra = 0
	for i in range(n):
		isle = list(map(int, input().split()))
		c = 0
		for el in isle:
			if l[el - 1] == 0:
				l[el - 1] = 1
				c += 1
		extra = 1 if c == 0 else 0
	if 0 in l:
		print('sad')
	elif extra:
		print('some')
	else:
		print('all')


t = int(input())
for i in range(t):
	p = 0
	count = 0
	a = []
	(n, k) = map(int, input().split(' '))
	c = [0] * (k + 1)
	for j in range(n):
		b = list(map(int, input().split(' ')))
		a.append(b)
	a.sort(key=len)
	for I in range(len(a) - 1, -1, -1):
		q = len(a[I])
		for J in range(1, q):
			if c[a[I][J]] == 0:
				c[a[I][J]] += 1
				count += 1
			if count == k:
				break
		p += 1
		if count == k:
			break
	if count == k and p == n:
		print('all')
	elif count == k and p < n:
		print('some')
	elif count != k:
		print('sad')


for I in range(int(input())):
	(n, k) = map(int, input().split())
	b = []
	for i in range(n):
		x = list(map(int, input().split()))
		for j in x:
			b.append(j)
	if not len(set(b)) == k:
		print('sad')
	elif len(set(b[0:len(b) - len(x)])) == k:
		print('some')
	else:
		print('all')


t = int(input())
for i in range(t):
	(n, k) = map(int, input().split())
	count = 0
	set1 = set()
	flag2 = False
	for i in range(n):
		count += 1
		l = input()
		l = [int(i) for i in l.split()]
		num_of_ing = l[0]
		for key in range(1, num_of_ing + 1):
			set1.add(l[key])
		if len(set1) == k:
			flag2 = True
			break
	for i in range(n - count):
		garbage = input()
	if flag2 == True:
		if count == n:
			print('all')
		else:
			print('some')
	else:
		print('sad')


t = int(input())
while t > 0:
	t -= 1
	(n, k) = map(int, input().split())
	required_ingredients = set([i + 1 for i in range(k)])
	l = -1
	found = False
	while n > 0:
		n -= 1
		temp = list(map(int, input().split()))
		temp.remove(temp[0])
		for i in temp:
			if i in required_ingredients:
				required_ingredients.remove(i)
		if len(required_ingredients) == 0 and (not found):
			found = True
			l = n
	if found and l is 0:
		print('all')
	elif found and l > 0:
		print('some')
	else:
		print('sad')


def solve():
	T = int(input())
	for t in range(T):
		(N, K) = input().split(' ')
		N = int(N)
		K = int(K)
		ing_count = [0 for i in range(K)]
		ing_list = []
		for n in range(N):
			ing_in_island = input().split(' ')
			no_ing = int(ing_in_island[0])
			ing_list.append(ing_in_island[1:])
			for i in range(no_ing):
				ing_count[int(ing_in_island[i + 1]) - 1] += 1
		sad = 0
		for k in range(K):
			if ing_count[k] == 0:
				sad = 1
				break
		if sad == 1:
			print('sad')
			continue
		all_islands = True
		for one_list in ing_list:
			island_needed_for = 0
			for ing in one_list:
				if ing_count[int(ing) - 1] == 1:
					island_needed_for += 1
			if island_needed_for == 0:
				all_islands = False
				break
		if all_islands:
			print('all')
		else:
			print('some')
solve()


t = int(input().strip())
for a0 in range(t):
	(n, k) = [int(x) for x in input().strip().split()]
	occurence = [0] * (k + 1)
	island_items = []
	for a1 in range(n):
		items = [int(x) for x in input().strip().split()]
		island_items.append(items)
		for i in range(1, len(items)):
			occurence[items[i]] += 1
	possible_to_fix = True
	for i in range(1, k + 1):
		if occurence[i] == 0:
			possible_to_fix = False
	need_to_visit_all = True
	for i in range(n):
		can_complete_without_island = True
		for j in range(1, len(island_items[i])):
			item = island_items[i][j]
			if occurence[item] == 1:
				can_complete_without_island = False
		if can_complete_without_island:
			need_to_visit_all = False
	if possible_to_fix == False:
		print('sad')
	elif need_to_visit_all == False:
		print('some')
	else:
		print('all')


t = int(input())
while t > 0:
	a = input().split()
	a = [int(i) for i in a]
	n = a[0]
	m = a[1]
	temp = set()
	flag = 0
	cnt = 0
	while n != 0:
		b = input().split()
		s = {int(i) for i in b[1:]}
		x = len(temp)
		temp |= s
		cnt += 1
		if len(temp) - x == 0 or (n != 1 and len(temp) == m):
			flag = 1
		n -= 1
	if len(temp) != m:
		print('sad')
	elif flag == 1:
		print('some')
	else:
		print('all')
	t -= 1


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	res = set()
	cnt = 0
	visit = True
	p = []
	for i in range(n):
		lis = tuple(map(int, input().split()))
		li = set(lis[1:])
		k1 = res.intersection(li)
		if k1 == li:
			visit = False
		if k1 == res and res != set():
			visit = False
		res.update(li)
	if len(res) != k:
		print('sad')
		continue
	elif visit:
		print('all')
	else:
		print('some')


T = int(input())
for t in range(1, T + 1):
	(N, K) = [int(i) for i in input().strip().split(' ')]
	ings = [0 for i in range(K)]
	is_ings = [[] for i in range(N)]
	for is_n in range(N):
		is_ings[is_n].extend([int(i) - 1 for i in input().strip().split(' ')])
		is_ings[is_n].pop(0)
		for is_ing in is_ings[is_n]:
			ings[is_ing] += 1
	if 0 in ings:
		print('sad')
	else:
		for is_n in range(N):
			good = True
			for is_ing in is_ings[is_n]:
				if ings[is_ing] < 2:
					good = False
			if good:
				print('some')
				break
		if not good:
			print('all')


t = int(input())
while t:
	t -= 1
	out = 'all'
	(n, k) = map(int, input().split())
	ps = []
	p = [0 for x in range(k + 1)]
	for x in range(n):
		ps.append(list(map(int, input().split())))
	sorted(ps, key=lambda x: x[0], reverse=True)
	all_exist = False
	for x in ps:
		some_unique = False
		for pi in x[1:]:
			p[pi] += 1
			if 1 == p[pi]:
				some_unique = True
		if not some_unique:
			all_exist = True
	if 0 in p[1:]:
		print('sad')
	elif all_exist:
		print('some')
	else:
		print('all')


for i in range(int(input())):
	a = [int(j) for j in input().split()]
	b = []
	c = []
	co = 0
	e = [0 for j in range(a[1])]
	for j in range(a[0]):
		tmp = input().split()
		b.append(int(tmp[0]))
		temp = []
		for k in tmp[1:]:
			temp.append(int(k))
			e[int(k) - 1] += 1
		c.append(temp)
	try:
		e.index(0)
		print('sad')
		continue
	except:
		pass
	for j in c:
		flag = 0
		for k in j:
			if e[k - 1] == 1:
				flag = 1
		if flag == 1:
			co += 1
	if co == a[0]:
		print('all')
	else:
		print('some')


t = int(input())
for _ in range(t):
	(n, k) = map(int, input().strip().split())
	a = [0] * k
	flag1 = 1
	flag2 = 1
	for i in range(0, n):
		flag2 = 1
		b = list(map(int, input().strip().split()))
		num = b[0]
		for j in range(1, len(b)):
			if a[b[j] - 1] == 0:
				flag2 = 0
			a[b[j] - 1] = 1
	for i in range(0, k):
		if a[i] == 0:
			flag1 = 0
			break
	if flag1 == 0:
		print('sad')
	elif flag2 == 0:
		print('all')
	else:
		print('some')


for _ in range(int(input())):
	(n, k) = [int(i) for i in input().split()]
	sumi = 0
	d = {}
	island = 1
	for j in range(1, n + 1):
		for i in [int(w) for w in input().split()][1:]:
			if sumi == k:
				continue
			if d.get(i, -1) == -1:
				sumi += 1
				d[i] = 1
			island = j
	if sumi < k:
		print('sad')
	elif island < n:
		print('some')
	else:
		print('all')


def dol():
	t = int(input())
	for i in range(t):
		(n, k) = input().split()
		n = int(n)
		k = int(k)
		d = {}
		covered_sofar = 0
		skipped = 0
		for j in range(n):
			s = input().split()
			if covered_sofar >= k:
				skipped += 1
				continue
			if int(s[0]) == k:
				if covered_sofar == 0:
					skipped += 1
					covered_sofar += k
					continue
				else:
					covered_sofar += k
					continue
			already_covered = True
			for l in range(1, len(s)):
				if s[l] not in d:
					d[s[l]] = 1
					covered_sofar += 1
					already_covered = False
			if already_covered is True:
				skipped += 1
		if covered_sofar < k:
			print('sad')
		elif skipped == 0:
			print('all')
		else:
			print('some')
dol()


T = int(input())
for testCaseID in range(T):
	(N, K) = map(int, input().split())
	islandList = []
	seenCount = [0] * K
	for islandID in range(N):
		itemList = list(map(int, input().split()))
		del itemList[0]
		islandList.append(itemList)
		for item in itemList:
			seenCount[item - 1] += 1
	isSad = 0 in seenCount
	if isSad:
		print('sad')
	else:
		isSome = False
		for island in islandList:
			canSkipIsland = True
			for item in island:
				if seenCount[item - 1] - 1 == 0:
					canSkipIsland = False
					break
			if canSkipIsland:
				isSome = True
				break
		if isSome:
			print('some')
		else:
			print('all')


k = int(input())
for i in range(k):
	tw = []
	t = list(map(int, input().split()))
	for lo in range(0, t[1] + 1):
		tw.append('false')
	tw[0] = 'true'
	f = []
	wq = 0
	e = 'sad'
	for j in range(t[0]):
		q = list(map(int, input().split()))
		if j < t[0] - 1:
			for tr in q:
				tw[tr] = 'true'
			if j == t[0] - 2:
				wq = tw.count('false')
				if wq == 0:
					e = 'some'
		elif j == t[0] - 1:
			for tr in q:
				tw[tr] = 'true'
			if j == t[0] - 1 and e != 'some':
				wq = tw.count('false')
				if wq == 0:
					e = 'all'
	print(e)


def main(args):
	T = int(input())
	while T:
		T -= 1
		(N, K) = list(map(int, input().split()))
		print(calc(N, K))
	return 0

def calc(N, K):
	flag = 0
	x = set()
	for i in range(N - 1):
		P = list(map(int, input().split()))
		for s in P:
			x.add(s)
		if len(x) == K:
			flag = 1
	P = list(map(int, input().split()))
	for s in P:
		x.add(s)
	if flag == 1:
		return 'some'
	elif len(x) == K:
		return 'all'
	else:
		return 'sad'
import sys
sys.exit(main(sys.argv))


t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	dd = dict()
	inn = []
	for i in range(n):
		a = list(map(int, input().split()))[1:]
		inn.append(a)
		for ing in a:
			try:
				dd[ing].append(i)
			except KeyError:
				dd[ing] = [i]
	tot_ing = set(dd)
	if len(tot_ing) != k:
		print('sad')
	else:
		al = True
		for i in inn:
			if all((len(dd[k]) > 1 for k in i)):
				al = False
				break
		if al:
			print('all')
		else:
			print('some')


from collections import defaultdict
testcases = int(input())
while testcases != 0:
	maps = defaultdict(int)
	(n, k) = [int(x) for x in input().split()]
	l = []
	flag = 0
	count = 0
	for x in range(n):
		now = input().split()
		l = now[1:]
		if flag == 0:
			for a in l:
				if maps[a] == 0:
					maps[a] = 1
					count += 1
			if count == k and x == n - 1:
				print('all')
			elif count == k:
				print('some')
				flag = 1
		else:
			continue
	if count != k:
		print('sad')
	testcases -= 1


def solve():
	nk = input().split()
	n = int(nk[0])
	k = int(nk[1])
	cnt = [0]
	size = [0]
	sets = [[]]
	for i in range(100005):
		cnt += [0]
		size += [0]
		sets += [[0]]
	for i in range(1, n + 1):
		qq = input().split()
		size[i] = int(qq[0])
		for x in range(1, size[i] + 1):
			tmp = int(qq[x])
			cnt[tmp] += 1
			sets[i] += [tmp]
	for x in range(1, k + 1):
		if cnt[x] == 0:
			print('sad')
			return
	for x in range(1, n + 1):
		ok = True
		for z in range(1, size[x] + 1):
			if cnt[sets[x][z]] == 1:
				ok = False
				break
		if ok:
			print('some')
			return
	print('all')
t = int(input())
for _ in range(t):
	solve()


def check1(x, y):
	j = 0
	for i in range(len(y)):
		while x[j] != y[i]:
			j += 1
			if j == len(x) or x[j] > y[i]:
				return False
		j += 1
	return True

def check2(x, y):
	for i in y:
		if i not in x:
			return False
	return True

def check3(x, y):
	s = set(x)
	f = len(s)
	for i in y:
		s.add(i)
	return f == len(s)
t = int(input())
for e in range(t):
	(n, k) = map(int, input().split())
	(a, b, s) = ([], [], set())
	flag = False
	for ee in range(n):
		y = []
		y = list(map(int, input().split()))
		b.append(y[0])
		y.pop(0)
		a.append(y)
		if len(y) == k:
			flag = True
		s |= set(y)
	if len(s) != k:
		print('sad')
		continue
	if flag:
		print('some')
		continue
	l = set()
	for i in range(len(a)):
		for j in a[i]:
			l.add(j)
			if len(l) == k:
				break
		if len(l) == k:
			if i < len(a) - 1:
				flag = True
			break
	if flag:
		print('some')
	else:
		print('all')


import logging
import sys

def fnHasMissing(totIng):
	for x in totIng:
		if x == 0:
			return True
	return False

def fnIsRedundant(totIng, isleIng):
	lTotIng = list(totIng)
	logging.debug('Total Ingredients before = %s', lTotIng)
	for x in range(1, len(isleIng)):
		lTotIng[int(isleIng[x]) - 1] -= 1
	logging.debug('Total Ingredients after = %s', lTotIng)
	for x in lTotIng:
		if x == 0:
			return False
	return True
logging.basicConfig(level=logging.ERROR)
cases = int(input(''))
logging.debug('No. of test cases is %d', cases)
for x in range(0, cases):
	line = input('')
	islands = int(line.split()[0])
	ingredients = int(line.split()[1])
	logging.debug('Case #%d: Islands = %d, Ingredients = %d', x + 1, islands, ingredients)
	totIng = []
	for y in range(0, ingredients):
		totIng.append(0)
	isleIng = []
	for y in range(0, islands):
		line = input('')
		isleIng.append(line.split())
		logging.debug('Case #%d: Island #%d: Ingredients = %s', x + 1, y + 1, isleIng[y])
		for z in range(1, len(isleIng[y])):
			totIng[int(isleIng[y][z]) - 1] += 1
		logging.debug('Case #%d: Island #%d: Total Ingredients = %s', x + 1, y + 1, totIng)
	if fnHasMissing(totIng):
		print('sad')
	else:
		redundantIsle = 0
		for y in range(0, islands):
			logging.debug('Case #%d: Test island: %d', x + 1, y + 1)
			if fnIsRedundant(totIng, isleIng[y]):
				redundantIsle += 1
				break
		if redundantIsle == 0:
			print('all')
		else:
			print('some')


t = int(input())
for i in range(t):
	(n, k) = input().split()
	st = set()
	s = set()
	cnt = 0
	arr = [list() for p in range(int(k))]
	for j in range(int(n)):
		l = [int(x) for x in input().split()]
		for p in range(1, l[0] + 1):
			st.add((j, l[p]))
			if len(arr[l[p] - 1]) == 0:
				cnt = cnt + 1
			arr[l[p] - 1].append(j)
	if cnt != int(k):
		print('sad')
	else:
		for j in range(int(k)):
			if len(arr[j]) == 1:
				s.add(arr[j][0])
		c = 0
		for x in range(int(n)):
			if x not in s:
				st1 = set()
				for p in range(1, int(k) + 1):
					st1.add((x, p))
				st2 = st.difference(st1)
				cnt = 0
				arr1 = [0 for p in range(int(k))]
				for p in st2:
					if arr1[p[1] - 1] == 0:
						arr1[p[1] - 1] = 1
						cnt = cnt + 1
				if cnt == int(k):
					print('some')
					c = 1
					break
		if c == 0:
			print('all')