n | a, b = eval(input()) | n | p, l = eval(input()) |
| d = dict() | | m = dict() |
| text = input() | | n = input() |
| while text: | | while n: |
| text = text.split() | | n = n.split() |
| for word in text: | | for z in n: |
| if "'" in word: | | if "'" in z: |
| word = word[0:word.find("'")] | | z = z[0:z.find("'")] |
| if ";" in word: | | if ";" in z: |
| word = word[0:word.find(";")] | | z = z[0:z.find(";")] |
| if "-" in word: | | if "-" in z: |
| word = word.replace((word[0:word.find("-")]+"-"), "") | | z = z.replace((z[0:z.find("-")]+"-"), "") |
| if len(word) > 1 and not word[-1].isalpha(): | | if len(z) > 1 and not z[-1].isalpha(): |
| word = word[0:-1] | | z = z[0:-1] |
| if len(word) > 1 and not word[0].isalpha(): | | if len(z) > 1 and not z[0].isalpha(): |
| word = word[1:] | | z = z[1:] |
| word = word.lower() | | z = z.lower() |
| if word.isalpha() and len(word) >= b: | | if z.isalpha() and len(z) >= l: |
| if word in d: | | if z in m: |
| d[word] += 1 | | m[z] += 1 |
| else: | | else: |
n | d[word] = 1 | n | m[z] = 1 |
| | | |
n | text = input() | n | n = input() |
| | | |
t | w_a = set(d.values()) | t | w_p = set(m.values()) |
| w_a = list(w_a) | | w_p = list(w_p) |
| w_a.sort(reverse=True) | | w_p.sort(reverse=True) |
| w_a = w_a[0:a] | | w_p = w_p[0:p] |
| w = [(v, k) for k, v in d.items() if v in w_a] | | w = [(v, k) for k, v in m.items() if v in w_p] |
| w.sort() | | w.sort() |
| for x in w: | | for x in w: |
| print(x[0], ': ', x[1], sep='') | | print(x[0], ': ', x[1], sep='') |
| | | |