while True:
    try:
        lst = input().split()
        words, x, k = lst[:-2], lst[-2], int(lst[-1])
        bros = []
        for w in words:
            if len(w) == len(x) and w != x:
                if sorted(w) == sorted(x):
                    bros.append(w)
        print(len(bros))
        if k <= len(bros):
            print(sorted(bros)[k-1])
    except:
        break