def myAssert(v): if not v: raise ValueError('constriant not satisfied') T = int(input()) myAssert(T >= 1 and T <= 1000) for _ in range(T): (n, K) = list(map(int, input().split(' '))) myAssert(n >= 1 and n <= 100) myAssert(K >= 0 and K <= 100) s = input() #print(s) myAssert(len(s) == n) for ch in s: myAssert((ch >= 'a' and ch <= 'z') or (ch >= 'A' and ch <= 'Z')) chef = sum([1 for ch in s if ch >= 'A' and ch <= 'Z']) <= K brother = sum([1 for ch in s if ch >= 'a' and ch <= 'z']) <= K # print(chef, brother) if (chef and brother): print("both") elif (chef): print("chef") elif (brother): print("brother") else: print("none")