#学会使用while true,try except 的结构,这对程序员排查出错误很有帮助。
#例如 
#try:
#	pass
#except ValueError:
#    print("Invalid input. Please enter a valid number.")
#except ZeroDivisionError:
#    print("Cannot divide by zero.")

#学会了使用预设变量c=0,减少使用list和append的次数,可以减少存储空间
while True:
    try:
        str1,n=input(),int(input())
        c=0
        if len(str1)>n:
            for i in range(len(str1)-n):
                substr1=str1[0+i:n+i]                
                ratio=(substr1.count('C')+substr1.count('G'))/n
                if ratio>c:
                    c=ratio
                    result_str=substr1
            print(result_str)
        else:
            print(str1)
    except:
        break