prime =  2015177
alphabet_size = 256

def exactSearch(s, pos, len):
	for j in range(pos,pos+len):
		if(s[j]!=s[j+len]):
			return False
	return True;

def lookForSafewords(s, j):
    hashtable = []
    pol = pow(alphabet_size,j-1,prime)
    myHash = 0
    for k in range(j):
        myHash= (myHash*alphabet_size+ ord(s[k])) % prime
    hashtable.append(myHash)
    for k in range(len(s)-j):
        myHash = (alphabet_size*(myHash - ord(s[k])*pol) + ord(s[k+j]))%prime
        if(myHash<0):
            myHash+=prime
        hashtable.append(myHash);
    ret = "Podraport Numer "+str(j)+":\n"
    for k in range(len(hashtable)-j):
        if(hashtable[k]==hashtable[k+j]):
            if(exactSearch(s,k,j)):
                end = k+2*j
                return ret+s[k:end]
    return ret+"Konto jest bezpieczne"

def test(i):
    S=input()
    K=int(input())
    print("Raport Generalny Numer "+str(i)+":")
    for j in range(1,K+1):
        print(lookForSafewords(S,j))

T=int(input())
for i in range(1,T+1):
    test(i)
