#include<iostream>
#include<vector>
#include<string>
#include<stdint.h>

#define prime 2015177
#define alphabet_size 256


using namespace std;

int64_t myPow(int64_t x, int64_t p)
{
  if (p == 0) return 1;
  if (p == 1) return x %prime;

  int64_t tmp = myPow(x, p/2) % prime;
  if (p%2 == 0) return (tmp * tmp) % prime;
  else return (x * ((tmp * tmp)%prime)) % prime;
}

bool exactSearch(string &s, int pos, int len){
	for(int j = pos; j<pos+len; j++){
		if(s[j]!=s[j+len]){
			return false;
		}
	}
	return true;
}

string lookForSafewords(string &s, int j){
	vector<int64_t> hashtable = vector<int64_t>();
	int64_t pol = myPow(alphabet_size,j-1);

	int64_t myHash = 0;
	for(int k = 0; k<j; k++){
		myHash= (myHash*alphabet_size+ s[k]) % prime;
	}
	hashtable.push_back(myHash);
	for(int k=0; k<s.size()-j; k++){
		myHash = (alphabet_size*(myHash - s[k]*pol) + s[k+j])%prime;  
		if(myHash<0){
			myHash+=prime;
		}
		hashtable.push_back(myHash);
	}
/*
//Debug purpose only
	for(int zz = 0; zz <hashtable.size(); zz++){
		cout<<" "<<hashtable[zz];
	}
*/
	string ret = "Podraport Numer "+to_string(j)+":";
	for(int k = 0; k<hashtable.size()-j; k++){
		if(hashtable[k]==hashtable[k+j]){
			if(exactSearch(s,k,j)){
				return ret+"\n"+s.substr(k,2*j)+"\n";
			}
		}
	}		
	return ret +"\n"+"Konto jest bezpieczne"+"\n";
}

void test(int i){
	string S;
	cin>>S;
	int K;
	cin>>K;
	cout<<"Raport Generalny Numer "+to_string(i)+":\n";
	for(int j = 1; j<=K; j++){
		cout<<lookForSafewords(S,j);
	}
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	//Number of cases
	int T;
	cin>>T;
	for(int i = 1; i<=T; i++){
		test(i);
	}
	return 0;
}
