f=open('Z3.txt','r',encoding='utf-8')
lines=f.readlines()
f.close()
n,k,l=map(int,lines[0].split())
text=' '.join(lines[1:])
words=[]
i=0
L=len(text)
while i<L:
if text[i].isalpha():
j=i
while j<L and text[j].isalpha():
j+=1
words.append(text[i:j].lower())
i=j
else:
i+=1
d={}
for w in words:
d[w]=d.get(w,0)+1
fd={}
for w,c in d.items():
if n<=c<=k and len(w)<=l:
fd.setdefault(c,[]).append(w)
for c in sorted(fd.keys(),reverse=True):
for w in sorted(fd[c]):
print(w,c)