Vanya is managed to enter his favourite site Codehorses. Vanya uses n distinct passwords for sites at all, however he can't remember which one exactly he specified during Codehorses registration.

Vanya will enter passwords in order of non-decreasing their lengths, and he will enter passwords of same length in arbitrary order. Just when Vanya will have entered the correct password, he is immediately authorized on the site. Vanya will not enter any password twice.

Entering any passwords takes one second for Vanya. But if Vanya will enter wrong password k times, then he is able to make the next try only 5 seconds after that. Vanya makes each try immediately, that is, at each moment when Vanya is able to enter password, he is doing that.

Determine how many seconds will Vanya need to enter Codehorses in the best case for him (if he spends minimum possible number of second) and in the worst case (if he spends maximum possible amount of seconds).


-----Input-----

The first line of the input contains two integers n and k (1 ≤ n, k ≤ 100) — the number of Vanya's passwords and the number of failed tries, after which the access to the site is blocked for 5 seconds.

The next n lines contains passwords, one per line — pairwise distinct non-empty strings consisting of latin letters and digits. Each password length does not exceed 100 characters.

The last line of the input contains the Vanya's Codehorses password. It is guaranteed that the Vanya's Codehorses password is equal to some of his n passwords.


-----Output-----

Print two integers — time (in seconds), Vanya needs to be authorized to Codehorses in the best case for him and in the worst case respectively.


-----Examples-----
Input
5 2
cba
abc
bb1
abC
ABC
abc

Output
1 15

Input
4 100
11
22
1
2
22

Output
3 4



-----Note-----

Consider the first sample case. As soon as all passwords have the same length, Vanya can enter the right password at the first try as well as at the last try. If he enters it at the first try, he spends exactly 1 second. Thus in the best case the answer is 1. If, at the other hand, he enters it at the last try, he enters another 4 passwords before. He spends 2 seconds to enter first 2 passwords, then he waits 5 seconds as soon as he made 2 wrong tries. Then he spends 2 more seconds to enter 2 wrong passwords, again waits 5 seconds and, finally, enters the correct password spending 1 more second. In summary in the worst case he is able to be authorized in 15 seconds.

Consider the second sample case. There is no way of entering passwords and get the access to the site blocked. As soon as the required password has length of 2, Vanya enters all passwords of length 1 anyway, spending 2 seconds for that. Then, in the best case, he immediately enters the correct password and the answer for the best case is 3, but in the worst case he enters wrong password of length 2 and only then the right one, spending 4 seconds at all.

Source: codeforces | Difficulty: EASY
Tags: Mathematics

String algorithms

Sorting

Implementation


Solutions:
(n, k) = map(int, input().split())
l = []
for i in range(n):
	l.append(input())
password = input()
maximum = 0
for i in l:
	if len(i) > maximum:
		maximum = len(i)
danhdau = [0] * (maximum + 1)
best = 0
worst = 0
for i in l:
	danhdau[len(i)] += 1
for i in range(len(danhdau)):
	if i <= len(password):
		best += danhdau[i]
		worst += danhdau[i]
best = best - danhdau[len(password)] + 1
if best % k == 0:
	best = best + (best // k - 1) * 5
else:
	best = best // k * 5 + best
if worst % k == 0:
	worst = worst + (worst // k - 1) * 5
else:
	worst = worst // k * 5 + worst
print('{0} {1}'.format(best, worst))


def sortA(inputStr):
	return len(inputStr)
(n, k) = map(int, input().split())
pas = []
s1 = 0
s2 = 0
for i in range(n):
	pas.append(input())
pas.sort(key=sortA)
ok_pass = input()
i = 0
while i < n and len(pas[i]) <= len(ok_pass):
	if len(pas[i]) == len(ok_pass) and s1 == 0:
		s1 = s2 + 1
	if (i + 1) % k == 0 and i + 1 < n and (len(ok_pass) >= len(pas[i + 1])):
		s2 += 5
	s2 += 1
	i += 1
print(s1, s2)


(n, d) = map(int, input().split())
l = [input() for _ in range(n + 1)]
pw = l[-1]
red = len([x for x in l if len(x) < len(pw)])
same = len([x for x in l if len(x) <= len(pw)]) - 2
print(red + red // d * 5 + 1, same + same // d * 5 + 1)


def inp():
	return map(int, input().split(' '))
(n, k) = inp()
cnt = [0 for i in range(101)]
for i in range(n):
	temp = input()
	length = len(temp)
	cnt[length] += 1
S = input()
mini = 0
maxi = 0
for i in range(len(S)):
	mini += cnt[i]
mini += int(mini / k) * 5
for i in range(len(S) + 1):
	maxi += cnt[i]
maxi -= 1
maxi += int(maxi / k) * 5
print(str(mini + 1) + ' ' + str(maxi + 1))


(n, k) = map(int, input().split())
l = [input() for i in range(n)]
z = []
d = {}
for i in l:
	t = len(i)
	if t in d:
		d[t] += 1
	else:
		d[t] = 1
		z.append(t)
(b, w) = (0, 0)
su = 0
x = len(input())
z.sort()
for i in z:
	if i == x:
		break
	su += d[i]
b = su // k * 5 + su + 1
w = (su + d[x] - 1) // k * 5 + su + d[x]
print(b, w)


(n, k) = map(int, input().split())
a = []
min = 0
max = 0
countLess = 0
countEqual = 0
for i in range(n):
	t = input()
	a.append(t)
correctPass = input()
for i in a:
	if len(i) < len(correctPass):
		countLess += 1
	elif len(i) == len(correctPass):
		countEqual += 1
min = countLess + countLess // k * 5 + 1
max = countLess + countEqual + (countLess + countEqual - 1) // k * 5
print('{0} {1}'.format(min, max))


(n, k) = map(int, input().split())
xs = []
for i in range(0, n):
	xs.append(input())
lp = len(input())
xs.sort(key=lambda s: len(s))
best = 0
worst = 0
t = 1
for i in xs:
	if len(i) < lp:
		best += 1
		if t % k == 0:
			best += 5
		t += 1
	else:
		best += 1
		break
t = 1
for i in xs:
	if not len(i) > lp:
		if (t - 1) % k == 0 and t != 1:
			worst += 5
		worst += 1
		t += 1
	else:
		break
print(best, worst)


(n, k) = map(int, input().split())
pas = []
for i in range(n):
	s = len(str(input()))
	pas.append(s)
password = len(str(input()))
pas.sort()
x = pas.index(password) + 1
pas = pas[::-1]
y = len(pas) - pas.index(password)
if x > k:
	a = 5 * ((x - 1) // k) + x
else:
	a = x
if y > k:
	b = 5 * ((y - 1) // k) + y
else:
	b = y
print(a, b)


def main():
	(n, k) = list(map(int, input().split()))
	trial = {}
	for _ in range(n):
		s = input()
		L = len(s)
		if L not in trial:
			trial[L] = 0
		trial[L] += 1
	ansL = len(input())
	shorter = sum((trial[x] for x in trial if x < ansL))
	(best, worst) = (shorter, shorter + trial[ansL] - 1)
	print(best + best // k * 5 + 1, worst + worst // k * 5 + 1)
main()


(n, k) = list(map(int, input().split()))
passwords = []
for i in range(n):
	passwords.append(input())
correct = input()
(shorter, same) = (0, 0)
for p in passwords:
	if len(p) < len(correct):
		shorter = shorter + 1
	elif len(p) == len(correct):
		same = same + 1
same = same + shorter + 5 * ((same + shorter - 1) // k)
shorter = 1 + shorter + 5 * (shorter // k)
print(shorter, same)
exit(0)


def main():
	from sys import stdin, stdout
	(n, k) = map(int, stdin.readline().split())
	p = []
	for _ in range(n):
		p.append(stdin.readline().strip())
	p.sort(key=len)
	P = stdin.readline().strip()
	j = 0
	count = 0
	for i in p:
		j += 1
		if len(i) == len(P):
			count += 1
			minim = count
			break
		else:
			count += 1
			if j % k == 0:
				count += 5
	count = 0
	j = 0
	for i in p:
		j += 1
		if len(i) > len(P):
			if (j - 1) % k == 0:
				count -= 5
			maxim = count
			break
		elif i == p[-1]:
			maxim = count + 1
			break
		else:
			count += 1
			if j % k == 0:
				count += 5
	stdout.write(str(minim) + ' ' + str(maxim))
main()


(n, k) = map(int, input().split())
lengths = [0] * 101
for pw in range(n):
	atl = len(input())
	lengths[atl] += 1
pwl = len(input())
wrong = 0
t = 0
for i in range(1, pwl):
	for j in range(lengths[i]):
		wrong += 1
		t += 1
		if wrong == k:
			t += 5
			wrong = 0
print(t + 1, end=' ')
for j in range(lengths[pwl] - 1):
	wrong += 1
	t += 1
	if wrong == k:
		t += 5
		wrong = 0
print(t + 1)


(n, k) = map(int, input().split())
d = {}
while n > 0:
	s = input()
	k1 = len(s)
	if k1 not in d:
		d[k1] = 1
	else:
		d[k1] += 1
	n -= 1
s = input()
k1 = len(s)
c = c1 = 0
for i in sorted(d):
	if i < k1:
		c += d[i]
	elif i == k1:
		c1 = c
		c += d[i]
	else:
		break
print(c1 + 1 + c1 // k * 5, c + (c - 1) // k * 5)


(n, k) = (int(_) for _ in input().split())
a = []
for i in range(n):
	a.append(input())
pw = input()
(x, y) = (0, 0)
for s in a:
	if s == pw:
		continue
	if len(s) < len(pw):
		x += 1
		y += 1
	if len(s) == len(pw):
		y += 1
x += x // k * 5
y += y // k * 5
print(x + 1, y + 1)


import math
(n, k) = map(int, input().split())
x = []
for i in range(n):
	y = input()
	x.append(y)
p = input()
l = len(p)
cnt1 = 0
cnt2 = 0
for i in x:
	if len(i) < l:
		cnt1 += 1
	if len(i) == l:
		cnt2 += 1
cnt2 += cnt1
ans1 = cnt1 + math.floor(cnt1 / k) * 5 + 1
ans2 = cnt2 + math.floor((cnt2 - 1) / k) * 5
print(ans1, ans2)


(n, k) = map(int, input().split())
ps = [len(input()) for _ in range(n)]
pl = len(input())
ps.sort()
i = 0
b = 0
w = 0
ct = 0
while ps[i] < pl:
	if ct == k:
		ct = 0
		b += 5
	i += 1
	ct += 1
	b += 1
w = b
b += 1 + (ct == k) * 5
while i < n and ps[i] == pl:
	if ct == k:
		ct = 0
		w += 5
	i += 1
	ct += 1
	w += 1
print(b, w)


import os
import sys
import math
import heapq
from decimal import *
from io import BytesIO, IOBase
from collections import defaultdict, deque

def r():
	return int(input())

def rm():
	return map(int, input().split())

def rl():
	return list(map(int, input().split()))
(n, k) = rm()
a = []
for i in range(n):
	a.append(input())
password = input()
passLen = len(password)
time = 0
min = 0
max = 0
gotMin = False
gotMax = False
b = []
for i in a:
	b.append(len(i))
b.sort()
kii = 0
for i in b:
	if i < passLen:
		time += 1
		kii += 1
		kiii = False
	elif i == passLen and (not gotMin):
		time += 1
		kii += 1
		gotMin = True
		min = time
		kiii = False
	elif i == passLen:
		time += 1
		kii += 1
		kiii = False
	else:
		max = time
		gotMax = True
		break
	if kii == k:
		time += 5
		kiii = True
		kii = 0
if gotMax:
	if kiii == True:
		max -= 5
if not gotMax:
	if kiii == True:
		time -= 5
	max = time
print(min, max)


(n, k) = [int(i) for i in input().strip().split()]
passwords = []
for i in range(n + 1):
	passwords.append(input())
right_password = passwords[-1]
less_passwords = 0
equal_passwords = 0
for i in range(n):
	if len(passwords[i]) < len(right_password):
		less_passwords += 1
	elif len(passwords[i]) == len(right_password):
		equal_passwords += 1
worse_time = int((equal_passwords - 1 + less_passwords % k) / k) * 5 + equal_passwords
best_time = 1
less_time = int(less_passwords / k) * 5 + less_passwords
total_time = [less_time + best_time, less_time + worse_time]
print(total_time[0], total_time[1])


def count_length(my_list, length):
	count = 0
	for x in my_list:
		if len(x) == length:
			count += 1
		if len(x) > length:
			break
	return count
(n, k) = [int(x) for x in input().split()]
passwords = [0] * n
for i in range(n):
	passwords[i] = input()
codehorses = input()
passwords = sorted(passwords, key=len)
best_time = 0
worst_time = 0
carry = 0
current = 1
target = len(codehorses)
while current < target:
	temp = count_length(passwords, current)
	best_time += temp + (temp + carry) // k * 5
	worst_time += temp + (temp + carry) // k * 5
	carry = (temp + carry) % k
	current += 1
best_time += 1
temp = count_length(passwords, target) - 1
worst_time += temp + (temp + carry) // k * 5
worst_time += 1
print(best_time, worst_time)


(n, k) = input().split()
a = []
for i in range(int(n)):
	a.append(input())
ans = input()
ceq = 0
cle = 0
s = ''
mx = len(ans)
for ax in a:
	if len(ax) < mx:
		cle += 1
	elif len(ax) == mx:
		ceq += 1
err = cle / int(k)
tmn = int(err) * 5 + cle + 1
err = (cle + ceq - 1) / int(k)
tmx = int(err) * 5 + cle + ceq
print(str(int(tmn)) + ' ' + str(int(tmx)))


(n, k) = map(int, input().split())
a = [0] * n
for i in range(n):
	a[i] = len(input())
rp = len(input())
a = sorted(a)
c = a.index(rp) + 1
b = n - a[::-1].index(rp)
minatemps = c + (c - 1) // k * 5
maxatemps = b + (b - 1) // k * 5
print(minatemps, maxatemps)


(n, k) = map(int, input().split())
l = []
p = {}
for i in range(n):
	temp = input()
	try:
		p[len(temp)].append(temp)
	except KeyError:
		p[len(temp)] = [temp]
ans = input()
best = 0
worst = 0
for i in range(len(ans)):
	try:
		best += len(p[i])
		worst += len(p[i])
	except KeyError:
		continue
z = best // k
z = z * 5
best += z
best += 1
for i in range(len(p[len(ans)])):
	temp = p[len(ans)].pop()
	if temp == ans:
		continue
	else:
		worst += 1
y = worst // k
y = y * 5
worst += y + 1
print('{} {}'.format(best, worst))


(a, b) = list(map(int, input().split()))
sa = []
for x in range(a):
	la = input()
	sa.append(la)
na = input()
pam = len(na)
jam = 0
for it in sa:
	if len(it) <= pam:
		jam += 1
if jam // b == jam / b:
	fam = int(jam // b) - 1
else:
	fam = int(jam // b)
hj = fam * 5
hj += jam
jam = 0
dj = 0
lim = 0
for it in sa:
	if len(it) < pam:
		jam += 1
	elif len(it) == pam and lim == 0:
		jam += 1
		lim = 1
	else:
		pass
if jam // b == jam / b:
	fam = int(jam // b) - 1
else:
	fam = int(jam // b)
dj += fam * 5
dj += jam
print(dj, hj)


import sys
input = sys.stdin.readline
(n, k) = map(int, input().split())
l = []
for _ in range(n):
	l.append(input())
ls = sorted(l, key=len)
length = len(input())
for i in range(n):
	if len(ls[i]) == length:
		ans1 = i + 1 + i // k * 5
		start = i
		break
if len(ls[-1]) == length:
	ans2 = n + (n - 1) // k * 5
else:
	for i in range(start + 1, n):
		if len(ls[i - 1]) == length and len(ls[i]) != length:
			ans2 = i + (i - 1) // k * 5
			break
print(ans1, ans2)


def count_time(_key):
	i = sorted(variants, key=_key).index(password)
	return i + 1 + i // k * 5
(n, k) = map(int, input().split())
variants = [input() for x in range(n)]
password = input()
print(*map(count_time, [lambda x: (len(x), x != password), lambda x: (len(x), x == password)]))


required_time = lambda tries, k: tries + (tries - 1) // k * 5
(n, k) = map(int, input().split())
(pw_lengths, l) = ([len(input()) for _ in range(n)], len(input()))
shorter_pw = sum((length < l for length in pw_lengths))
equal_pw = sum((length == l for length in pw_lengths))
print(required_time(shorter_pw + 1, k), required_time(shorter_pw + equal_pw, k))


(n, k) = map(int, input().split())
pas = []
for i in range(n):
	s = input()
	pas.append(s)
s = input()
arr1 = list(filter(lambda x: len(x) < len(s), pas))
best = len(arr1)
arr2 = list(filter(lambda x: len(x) <= len(s), pas))
worst = len(arr2)
arr3 = list(filter(lambda x: x == s, pas))
same = len(arr3)
worst -= same
if worst == 0:
	print(best + 5 * (best // k) + 1, '1')
else:
	print(best + 5 * (best // k) + 1, worst + 5 * (worst // k) + 1)


(passwords_count, tries) = map(int, input().split())
passwords = {}
for _ in range(passwords_count):
	s = input()
	p_length = len(s)
	if p_length in passwords:
		passwords[p_length].append(s)
	else:
		passwords[p_length] = list()
		passwords[p_length].append(s)
correct = input()
ordered_keys = sorted(passwords.keys(), key=lambda x: x)

def find_min_tries():
	min_tries = 0
	max_tries = 0
	for key in ordered_keys:
		if correct in passwords[key]:
			min_tries += 1
			max_tries += len(passwords[key])
			return (min_tries, max_tries)
		else:
			min_tries += len(passwords[key])
			max_tries += len(passwords[key])
(min_, max_) = find_min_tries()
min_ = min_ - 1
max_ = max_ - 1
awaiting_min = 1
awaiting_max = 1
if min_ < tries:
	awaiting_min += min_
else:
	overlaps = min_ // tries
	awaiting_min += overlaps * 5 + (min_ - overlaps * tries) + overlaps * tries
if max_ < tries:
	awaiting_max += max_
else:
	overlaps = max_ // tries
	awaiting_max += overlaps * 5 + overlaps * tries + (max_ - overlaps * tries)
print(awaiting_min, awaiting_max)


(n, k) = map(int, input().split(' '))
s = list()
for i in range(0, n):
	s.append(len(input()))
s = sorted(s)
passw = input()
c = 0
h = len(passw)
small = 1
i = 0
while i < n:
	i = i + 1
	if s[i - 1] < h:
		small = small + 1
		c = c + 1
		if i % k == 0:
			small = small + 5
i = 0
large = -1
while i < n:
	i = i + 1
	if s[i - 1] == h:
		large = large + 1
		c = c + 1
		if i % k == 0:
			large = large + 5
if c % k == 0:
	large = large - 5
print(str(small) + ' ' + str(small + large))


(n, k) = [int(i) for i in input().split()]
ary = []
for i in range(n):
	ary.append(input())
key = input()

def allSum(n):
	return n * 1 + n // k * 5

def worstSum(n):
	if n % k != 0:
		return n * 1 + n // k * 5
	return n * 1 + (n // k - 1) * 5
smaller = 0
equal = 0
for i in ary:
	if len(i) < len(key):
		smaller += 1
	if len(i) == len(key):
		equal += 1
print(allSum(smaller) + 1)
print(worstSum(smaller + equal))


(n, k) = map(int, input().split())
t = []
for i in range(n):
	t.append(len(input()))
l = len(input())
t.sort()
cnt = 0
for i in t:
	if i < l:
		cnt += 1
	else:
		break
temp = t.count(l)
print(cnt + cnt // k * 5 + 1, cnt + (cnt + temp - 1) // k * 5 + temp)


def func():
	(numpw, penal) = (int(i) for i in input().split(' '))
	codes = []
	for i in range(numpw):
		code = input()
		codes.append(code)
	pwd = input()
	codes = sorted(codes, key=len)
	best_way = 0
	worst_way = 0
	for i in codes:
		if len(i) < len(pwd):
			best_way += 1
		if len(i) <= len(pwd):
			worst_way += 1
	best_way = best_way + best_way // penal * 5 + 1
	worst_way = worst_way + (worst_way - 1) // penal * 5
	print('%s %s' % (best_way, worst_way))
func()


(a, b) = map(int, input().split())
d = [len(input()) for x in range(a)]
d.sort()
c = len(input())
i = d.index(c)
r = i + d.count(c)
print(i + 1 + i // b * 5, r + (r - 1) // b * 5)


import sys
input = lambda : sys.stdin.readline()
A = []
(n, k) = map(int, input().split())
for _ in range(n):
	s = input()
	A.append(s)
pas = input()
l = len(A)
A = list(filter(lambda x: len(x) >= len(pas), A))
same_length = len(list(filter(lambda x: len(x) == len(pas), A)))
l -= len(A)
if l < k:
	best_case = l + 1
else:
	best_case = l + l // k * 5 + 1
if l + same_length - 1 < k:
	worst_case = l + same_length
else:
	worst_case = l + same_length + (l + same_length - 1) // k * 5
print(best_case, worst_case)


(n, k) = map(int, input().split())
result = {}
for i in range(n):
	p = input()
	if not result.get(len(p)):
		result[len(p)] = 1
	else:
		result[len(p)] += 1
password = input()
aim = len(password)
errors = 0
m = 0
for key in sorted(result.keys()):
	if key < aim:
		m += result[key]
		errors += result[key]
		m += int(errors / k) * 5
		errors %= k
	else:
		errors += result[key] - 1
		print(m + 1, m + result[key] + int(errors / k) * 5)
		break


(n, k) = map(int, input().split())
(a, temp) = ([], [])
for i in range(n):
	temp.append(input())
right_pass = input()
len_s = len(right_pass)
len_not_equal = 0
for i in range(n):
	if len(temp[i]) == len_s:
		a.append(temp[i])
	elif len(temp[i]) < len_s:
		len_not_equal += 1
t = len(a) - 1
worst_case = int((len_not_equal % k + t) / k) * 5 + t + 1
best_case = 1 + int(len_not_equal / k) * 5 + len_not_equal
print(best_case, best_case - 1 + worst_case)


(n, k) = map(int, input().split())
passwords = []
taim = 0
for i in range(n):
	passwords += [input()]
x = len(input())
countl = 0
countle = 0
for i in passwords:
	if len(i) < x:
		countl += 1
	if len(i) <= x:
		countle += 1
print(countl + 5 * (countl // k) + 1, countle + 5 * ((countle - 1) // k))


import sys
(n, k) = sys.stdin.readline().split()
(n, k) = (int(n), int(k))
passwords = []
for i in range(n):
	pwd = sys.stdin.readline().strip()
	passwords.append(pwd)
correct_pwd = sys.stdin.readline().strip()
target_len = len(correct_pwd)
num_shorter = 0
num_equal = 0
min_time = 0
max_time = 0
for pwd in passwords:
	if len(pwd) < target_len:
		num_shorter += 1
	if len(pwd) <= target_len:
		num_equal += 1
min_time = num_shorter + 1
max_time = num_equal
if min_time >= k:
	min_time = (min_time - 1) // k * 5 + min_time
if max_time >= k:
	max_time = (max_time - 1) // k * 5 + max_time
print('%i %i' % (min_time, max_time))


(n, k) = map(int, input().split(' '))
count = [0] * 101
for i in range(n):
	count[len(input())] += 1
length = len(input())
(minTry, maxTry) = (sum(count[:length]) + 1, sum(count[:length + 1]))
print(minTry + (minTry - 1) // k * 5, maxTry + (maxTry - 1) // k * 5)


def solution(passwords, correct_pass, k):
	less = passwords.index(correct_pass)
	same = passwords.count(correct_pass)
	print(less + less // k * 5 + 1, same + (same + less - 1) // k * 5 + less)

def main():
	(p, q) = map(int, input().split())
	passwords = sorted((len(input()) for i in range(p)))
	correct_pass = len(input())
	solution(passwords, correct_pass, q)
main()


(n, k) = [int(i) for i in input().split()]
cnts = [0] * 1000
for i in range(n):
	s = input()
	cnts[len(s)] += 1
password = input()
stop = 0
found = 0
i = 1
while i < len(password):
	for j in range(cnts[i]):
		if stop == k:
			found += 5
			stop = 0
		found += 1
		stop += 1
	i += 1
if stop == k:
	found += 5
	stop = 0
mn = found + 1
for j in range(cnts[len(password)]):
	if stop == k:
		found += 5
		stop = 0
	found += 1
	stop += 1
mx = found
print(mn, mx)


import sys
(n, k) = map(int, sys.stdin.readline().split())
p = []
for _ in range(n):
	p.append(input().strip())
pwd = input().strip()
p1 = [i for i in p if len(i) <= len(pwd)]
p2 = [i for i in p1 if len(i) < len(pwd)]
nbl = len(p2)
nbe = len(p1)
mi = nbl + 1 + nbl // k * 5
ma = nbe + (nbe - 1) // k * 5
print(mi, ma)


(n, k) = map(int, input().split())
p = [input() for i in range(n)]
pw = input()
p.sort(key=len)
best = sum((len(i) < len(pw) for i in p))
worst = sum((len(i) <= len(pw) for i in p)) - 1
print(best + 5 * (best // k) + 1, worst + 5 * (worst // k) + 1)


(n, k) = map(int, input().split())
passwords = []
for i in range(n):
	passwords.append(input())
passwords = sorted(passwords, key=lambda x: -len(x))
correct_pwd = input()
right_break_point = n - 1
left_break_point = 0
for i in range(n - 1, -1, -1):
	if len(correct_pwd) == len(passwords[i]):
		right_break_point = i
		break
for i in range(right_break_point, -1, -1):
	if len(correct_pwd) != len(passwords[i]):
		left_break_point = i + 1
		break
same_length_list = passwords[left_break_point:right_break_point + 1]
number_of_corrects = 0
for i in range(len(same_length_list)):
	if same_length_list[i] == correct_pwd:
		number_of_corrects += 1
counter_best_case = n - right_break_point
counter_worst_case = n - (left_break_point + number_of_corrects - 1)
best_case_mod = 1 if counter_best_case % k == 0 and counter_best_case // k > 0 else 0
worst_case_mod = 1 if counter_worst_case % k == 0 and counter_worst_case // k > 0 else 0
best_case = counter_best_case + (counter_best_case // k - best_case_mod) * 5
worst_case = counter_worst_case + (counter_worst_case // k - worst_case_mod) * 5
print(best_case, worst_case)


import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
import math

def fact(x):
	if x == 0:
		return 1
	else:
		return x * fact(x - 1)

def lower_bound(li, num):
	answer = -1
	start = 0
	end = len(li) - 1
	while start <= end:
		middle = (end + start) // 2
		if li[middle] >= num:
			answer = middle
			end = middle - 1
		else:
			start = middle + 1
	return answer

def upper_bound(li, num):
	answer = -1
	start = 0
	end = len(li) - 1
	while start <= end:
		middle = (end + start) // 2
		if li[middle] <= num:
			answer = middle
			start = middle + 1
		else:
			end = middle - 1
	return answer
for t in range(1):
	(n, k) = list(map(int, input().split()))
	cntl = 0
	cntng = 0
	li = []
	for i in range(n + 1):
		string = input()
		li.append(string)
	for i in range(n):
		if len(li[i]) < len(li[-1]):
			cntl += 1
		if len(li[i]) <= len(li[-1]):
			cntng += 1
	print(cntl + cntl // k * 5 + 1, cntng + (cntng - 1) // k * 5)


def main():
	l = [0] * 101
	(n, k) = map(int, input().split())
	for _ in range(n):
		l[len(input())] += 1
	i = len(input())
	a = sum(l[:i])
	print(*[x + 1 + x // k * 5 for x in (a, a + l[i] - 1)])
main()


(n, k) = input().split()
n = int(n)
k = int(k)
array = []
for i in range(n):
	array.append(input())
correcta = input()
saiz = len(correcta)
countMenor = len([1 for l in array if len(l) < saiz])
countIgual = len([1 for l in array if len(l) == saiz])
best = countMenor + countMenor // k * 5 + 1
worst = countMenor + countIgual + (countMenor + countIgual - 1) // k * 5
print(best, worst)


(n, k) = map(int, input().split())
l = []
for _ in range(n):
	l.append(len(input()))
l.sort()
p = len(input())
rl = l.index(p)
rr = n - 1 - l[::-1].index(p)
print(rl + 1 + rl // k * 5, rr + 1 + rr // k * 5)


(n, m) = input().split()
n = int(n)
m = int(m)
l = []
for i in range(n):
	l.append(input())
s = input()
lc = 0
ec = 0
for i in l:
	if len(i) < len(s):
		lc = lc + 1
	if len(i) == len(s):
		ec = ec + 1
bt = 0
wt = 0
for i in range(lc):
	if (i + 1) % m == 0:
		bt = bt + 6
	else:
		bt = bt + 1
for i in range(lc + ec - 1):
	if (i + 1) % m == 0:
		wt = wt + 6
	else:
		wt = wt + 1
print(bt + 1, wt + 1)


(n, k) = [int(j) for j in input().split()]
s = [['', 0] for j in range(n)]
for j in range(n):
	s[j][0] = input()
	s[j][1] = len(s[j][0])
p = input()
l = len(p)
s = sorted(s, key=lambda x: x[1])
(min, max) = (1, n)
f = 1
for i in range(n):
	if s[i][1] == l and f:
		min = i + 1
		f = 0
	if s[i][1] > l:
		max = i
		break
min_time = min // k * 5 + min
max_time = max // k * 5 + max
if min % k == 0:
	min_time -= 5
if max % k == 0:
	max_time -= 5
print(min_time, max_time)


(n, k) = map(lambda a: int(a), input().split(' '))
_map = {}
for i in range(n):
	s = input()
	l = len(s)
	if l in _map:
		_map[l] += 1
	else:
		_map[l] = 1
ans = input()

def solve1(n, s):
	res = []
	count = 0
	for c in s:
		if c == 'B':
			count += 1
		if c == 'W':
			if count > 0:
				res.append(count)
			count = 0
	if count >= 1:
		res.append(count)
	print(len(res))
	if len(res) >= 1:
		for c in range(len(res) - 1):
			print(res[c], end=' ')
		print(res[len(res) - 1], end='')

def solve2(n, k, _map, ans):
	best = 0
	worst = 0
	l_k = len(ans)
	for i in _map.keys():
		if i < l_k:
			best += _map[i]
			worst += _map[i]
	best_time = best // k * 5 + best
	worst_time = worst // k * 5 + worst
	best_time += 1
	worst += _map[l_k] - 1
	worst_time = worst // k * 5 + worst + 1
	print(best_time, worst_time)
solve2(n, k, _map, ans)


(n, k) = map(int, input().split())
pas = []
for i in range(n):
	pas.append(input())
cp = input()
les = 0
eq = 0
for item in pas:
	if len(item) < len(cp):
		les += 1
	if len(item) <= len(cp):
		eq += 1
print(les + les // k * 5 + 1, eq + (eq - 1) // k * 5)


(n, k) = map(int, input().split())
pwList = []
pwLen = []
for i in range(n):
	pwList.append(input())
	pwLen.append(len(pwList[i]))
truePW = input()
trueLen = len(truePW)
minTry = sum((i < trueLen for i in pwLen)) + 1
if minTry <= k:
	minTime = minTry
elif minTry % k == 0:
	minTime = minTry + 5 * (minTry // k - 1)
else:
	minTime = minTry + 5 * (minTry // k)
maxTry = sum((i <= trueLen for i in pwLen))
if maxTry <= k:
	maxTime = maxTry
elif maxTry % k == 0:
	maxTime = maxTry + 5 * (maxTry // k - 1)
else:
	maxTime = maxTry + 5 * (maxTry // k)
print(minTime, maxTime, sep=' ')


from collections import defaultdict
(X, MyDict, Best, Worst, Size, Sum) = (list(map(int, input().split())), defaultdict(int), 0, 0, 0, 0)
for i in range(X[0]):
	MyDict[len(input())] += 1
Size = len(input())
for key in sorted(MyDict.keys()):
	if key != Size:
		Sum += MyDict[key]
	else:
		print(5 * (Sum // X[1]) + Sum + 1, 5 * ((Sum + MyDict[key] - 1) // X[1]) + Sum + MyDict[key])


(n, m) = map(int, input().split())
passwords = []
for i in range(n):
	a = input()
	passwords.append(a)
answer = input()
passwords.sort(key=len)
oper = 0
start = -1
finish = 0
for i in range(n):
	if len(passwords[i]) == len(answer):
		if oper == 0:
			start = i
			finish = i
			oper = 1
		else:
			finish = i
start += 1
finish += 1
print((start - 1) // m * 5 + start, (finish - 1) // m * 5 + finish)


(n, k) = map(int, input().split())
ipl = []
for i in range(n):
	ipl.append(len(str(input())))
pw = str(input())
ipl = sorted(ipl)
m = ipl.index(len(pw))
ans1 = m // k * 5 + m
rl = -1
for i in ipl:
	if i <= len(pw):
		continue
	else:
		rl = i
		break
if rl != -1:
	m = ipl.index(rl)
	m -= 1
else:
	m = n - 1
ans2 = m // k * 5 + m
print(ans1 + 1, ans2 + 1)


t = input()
n = int(t.split(' ')[0])
k = int(t.split(' ')[1])
l = []
for i in range(n):
	l.append(input())
password = input()
t = 0
l.sort(key=len)
for i in l:
	t += 1
	if len(i) == len(password):
		break

def getans(t):
	global k
	q = -1
	ans = 0
	for i in range(t):
		q += 1
		ans += 1
		if q % k == 0 and q >= k:
			ans += 5
	return ans
a = getans(t)
t = 0
for i in l:
	if len(i) > len(password):
		break
	t += 1
b = getans(t)
print(a, b)


(n, k) = map(int, input().split())
li = []
for i in range(n):
	li.append(input())
pwd = input()
l = len(pwd)
li = sorted(li, key=len)
count1 = 0
count2 = 0
i = 0
while i < n and len(li[i]) < l:
	count1 = count1 + 1
	i = i + 1
count2 = count1
while i < n and len(li[i]) <= l:
	count2 = count2 + 1
	i = i + 1
min_t = count1 + 1 + count1 // k * 5
max_t = count2 + (count2 - 1) // k * 5
print(min_t, max_t)


b = input().split()
n = int(b[0])
k = int(b[1])
list = []
for i in range(n):
	list.append(input())
pwd = input()
minl = 0
maxl = 0
for i in range(n):
	if len(list[i]) < len(pwd):
		minl += 1
	if len(list[i]) <= len(pwd):
		maxl += 1
print(minl + minl // k * 5 + 1, maxl + (maxl - 1) // k * 5)


(n, k) = map(int, input().split())
psw = tuple(sorted((input() for i in range(n)), key=lambda s: len(s)))
correct = input()
q1 = 1
q2 = 0
for vl in psw:
	if len(vl) < len(correct):
		q1 += 1
	if len(vl) < len(correct) + 1:
		q2 += 1
print(q1 + (q1 - 1) // k * 5, q2 + (q2 - 1) // k * 5)


(n, tries) = [int(x) for x in input().split(' ')]
lengths = [0] * 100
for _ in range(n):
	lengths[len(input()) - 1] += 1
correct_length = len(input())
current_seconds = 0
current_tries = 0
for i in range(100):
	if lengths[i] > 0:
		if i + 1 == correct_length:
			print(current_seconds + 1, end=' ')
			current_seconds += lengths[i] + int((lengths[i] + current_tries - 1) / tries) * 5
			print(current_seconds)
			break
		else:
			current_seconds += lengths[i] + int(lengths[i] / tries) * 5
			current_tries += lengths[i] % tries
			if current_tries >= tries:
				current_seconds += 5
				current_tries %= tries


(n, k) = map(int, input().split())
passwords = [input() for i in range(n)]
real_psw = input()

def calc_time(total, k):
	return 5 * (total // k) + total
short_psw_count = len([psw for psw in passwords if len(psw) < len(real_psw)])
equal_psw_count = len([psw for psw in passwords if len(psw) <= len(real_psw)])
best_time = calc_time(short_psw_count, k) + 1
worst_time = calc_time(equal_psw_count - 1, k) + 1
print(best_time, worst_time)


(n, k) = [int(x) for x in input().split()]
l = []
for i in range(n):
	l.append(input())
s = input()
t = 0
v = 0
for j in range(len(l)):
	if len(l[j]) < len(s):
		t += 1
	if len(l[j]) == len(s):
		v += 1
p = t + t // k * 5
d = t + v + (t + v - 1) // k * 5
print(p + 1, d)


(n, m) = map(int, input().split())
a = [0] * 101
for i in range(n):
	s = input()
	l = len(s)
	a[l] += 1
l = len(input())
s = 0
for i in range(l):
	s += a[i]
print(s // m * 5 + s + 1, (s + a[l] - 1) // m * 5 + s + a[l])


(n, k) = map(int, input().split())
a = []
for _ in range(n):
	s = input()
	a.append(len(s))
x = input()
y = len(x)
a.sort()
i = a.index(y)
j = a.count(y)
p = i
q = i + j - 1
print(p // k * 5 + p + 1, q // k * 5 + q + 1)


(n, k) = map(int, input().split())
P = tuple((len(input()) for _ in range(n)))
n = len(input())
x = 0
y = -1
for z in P:
	x += n > z
	y += n >= z
print(1 + x + x // k * 5, 1 + y + y // k * 5)


num = [int(n) for n in input().split()]
p = []
for i in range(num[0]):
	p.append(input())
actual = input()
p.sort(key=len)
for i in range(len(p)):
	if len(p[i]) == len(actual):
		pos = i
		break
for j in range(len(p)):
	if j == len(p) - 1 and len(p[j]) == len(actual):
		pos1 = j
	if len(p[j]) > len(actual):
		pos1 = j - 1
		break
best = pos + pos // num[1] * 5 + 1
worst = pos1 + pos1 // num[1] * 5 + 1
print(best, worst)


(n, k) = map(int, input().split())
l = sorted((len(input()) for i in range(n)))
t = input()
x = l.index(len(t))
count = l.count(len(t))
print(1 + x + x // k * 5, x + count + (x + count - 1) // k * 5)


x = input()
(n, k) = list(map(int, x.split()))
pasw = dict()
for i in range(1, 101):
	pasw[i] = []
for i in range(n):
	x = input()
	d = len(x)
	pasw[d].append(x)
res = input()
dol = len(res)
sekund = 0
for dolzina in range(1, dol):
	sekund += len(pasw[dolzina])
prvi = sekund + 5 * (sekund // k) + 1
dod = sekund + len(pasw[dol]) - 1
drugi = dod + 5 * (dod // k) + 1
print(prvi, drugi)


import math
(n, k) = map(int, input().split())
l = []
for _ in range(n):
	w = input()
	l.append(w)
r = input()
l.sort(key=len)
le = len(r)
m = [x for x in l if len(x) < le]
print(len(m) + 1 + len(m) // k * 5, end=' ')
o = [x for x in l if len(x) <= le]
print((len(o) - 1) // k * 5 + len(o))


(n, k) = map(int, input().split())
passwords = []
for _ in range(n):
	passwords.append(input())
vasyaPass = input()
passwords.sort(key=len)
best = worst = 0
i = 0
while i < len(passwords) and len(passwords[i]) < len(vasyaPass):
	i += 1
	best += 1
	worst += 1
	if i % k == 0:
		best += 5
		worst += 5
while i < len(passwords) and len(passwords[i]) == len(vasyaPass):
	i += 1
	worst += 1
	if i % k == 0:
		worst += 5
best += 1
if i % k == 0:
	worst -= 5
print(best, worst)


(n, k) = list(map(int, input().split()))
a = []
for i in range(n):
	b = input()
	a.append(b)
s = input()
a = list(set(a))
b = {}
for i in a:
	l = len(i)
	if l in b:
		b[l] += 1
	else:
		b[l] = 1
(l, i, t, p) = (len(s), 0, 0, 0)
b = sorted(zip(b.keys(), b.values()))
while b[i][0] != l:
	p += b[i][1]
	i += 1
t = p + p // k * 5
mi = t + 1
ma = t + (p % k + (b[i][1] - 1)) // k * 5 + b[i][1]
print(mi, ma)


(n, m) = [int(a_temp) for a_temp in input().strip().split()]
table = [0] * 101
for _ in range(n):
	w = str(input().strip())
	table[len(w)] += 1
mn = 1
p = len(str(input().strip()))
for i in range(p):
	mn += table[i]
mx = mn + table[p] - 1
mn = mn + (mn - 1) // m * 5
mx = mx + (mx - 1) // m * 5
print('{0} {1}'.format(mn, mx))


(n, k) = map(int, input().split())
a = [input() for i in range(n)]
p = input()
c = 0
d = 0
for i in range(n):
	if len(a[i]) == len(p):
		d += 1
	if len(a[i]) < len(p):
		c += 1
x = c // k
l = c + x * 5 + 1
y = (d + c - 1) // k
h = d + c + y * 5
print(l, h)


import sys
inf = float('inf')
from math import ceil, floor, log, sqrt, factorial, pow, pi, gcd
abc = 'abcdefghijklmnopqrstuvwxyz'
abd = {'a': 0, 'b': 1, 'c': 2, 'd': 3, 'e': 4, 'f': 5, 'g': 6, 'h': 7, 'i': 8, 'j': 9, 'k': 10, 'l': 11, 'm': 12, 'n': 13, 'o': 14, 'p': 15, 'q': 16, 'r': 17, 's': 18, 't': 19, 'u': 20, 'v': 21, 'w': 22, 'x': 23, 'y': 24, 'z': 25}
(mod, MOD) = (1000000007, 998244353)
vow = ['a', 'e', 'i', 'o', 'u']
(dx, dy) = ([-1, 1, 0, 0], [0, 0, 1, -1])

def get_array():
	return list(map(int, sys.stdin.readline().strip().split()))

def get_ints():
	return map(int, sys.stdin.readline().strip().split())

def input():
	return sys.stdin.readline().strip()
(n, k) = get_ints()
myArr = []
for i in range(n):
	myArr.append(input())
ans = input()
length_a = len(ans)
nlengthwaale = 0
n1lengthwaale = 0
for i in range(n):
	if len(myArr[i]) == length_a:
		nlengthwaale += 1
	elif len(myArr[i]) <= length_a - 1:
		n1lengthwaale += 1
best = 0
count = 0
for i in range(n1lengthwaale):
	best += 1
	count += 1
	if count == k:
		count = 0
		best += 5
worst = 0
count = 0
for i in range(n1lengthwaale + nlengthwaale):
	if count == k:
		count = 0
		worst += 5
	worst += 1
	count += 1
print(best + 1, worst)


(n, k) = map(int, input().split())
lst = []
for i in range(n):
	pwd = input()
	lst.append(len(pwd))
lst.sort()
codehorses = len(input())
left = lst.index(codehorses)
right = len(lst) - lst[::-1].index(codehorses) - 1
mi = left + 1 + left // k * 5
ma = right + 1 + right // k * 5
print(mi, ma)


(n, k) = map(int, input().split())
sl = []
for i in range(0, n):
	s = input()
	sl.append(s)
tg = input()
tl = len(tg)
ans1 = 0
lsn = 0
ans2 = 0
eq = 0
for i in range(0, n):
	if len(sl[i]) < tl:
		lsn += 1
	if len(sl[i]) == tl:
		eq += 1
ans1 = int(int(lsn) / k) * 5 + lsn + 1
ans2 += int(int(lsn + eq - 1) / k) * 5 + lsn + eq
print(int(ans1), int(ans2))


(n, k) = list(map(int, input().split()))
L = []
for _ in range(n + 1):
	s = input()
	l = len(s)
	L.append((l, s))
pas = L.pop()
L.sort()
sz = pas[0]
flag = True
(cnt1, cnt2) = (0, 0)
for i in range(n):
	if L[i][0] < sz:
		cnt1 += 1
	if L[i][0] <= sz:
		cnt2 += 1
best = cnt1 + 1 + cnt1 // k * 5
worst = cnt2 + (cnt2 - 1) // k * 5
print(best, end=' ')
print(worst)


string = input()
numbers = string.split()
a = int(numbers[0])
b = int(numbers[1])
lengths = []
for x in range(a):
	string = input()
	lengths.append(len(string))
lengths.sort()
length = len(input())
p = lengths.index(length) + 1
q = p
while q < a:
	if lengths[q] != length:
		break
	q += 1
p += (p - 1) // b * 5
q += (q - 1) // b * 5
print('%d %d' % (p, q))


from sys import stdin

def main():
	x = [0] * 1000
	(n, k) = stdin_get_ints_from_line()
	for i in range(n):
		passwd = stdin.readline().strip()
		x[len(passwd)] += 1
	real_passwd = stdin.readline().strip()
	res_min = 0
	res_max = 0
	for i in range(0, len(real_passwd)):
		res_min += x[i]
	res_max += res_min + x[len(real_passwd)]
	res_min += 1
	res_min += (res_min - 1) // k * 5
	res_max += (res_max - 1) // k * 5
	print(res_min, res_max)
	return

def stdin_get_ints_from_line():
	return (int(x) for x in stdin.readline().strip().split(' '))

def stdin_get_ints_list_from_line():
	return list((int(x) for x in stdin.readline().strip().split(' ')))

def stdin_get_string_from_line():
	return stdin.readline().strip()
main()


(n, k) = map(int, input().split())
length = []
for i in range(n):
	length += [len(input())]
req = len(input())
length.sort()
min_ans = n - 1
max_ans = 0
for i in range(n):
	if length[i] == req and i < min_ans:
		min_ans = i
	if length[n - 1 - i] == req and n - 1 - i > max_ans:
		max_ans = n - 1 - i
min_ans += 1
max_ans += 1
min_ans += (min_ans - 1) // k * 5
max_ans += (max_ans - 1) // k * 5
print(min_ans, max_ans)


(n, k) = map(int, input().split())
s = []
sum1 = 0
sum2 = 0
for i in range(110):
	s.append(0)
for i in range(n):
	l = input()
	p = len(l)
	s[p] += 1
ans = input()
for i in range(len(ans)):
	sum1 += s[i]
sum2 = sum1 + s[len(ans)]
ans1 = sum1 + 5 * (sum1 // k) + 1
ans2 = sum2 + 5 * ((sum2 - 1) // k)
print(ans1, ans2)


inp = list(map(int, input().split()))
n = inp[0]
k = inp[1]
less = 0
same = 0
all_passes = []
for i in range(n):
	cur_pass = input()
	all_passes.append(cur_pass)
real_pass = input()
for p in all_passes:
	if len(p) < len(real_pass):
		less += 1
	elif len(p) == len(real_pass):
		same += 1
print(int(less / k) * 5 + less + 1)
print(int((less + same - 1) / k) * 5 + (less + same))


(n, k) = map(int, input().split())
count = [0] * 101
for _ in range(n):
	s = input()
	count[len(s)] += 1
l = len(input())
Sum = sum(count[:l])
Best = Sum + Sum // k * 5 + 1
Sum = Sum + count[l] - 1
Worst = Sum + Sum // k * 5 + 1
print('%s %s' % (Best, Worst))


(n, k) = map(int, input().split())
s = []
for i in range(n):
	t = input()
	l = len(t)
	r = (t, l)
	s.append(r)
r1 = sorted(s, key=lambda x: x[1])
t = input()
ans = [0, 0]
length = len(t)
flag = 0
for i in range(n):
	if r1[i][1] == length and flag == 0:
		ans[0] = i
		flag = 1
	if i == n - 1 or r1[i + 1][1] > length:
		ans[1] = i
		break
print(ans[0] + 5 * (ans[0] // k) + 1, ans[1] + 5 * (ans[1] // k) + 1)


(n, k) = [int(x) for x in input().split()]
s = [0 for i in range(101)]
for i in range(n):
	s[len(input())] += 1
p = len(input())
ans = 0
for i in range(p):
	ans += s[i]
print(ans // k * 5 + (ans + 1), (ans + s[p] - 1) // k * 5 + (ans + s[p]))


(n, k) = map(int, input().split())
r = []
for i in range(n):
	r.append(input())
key = input()
r.sort(key=len)
mln = 0
mxm = 0
if len(r[0]) == len(key):
	mln = 1
	q = 0
	for i in range(n):
		if len(r[i]) > len(key):
			q = i
			break
	if q == 0:
		q = n
	mxm = (q - 1) // k * 5 + q
else:
	t = 0
	t1 = 0
	f = False
	for i in range(n):
		if len(r[i]) == len(key) and (not f):
			t = i
			f = True
		if len(r[i]) > len(key):
			t1 = i
			break
	mln = t // k * 5 + (t + 1)
	if t1 != 0:
		mxm = (t1 - 1) // k * 5 + t1
	else:
		mxm = (n - 1) // k * 5 + n
print(mln, mxm)


(n, k) = (int(i) for i in input().split())
l = {}
for _ in range(n):
	i = input()
	if len(i) in l:
		l[len(i)].append(i)
	else:
		l[len(i)] = [i]
p = input()
tries = 0
for i in range(1, len(p)):
	if i in l:
		tries += len(l[i])
best = tries + 5 * (tries // k) + 1
worst = tries + len(l[len(p)])
worst += 5 * ((worst - 1) // k)
print(best, worst)


__author__ = 'Think'

def format(ans):
	return ans + 5 * (ans // k)
(n, k) = [int(i) for i in input().split()]
freq = {i: 0 for i in range(1, 105)}
for i in range(n):
	s = input()
	freq[len(s)] += 1
correct = len(input())
t = 0
for i in range(1, correct):
	t += freq[i]
print(format(t) + 1, format(t + freq[correct] - 1) + 1)


(n, k) = map(int, input().split())
a = sorted((len(input()) for i in range(n)))
p = len(input())
t = a.index(p)
(a, b) = (t, t + a.count(p))
print(1 + a + a // k * 5, b + (b - 1) // k * 5)


(n, k) = map(int, input().split())
in_p = {}
for i in range(n):
	a = len(input())
	if a in in_p.keys():
		in_p.update({a: in_p.get(a) + 1})
	else:
		in_p.update({a: 1})
pd = len(input())
h = 0
l = 0
for x in in_p.keys():
	if x < pd:
		h += in_p.get(x)
		l += in_p.get(x)
	if x == pd:
		h += in_p.get(x)
l += 5 * (l // k)
h += 5 * ((h - 1) // k)
print(l + 1, h)


inp = input().split(' ')
n = int(inp[0])
k = int(inp[1])
passwords = {}
for i in range(n):
	pas = str(input())
	try:
		passwords[len(pas)].append(pas)
	except:
		passwords[len(pas)] = [pas]
mainPas = str(input())
tmpArr = [k for k in passwords]
tmpArr.sort()
mainL = len(mainPas)
count = 0
for l in tmpArr:
	if l > mainL:
		break
	count = count + len(passwords[l])
minT = count - len(passwords[mainL]) + 1
minT = minT + (minT - 1) // k * 5
maxT = count + (count - 1) // k * 5
print(str(minT) + ' ' + str(maxT))


(n, k) = map(int, input().strip().split())
v = [0] * 101
for i in range(n):
	s = input()
	v[len(s)] += 1
corr = len(input())
i = 1
c = 0
while i < corr:
	c += v[i]
	i += 1
best = c + 1 + int(c / k) * 5
c += v[corr] - 1
worst = c + 1 + int(c / k) * 5
print(best, worst)


lengths = [0 for x in range(101)]
(n, k) = (int(x) for x in input().split())
for i in range(n):
	passwd = input()
	lengths[len(passwd)] += 1
p = input()
i = 0
shortersum = 0
while i < len(p):
	shortersum += lengths[i]
	i += 1
minattempts = shortersum + 1
maxattempts = shortersum + lengths[i]
mintime = minattempts + (minattempts - 1) // k * 5
maxtime = maxattempts + (maxattempts - 1) // k * 5
print(str(mintime) + ' ' + str(maxtime))


from collections import defaultdict
import sys, os, math
(n, k) = map(int, input().split())
cnt = [0] * 110
for i in range(n):
	s = input()
	cnt[len(s)] += 1
s = input()
t = sum(cnt[:len(s)])
print(t + t // k * 5 + 1, t + cnt[len(s)] + (t + cnt[len(s)] - 1) // k * 5)


import sys, math
(n, k) = list(map(int, input().split()))
z = [0] * n
for i in range(n):
	z[i] = len(input())
passw = len(input())
bef = 0
same = 0
for i in range(n):
	if z[i] == passw:
		same += 1
	elif z[i] < passw:
		bef += 1
print(bef + 1 + 5 * (bef // k), bef + same + 5 * ((bef + same - 1) // k))


(n, k) = [int(x) for x in input().split()]
passwords = []
maxTime = 1
minTime = 1
for i in range(n):
	passwords.append(str(input()))
truePassword = str(input())
for i in range(n):
	if len(passwords[i]) < len(truePassword):
		maxTime += 1
		minTime += 1
	elif len(passwords[i]) == len(truePassword) and passwords[i] != truePassword:
		maxTime += 1
res1 = int(minTime / k) * 5 + minTime
res2 = int(maxTime / k) * 5 + maxTime
if minTime % k == 0:
	res1 -= 5
if maxTime % k == 0:
	res2 -= 5
print(res1, res2)


(n, k) = map(int, input().split())
p = []
for _ in range(n):
	p.append(len(input()))
l = len(input())
p.sort()
smallLength = 0
for i in p:
	if i < l:
		smallLength += 1
	else:
		break
sameLength = p.count(l)
print(smallLength + smallLength // k * 5 + 1, smallLength + ((smallLength + sameLength - 1) // k * 5 + sameLength))


inputs = [int(n) for n in input().split()]
n = inputs[0]
k = inputs[1]
input_list = []
for i in range(n):
	input_list.append(str(input()))
correct = len(input())
input_list = list(set(sorted(input_list, key=len)))
len_list = []
for item in input_list:
	len_list.append(len(item))
tries = 0
equals = 0
best_time = 0
worst_time = 0
for item in len_list:
	if item == correct:
		equals += 1
	elif item > correct:
		break
	tries += 1
best_time = tries - equals + 1
best_time = int(best_time) + int((best_time - 1) / k) * 5
worst_time = tries + int((tries - 1) / k) * 5
print(int(best_time), int(worst_time))


import sys
(n, k) = map(int, sys.stdin.readline().split(' '))
count = [0] * 101
for i in range(n):
	count[len(sys.stdin.readline().strip())] += 1
password_length = len(sys.stdin.readline().strip())
before_length = 0
for i in range(password_length):
	before_length += count[i]
min_passwords = before_length + 1
max_passwords = before_length + count[password_length]
print(str(min_passwords + (min_passwords - 1) // k * 5) + ' ' + str(max_passwords + (max_passwords - 1) // k * 5))


a = input().split()
a = [int(x) for x in a]
names = list()
for i in range(a[0]):
	names.append(len(input()))
c = len(input())
names.sort()
diff = 0
point = 0
for i in range(a[0]):
	if c == names[i]:
		point = i
		while i < a[0] and names[i] == c:
			diff += 1
			i += 1
		break
diff -= 1
mintime = point + point // a[1] * 5 + 1
maxtime = point + diff + (point + diff) // a[1] * 5 + 1
print(mintime, end=' ')
print(maxtime)


import logging
import copy
import sys
import math
logging.basicConfig(stream=sys.stderr, level=logging.DEBUG)

def solve(k, lines, password):
	noShort = 0
	best = 0
	worst = 0
	found = False
	noSame = 0
	if len(lines) < 2:
		print('%d %d' % (len(lines), len(lines)))
		return
	for l in lines:
		if l == password:
			found = True
		if len(l) < len(password):
			noShort += 1
		elif len(l) == len(password):
			noSame += 1
	worst = (noShort + noSame - 1) // k * 5 + noShort + noSame
	if found == False:
		best = worst
	else:
		best = noShort // k * 5 + noShort + 1
	print('%d %d' % (best, worst))

def main():
	firstLine = input().split()
	firstLine = list(map(int, firstLine))
	lines = []
	k = firstLine[1]
	for i in range(firstLine[0]):
		lines.append(input())
	solve(k, lines, input())

def log(*message):
	logging.debug(message)
main()


(n, k) = map(int, input().split())
L = [input() for i in range(n)]
p = input()
(res, tr, MAX) = (0, 0, 0)
L.sort(key=lambda x: len(x))
for i in range(n):
	if len(L[i]) < len(p):
		res += 1
		tr += 1
		if tr == k:
			res += 5
			tr = 0
	elif len(L[i]) == len(p):
		MAX += 1
		tr += 1
		if tr == k:
			MAX += 5
			tr = 0
	else:
		break
if tr == 0:
	MAX -= 5
print(res + 1, res + MAX)


(n, k) = map(int, input().split())
l = []
for _ in range(n):
	l.append(input())
s = input()
ca = l.count(s)
cb = 0
cc = 0
l.sort()
for i in range(n):
	if len(l[i]) < len(s):
		cb += 1
	if len(l[i]) == len(s):
		cc += 1
low = cb + cb // k * 5 + 1
hi = cb + cc - ca + (cb + cc - ca) // k * 5 + 1
print(low, hi)


def cmp_to_key(mycmp):

	class K:

		def __init__(self, obj, *args):
			self.obj = obj

		def __lt__(self, other):
			return mycmp(self.obj, other.obj) < 0

		def __gt__(self, other):
			return mycmp(self.obj, other.obj) > 0

		def __eq__(self, other):
			return mycmp(self.obj, other.obj) == 0

		def __le__(self, other):
			return mycmp(self.obj, other.obj) <= 0

		def __ge__(self, other):
			return mycmp(self.obj, other.obj) >= 0

		def __ne__(self, other):
			return mycmp(self.obj, other.obj) != 0
	return K

def mycmp(a, b):
	if len(a) > len(b):
		return 1
	elif len(a) < len(b):
		return -1
	else:
		return a < b
[n, k] = list(map(int, input().split()))
words = []
for i in range(n):
	words.append(input())
words.sort(key=cmp_to_key(mycmp))
pw = input()
t = 0
tmin = int(1000000000.0 + 7)
tmax = 0
cnt = 0
for i in range(n):
	cnt += 1
	if len(words[i]) < len(pw):
		t += 1
	elif len(words[i]) == len(pw):
		t += 1
		tmin = min(tmin, t)
		tmax = max(tmax, t)
	if cnt == k:
		t += 5
		cnt = 0
print(tmin, tmax)


def getin():
	xin = input()
	while xin.strip() == '':
		xin = input()
	return xin

def gi():
	return [int(x) for x in getin().split()]

def count(n, k):
	return int(n / k) * k + int((n - 1) / k) * 5 + n % k
(n, k) = gi()
m = -1
c = [0] * 109
p = []
for i in range(n):
	s = input()
	c[len(s)] += 1
	if len(s) > m:
		m = len(s)
	p.append(s)
ac = input()
if ac not in p:
	print(count(n, k), count(n, k))
else:
	i = 1
	mi = 0
	while i < len(ac):
		mi += c[i]
		i += 1
	print(count(mi + 1, k), count(mi + c[len(ac)], k))


(n, k) = input().split()
n = int(n)
k = int(k)
l = []
for i in range(n + 1):
	s = input()
	l.append(s)
a = len(l[-1])
t = 0
for i in range(len(l)):
	if len(l[i]) < a:
		t += 1
t = t + t // k * 5
print(t + 1, end=' ')
t = 0
for i in range(len(l)):
	if len(l[i]) <= a and l[i] != l[-1]:
		t += 1
t = t + t // k * 5
print(t + 1)


mod = 1000000007
ii = lambda : int(input())
si = lambda : input()
dgl = lambda : list(map(int, input()))
f = lambda : map(int, input().split())
il = lambda : list(map(int, input().split()))
ls = lambda : list(input())
(n, k) = f()
l = [si() for _ in range(n)]
psd = si()
lp = len(psd)
mxt = 0
mnt = 0
for i in l:
	if len(i) < lp:
		mnt += 1
	if len(i) <= lp:
		mxt += 1
print(mnt // k * 5 + 1 + mnt, (mxt - 1) // k * 5 + mxt)


import sys, re
from itertools import product
from collections import Counter
ls = [l.rstrip() for l in sys.stdin.readlines()]
(n, k) = map(int, ls[0].split(' '))
pss = ls[1:1 + n]
corr = ls[1 + n]
a = list(map(lambda x: len(x), pss))
m = len(corr)
r1 = 0
for i in range(1, m):
	r1 += a.count(i)
r2 = r1 + a.count(m) - 1
print(r1 // k * 5 + r1 + 1, r2 // k * 5 + r2 + 1)


(n, k) = [int(i) for i in input().split()]
len_list = []
len_dict = {}
for i in range(n):
	key = input()
	l = len(key)
	if l not in len_list:
		len_list.append(l)
	if l not in len_dict:
		len_dict[l] = [key]
	else:
		len_dict[l].append(key)
c_key = input()
c_l = len(c_key)
len_list.sort()
min_flag = 0
max_flag = 0
for i in len_list:
	if i < c_l:
		min_flag += len(len_dict[i])
		max_flag += len(len_dict[i])
	if i == c_l:
		min_flag += 1
		max_flag += len(len_dict[i])
(min_flag, max_flag) = (min_flag + (min_flag - 1) // k * 5, max_flag + (max_flag - 1) // k * 5)
print(min_flag, max_flag)


(n, k) = [int(x) for x in input().split(' ')]
password = []
for nn in range(n):
	x = input()
	password.append((len(x), x))
pwd = input()
password.sort()
password = [x[1] for x in password]
c = 0
bestc = 0
worsec = 0
pt = False
for p in password:
	c += 1
	if len(p) == len(pwd) and bestc == 0:
		bestc = c
		continue
	if len(p) > len(pwd):
		worsec = c - 1
		break
if worsec == 0:
	worsec = n
(best, worse) = (0, 0)
best = (bestc - 1) // k * 5 + bestc
worse = (worsec - 1) // k * 5 + worsec
print(best, worse)


(n, k) = list(map(int, input().strip().split(' ')))
test_secret = []
for i in range(n):
	test_secret.append(len(input().strip()))
ans = len(input())
test_secret.sort()
min_times = 0
max_times = 0
flag_min = False
flag_max = False
for i in range(n):
	if test_secret[i] == ans:
		if not flag_min:
			min_times = i + 1
			flag_min = True
	if test_secret[i] > ans:
		if not flag_max:
			max_times = i
			flag_max = True
	if flag_max and flag_min:
		break
min_res = min_times + (min_times - 1) // k * 5
if not flag_max:
	max_times = len(test_secret)
max_res = max_times + (max_times - 1) // k * 5
print(min_res, max_res)


ss = input()
(n, k) = (int(ss.split()[0]), int(ss.split()[1]))
password = [''] * n
for i in range(n):
	password[i] = input()
s = input()
from collections import defaultdict
d = defaultdict(int)
for i in range(n):
	d[len(password[i])] += 1
pred = 0
for i in range(1, len(s)):
	pred += d[i]
mind = pred + pred // k * 5 + 1
pred += d[len(s)]
if pred % k == 0:
	maxd = pred + (pred // k - 1) * 5
else:
	maxd = pred + pred // k * 5
print(mind, maxd)


(n, m) = [int(i) for i in input().split()]
lst = []
for i in range(n):
	lst.append(len(input()))
k = len(input())
bef = 0
befs = -1
for i in range(n):
	if lst[i] < k:
		bef += 1
	if lst[i] <= k:
		befs += 1
tr = 5 * (bef // m)
rem = 5 * (befs // m)
ans1 = 1 + bef + tr
ans2 = 1 + befs + rem
print(ans1, ans2)


(n, k) = map(int, input().split())
list_pass = []
for i in range(0, n):
	list_pass.append(input())
true_pass = input()
total_minTime = total_maxTime = 0
numSameLen = 0
numSmallLen = 0
for i in range(0, n):
	if len(list_pass[i]) < len(true_pass):
		numSmallLen += 1
	elif len(list_pass[i]) == len(true_pass):
		numSameLen += 1
total_minTime = numSmallLen // k * 5 + 1 + numSmallLen
numSameLen += numSmallLen
total_maxTime = (numSameLen - 1) // k * 5 + numSameLen
print(total_minTime, total_maxTime)


(n, t) = map(int, input().split())
l = []
for i in range(n):
	j = str(input())
	l.append(j)
f = str(input())
le = sorted(l, key=len)
y = 0
g = 0
for i in le:
	if len(i) < len(f):
		y = y + 1
	if len(i) <= len(f):
		g = g + 1
print(y + y // t * 5 + 1)
print(g + (g - 1) // t * 5)


(n, k) = map(int, input().split())
a = []
for i in range(n + 1):
	a.append(len(input()))
l = a[n]
a = a[:n]
a = sorted(a)
r = 0
t = 0
for i in range(n):
	if a[i] <= l:
		t += 1
	if a[i] < l:
		r += 1
d1 = r + r // k * 5 + 1
d2 = t + (t - 1) // k * 5
print(d1, d2, sep=' ')


from collections import defaultdict
(n, k) = list(map(int, input().split(' ')))
lengths_dict = defaultdict(lambda : 0)
for _ in range(n):
	next_pas_len = len(input())
	lengths_dict[next_pas_len] += 1
password_len = len(input())
(min_tries, max_tries) = (0, 0)
lengths = []
for (key, value) in lengths_dict.items():
	lengths.append([key, value])
lengths = sorted(lengths, key=lambda elem: elem[0])
seconds_count = 0
for x in lengths:
	if x[0] == password_len:
		min_tries += 1
		max_tries += x[1]
		break
	else:
		min_tries += x[1]
		max_tries += x[1]
min_seconds = min_tries // k * 5 + min_tries - (min_tries % k == 0 and 5 or 0)
max_seconds = max_tries // k * 5 + max_tries - (max_tries % k == 0 and 5 or 0)
print(min_seconds, max_seconds)


(n, k) = list(map(int, input().split()))
line = []
for i in range(200):
	line += [0]
for i in range(n):
	password = input()
	line[len(password)] += 1
password = input()
length = len(password)
min_time = 0
max_time = 0
ostatok = k
for i in range(len(line)):
	if i != length:
		for j in range(line[i]):
			min_time += 1
			max_time += 1
			ostatok -= 1
			if ostatok == 0:
				ostatok = k
				min_time += 5
				max_time += 5
	else:
		min_time += 1
		for j in range(line[i] - 1):
			max_time += 1
			ostatok -= 1
			if ostatok == 0:
				ostatok = k
				max_time += 5
		max_time += 1
		break
print(min_time, max_time)


(n, k) = map(int, input().split())
l = [0] * 100
for i in range(n):
	l[len(input()) - 1] += 1
p = len(input())
(min, max, i) = (0, 0, 0)
while i + 1 != p:
	min += l[i]
	max += l[i]
	i += 1
max += l[p - 1] - 1
min += 5 * (min // k)
max += 5 * (max // k)
min += 1
max += 1
print(min, max)


(n, k) = map(int, input().split())
lens = sorted([len(input()) for i in range(n)])
password = len(input())
k1 = lens.index(password)
time_best = k1 + 1
time_best += k1 // k * 5
k1 = n - lens[::-1].index(password) - 1
time_worst = k1 + 1
time_worst += k1 // k * 5
print(time_best, time_worst)


(n, k) = list(map(int, input().split()))
a = [0 for i in range(101)]
for i in range(n):
	a[len(input().rstrip())] += 1
passw = input()
mn = sum(a[:len(passw)])
mx = mn + a[len(passw)] - 1
print(mn // k * 5 + mn + 1, mx // k * 5 + mx + 1)


from collections import Counter

def f(x, k):
	return 5 * ((x - 1) // k) + x
(n, k) = [int(s) for s in input().split()]
ctr = Counter()
for i in range(n):
	ctr[len(input())] += 1
lc = len(input())
x = sum((ctr[l] for l in ctr if l < lc)) + 1
y = sum((ctr[l] for l in ctr if l <= lc))
print(f(x, k), f(y, k))


(n, k) = map(int, input().split())
worst = best = w = b = 0
l = []
a = [0] * 101
for i in range(n):
	s = input()
	l.append(s)
x = input()
for i in range(n):
	h = len(l[i])
	a[h] += 1
h = len(x)
for i in range(h + 1):
	w += a[i]
for i in range(h):
	b += a[i]
worst = w + (w - 1) // k * 5
best = b + b // k * 5
print(best + 1, worst, sep=' ')


def f(l, k, p):
	n = len(l)
	ll = [len(s) for s in l]
	ll.sort()
	cl = len(p)
	fi = ll.index(cl)
	li = fi
	while li < n and ll[li] == cl:
		li += 1
	li = li - 1
	return [1 + i + 5 * (i // k) for i in [fi, li]]
(n, k) = list(map(int, input().split()))
l = [input() for _ in range(n)]
p = input()
print(*f(l, k, p))


(less, equal) = (0, 0)
(n, k) = map(int, input().strip().split())
arr = []
for i in range(n):
	arr.append(input().strip())
actual = input().strip()
l = len(actual)
for i in arr:
	if len(i) < l:
		less += 1
	elif len(i) == l:
		equal += 1
best = less + less // k * 5 + 1
extra = less + equal - 1
worst = extra + extra // k * 5 + 1
print(best, worst)


d = input().split()
n = int(d[0])
k = int(d[1])
S = []
(q, w) = (0, 0)
for i in range(n):
	s = input()
	S.append(s)
pas = input()
for i in S:
	if len(i) < len(pas):
		q += 1
	elif len(i) == len(pas) and i != pas:
		w += 1
print(q + 1 + q // k * 5, q + w + 1 + (q + w) // k * 5)


import math
(n, k) = map(int, input().split())
l = []
p = []
for i in range(0, n):
	x = input()
	p.append(x)
	l.append(len(x))
password = input()
pass_len = len(password)
small = 0
equal = 0
for i in range(0, n):
	if l[i] < pass_len:
		small += 1
	elif l[i] == pass_len:
		equal += 1
equal += small
best = small + small // k * 5 + 1
worst = equal + (equal - 1) // k * 5
print('%d %d' % (best, worst))


import sys
import math
import itertools
import collections

def sieve(n):
	if n < 2:
		return list()
	prime = [True for _ in range(n + 1)]
	p = 3
	while p * p <= n:
		if prime[p]:
			for i in range(p * 2, n + 1, p):
				prime[i] = False
		p += 2
	r = [2]
	for p in range(3, n + 1, 2):
		if prime[p]:
			r.append(p)
	return r

def divs(n, start=1):
	r = []
	for i in range(start, int(math.sqrt(n) + 1)):
		if n % i == 0:
			if n / i == i:
				r.append(i)
			else:
				r.extend([i, n // i])
	return r

def prime(n):
	if n == 2:
		return True
	if n % 2 == 0 or n <= 1:
		return False
	sqr = int(math.sqrt(n)) + 1
	for d in range(3, sqr, 2):
		if n % d == 0:
			return False
	return True

def convn(number, base):
	newnumber = 0
	while number > 0:
		newnumber += number % base
		number //= base
	return newnumber

def cdiv(n, k):
	return n // k + (n % k != 0)

def ii():
	return int(input())

def mi():
	return map(int, input().split())

def li():
	return list(map(int, input().split()))

def lcm(a, b):
	return abs(a * b) // math.gcd(a, b)

def wr(arr):
	return '\n'.join(map(str, arr))

def revn(n):
	return str(n)[::-1]

def dd():
	return collections.defaultdict(int)

def ddl():
	return collections.defaultdict(list)
(n, k) = mi()
lenp = [0] * 101
for i in range(n):
	lenp[len(input())] += 1
rlen = len(input())
wrong = sum(lenp[:rlen]) + sum(lenp[:rlen]) // k * 5
lans = wrong + 1
rans = wrong + lenp[rlen] + (sum(lenp[:rlen]) % k + lenp[rlen] - 1) // k * 5
print(lans, rans)


__author__ = 'goran'
spl = [int(i) for i in input().split()]
N = spl[0]
K = spl[1]
passwords_with_length = dict()
for i in range(N):
	password_len = len(input())
	passwords_with_length[password_len] = passwords_with_length.get(password_len, 0) + 1
password_length = len(input())
(shorter, longer) = (0, 0)
for (k, v) in passwords_with_length.items():
	if k < password_length:
		shorter += v
	elif k > password_length:
		longer += v
equal = N - shorter - longer
best = shorter + shorter // K * 5 + 1
shorter_or_equal = shorter + equal
worst = shorter_or_equal + (shorter_or_equal - 1) // K * 5
print(best, worst)


(n, k) = map(int, input().split())
passwords = []
lesser = 0
same = 0
worst = 0
time = 0
for i in range(n):
	passwords.append(input())
correct = input()
for password in passwords:
	if len(password) < len(correct):
		lesser += 1
	elif len(password) == len(correct):
		same += 1
time = lesser // k * 5 + lesser
timer = k - lesser % k
if same > timer:
	worst += timer + 5
	same -= timer
worst += (same - 1) // k * 5 + same
if worst < 1:
	worst = 1
print(time + 1, time + worst)


arr = []
res = 0
bres = 0
sl = [0] * 101
(n, m) = map(int, input().split())
for i in range(n):
	s = input()
	arr.append(s)
	sl[len(s)] += 1
example = input()
for i in range(len(example)):
	res += sl[i]
bres = res + sl[len(example)] - 1
res += res // m * 5 + 1
bres += bres // m * 5 + 1
print(res, end=' ')
print(bres)


(n, k) = map(int, input().split())
ll = []
for i in range(n):
	ll.append(len(input()))
ll.sort()
l = len(input())
ft = ll.index(l) + 1
lt = n - ll[::-1].index(l)
print(ft + (ft - 1) // k * 5, lt + (lt - 1) // k * 5)


ip = input().split(' ')
n = int(ip[0])
k = int(ip[1])
passwords = []
for x in range(n):
	passwords.append(input())
vanya = input()
length = len(vanya)
lengths = []
for y in passwords:
	lengths.append(len(y))
above = 0
below = 0
equal = 0
for x in range(len(lengths)):
	if lengths[x] < length:
		above += 1
	elif lengths[x] > length:
		below += 1
	elif lengths[x] == length:
		equal += 1
failuretime = int(above / k) * 5
bestcase = above + failuretime + 1
worstcase = int((above + equal - 1) / k) * 5 + (above + equal)
print(bestcase, worstcase)


(n, k) = [int(a) for a in input().split()]
p = []
for i in range(n):
	p.append(input())
real = input()
l = len(real)
(cmin, cmax) = (0, 0)
for s in p:
	if len(s) <= l:
		cmax = cmax + 1
		if len(s) < l:
			cmin = cmin + 1

def calc(c):
	if c == 0:
		return 0
	return c + 5 * (c // k)
print(calc(cmin) + 1, calc(cmax - 1) + 1)


import sys
import math
import bisect

def query_value(A, m):
	ans = 0
	cnt = 0
	for a in A:
		if cnt and cnt % m == 0:
			ans += 5
		ans += 1
		if a == 0:
			cnt += 1
		elif a == 1:
			return ans
	return ans

def query_maximum_value(d, s, m):
	A = []
	for key in sorted(d.keys()):
		B = []
		for t in d[key]:
			if t == s:
				B.append(1)
			else:
				B.append(0)
		B.sort()
		A.extend(B)
	return query_value(A, m)

def query_minimum_value(d, s, m):
	A = []
	for key in sorted(d.keys()):
		B = []
		for t in d[key]:
			if t == s:
				B.append(1)
			else:
				B.append(0)
		B.sort(reverse=True)
		A.extend(B)
	return query_value(A, m)

def main():
	(n, m) = map(int, input().split())
	d = dict()
	for i in range(n):
		s = input()
		if len(s) not in d:
			d[len(s)] = []
		d[len(s)].append(s)
	s = input()
	min_val = query_minimum_value(d, s, m)
	max_val = query_maximum_value(d, s, m)
	print('%d %d' % (min_val, max_val))
main()


import sys
from collections import Counter
from math import factorial
input = sys.stdin
output = sys.stdout

def read_int():
	return [int(x) for x in input.readline().rstrip().split()]
(n, k) = read_int()
words = []
for _ in range(n):
	words.append(input.readline().rstrip())
password = input.readline().rstrip()
(less, eq) = (0, 0)
for word in words:
	if len(word) < len(password):
		less += 1
	elif len(word) == len(password):
		eq += 1
min_answer = less + 1 + less // k * 5
max_answer = less + eq + (less + eq - 1) // k * 5
output.write('%d %d\n' % (min_answer, max_answer))


ll = lambda : map(int, input().split())
t = lambda : int(input())
ss = lambda : input()
lx = lambda x: map(int, input().split(x))
yy = lambda : print('Yes')
nn = lambda : print('No')
from math import log10, log2, ceil, factorial as fac, gcd, inf, sqrt, log
from bisect import bisect_right as br, bisect_left as bl
from collections import Counter
mod = 10 ** 9 + 7

def f():
	(n, k) = ll()
	d = {}
	q = []
	for i in range(n):
		s = ss()
		if len(s) not in d:
			d[len(s)] = 0
		d[len(s)] += 1
		q.append(s)
	p = ss()
	(x, y) = (0, 0)
	for i in sorted(d.keys()):
		if i > len(p):
			break
		if i != len(p):
			x += d[i]
		y += d[i]
	x += 1
	x = x + ((x - 1) // k * 5 if x > k else 0)
	y = y - q.count(p) + 1
	y = y + ((y - 1) // k * 5 if y > k else 0)
	print(x, y)
f()


(n, k) = map(int, input().split())
cnt = [0] * 101
for i in range(n):
	cnt[len(input())] += 1
x = len(input())
a = sum(cnt[:x])
b = sum(cnt[:x + 1]) - 1
r1 = a // k * 5 + a + 1
r2 = b // k * 5 + b + 1
print(r1, r2)


import sys
(n, k) = map(int, sys.stdin.readline().split())
psw = []
psw_l = [0] * 101
for i in range(n):
	psw.append(sys.stdin.readline().split()[0])
	psw_l[len(psw[i])] += 1
c_psw = sys.stdin.readline().split()[0]
l_c_psw = len(c_psw)
time = 0
for i in range(l_c_psw):
	time += psw_l[i]
min_r = time + time // k * 5 + 1
time += psw_l[l_c_psw] - 1
max_r = time + time // k * 5 + 1
print(str(min_r) + ' ' + str(max_r))


s = input().split()
n = int(s[0])
k = int(s[1])
a = []
for i in range(n):
	a.append(input())
password = input()
length = len(password)
count_1 = 0
count_2 = 0
a.sort()
for i in a:
	length_1 = len(i)
	if length_1 < length:
		count_1 += 1
	elif length_1 == length:
		count_2 += 1
if count_1 == 0:
	minimum = 1
	temp = count_2 // k
	if count_2 % k != 0:
		maximum = 5 * temp + count_2
	else:
		maximum = 5 * (temp - 1) + count_2
else:
	temp = (count_1 + 1) // k
	if (count_1 + 1) % k != 0:
		minimum = 5 * temp + (count_1 + 1)
	else:
		minimum = 5 * (temp - 1) + (count_1 + 1)
	temp = (count_1 + count_2) // k
	if (count_1 + count_2) % k != 0:
		maximum = 5 * temp + (count_1 + count_2)
	else:
		maximum = 5 * (temp - 1) + (count_1 + count_2)
print(str(minimum) + ' ' + str(maximum))


(n, k) = [int(i) for i in input().split()]
passwords = list()
for i in range(n):
	word = input()
	passwords.append(word)
result = input()
(lower, upper) = (0, 0)
for i in range(n):
	lower += len(passwords[i]) < len(result)
	upper += len(passwords[i]) <= len(result)
print(lower + lower // k * 5 + 1, upper + (upper - 1) // k * 5)


from collections import Counter
(n, k) = map(int, input().split())
words = list()
for i in range(n):
	words.append(input())
real = input()
words = [len(i) for i in words if len(i) <= len(real)]
c = Counter(words)
sorted_c = sorted(c)
real_value = c[len(real)]
all_but_real = 0
for i in range(len(sorted_c) - 1):
	all_but_real += c[sorted_c[i]]
tmin = 1 + all_but_real + all_but_real // k * 5
if (real_value + all_but_real) % 2 != 0:
	tmax = real_value + all_but_real + (real_value + all_but_real) // k * 5
else:
	tmax = real_value + all_but_real + (real_value + all_but_real - 1) // k * 5
if k == 1:
	if (real_value + all_but_real) % 2 != 0:
		tmax = real_value + all_but_real + (real_value + all_but_real - 1) // k * 5
	else:
		tmax = real_value + all_but_real + (real_value + all_but_real - 1) // k * 5
print(tmin, tmax)


(n, k) = map(int, input().split())
a = []
for i in range(n):
	a.append(input())
key = input()
a.sort(key=lambda x: len(x))
i = 0
c = 0
while len(a[i]) < len(key):
	c += 1
	i += 1
t1 = c + c // k * 5 + 1
d = 0
while i < len(a) and len(a[i]) == len(key):
	if a[i] == key:
		d += 1
	c += 1
	i += 1
t2 = c - d + (c - d) // k * 5 + 1
print(t1, t2)


(n, k) = map(int, input().split())
l = []
for _ in range(n + 1):
	l.append(input())
pwd = l[-1]
l.pop()
sl = sorted(l)
tot = 0
smaller_than_pwd = []
for e in sl:
	if len(e) < len(pwd):
		smaller_than_pwd.append(e)
		tot += 1
	if len(e) == len(pwd):
		tot += 1
best = len(smaller_than_pwd) + len(smaller_than_pwd) // k * 5 + 1
worst = (tot - 1) // k * 5 + tot
print(best, end=' ')
print(worst)


(n, k) = list(map(int, input().split()))
pwd = []
for _ in range(n):
	pwd.append(input())
pwd = list(set(pwd))
corr = input()
mn = len([p for p in pwd if len(p) < len(corr)])
mx = len([p for p in pwd if len(p) <= len(corr)])
print(1 + mn + mn // k * 5, mx + (mx - 1) // k * 5)


(n, k) = map(int, input().split())
S = [str(input()) for _ in range(n)]
p = str(input())
L = [len(S[i]) for i in range(n)]
lp = len(p)
L.sort()
ok = 0
for i in range(n):
	if L[i] == lp and ok == 0:
		ok = 1
		print(i + 1 + i // k * 5, end=' ')
	if L[i] > lp:
		print(i + (i - 1) // k * 5)
		ok = 2
		break
if ok == 1:
	print(n + (n - 1) // k * 5)


(n, k) = map(int, input().split())
a = []
for i in range(n):
	tmp = input()
	a.append((len(tmp), tmp))
a.sort()
ans = input()
ansmin = 10 ** 18
ansmax = 0
nowt = 0
for i in range(n):
	if i % k == 0 and i != 0:
		nowt += 5
	nowt += 1
	if len(ans) == len(a[i][1]):
		ansmax = nowt
		ansmin = min(ansmin, nowt)
print(ansmin, ansmax)


v = [0] * 101
(n, k) = map(int, input().split())
for i in range(n):
	z = str(input())
	v[len(z)] += 1
z = str(input())
a = len(z)
ans = 0
for i in range(101):
	if a == i:
		print(ans + ans // k * 5 + 1, end=' ')
		ans += v[i] - 1
		print(ans + ans // k * 5 + 1)
		exit()
	else:
		ans += v[i]


(n, m) = map(int, input().split())
l = sorted([len(input()) for i in range(n)])
p = len(input())
k = l.index(p)
b = k + 1
b += k // m * 5
wk = n - l[::-1].index(p) - 1
w = wk + 1
w += wk // m * 5
print(b, w)


from collections import defaultdict
(n, k) = [int(i) for i in input().split()]
password_dict = defaultdict(int)
for i in range(n):
	password_dict[len(input())] += 1
answer_len = len(input())
base_len = sum([password_dict[j] for j in password_dict if j < answer_len])
add_len = sum([password_dict[j] for j in password_dict if j == answer_len])
print(5 * (base_len // k) + base_len + 1, end=' ')
print(5 * ((base_len + add_len - 1) // k) + base_len + add_len)


import math
(n, k) = map(int, input().split(' '))
arr = []
l = n
while n + 1 != 0:
	n -= 1
	s = input()
	arr.append(s)
pas = arr[-1]
paslen = len(arr[-1])
cntl = 0
cntle = 0
for i in range(l):
	if len(arr[i]) < paslen:
		cntl += 1
	if len(arr[i]) <= paslen:
		cntle += 1
cntl = cntl + math.floor(cntl / k) * 5 + 1
cntle = cntle + math.floor((cntle - 1) / k) * 5
print(cntl, cntle)


from functools import reduce
(n, k) = list(map(int, input().split()))
passwords = []
for _ in range(n + 1):
	passwords.append(input())
correctPassword = passwords[n]
passwords = passwords[:-1]
passwords.sort()
sortedByLength = {}
for password in passwords:
	if len(password) not in sortedByLength.keys():
		sortedByLength.update({len(password): 1})
	else:
		sortedByLength[len(password)] += 1
minTries = 1
keys = list(sortedByLength.keys())
keys.sort()
for i in keys:
	if i < len(correctPassword):
		minTries += sortedByLength[i]
maxTries = minTries + sortedByLength[len(correctPassword)] - 1
minTime = minTries + int((minTries - 1) / k) * 5
maxTime = maxTries + int((maxTries - 1) / k) * 5
print(minTime, maxTime)


le = [0] * 106
(n, k) = (int(z) for z in input().split())
for i in range(n):
	le[len(input())] += 1
real = len(input())
failed = sum(le[:real + 1]) - 1
best = sum(le[:real]) + sum(le[:real]) // k * 5 + 1
failed += failed // k * 5
failed += 1
print(best, failed)


from collections import Counter
(n, k) = list(map(int, input().split()))
passwords = []
for i in range(n):
	passwords.append(input())
required = input()
passwords = sorted(passwords, key=len)
count = Counter(map(len, passwords))
mini = len(list(filter(lambda x: len(x) < len(required), passwords)))
best = mini + mini // k * 5 + 1
maxi = mini + count[len(required)]
worst = maxi + (maxi - 1) // k * 5
print(best, worst)


(n, k) = map(int, input().split())
a = []
for i in range(n):
	a.append(len(input()))
a.sort()
p = input()
l = len(p)
i = 0
la = len(a)
ans = 0
ans1 = 1
while i <= la - 1 and a[i] <= l:
	if l > a[i]:
		ans1 += 1
	ans += 1
	i += 1
if ans1 % k != 0:
	print(ans1 + ans1 // k * 5, end=' ')
else:
	print(ans1 + (ans1 // k - 1) * 5, end=' ')
if ans % k != 0:
	print(ans + ans // k * 5)
else:
	print(ans + (ans // k - 1) * 5)


(n, k) = input().split()
(n, k) = (int(n), int(k))
all_passwords = list()
for _ in range(n):
	all_passwords.append(input())
correct_password = input()
same_len_passwords = set()
total = 0
for s in all_passwords:
	if len(s) < len(correct_password):
		total += 1
	elif len(s) == len(correct_password):
		same_len_passwords.add(s)
worst = total + len(same_len_passwords)
print(str(total + total // k * 5 + 1), str(worst + max(worst - 1, 0) // k * 5))


[num_passwords, num_tries] = [int(item) for item in input().split()]
passwords = []
for _ in range(num_passwords):
	passwords.append(len(input()))
password_len = len(input())
passwords.sort()
min = 0
max = len(passwords)
count = 0
time = 0
for i in range(len(passwords)):
	time += 1
	if passwords[i] == password_len:
		if min == 0:
			min = time
		if i < len(passwords) - 1:
			if passwords[i + 1] != password_len:
				max = time
				break
		else:
			max = time
	count += 1
	if count == num_tries:
		time += 5
		count = 0
print(min, max)


(n, k) = map(int, input().split())
passwords = [input() for i in range(n)]
true_password = input()
(time_less, time_equal) = (0, 0)
delay = k
passwords.sort(key=lambda x: len(x))
for element in passwords:
	if len(element) < len(true_password):
		time_less += 1
		k -= 1
		if k == 0:
			time_less += 5
			k = delay
	elif len(element) == len(true_password):
		if k == 0:
			time_equal += 5
			k = delay
		time_equal += 1
		k -= 1
	else:
		break
print(time_less + 1, time_less + time_equal)


(n, k) = map(int, input().split())
tab = []
for i in range(n):
	tab.append(input())
haslo = input()
mniejsze_rowne_haslo = 0
krotsze_niz_haslo = 0
for i in tab:
	if len(i) < len(haslo):
		krotsze_niz_haslo += 1
	if len(i) <= len(haslo):
		mniejsze_rowne_haslo += 1
print(krotsze_niz_haslo + krotsze_niz_haslo // k * 5 + 1, mniejsze_rowne_haslo + (mniejsze_rowne_haslo - 1) // k * 5)


(n, m) = list(map(int, input().split()))
l1 = h1 = 0
a = []
for i in range(n):
	a.append(input())
k = input()
l = 1
h = 1
for i in range(n):
	if len(a[i]) < len(k):
		l1 += 1
	elif len(a[i]) == len(k):
		h1 += 1
h1 += l1 - 1
l1 += l1 // m * 5
h1 += h1 // m * 5
print(l + l1, h + h1)


(n, m) = map(int, input().strip().split())
possible_list = []
for i in range(n):
	possible_list.append(input().strip())
answer = input().strip()
answer_len = len(answer)
possible_list = filter(lambda _: len(_) <= answer_len, possible_list)
possible_list_sorted = sorted(possible_list, key=lambda _: len(_))
possible_list_real_len = list(filter(lambda _: len(_) == answer_len, possible_list_sorted))
possible_list_real_len_first = possible_list_real_len[0]
min_result = possible_list_sorted.index(possible_list_real_len_first) + 1
max_result = min_result + len(possible_list_real_len) - 1
if min_result >= m:
	punish_min = (min_result - 1) // m * 5
	min_result = min_result + punish_min
if max_result >= m:
	punish = (max_result - 1) // m * 5
	max_result = max_result + punish
print(min_result, max_result)


(n, k) = map(int, input().split(' '))

def srt_len(s):
	return len(s)
a = []
for i in range(n):
	a.append(len(input()))
ps = len(input())
a.append(-1)
a.append(101)
a.sort()
f_i = 0
s_i = 0
for i in range(n + 2):
	if a[i] == ps:
		if a[i - 1] < ps:
			f_i = i
		if a[i + 1] > ps:
			s_i = i
			break
print((f_i - 1) // k * 5 + f_i, (s_i - 1) // k * 5 + s_i)


(n, k) = map(int, input().split())
pw = []
for _ in range(n):
	pw.append(input())
s = input()
pw = sorted(pw, key=len)
ans1 = 1
ans2 = 0
for i in pw:
	if len(s) < len(i):
		break
	if len(s) == len(i):
		ans2 += 1
	if len(s) > len(i):
		ans1 += 1
ans2 += ans1 + (ans1 + ans2 - 2) // k * 5 - 1
ans1 += (ans1 - 1) // k * 5
print(ans1, ans2)


(n, k) = map(int, input().split())
table = [len(input()) for _ in range(n)]
x = len(input())
a = len(list(filter(lambda s: s < x, table)))
b = len(list(filter(lambda s: s <= x, table)))
print(a // k * 5 + a + 1, (b - 1) // k * 5 + b)


(n, k) = map(int, input().split())
a = []
for i in range(n):
	a.append(len(input()))
p = len(input())
a.sort()
flag = True
for i in range(n):
	if flag:
		if a[i] == p:
			mini = i + 1
			flag = False
	elif a[i] != p:
		maxi = i
		break
else:
	maxi = i + 1
print(int((mini - 1) / k) * 5 + mini, int((maxi - 1) / k) * 5 + maxi)


(n, k) = [int(x) for x in input().split()]
passwords = []
for i in range(0, n):
	passwords.append(len(input()))
correct = len(input())
passwords = sorted(passwords)
t = 0
i = 0
(opt, pes) = (-1, -1)
for i in range(0, len(passwords)):
	t += 1
	if passwords[i] == correct:
		pes = t
		if opt == -1:
			opt = t
	if (i + 1) % k == 0:
		t += 5
print(opt, pes)


(n, k) = map(int, input().split())
passw = []
for i in range(n):
	passw.append(len(input()))
correct_passw = len(input())
passw = sorted(passw)
count = 0
best_case = 0
for i in range(n):
	if passw[i] < correct_passw:
		count += 1
		best_case += 1
	else:
		break
	if count % k == 0:
		count = 0
		best_case += 5
count_2 = 0
worst_case = 0
for i in range(n):
	if passw[i] <= correct_passw:
		count_2 += 1
		worst_case += 1
	else:
		break
	if count_2 % k == 0 and (i + 1 < n and passw[i + 1] <= correct_passw):
		count_2 = 0
		worst_case += 5
print(best_case + 1, worst_case)


(n, k) = map(int, input().split())
a = [input() for i in range(n)]
pwd = input()
a_len = [len(i) for i in a]
a_min = sum([i < len(pwd) for i in a_len])
a_min = a_min + a_min // k * 5 + 1
a_max = sum([i <= len(pwd) for i in a_len]) - 1
a_max = a_max + a_max // k * 5 + 1
print(a_min, a_max)


(n, m) = map(int, input().split())
M = [input() for i in range(n)]
S = input()
mi = 0
ma = 0
k = 0
p = len(S)
t = 0
r = 0
v = 0
for i in range(0, 100):
	for j in range(n):
		if len(M[j]) == i + 1:
			t = t + 1
	if p != i + 1:
		k = k + t
	else:
		if (k + t) % m == 0:
			ma = k + t + ((k + t) // m - 1) * 5
		else:
			ma = k + t + (k + t) // m * 5
		if (k + 1) % m == 0:
			mi = k + 1 + ((k + 1) // m - 1) * 5
		else:
			mi = k + 1 + (k + 1) // m * 5
		break
	t = 0
print(mi, ma)


(n, k) = map(int, input().split())
ln = [0 for _ in range(101)]
for i in range(n):
	ln[len(input())] += 1
pw = len(input())
res = 0
for i in range(1, pw):
	res += ln[i]
print(res + 1 + 5 * (res // k), res + ln[pw] + 5 * ((res + ln[pw] - 1) // k))


(n, k) = map(int, input().split())
cnt = [0] * 101
for x in range(n):
	cnt[len(input())] += 1
l = len(input())
attempts = 0
for i in range(l):
	attempts += cnt[i]
minAttempts = attempts + 1
maxAttempts = attempts + cnt[l]
print(5 * ((minAttempts - 1) // k) + minAttempts, 5 * ((maxAttempts - 1) // k) + maxAttempts)


(n, k) = map(int, input().split())
l = []
for i in range(n):
	l.append(input())
s = input()
x = 0
y = 0
for j in range(len(l)):
	if len(l[j]) < len(s):
		x += 1
	if len(l[j]) == len(s):
		y += 1
bc = x + x // k * 5
wc = x + y + (x + y - 1) // k * 5
print(bc + 1, wc)


I = lambda : map(int, input().split())
(n, k) = I()
a = []
for _ in range(n):
	a.append(input())
pw = input()
a.sort(key=len)
i = 0
count = 0
count_eq = 0
while i <= n - 1 and len(a[i]) <= len(pw):
	if len(a[i]) < len(pw):
		count += 1
	elif len(a[i]) == len(pw):
		count_eq += 1
	i += 1
time_max = (count + count_eq) // k
if (count + count_eq) % k == 0:
	time_max -= 1
print(count + 1 + count // k * 5, count + count_eq + time_max * 5)


import sys
count = 0
r_list = []
dic = {}
for line in sys.stdin:
	if count == 0:
		n = int(line.strip().split(' ')[0])
		k = int(line.strip().split(' ')[1])
		count += 1
		continue
	count += 1
	if count == n + 2:
		answer_len = len(line.strip())
		break
	tmp = line.strip()
	dic[len(tmp)] = dic.get(len(tmp), 0) + 1
sorted_dic = sorted(dic.items(), key=lambda x: x[1])
num = 0
for tmp in sorted_dic:
	if tmp[0] < answer_len:
		num += tmp[1]
min = num + 1
max = num + dic[answer_len]
min_t = (min - 1) // k * 5 + min
max_t = (max - 1) // k * 5 + max
print(str(min_t) + ' ' + str(max_t))


inp = list(map(int, input().split()))
passwords = {}
min = 101
max = 0
menores = 0
mismo = 0
for i in range(inp[0] + 1):
	passw = input()
	if i != inp[0]:
		if len(passw) not in passwords:
			passwords[len(passw)] = list()
			passwords[len(passw)].append(passw)
		else:
			passwords[len(passw)].append(passw)
		if len(passw) > max:
			max = len(passw)
		if len(passw) < min:
			min = len(passw)
	else:
		correct = len(passw)
		for i in passwords:
			if i < correct:
				menores += len(passwords[i])
			elif i == correct:
				mismo += len(passwords[i])
			else:
				pass
best = menores + int(menores / inp[1]) * 5 + 1
worst = menores + mismo + int((menores + mismo - 1) / inp[-1]) * 5
print(best, worst)


(n, k) = list(map(int, input().split()))
a = []
c = 0
for i in range(n + 1):
	b = input()
	c = b
	a.append(len(b))
a = a[:-1]
a = sorted(a)
s = len(c)
mal = a.index(s) + 1
a = list(reversed(a))
big = n - a.index(s)
q = mal
w = big
if n > k:
	if mal >= k:
		if k == 1:
			mal = (mal - 1) * 5 + mal
		else:
			mal = mal // k * 5 + mal
	if big >= k:
		if k == 1:
			big = (big - 1) * 5 + big
		else:
			big = big // k * 5 + big
	if q % k == 0 and k > 1:
		mal = mal - 5
	if w % k == 0 and k > 1:
		big = big - 5
if big < mal:
	big += 5
print(mal, big)


(a, b) = map(int, input().split())
x = []
for i in range(a):
	x.append(input())
ans = input()
lna = len(ans)
lolen = 0
eqlen = 0
for i in x:
	if len(i) < lna:
		lolen += 1
	elif len(i) == lna:
		eqlen += 1
eqlen -= 1
total = lolen + 5 * (lolen // b) + 1
print(total, end=' ')
total = lolen + eqlen + 5 * ((lolen + eqlen) // b) + 1
print(total)


s = input().split()
(n, k) = (int(s[0]), int(s[1]))
password = []
for i in range(n):
	password.append(input())
target = input()
(front, equal) = (0, 0)
for p in password:
	if len(p) < len(target):
		front += 1
front = front
min_ans = front + 5 * (front // k) + 1
for p in password:
	if len(p) == len(target):
		equal += 1
front += equal - 1
max_ans = front + 5 * (front // k) + 1
print(min_ans, max_ans)


holderList = [[] for i in range(104)]
accumulationFailed = 0
pairSetOne = 1
time = 0
userInput = input()
userInput = userInput.split(' ')
attempts = userInput[0]
attempts = int(userInput[0])
failedAttempts = userInput[1]
failedAttempts = int(userInput[1])
count = 0
while count != attempts:
	passwordInput = input()
	holderList[len(passwordInput)].append(passwordInput)
	count += 1
answer = input()
for i in range(105):
	if holderList[i]:
		if i != len(answer):
			time += len(holderList[i])
			pairSetOne += 1
		if i == len(answer):
			time += 1
			break
time_1 = time - 1
abc = time_1 + len(holderList[len(answer)])
timeFailed = time_1 + len(holderList[len(answer)]) + (abc - 1) // failedAttempts * 5
totalTimeCorrect = time + time_1 // failedAttempts * 5
print(totalTimeCorrect, timeFailed)


(n, k) = map(int, input().split(' '))
passwords = list()
for i in range(n):
	x = input()
	lx = len(x)
	passwords.append([lx, x])
correct_pass = input()
len_correct_pass = len(correct_pass)
passwords.sort(key=lambda x: x[0])
best = 0
worst = 0
trials = 0
for i in range(n):
	if passwords[i][0] == len_correct_pass:
		c = 0
		for j in range(i + 1, n):
			if passwords[j][0] == len_correct_pass:
				c += 1
		best = 1 + trials + 5 * (trials // k)
		worst = 1 + trials + c + 5 * ((trials + c) // k)
		print(best, worst)
		break
	else:
		trials += 1


from collections import Counter
(n, K) = map(int, input().split())
counts = Counter()
for _ in range(n):
	counts[len(input())] += 1
ans = input()
size = len(ans)
best = worst = 0
for k in sorted(counts.keys()):
	if k == size:
		best += 1
		worst += counts[k]
		break
	else:
		best += counts[k]
		worst += counts[k]
print(best + (best - 1) // K * 5, worst + (worst - 1) // K * 5)


I = input
(n, k) = map(int, I().split())
a = sorted((len(I()) for _ in '0' * n))
p = len(I())
t = a.index(p)
(a, b) = (t, t + a.count(p))
print(1 + a + a // k * 5, b + (b - 1) // k * 5)


(n, k) = input().split()
n = int(n)
k = int(k)
a = []
for i in range(n):
	a.append(input())
a.sort(key=len)
correct = input()
dd = dict()
for i in range(n):
	if not a[i] in dd:
		dd.update({f'{a[i]}': i})
if correct in dd:
	c = dd[f'{correct}']
	for i in range(n):
		if len(a[i]) == len(correct):
			if i != c:
				(a[c], a[i]) = (a[i], a[c])
			else:
				break
needed = 1
t = 0
for i in range(n):
	if a[i] != correct:
		needed += 1
		t += 1
		if t == k:
			t = 0
			needed += 5
	else:
		break
print(needed, end=' ')
needed = 1
t = 0
found = 0
for i in range(n):
	if a[i] != correct:
		needed += 1
		t += 1
		if t == k:
			t = 0
			needed += 5
	elif a[i] == correct:
		found = 1
	if found == 1 and i < n - 1:
		if len(a[i + 1]) > len(correct):
			break
print(needed, end='')


(n, k) = map(int, input().split())
l = [input() for _ in range(n)]
imp = input()
d = {}
for x in l:
	t = len(x)
	d[t] = d.get(t, 0) + 1
leimp = len(imp)
leimpc = d[leimp]
ans = 0
for x in d:
	if x < leimp:
		ans += d[x]
ansl = ans + leimpc
print(ans + 1 + ans // k * 5, ansl + (ansl - 1) // k * 5)


def length(n):
	return len(n)
(n, k) = [int(i) for i in input().split()]
arr = [input() for i in range(n)]
c = 1
ps = input()
minValue = 1
maxValue = 1
arr.sort(key=length)
for i in range(n):
	if len(arr[i]) == len(ps) and i < arr.index(ps):
		ind = arr.index(ps)
		arr[ind] = arr[i]
		arr[i] = ps
for x in arr:
	if x == ps:
		break
	elif c == k:
		minValue += 6
		c = 1
	else:
		minValue += 1
		c += 1
for i in range(n)[::-1]:
	if len(arr[i]) == len(ps) and i > arr.index(ps):
		ind = arr.index(ps)
		arr[ind] = arr[i]
		arr[i] = ps
c = 1
for x in arr:
	if x == ps:
		break
	if c < k:
		maxValue += 1
	else:
		maxValue += 6
		c = 0
	c += 1
print(minValue, maxValue)


(n, k) = map(int, input().split())
m = []
for i in range(n):
	g = list(input())
	m.append(g)
pas = list(input())
x = len(pas)
l = []
for i in range(n):
	l.append(len(m[i]))
l.sort()
f = 0
ans = []
for i in range(n):
	if l[i] == x and f == 0:
		ans.append(i + 1)
		f = 1
	elif f == 1 and l[i] > x:
		ans.append(i)
		f = 0
		break
if f == 1:
	ans.append(n)
a1 = ans[0] // k
a2 = ans[1] // k
if ans[0] % k == 0:
	a1 -= 1
if ans[1] % k == 0:
	a2 -= 1
print(ans[0] + a1 * 5, ans[1] + a2 * 5)


def main():
	ss = str(input()).split()
	(n, k) = (int(ss[0]), int(ss[1]))
	del ss
	qs = {}
	for i in range(n):
		l = len(str(input()))
		if l in qs:
			qs[l] += 1
		else:
			qs.update({l: 1})
	passL = len(str(input()))
	pNMQ = 0
	pMQ = 0
	for (i, j) in qs.items():
		if i == passL:
			pMQ = j
		elif i < passL:
			pNMQ += j
	minTime = pNMQ + 1 + pNMQ // k * 5
	maxTime = pNMQ + pMQ + (pNMQ + (pMQ - 1)) // k * 5
	print(minTime, maxTime)
main()


(n, k) = map(int, input().split())
cnt = [0] * 101
for _ in range(n):
	s = input()
	cnt[len(s)] += 1
password = input()
best_time = worst_time = 0
for i in range(len(password)):
	best_time += cnt[i]
worst_time = best_time + cnt[len(password)] - 1
best_time += best_time // k * 5
worst_time += worst_time // k * 5
print(best_time + 1, worst_time + 1, sep=' ')


(n, k) = [int(x) for x in input().split()]
lst = list()
for _ in range(n):
	lst.append(str(input()))
pas = str(input())
lst.sort(key=len)
tempk = 0
bestcnt = 0
worstcnt = 0
i = 0
while i < len(lst):
	if len(lst[i]) == len(pas) and tempk != k:
		bestcnt += 1
		break
	elif len(lst[i]) != len(pas) or (len(lst[i]) == len(pas) and tempk == k):
		if tempk < k:
			bestcnt += 1
			tempk += 1
		elif tempk == k:
			bestcnt += 5
			tempk = 0
			i -= 1
	i += 1
tempk = 0
tempass = list()
i = 0
while i < len(lst):
	if len(lst[i]) <= len(pas) and lst[i] != pas:
		tempass.append(lst[i])
	elif len(lst[i]) > len(pas):
		break
	i += 1
tempass.append(pas)
while i < len(lst):
	tempass.append(lst[i])
	i += 1
i = 0
while i < len(tempass):
	if tempass[i] == pas and tempk != k:
		worstcnt += 1
		break
	elif tempass[i] != pas or (tempass[i] == pas and tempk == k):
		if tempk < k:
			worstcnt += 1
			tempk += 1
		elif tempk == k:
			worstcnt += 5
			tempk = 0
			i -= 1
	i += 1
print('{} {}'.format(bestcnt, worstcnt))


(n, k) = map(int, input().split())
l = []
for i in range(n):
	l.append(input())
pa = input()
cnt1 = 0
cnt2 = 0
for i in l:
	if len(i) < len(pa):
		cnt1 += 1
	if len(i) <= len(pa):
		cnt2 += 1
print(cnt1 + cnt1 // k * 5 + 1, cnt2 + (cnt2 - 1) // k * 5)


read = lambda : tuple(map(int, input().split()))
(n, k) = read()
ps = [len(input()) for i in range(n)]
p = len(input())
kmn = len(list(filter(lambda v: v < p, ps)))
kmx = len(list(filter(lambda v: v <= p, ps))) - 1
ans = lambda v: v + v // k * 5
print(ans(kmn) + 1, ans(kmx) + 1)


(n, k) = list(map(int, input().split()))
s = [input() for i in range(n)]
pas = input()
a = sorted([len(i) for i in s])
f = lambda x: x + (x - 1) // k * 5
for i in range(n):
	if a[i] == len(pas):
		L = i + 1
		break
ans1 = f(L)
R = n
for i in range(n):
	if a[i] > len(pas):
		R = i
		break
ans2 = f(R)
print(ans1, ans2)


(n, k) = list(map(int, input().split()))
a = []
for i in range(n):
	a.append(input())
s = input()
kmn = 1
kmx = 0
for i in range(n):
	if len(a[i]) < len(s):
		kmn += 1
		kmx += 1
	elif len(a[i]) == len(s):
		kmx += 1
print((kmn - 1) // k * 5 + kmn, (kmx - 1) // k * 5 + kmx)


(N, K) = list(map(int, input().split()))
pwds = [input() for _ in range(N)]
correct = input()
pwds = sorted([pwd for pwd in pwds if len(pwd) <= len(correct)], key=len)
time = 0
count = 0
i = 0
while len(pwds[i]) < len(correct):
	time += 1
	count += 1
	if count == K:
		time += 5
		count = 0
	i += 1
best = time + 1
while i < len(pwds) - 1:
	time += 1
	count += 1
	if count == K:
		time += 5
		count = 0
	i += 1
worst = time + 1
print(str(best) + ' ' + str(worst))


(n, k) = map(int, input().split())
a = []
for i in range(n):
	a.append(input())
s = input()
ans = 0
b = []
for i in range(n):
	t = 1
	if a[i] == s:
		t = 0
	b.append([len(a[i]), t])
b = sorted(b)
cnt = 0
x = 0
for g in b:
	cnt += 1
	x += 1
	if g[1] == 0:
		break
	if x % k == 0:
		cnt += 5
print(cnt, end=' ')
b = []
for i in range(n):
	t = 0
	if a[i] == s:
		t = 1
	b.append([len(a[i]), t])
b = sorted(b)
cnt = 0
x = 0
for g in b:
	cnt += 1
	x += 1
	if g[1] == 1:
		break
	if x % k == 0:
		cnt += 5
print(cnt)


parse_int = lambda : list(map(int, input().split()))
(n, k) = parse_int()
passw = set()
for _ in range(n):
	passw.add(input().strip())
passw = [len(el) for el in passw]
passw.sort()
tru = len(input().strip())
time = 0
before_shtraf = k
(lucky, unlucky) = (999999999, 0)
for el in passw:
	time += 1
	if el == tru:
		lucky = min(lucky, time)
		unlucky = time
	before_shtraf -= 1
	if before_shtraf <= 0:
		before_shtraf = k
		time += 5
print(lucky, unlucky)


(n, k) = input().split()
n = int(n)
k = int(k)
passwords = []
for i in range(n):
	password = input()
	passwords.append(password)
correct = input()
z = len(correct)
ans1 = 0
ans2 = 0
for el in passwords:
	x = len(el)
	if x < z:
		ans1 += 1
	if x <= z:
		ans2 += 1
a = ans1 // k
ans1 += 5 * a + 1
b = (ans2 - 1) // k
ans2 += b * 5
print(ans1, ans2)


def sbl(s):
	return len(s)
(n, k) = input().split()
a = []
for i in range(0, int(n)):
	a.append(input())
cor = input()
n = int(n)
k = int(k)
a.sort(key=sbl)
for i in a:
	if len(cor) == len(i):
		m = a.index(i)
		break
for i in a:
	if len(cor) < len(i):
		m1 = a.index(i)
		break
else:
	m1 = n
ans1 = m + m // k * 5 + 1
ans2 = m1 + (m1 - 1) // k * 5
print(ans1, ans2)


(a, b) = map(int, input().split())
(v, w, r) = ([], 0, 0)
for _ in range(a):
	z = input()
	v.append(len(z))
q = len(input())
for i in v:
	if i < q:
		w += 1
	if i <= q:
		r += 1
print(w + 1 + w // b * 5, r + (r - 1) // b * 5)


(n, k) = map(int, input().split())
p = [input() for i in range(n)]
L = len(input())
p.sort(key=lambda x: len(x))
c = 0
minc = 0
maxc = 0
for i in p:
	le = len(i)
	if le < L:
		maxc += 1
		minc += 1
	if le == L:
		maxc += 1
	elif le > L:
		break
print(minc + 1 + minc // k * 5, maxc + (maxc - 1) // k * 5)


(n, k) = map(int, input().split())
l1 = []
for i in range(n):
	s = input()
	l1.append(s)
same = 0
kam = 0
pswd = input()
if n == 1:
	print(1, 1)
	exit(0)
for i in l1:
	if len(i) == len(pswd):
		same += 1
	if len(i) < len(pswd):
		kam += 1
if k != 1:
	t = 0
	r = kam % k
	t = kam // k * 5
	t += kam
	T = (same + kam - 1) // k * 5
	T += same + kam
	print(t + 1, ' ', T)
else:
	print(kam * 6 + 1, (same - 1 + kam) * 6 + 1)


(n, k) = map(int, input().split())
length = [0] * 106
for i in range(n):
	length[len(input())] += 1
correct = len(input())
best = sum(length[0:correct]) + 1
worse = sum(length[0:correct + 1])
worse += (worse - 1) // k * 5
best += (best - 1) // k * 5
print(best, worse)


(n, k) = [int(i) for i in input().split()]
passws = []
for i in range(n):
	passws.append(input())
main = input()
ml = len(main)
lens = [0] * 101
for i in passws:
	lens[len(i)] += 1
mls = sum(lens[:ml])
mls2 = sum(lens[:ml + 1])
print(mls + mls // k * 5 + 1, mls2 + (mls2 - 1) // k * 5)


(n, k) = map(int, input().split())
s = []
for i in range(n):
	s.append(input())
p = input()
p_lg = len(p)
less_p = 0
is_p = 0
for password in s:
	if len(password) < p_lg:
		less_p += 1
	if len(password) == p_lg:
		is_p += 1
nr_tries_best = less_p + 1
time_best = nr_tries_best + 5 * int(nr_tries_best / k)
if nr_tries_best % k == 0:
	time_best -= 5
nr_tries_worst = less_p + is_p
time_worst = nr_tries_worst + 5 * int(nr_tries_worst / k)
if nr_tries_worst % k == 0:
	time_worst -= 5
print(time_best, time_worst)


def main():
	try:
		while True:
			(n, k) = list(map(int, input().split()))
			ls = sorted((input() for i in range(n)), key=len)
			true = len(input())
			first = 1000000000.0
			last = 0
			cur = 0
			flag = True
			for (i, s) in enumerate(ls):
				cur += 1
				if len(s) == true:
					last = cur
					if flag:
						flag = False
						first = cur
				elif not flag:
					break
				if (i + 1) % k == 0:
					cur += 5
			print(first, last)
	except EOFError:
		pass
main()


(n, k) = map(int, input().split())
d = {}
for i in range(n):
	str = input()
	d[len(str), i] = str
pas = input()
paslen = len(pas)
cnt = 0
for (a, b) in sorted(d):
	if a < paslen:
		cnt += 1
	else:
		break
a1 = cnt + 1 + int(cnt / k) * 5
cnt = 0
for (a, b) in sorted(d):
	if a <= paslen:
		cnt += 1
	else:
		break
b = cnt + int((cnt - 1) / k) * 5
print(a1, b)


(n, k) = [int(i) for i in input().split()]
passLength = [0] * 101
for i in range(n):
	password = input()
	passLength[len(password)] += 1
actualPassLength = len(input())
minTime = sum(passLength[:actualPassLength]) + 1 + sum(passLength[:actualPassLength]) // k * 5
if sum(passLength[:actualPassLength + 1]) % k != 0:
	maxTime = sum(passLength[:actualPassLength + 1]) + sum(passLength[:actualPassLength + 1]) // k * 5
else:
	maxTime = sum(passLength[:actualPassLength + 1]) + (sum(passLength[:actualPassLength + 1]) - 1) // k * 5
print(minTime, maxTime)


num_input = input()
num_input = num_input.split(' ')
n = int(num_input[0])
k = int(num_input[1])
password_list = []
map = {}
for i in range(0, n):
	password = input()
	password_list.append(password)
	if len(password) in map:
		map[len(password)] += 1
	else:
		map[len(password)] = 1
required_password = input()
failed = 0
for i in range(1, len(required_password)):
	if i in map:
		failed += map[i]
best_time = failed + int(failed / k) * 5
failed = failed + map[len(required_password)] - 1
worst_time = failed + int(failed / k) * 5
print(f'{best_time + 1} {worst_time + 1}')


[n, k] = [int(i) for i in input().strip().split()]
count = [0] * 101
for i in range(n):
	password = len(str(input().strip()))
	count[password] += 1
true = len(str(input().strip()))
total = 0
for i in range(true):
	total += count[i]
best = total + 1 + total // k * 5
total += count[true] - 1
worst = total + 1 + total // k * 5
print(best, ' ', worst)


(n, k) = map(int, input().split())
a = sorted([input() for i in range(n)], key=lambda k: len(k))
pw = input()
cnt = 0
time = 0
(best, worst) = (-1, -1)
for entered in a:
	time += 1
	if best == -1:
		if len(entered) != len(pw):
			cnt += 1
			if cnt == k:
				cnt = 0
				time += 5
		else:
			best = time
	elif len(entered) == len(pw):
		cnt += 1
		if cnt == k:
			cnt = 0
			time += 5
	else:
		worst = time - 1
		break
if len(a[-1]) == len(pw):
	worst = 5 * ((n - 1) // k) + n
print(best, worst)


def len_sort(s):
	return len(s)
(n, k) = map(int, input().split())
a = []
for i in range(n):
	x = input()
	if x not in a:
		a.append(x)
a.sort(key=len_sort)
password = input()
need_len = len(password)
less = True
min_time = 0
max_time = 0
c1 = 0
c2 = 0
for i in range(n):
	if len(a[i]) < need_len:
		c1 += 1
	elif len(a[i]) == need_len:
		c2 += 1
	else:
		break
min_time = c1 // k * 5 + c1 + 1
max_time = (c1 + c2 - 1) // k * 5 + c1 + c2
print(min_time, max_time)


(n, k) = list(map(int, input().split()))
lengths = []
countDict = {}
for _ in range(n):
	length = len(input())
	if length in countDict:
		countDict[length] = countDict[length] + 1
	else:
		countDict[length] = 1
		lengths.append(length)
pwd = len(input())
lengths.sort()
minEnter = 0
maxEnter = 0
for x in lengths:
	if x is pwd:
		maxEnter = minEnter + countDict[x]
		break
	minEnter = minEnter + countDict[x]
minEnter = minEnter + 1
minSec = (minEnter - 1) // k * 5 + minEnter
maxSec = (maxEnter - 1) // k * 5 + maxEnter
print(minSec, maxSec)


user_input = input()
first_line = user_input.split(' ')
n_passwords = int(first_line[0])
pass_limit = int(first_line[1])
passwords = []
for i in range(n_passwords):
	user_input = input()
	passwords.extend([user_input])
passwords.sort(key=len)
correct_answer = input()
correct_length = len(correct_answer)
counter1 = 0
counter2 = 0
for item in passwords:
	if len(item) < correct_length:
		counter1 += 1
	if len(item) == correct_length:
		counter2 += 1
counter2 += counter1 - 1
best_time = 1
worst_time = 1
if counter1 > 0:
	best_time += counter1 + counter1 // pass_limit * 5
if counter2 > 0:
	worst_time += counter2 + counter2 // pass_limit * 5
print(best_time, worst_time)


from sys import stdin
(n, k) = (int(x) for x in stdin.readline().split())
passwords = []
for _ in range(n):
	passwords.append(stdin.readline().strip())
right_password = stdin.readline().strip()
length_less_than_password = len([password for password in passwords if len(password) < len(right_password)])
length_less_than_or_equal_to_password = len([password for password in passwords if len(password) <= len(right_password)])
a = length_less_than_password // k
spent = length_less_than_password + a * 5
print(spent + 1, end=' ')
a = (length_less_than_or_equal_to_password - 1) // k
spent = length_less_than_or_equal_to_password + a * 5
print(spent)


def passwords(p, codehorse, n, k):
	p.sort(key=lambda word: len(word))
	best = 0
	worst = 0
	k_count = 0
	for word in p:
		if k_count >= k:
			k_count = 0
			best += 5
		best += 1
		if len(word) == len(codehorse):
			print(best, end=' ')
			break
		k_count += 1
	k_count = 0
	p = [word for word in p if len(word) <= len(codehorse)]
	for word in p:
		if k_count >= k:
			k_count = 0
			worst += 5
		worst += 1
		k_count += 1
	print(worst)
(n, k) = list(map(int, input().strip().split(' ')))
p = []
for _ in range(n):
	p.append(input().strip())
codehorse = input().strip()
passwords(p, codehorse, n, k)


(n, k) = map(int, input().split())
leng = [0 for _ in range(105)]
for _ in range(n):
	line = str(input())
	leng[len(line)] += 1
line = str(input())
acPass = len(line)
summ = sum(leng[1:acPass + 1])
res1 = summ - leng[acPass] + int((summ - leng[acPass]) / k) * 5 + 1
res2 = summ + int((summ - 1) / k) * 5
print(res1, res2)


(n, k) = map(int, input().split())
l = []
for i in range(n):
	l.append(input())
p = input()
(a, b) = (0, 0)
for i in l:
	if len(i) < len(p):
		a += 1
	if len(i) <= len(p):
		b += 1

def fun(s, k):
	y = s % k
	if y == 0:
		y = k
	x = (s - y) // k
	return x * (k + 5) + y
print(fun(a + 1, k), fun(b, k))


(n, k) = map(int, input().split(' '))
ss = [input() for _ in range(n)]
pl = len(input())

def time(i):
	return i + (i - 1) // k * 5
print(time(sum((len(s) < pl for s in ss)) + 1), time(sum((len(s) <= pl for s in ss))))


line = input().split()
n = int(line[0])
k = int(line[1])
lengths = []
passwords = []
for i in range(n):
	line = input()
	lengths.append(len(line))
	passwords.append(line)
password = input()
pass_len = len(password)
lengths.sort()
first = lengths.index(pass_len)
if password in passwords:
	last = lengths.count(pass_len) + first
else:
	last = n - 1
print(first + 1 + first // k * 5, last + (last - 1) // k * 5)


(n, k) = input().split(' ')
n = int(n)
k = int(k)
passwords = []
for _ in range(n):
	passwords.append(input())
right_pass = input()
right_len = len(right_pass)
lens = 0
min_attempts = 1
max_attempts = 0
for password in passwords:
	if len(password) < right_len:
		min_attempts += 1
		max_attempts += 1
	if len(password) == right_len:
		max_attempts += 1
min_time = 0
attemp = 1
while min_attempts != 0:
	min_time += 1
	min_attempts -= 1
	if min_attempts == 0:
		break
	if attemp == k:
		min_time += 5
		attemp = 1
	else:
		attemp += 1
max_time = 0
attemp = 1
while max_attempts != 0:
	max_time += 1
	max_attempts -= 1
	if max_attempts == 0:
		break
	if attemp == k:
		max_time += 5
		attemp = 1
	else:
		attemp += 1
print(str(min_time) + ' ' + str(max_time))


(n, k) = map(int, input().split())
lst = []
for i in range(n):
	x = input()
	lst.append(x)
p = input()
d = {}
lst.sort()
for i in lst:
	if len(i) in d:
		d[len(i)] += 1
	else:
		d[len(i)] = 1
l = len(p)
s = 1
e = 0
for key in d.keys():
	if key < l:
		s += d[key]
	if key <= l:
		e += d[key]
if s % k != 0:
	s1 = s + s // k * 5
else:
	s1 = s + (s - 1) // k * 5
if e % k != 0:
	e1 = e + e // k * 5
else:
	e1 = e + (e - 1) // k * 5
print(s1, e1)


(n, k) = map(int, input().split())
passwords = []
best = 0
worst = 0
for i in range(n):
	password = input()
	passwords.append(password)
correctPassword = input()
lengthOfCorrectPassword = len(correctPassword)
numberOfPasswordsShorter = 0
numberOfPasswordsLonger = 0
for password in passwords:
	lengthOfPassword = len(password)
	if lengthOfPassword < lengthOfCorrectPassword:
		numberOfPasswordsShorter += 1
	if lengthOfPassword <= lengthOfCorrectPassword:
		numberOfPasswordsLonger += 1
best = numberOfPasswordsShorter + numberOfPasswordsShorter // k * 5 + 1
worst = numberOfPasswordsLonger + (numberOfPasswordsLonger - 1) // k * 5
print('{0} {1}'.format(best, worst))


(n, k) = map(int, input().split())
Pass = {}
for i in range(n):
	In = input()
	Pass[In] = len(In)
Cor = input()
Lens = list(sorted(Pass.values()))
Min = Lens.index(len(Cor)) + 1 + Lens.index(len(Cor)) // k * 5
index = n - list(reversed(Lens)).index(len(Cor)) - 1
time = index + 1 + index // k * 5
print(Min, time)


dict = {}
(tmp1, tmp2) = input().split()
(n, k) = (int(tmp1), int(tmp2))
i = 0
while i < n:
	l = len(input())
	if l in dict:
		dict[l] += 1
	else:
		dict[l] = 1
	i += 1
lp = len(input())
i = 1
count = 0
while i < lp:
	if i in dict:
		count += dict[i]
	i += 1
min = count + 1
max = count + dict[lp]
if min % k == 0:
	min += 5 * (int(min / k) - 1)
else:
	min += 5 * int(min / k)
if max % k == 0:
	max += 5 * (int(max / k) - 1)
else:
	max += 5 * int(max / k)
print(str(min) + ' ' + str(max))


(n, k) = map(int, input().strip().split())
password_lengths = list()
pass_table = dict()
length = 0
for i in range(n):
	length = len(input().strip())
	if length not in password_lengths:
		password_lengths.append(length)
	if pass_table.get(length, -1) == -1:
		pass_table[length] = 0
	pass_table[length] += 1
actual_password_len = len(input().strip())
password_lengths = sorted(password_lengths)
times = 0
for l in password_lengths:
	if l < actual_password_len:
		times += pass_table[l]
	if l == actual_password_len:
		length = pass_table[l]
		break
best = times + times // k * 5 + 1
worst = times + (length - 1) + (times + (length - 1)) // k * 5 + 1
print(str(best) + ' ' + str(worst))


import math
import string

def main():
	(n, k) = map(int, input().split())
	cnt = [0] * 101
	for i in range(n):
		cnt[len(input())] += 1
	x = len(input())
	s = sum(cnt[:x])
	t = sum(cnt[:x + 1]) - 1
	print(s // k * 5 + s + 1, t // k * 5 + t + 1)
main()


(n, t) = map(int, input().split())
size = [0] * 102
for _ in range(n):
	s = input()
	size[len(s)] += 1
cr = input()
crl = len(cr)
time = 0
spend = 0
for i in range(1, crl + 1):
	if size[i] > 0:
		if i == crl:
			best = spend + spend // t * 5 + 1
			spend += size[i] - 1
			break
		else:
			spend += size[i]
worst = spend + spend // t * 5 + 1
print(best, worst)


(n, k) = map(int, input().split())
a = []
for i in range(n):
	a.append(len(input()))
m = len(input())
a.sort()
i = a.index(m) + 1
j = n - 1
while a[j] != m:
	j -= 1
j += 1
print(i + (i - 1) // k * 5, j + (j - 1) // k * 5)


(n, k) = str(input()).split()
(n, k) = (int(n), int(k))
line = [0] * 101
for i in range(n):
	s = str(input())
	line[len(s)] += 1
a = str(input())
c = len(a)
b = sum(line[:c])
(m0, m1) = (b + 1, b + line[c])
r0 = m0 + (m0 - 1) // k * 5
r1 = m1 + (m1 - 1) // k * 5
print(str(r0) + ' ' + str(r1))


(n, k) = tuple(map(int, input().split()))
ls = [set() for i in range(1, 110)]
for i in range(n):
	s = input().strip()
	ls[len(s)].add(s)
key = input().strip()
kl = len(key)
kk = 0
for i in range(1, kl):
	kk += len(ls[i])
bt = kk + kk // k * 5 + 1
ft = kk + len(ls[kl]) + (kk + len(ls[kl]) - 1) // k * 5
print(bt, ft)


(n, k) = map(int, input().split())
arr = []
for i in range(n):
	arr.append(input())
corr = input()
least = 0
for x in arr:
	if len(x) < len(corr):
		least += 1
lw = 0
for x in arr:
	if len(x) == len(corr):
		if x != corr:
			lw += 1
print(least // k * 5 + least + 1, (least + lw) // k * 5 + least + lw + 1)


from collections import Counter
(n, k) = map(int, input().split())
pas = [input() for i in range(n)]
pass_ = input()
c = Counter([len(s) for s in pas])
was = sum([c[k] for k in c.keys() if k < len(pass_)])
min_ = was + 5 * (was // k) + 1
max_ = was + c[len(pass_)] + 5 * ((was + c[len(pass_)] - 1) // k)
print(min_, max_)


(n, k) = map(int, input().split())
ps = []
for _ in range(n):
	ps.append(len(input()))
ps.sort()
a = len(input())
l = ps.index(a)
r = n - 1 - ps[::-1].index(a)
print(l + 1 + l // k * 5, r + 1 + r // k * 5)


(N, K) = map(int, input().split())
pass_len_lst = [len(input()) for _ in range(N)]
password_len = len(input())
d = {}
for pass_len in pass_len_lst:
	d[pass_len] = d.get(pass_len, 0) + 1
minans = 0
minv = 0
maxans = 0
maxv = 0
for i in range(1, password_len):
	if i not in d:
		continue
	minans += d[i]
	minv += d[i]
	maxans += d[i]
	maxv += d[i]
minans += 1
minv += 1
minans += (minv - 1) // K * 5
maxans += d[password_len]
maxv += d[password_len]
maxans += (maxv - 1) // K * 5
print('{} {}'.format(minans, maxans))


(n, k) = map(int, input().split())
p = [input() for i in range(n)]
s = input()
m = len(s)
counter = 0
counter2 = 0
d = dict()
for elem in p:
	a = len(elem)
	if a in d:
		d[a] += 1
	else:
		d[a] = 1
for key1 in sorted(d):
	if key1 < m:
		counter += d[key1]
	elif key1 == m:
		counter2 = d[key1]
	else:
		break
ans1 = counter // k * 5 + (counter + 1)
ans2 = (counter + counter2 - 1) // k * 5 + (counter + counter2)
print(ans1, ans2)


(n, k) = map(int, input().split())
passwords = []
for i in range(n):
	s = input()
	passwords.append(s)
cpass = input()
countL = 0
countE = 0
for p in passwords:
	if len(p) < len(cpass):
		countL += 1
	elif len(p) == len(cpass):
		countE += 1
bestcase = countL + 1 + 5 * (countL // k)
worstcase = countL + countE + 5 * ((countL + countE - 1) // k)
print(bestcase, worstcase)


(a, b) = map(int, input().split())
m = []
for i in range(a):
	m.append(len(input()))
m.sort()
answ = len(input())
c = 0
for i in m:
	c += 1
	if i == answ:
		break
minn = c + 5 * ((c - 1) // b)
c = 0
trig = False
for i in m:
	if i == answ:
		trig = True
	if i != answ and trig:
		break
	c += 1
maxx = c + 5 * ((c - 1) // b)
print(minn, maxx)


(n, k) = (int(i) for i in input().split())
l = []
for i in range(n):
	l += [input()]
ans_pas = input()
low_bow = 0
up_bow = 0
for el in l:
	if len(el) < len(ans_pas):
		low_bow += 1
	elif len(el) == len(ans_pas):
		up_bow += 1
up_bow += low_bow - 1
min_ans = low_bow + low_bow // k * 5 + 1
max_ans = up_bow + up_bow // k * 5 + 1
print(min_ans, max_ans)


a = []
w = input()
w = w.split(' ')
n = int(w[0])
m = int(w[1])
for i in range(0, n):
	s = input()
	a.append(s)
s = input()
c = len(s)
num1 = 0
num2 = 0
for i in range(0, n):
	if len(a[i]) < c:
		num1 += 1
	if len(a[i]) == c:
		num2 += 1
c1 = num1 // m
c2 = (num1 + num2 - 1) // m
mi = num1 + 1 + c1 * 5
mx = num2 + num1 + c2 * 5
print(mi, mx)


import bisect
(n, k) = map(int, input().split())
l = []
t = []
for i in range(n):
	s = input()
	t += [s]
	l += [len(s)]
s = input()
c = 0
l.sort()
res1 = bisect.bisect_left(l, len(s)) + 1
res = bisect.bisect_right(l, len(s))
mx = res
while res > 0:
	res -= k
	if res > 0:
		c += 1
	else:
		break
mx += c * 5
mn = res1
c = 0
while res1 > 0:
	res1 -= k
	if res1 > 0:
		c += 1
	else:
		break
mn += c * 5
print(mn, mx)


(n, k) = map(int, input().split())
passwords = []
for i in range(n):
	passwords.append(input())
realpass = input()
lenpass = len(realpass)
lt = 0
eq = 0
for password in passwords:
	if len(password) < lenpass:
		lt += 1
	elif len(password) == lenpass:
		eq += 1
print(lt + lt // k * 5 + 1, lt + eq + (lt + eq - 1) // k * 5)


(n, k) = map(int, input().split())
d = []
for _ in range(n):
	d.append(len(input()))
s = input()
d.sort()
c = sum((i < len(s) for i in d))
mi = c + c // k * 5 + 1
c = sum((i <= len(s) for i in d))
ma = c + (c - 1) // k * 5
print(mi, ma)


(n, k) = map(int, input().split())
arr = []
for i in range(n):
	arr.append(input())
arr.sort(key=lambda x: len(x))
correctPass = input()
lengthPass = len(correctPass)
indexCorrectPass = 0
indexLastTry = n - 1
for i in range(n):
	if len(arr[i]) == lengthPass:
		indexCorrectPass = i
		break
for i in range(n):
	if len(arr[i]) > lengthPass:
		indexLastTry = i - 1
		break
t1 = indexCorrectPass
bestCase = t1 // k * 5 + t1 + 1
t2 = indexLastTry
worstCase = t2 // k * 5 + t2 + 1
print(bestCase, worstCase)


(n, k) = map(int, input().split())
arr = []
for _ in range(n):
	arr.append(input())
right = input()
l = len(right)
the_best = 1
the_worst = 1
bad_requests_good = 0
bad_requests_bad = 0
for password in arr:
	if len(password) < l:
		the_best += 1
		the_worst += 1
		bad_requests_good += 1
		bad_requests_bad += 1
		if bad_requests_good >= k:
			bad_requests_good = 0
			the_best += 5
		if bad_requests_bad >= k:
			bad_requests_bad = 0
			the_worst += 5
	elif len(password) == l and password != right:
		the_worst += 1
		bad_requests_bad += 1
		if bad_requests_bad >= k:
			bad_requests_bad = 0
			the_worst += 5
print(the_best, the_worst)


(a, b) = map(int, input().split())
z = [input() for _ in ' ' * a]
x = input()
z = sorted(z, key=len)
p = len(x)
(ans, ans1) = (0, 0)
for i in z:
	if len(i) < len(x):
		ans += 1
		ans1 += 1
	elif len(i) == len(x):
		ans1 += 1
ans1 -= 1
print(1 + ans + 5 * (ans // b), 1 + ans1 + 5 * (ans1 // b))


from collections import defaultdict
(n, k) = map(int, input().split())
c = defaultdict(lambda : 0)
for _ in range(n):
	s = input()
	c[len(s)] += 1
original = input()
ans = 0
for i in range(1, len(original)):
	ans += c[i]
print(ans + ans // k * 5 + 1, end=' ')
ans += c[len(original)] - 1
print(ans + ans // k * 5 + 1)


def solution(passwords, correct_pass, k) -> None:
	n = len(correct_pass)
	n1 = n2 = 0
	for x in passwords:
		l = len(x)
		if l < n:
			n1 += 1
		elif l == n:
			n2 += 1
	res = n1 // k * (k + 5)
	extra = n1 % k
	best = res + extra + 1
	other = extra + n2 - 1
	worst = other // k * (k + 5)
	worst += res + other % k + 1
	print('{} {}'.format(best, worst))

def main():
	(p, q) = map(int, input().split())
	passwords = []
	for i in range(p):
		passwords.append(input())
	correct_pass = input()
	solution(passwords, correct_pass, q)
main()


(n, k) = input().split()
n = int(n)
k = int(k)
pws = []
for i in range(n):
	pws.append(input())
password = input()
l = len(pws)
pws = list(filter(lambda x: len(x) >= len(password), pws))
same_length = len(list(filter(lambda x: len(x) == len(password), pws)))
l -= len(pws)
if l < k:
	best_case = l + 1
else:
	best_case = l + l // k * 5 + 1
if l + same_length - 1 < k:
	worst_case = l + same_length
else:
	worst_case = l + same_length + (l + same_length - 1) // k * 5
print(best_case, worst_case)


(n, s) = list(map(int, input().split()))
passwords = [input() for _ in range(n)]
correctPassword = input()
lens = [len(x) for x in passwords]
pswLen = len(correctPassword)
minCount = len(list((x for x in lens if x < pswLen))) + 1
maxCount = len(list((x for x in lens if x <= pswLen)))
minSec = minCount + (minCount - 1) // s * 5
maxSec = maxCount + (maxCount - 1) // s * 5
print(str(minSec) + ' ' + str(maxSec))


(n, k) = map(int, input().split())
l1 = [0] * 101
for i in range(0, n):
	s = input()
	l1[len(s)] += 1
pword = input()
x = len(pword)
best = 0
worst = 0
best += sum(l1[:x])
best = best + best // k * 5 + 1
worst += sum(l1[:x + 1]) - 1
worst = worst + worst // k * 5 + 1
print(best, worst)


(n, k) = map(int, input().split())
data = [[] for i in range(101)]
for i in range(n):
	word = input()
	data[len(word)].append(word)
correct = len(input())
s = 0
for i in range(1, correct):
	s = s + len(data[i])
print(s + 1 + s // k * 5, s + len(data[correct]) + (s + len(data[correct]) - 1) // k * 5)


(n, k) = map(int, input().split())
f = {}
d = []
for i in range(n):
	s = input()
	try:
		f[len(s)] += 1
	except:
		f[len(s)] = 1
key = input()
t = len(key)
for x in f.keys():
	d.append(x)
d.sort()
(a, b) = (0, 0)
ost = 0
for x in d:
	if x == t:
		a += 1
		b += f[x] + 5 * ((f[x] + ost - 1) // k)
		break
	else:
		a += f[x] + 5 * ((f[x] + ost) // k)
		b += f[x] + 5 * ((f[x] + ost) // k)
		ost = (f[x] + ost) % k
print(a, b)


[n, k] = input().split(' ')
n = int(n)
k = int(k)
l = 0
d = 0
arr = [] * (n + 1)
for i in range(n):
	str = input()
	arr.append(str)
str1 = input()
len1 = len(str1)
for i in range(n):
	if len(arr[i]) < len1:
		l = l + 1
	elif len(arr[i]) == len1:
		d = d + 1
ans1 = l + int(l / k) * 5 + 1
ansr = l + d + int((l + d - 1) / k) * 5
print(int(ans1), int(ansr))


x = input().split(' ')
tmp = set()
sz = {}
inp = []
temp = 0
ans1 = 0
ans2 = 0
for i in range(int(x[0])):
	y = input()
	inp.append(y)
key = input()
for i in range(int(x[0])):
	if len(inp[i]) < len(key) and inp[i] not in tmp:
		tmp.add(inp[i])
		ans1 += 1
		ans2 += 1
		temp += 1
		if temp % int(x[1]) == 0:
			ans1 += 5
			ans2 += 5
for i in range(int(x[0])):
	if len(inp[i]) == len(key) and inp[i] not in tmp and (key != inp[i]):
		tmp.add(inp[i])
		ans2 += 1
		temp += 1
		if temp % int(x[1]) == 0:
			ans2 += 5
print(str(ans1 + 1) + ' ' + str(ans2 + 1))


(n, k) = map(int, input().split(' '))
arr = [0] * 105
for i in range(n):
	arr[len(input())] += 1
pw = len(input())
tries = 0
for i in range(1, pw):
	tries += arr[i]
best = tries + 1 + tries // k * 5
worst = tries + arr[pw] + (tries + arr[pw] - 1) // k * 5
print(best, worst)


def shuru(t=0, s=0):
	in_item = input().strip()
	if not t:
		return in_item
	elif not s:
		str_t = t + '(' + in_item + ')'
		in_item = eval(str_t)
		return in_item
	else:
		str_s = 'list(' + s + '(lambda x:int(x) ,in_item.split() ))'
		return eval(str_s)

def fun1():
	import math
	(n, k) = shuru('int', 'map')
	mima = {}
	for i in range(n):
		temp = shuru()
		temp_l = len(temp)
		if temp_l not in mima:
			mima[temp_l] = 0
		mima[temp_l] += 1
	zhengque = shuru()
	l = len(zhengque)
	min = 0
	max = 0
	for i in mima:
		if i < l:
			min += mima[i]
			max += mima[i]
		elif i == l:
			min += 1
			max += mima[i]
	print(math.floor((min - 1) / k) * 5 + min, math.floor((max - 1) / k) * 5 + max)
fun1()


import bisect
(n, k) = map(int, input().split())
a = []
st = []
for i in range(n):
	s = input()
	st.append(s)
	a.append(len(s))
pas = input()
c = a.count(len(pas)) - st.count(pas)
a.sort()
ws = bisect.bisect(a, len(pas) - 1)
print(ws // k * 5 + ws + 1, end=' ')
ws += c
print(ws // k * 5 + ws + 1)


(n, k) = map(int, input().split())
a = []
for i in range(n):
	s = input()
	a.append(s)
s = input()
pwdlen = len(s)
shorter_pwdlen = 0
equal_pwdlen = 0
for i in range(n):
	if len(a[i]) < pwdlen:
		shorter_pwdlen += 1
	elif len(a[i]) == pwdlen:
		equal_pwdlen += 1
min_times = shorter_pwdlen + shorter_pwdlen // k * 5 + 1
max_times = shorter_pwdlen + equal_pwdlen - 1 + (shorter_pwdlen + equal_pwdlen - 1) // k * 5 + 1
print(min_times, max_times)


(n, k) = map(int, input().split())
a = sorted([len(input()) for i in range(n)])
b = len(input())
(ans1, ans2) = (0, 0)
for i in range(n):
	ans1 += 1
	if a[i] == b:
		break
	if i % k == k - 1:
		ans1 += 5
for i in range(n):
	ans2 += 1
	if i == n - 1 or a[i + 1] > b:
		break
	if i % k == k - 1:
		ans2 += 5
print(ans1, ans2)


a = input().split(' ')
n = int(a[0])
k = int(a[1])
i = 0
l = []
while i <= n:
	s = input()
	l = l + [s]
	i = i + 1
password = l[len(l) - 1]
best = 0
i = 0
c = 0
while i < len(l) - 1:
	if len(l[i]) < len(password):
		best += 1
	if len(l[i]) == len(password):
		c = c + 1
	i = i + 1
worst = c + best
best = best + 1
i = 1
tw = 1
while i < worst:
	if i % k == 0:
		tw += 5
	tw = tw + 1
	i = i + 1
i = 1
tb = 1
while i < best:
	if i % k == 0:
		tb += 5
	tb = tb + 1
	i = i + 1
print(tb, tw)


(n, k) = map(int, input().split())
pw_list = []
length = [0] * 101
for _ in range(n):
	word = input()
	length[len(word)] += 1
	pw_list.append(word)
password = input()
count = pw_list.count(password)
failed = sum(length[:len(password)])
best = failed + 1 + failed // k * 5
worst_tries = failed + length[len(password)] - count
worst = worst_tries // k * 5 + worst_tries + 1
print('%d %d' % (best, worst))


import sys
input = lambda : sys.stdin.readline()
(n, k) = map(int, input().split())
A = [len(input()) for _ in range(n)]
x = len(input())
a = len(list(filter(lambda s: s < x, A)))
b = len(list(filter(lambda s: s <= x, A)))
best = a // k * 5 + a + 1
worst = (b - 1) // k * 5 + b
print(best, worst)


a = list(map(int, input().split()))
lista = list()
for i in range(a[0]):
	lista.append(len(input()))
lista.sort()
contrasena = len(input())
i = 1
first = False
last = False
count = 0
f = 0
l = 0
while (not first or not last) and i <= len(lista):
	count += 1
	if lista[i - 1] == contrasena and (not first):
		f = count
		first = True
	if lista[i - 1] > contrasena and (not last):
		if (i - 1) % a[1] == 0:
			l = count - 6
		else:
			l = count - 1
		last = True
	if i % a[1] == 0:
		count += 5
	i += 1
if not last:
	if (i - 1) % a[1] == 0:
		l = count - 5
	else:
		l = count
print(f, l)


(n, k) = map(int, input().split())
v = [len(input()) for i in range(n)]
ans = len(input())
mn = 1
mx = 0
for x in v:
	if x < ans:
		mn += 1
	if x <= ans:
		mx += 1
mn += 5 * ((mn - 1) // k)
mx += 5 * ((mx - 1) // k)
print(mn, mx)


def s():
	[n, k] = list(map(int, input().split()))
	a = sorted([input() for i in range(n)], key=lambda x: len(x))
	t = 0
	r = 0
	rr = 0
	kk = True
	p = input()
	for i in a:
		if t == k:
			t = 0
			r += 5
		t += 1
		r += 1
		if kk and len(i) == len(p):
			kk = False
			print(r, end=' ')
		if len(i) > len(p):
			print(rr)
			return
		rr = r
	print(rr)
s()


class node:

	def __init__(self, value):
		self.value = value

	def __lt__(self, other):
		return len(self.value) < len(other.value)
(n, k) = map(int, input().split())
a = []
for i in range(n):
	s = input()
	a.append(node(s))
password = input()
best = 0
worst = 0
time = 0
wrong = 0
a.sort()
for i in range(n):
	if wrong == k:
		time += 5
		wrong = 0
	if len(a[i].value) != len(password):
		time += 1
		wrong += 1
	else:
		best = time + 1
		j = i
		while j < n and len(a[j].value) == len(password):
			if wrong == k:
				time += 5
				wrong = 0
			time += 1
			wrong += 1
			j += 1
		worst = time
		print(best, worst)
		exit(0)


(n, k) = [int(i) for i in input().split()]
d = {}
for i in range(n):
	w = input()
	s = len(w)
	if s not in d.keys():
		d[s] = 1
	else:
		d[s] += 1
p = input()
len_p = len(p)
before = [v for (k, v) in d.items() if k < len_p]
sum_before = sum(before)
len_before = len(before)
minr = sum_before // k * 5 + sum_before + 1
maxr = sum_before + (sum_before + d[len_p] - 1) // k * 5 + d[len_p]
print(minr, maxr)


def passwords(n, tries, password, valid):
	length = len(valid)
	lower = [x for x in password if len(x) < length]
	higher = [x for x in password if len(x) > length]
	best = len(lower) // tries * 5 + len(lower) + 1
	for_worst = n - len(higher) - 1
	worst = for_worst // tries * 5 + for_worst + 1
	return (best, worst)
(n, tries) = list(map(int, input().split()))
password = []
for x in range(n):
	password.append(input())
valid = input()
(best, worst) = passwords(n, tries, password, valid)
print(best, worst)


q = input().split()
for i in range(2):
	q[i] = int(q[i])
n = q[0]
k = q[1]
seconds1 = 0
l = []
wast1 = 0
wast2 = 0
seconds2 = 0
answer = 0
for i in range(n + 1):
	if n == i:
		answer = input()
	else:
		l.append(input())
for i in range(len(l)):
	if len(answer) > len(l[i]):
		seconds1 = seconds1 + 1
		if seconds1 % k == 0:
			wast1 = wast1 + 5
	if len(answer) >= len(l[i]):
		if seconds2 % k == 0 and seconds2 != 0:
			wast2 = wast2 + 5
		seconds2 = seconds2 + 1
print(str(seconds1 + wast1 + 1) + ' ', end='')
print(str(seconds2 + wast2), end='')


(n, k) = map(int, input().split())
HASH = [0] * 101
for i in range(n):
	s = input()
	HASH[len(s)] += 1
ans = len(input())
res = sum(HASH[:ans])
print(1 + res + int(res / k) * 5, res + HASH[ans] + int((res + HASH[ans] - 1) / k) * 5)


in1 = input()
n = int(in1.split()[0])
block = int(in1.split()[1])
pw = {}
for i in range(n):
	length = len(input())
	pw[length] = pw.get(length, 0) + 1
pass_len = len(input())
min_tries = 1
for length in sorted(pw.keys()):
	if length < pass_len:
		min_tries += pw[length]
	else:
		max_tries = min_tries + pw[length] - 1
		break
min_time = min_tries // block * 5 + min_tries
max_time = max_tries // block * 5 + max_tries
if min_tries % block == 0:
	min_time -= 5
if max_tries % block == 0:
	max_time -= 5
print(min_time, max_time)


(n, k) = map(int, input().split(' '))
cases = []
best = 0
worst = 0
for i in range(0, n):
	cases.append(input())
password = input()
for items in cases:
	if len(items) < len(password):
		best = best + 1
	elif len(items) == len(password):
		worst = worst + 1
best_answer = best + int(best / k) * 5
worst_answer = best + worst + int((best + worst - 1) / k) * 5
print(best_answer + 1, worst_answer)


(n, k) = map(int, input().split())
L = []
for i in range(n):
	L.append(input())
L.sort(key=len)
s = input()
ans = 0
b = -1
for i in range(len(L)):
	ans += 1
	if len(s) == len(L[i]) and b == -1:
		print(ans + 5 * ((ans - 1) // k), end=' ')
		b = 0
	if len(s) < len(L[i]):
		ans -= 1
		print(ans + 5 * ((ans - 1) // k), end=' ')
		ans = -1
		break
if ans >= 0:
	print(ans + 5 * ((ans - 1) // k))


def myFunc(e):
	return len(e)
(n, k) = map(int, input().split())
liste = []
compteur = 1
compteurmax = 0
i = 0
r = 0
for loop in range(n):
	texte = input()
	liste.append(texte)
liste.sort(reverse=False, key=myFunc)
solution = input()
while len(liste[i]) != len(solution):
	compteur += 1
	i += 1
	r += 1
	if r % k == 0:
		compteur += 5
compteurmax = compteur
i += 1
if i < len(liste):
	while len(liste[i]) == len(solution):
		i += 1
		r += 1
		compteurmax += 1
		if r % k == 0:
			compteurmax += 5
		if i == len(liste):
			break
print('{} {}'.format(compteur, compteurmax))


(n, k) = map(int, input().split())
l = []
cnt = 0
bb = 0
for i in range(n):
	a = input()
	l.append(a)
b = input()
for i in l:
	if len(i) < len(b):
		cnt += 1
	if len(i) == len(b) and i != b:
		bb += 1
mn = cnt + cnt // k * 5
mx = cnt + bb + (cnt + bb) // k * 5
print(mn + 1, mx + 1)


(n, k) = map(int, input().split())
f = []
for i in range(n):
	s = str(input())
	f.append(len(s))
d = len(str(input()))
f.append(d + 1)
f.sort()
best_t = f.index(d) + 1 + f.index(d) // k * 5
wor_t = f.index(d + 1) + (f.index(d + 1) - 1) // k * 5
print(best_t, wor_t)


(n, k) = map(int, input().split())
la = []
for i in range(100):
	la.append(0)
for i in range(n):
	x = input()
	a = len(x)
	la[a - 1] += 1
q = 0
z = input()
al = len(z)
for i in range(100):
	if i < al - 1:
		q += la[i]
	if i == al - 1:
		break
t = q
extra = q // k
t = t + extra * 5
q = q % k
best = t + 1
t += la[al - 1] - 1
q += la[al - 1] - 1
extra = q // k
t += extra * 5
t += 1
worst = t
print(str(best) + ' ' + str(worst))


import math

def fact(n):
	ans = 1
	for i in range(2, n + 1):
		ans *= i
	return ans

def comb(n, c):
	return fact(n) // (fact(n - c) * c)
(n, k) = map(int, input().split())
mini = 0
maxi = 0
pas = []
for i in range(n):
	pas.append(str(input()))
pas = sorted(pas, key=lambda x: len(x))
cor = str(input())
ok = True
clen = len(cor)
for i in range(n):
	if len(pas[i]) == clen and mini == 0:
		mini = i + 1 + i // k * 5
	if len(pas[i]) == clen:
		maxi = i + 1 + i // k * 5
		ok = False
	if ok and len(pas[i]) > clen:
		maxi = i + 1 + i // k * 5
print(mini, maxi)


(n, k) = list(map(int, input().split()))
passwords = []
for i in range(n):
	x = input()
	passwords.append(x)
passwords.sort(key=lambda x: len(x))
ans = input()
bestAns = 0
worstAns = 0
mark = 0
for i in passwords:
	if len(i) != len(ans):
		bestAns += 1
		if mark == k:
			bestAns += 5
			mark = 0
	else:
		bestAns += 1
		if mark == k:
			bestAns += 5
			mark = 0
		break
	mark += 1
mark = 0
for i in passwords:
	if len(i) > len(ans):
		break
	if len(i) != len(ans):
		worstAns += 1
		if mark == k:
			worstAns += 5
			mark = 0
	else:
		worstAns += 1
		if mark == k:
			worstAns += 5
			mark = 0
	mark += 1
print(bestAns, worstAns)


(n, k) = map(int, input().split())
lst = [input() for _ in range(n)]
correct_password = input()
cnt1 = 0
cnt_le = 0
for pas in lst:
	if len(pas) < len(correct_password):
		cnt1 += 1
	if len(pas) <= len(correct_password):
		cnt_le += 1
best_case = cnt1 + cnt1 // k * 5 + 1
worse_case = cnt_le + (cnt_le - 1) // k * 5
print(best_case, worse_case)


(n, k) = map(int, input().split())
ll = [0] * 101
for i in range(n):
	ll[len(input().strip())] += 1
pp = len(input().strip())
ansmin = 0
baq = 0
for i in range(pp):
	if ll[i] != 0:
		ansmin += ll[i] + (ll[i] + baq) // k * 5
		baq = (ll[i] + baq) % k
print(ansmin + 1, ansmin + ll[pp] + (ll[pp] - 1 + baq) // k * 5)


(n, k) = map(int, input().split())
p = [input() for _ in range(n)]
p1 = input()
p.sort(key=len)
l = len([x for x in p if len(x) < len(p1)])
print(5 * (l // k) + l + 1, end=' ')
y = len([x for x in p if len(x) == len(p1)])
if (y + l) % k == 0:
	print(5 * ((y + l - 1) // k) + y + l)
else:
	print(5 * ((y + l) // k) + y + l)


from collections import defaultdict
(n, k) = map(int, input().split())
pws = defaultdict(list)
for _ in range(n):
	pw = input()
	pws[len(pw)].append(pw)
target = input()
min_time = max_time = 0
for l in sorted(pws.keys()):
	if l > len(target):
		break
	if l < len(target):
		min_time += len(pws[l])
	max_time += len(pws[l])
min_time += 5 * (min_time // k) + 1
max_time += 5 * ((max_time - 1) // k)
print(min_time, max_time)


(n, k) = list(map(int, input().split()))
lst = []
for i in range(n + 1):
	s = input()
	lst.append(s)
vanya_password = lst[-1]
lst.pop(-1)
best_case = 0
worst_case = 0
count1 = 0
count2 = 0
for i in range(len(lst)):
	if len(lst[i]) < len(vanya_password):
		count1 += 1
	if len(lst[i]) <= len(vanya_password):
		count2 += 1
best_case = count1 + count1 // k * 5 + 1
worst_case = count2 + (count2 - 1) // k * 5
print('{0} {1}'.format(best_case, worst_case))


(n, k) = map(int, input().split())
lis = [len(input()) for _ in range(n)]
lis.sort()
p = len(input())
import bisect
r = bisect.bisect(lis, p)
l = bisect.bisect_left(lis, p) + 1
print(l + 5 * ((l - 1) // k), r + 5 * ((r - 1) // k))


import sys
Input = sys.stdin.readline
(n, k) = map(int, Input().split())
Pass = {}
for i in range(n):
	In = Input()
	Pass[In] = len(In)
Cor = Input()
Lens = list(sorted(Pass.values()))
Min = Lens.index(len(Cor)) + 1 + Lens.index(len(Cor)) // k * 5
index = n - list(reversed(Lens)).index(len(Cor)) - 1
time = index + 1 + index // k * 5
print(Min, time)


(n, k) = map(int, input().split())
s = []
for i in range(n):
	inp = input()
	s.append(inp)
p = input()
cnt_less = cnt_less_and_equal = time = 0
for i in s:
	if len(i) < len(p):
		cnt_less += 1
		cnt_less_and_equal += 1
	elif len(i) == len(p):
		cnt_less_and_equal += 1
print(cnt_less + cnt_less // k * 5 + 1, cnt_less_and_equal + (cnt_less_and_equal - 1) // k * 5)


(n, k) = map(int, input().split())
l = []
for i in range(n):
	l.append(input())
s = input()
l.append('a' * (len(s) + 1))
l.sort(key=lambda x: len(x))
i = 0
curr = 0
last = 0
while len(l[i]) != len(s):
	curr += 1
	last += 1
	if last == k:
		curr += 5
		last = 0
	i += 1
print(curr + 1)
i = 0
curr = 0
last = 0
while len(l[i]) != len(s) + 1:
	curr += 1
	last += 1
	if len(l[i + 1]) != len(s) + 1:
		if last == k:
			curr += 5
			last = 0
	i += 1
print(curr)


(n, k) = map(int, input().split())
M = {}
for _ in range(n):
	s = input()
	if len(s) not in M:
		M[len(s)] = 0
	M[len(s)] += 1
p = len(input())
minA = 0
maxA = 0
for (l, c) in sorted(M.items()):
	if l < p:
		minA += c
		maxA += c
	elif l == p:
		minA += 1
		maxA += c
print('{} {}'.format(minA + (minA - 1) // k * 5, maxA + (maxA - 1) // k * 5))


(n, k) = map(int, input().split())
p = []
for i in range(n):
	p.append(len(input()))
p.sort()
r = len(input())
l = p.index(r)
m1 = l + l // k * 5 + 1
l1 = p.count(r) - 1
l += l1
m2 = l + l // k * 5 + 1
print(str(m1) + ' ' + str(m2))


(n, k) = [int(i) for i in input().split()]
ar = [0] * 101
for i in range(n):
	ar[len(input())] += 1
tru = len(input())
mn = sum(ar[:tru])
mx = sum(ar[:tru + 1]) - 1
print(mn // k * 5 + mn + 1, mx // k * 5 + mx + 1)


(n, k) = map(int, input().split())
l = []
for _ in range(n):
	s = input()
	l.append(s)
pwd = input()
l.sort(key=lambda s: len(s))
worst = 0
best = 0
for s in l:
	if len(s) == len(pwd):
		worst += 1
	elif len(s) < len(pwd):
		best += 1
		worst += 1
	else:
		break
worst -= 1
worst += worst // k * 5 + 1
best += best // k * 5 + 1
print(best, worst)


import math, string, itertools, fractions, heapq, collections, re, array, bisect, sys, random, time, copy, functools
sys.setrecursionlimit(10 ** 7)
inf = 10 ** 20
eps = 1.0 / 10 ** 10
mod = 10 ** 9 + 7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)]

def LI():
	return [int(x) for x in sys.stdin.readline().split()]

def LI_():
	return [int(x) - 1 for x in sys.stdin.readline().split()]

def LF():
	return [float(x) for x in sys.stdin.readline().split()]

def LS():
	return sys.stdin.readline().split()

def I():
	return int(sys.stdin.readline())

def F():
	return float(sys.stdin.readline())

def S():
	return input()

def pf(s):
	return print(s, flush=True)

def main():
	(n, k) = LI()
	a = [S() for _ in range(n)]
	p = S()
	pl = len(p)
	s = set()
	c = collections.defaultdict(int)
	for t in a:
		if t in s:
			continue
		s.add(t)
		c[len(t)] += 1
	t = 0
	for i in range(pl):
		t += c[i]
	ti = t + 1
	ta = t + c[pl]
	return '{} {}'.format(ti + (ti - 1) // k * 5, ta + (ta - 1) // k * 5)
print(main())


(n, k) = map(int, input().split())
l_l = list()
for _ in range(n):
	l_l.append(len(input()))
p = len(input())
h_t = 0
l_t = 0
for l in l_l:
	if l < p:
		h_t += 1
		l_t += 1
	elif l == p:
		h_t += 1
l_t += 1
print('%d %d' % (l_t + (l_t - 1) // k * 5, h_t + (h_t - 1) // k * 5))


(n, k) = map(int, input().split())
st = [input() for i in range(n)]
pw = input()
st.sort()
best = 0
worst = 0
for i in st:
	if len(i) < len(pw):
		best += 1
		worst += 1
	if len(i) == len(pw):
		worst += 1
bt = best // k * 5 + best
print(bt + 1, end=' ')
rem = best % k
worst = worst - best
print(bt + (worst - 1 + rem) // k * 5 + worst)


(n, m) = [int(i) for i in input().split()]
a = []
s1 = 0
s2 = 0
p = True
f = True
for i in range(n):
	a.append(input())
v = input()
a.sort(key=lambda x: len(x))
x = 0
for i in range(n):
	if p:
		s1 += 1
	if f:
		s2 += 1
	if len(a[i]) == len(v):
		p = 0
	elif (i + 1) % m == 0 and p:
		s1 += 5
	if i == n - 1:
		f = 0
	elif len(a[i + 1]) > len(v):
		f = 0
	elif (i + 1) % m == 0 and f:
		s2 += 5
	if p == False and f == False:
		break
print(s1, s2)


def sortByLen(inp):
	return len(inp)
(n, k) = [int(x) for x in input().split()]
pswds = [input() for x in range(n)]
real = input()
l = len(real)
pswds.sort(key=sortByLen)
j0 = 0
j = 0
for i in pswds:
	if len(i) < l:
		j = j + 1
	elif len(i) == l:
		j0 = j0 + 1
	else:
		break
print(j + 5 * (j // k) + 1, j + j0 + 5 * ((j + j0 - 1) // k))


import sys
(n, k) = map(int, input().split())
lines = []
length = []
for i in range(n + 1):
	word = input()
	if i < n:
		length.append(len(word))
	else:
		password = len(word)
	lines += word + '\n'
length.sort()
best = length.index(password) + 1
worst = best + length.count(password) - 1
if best > k:
	if best % k == 0:
		d = int(best / k) - 1
	else:
		d = int(best / k)
	best += d * 5
if worst > k:
	if worst % k == 0:
		d = int(worst / k) - 1
	else:
		d = int(worst / k)
	worst += d * 5
print(best, worst)


(n, k) = map(int, input().split())
max_password_len = 100
password_len_freqs = [0 for i in range(max_password_len + 1)]
passwords = []
for i in range(n):
	curr_password = input().strip()
	password_len_freqs[len(curr_password)] += 1
	passwords.append(curr_password)
correct_password = input().strip()
correct_password_len = len(correct_password)
num_passwords_before = sum(password_len_freqs[:correct_password_len])
blocked_waiting_time = 5
num_entries_mn = num_passwords_before + 1
num_blocks_mn = (num_entries_mn - 1) // k
mn_waiting_time = num_blocks_mn * blocked_waiting_time + num_entries_mn
num_entries_mx = num_passwords_before + password_len_freqs[correct_password_len]
num_blocks_mx = (num_entries_mx - 1) // k
mx_waiting_time = num_blocks_mx * blocked_waiting_time + num_entries_mx
print(str(mn_waiting_time) + ' ' + str(mx_waiting_time))


(n, k) = map(int, input().split())
sec = 0
d = []
first = True
for i in range(n):
	a = input()
	d.append(len(a))
d.sort()
c = len(input())
for j in range(len(d)):
	if c == d[j] and first == True:
		print(j + 1 + sec, end=' ')
		first = False
	if j + 1 >= len(d) or (c == d[j] and c != d[j + 1]):
		print(j + 1 + sec)
		break
	if (j + 1) % k == 0:
		sec += 5


def password(n, k, passwords, correct):
	lengths = []
	less = 0
	equal = 0
	for i in range(n):
		this_len = len(passwords[i])
		lengths.append(this_len)
	for j in range(n):
		if lengths[j] < len(correct):
			less += 1
		elif lengths[j] > len(correct):
			pass
		elif lengths[j] == len(correct):
			equal += 1
	best_case = less + less // k * 5 + 1
	worst_case = less + equal + (less + equal - 1) // k * 5
	print(best_case, worst_case)
(n, k) = map(int, input().split())
passwords = []
for i in range(n):
	passwords.append(input())
correct = input()
password(n, k, passwords, correct)


from collections import Counter
t = input
p = print
r = range
(n, k) = map(int, t().split())
pasw = []
for i in r(n):
	pasw.append(t())
password = t()
pasw.sort(key=len)
c = 0
best_found = False
l = 0
for i in r(n):
	if len(pasw[i]) == len(password):
		if best_found:
			l += 1
		best_found = True
	if len(pasw[i]) < len(password):
		c += 1
b = c // k * 5 + c + 1
p(b, b + (l + c % k) // k * 5 + l)


(n, k) = [int(i) for i in input().split()]
cs = [len(input()) for i in range(n)]
p = len(input())
d = dict()
for c in cs:
	d[c] = d.get(c, 0) + 1
b = sum((d[c] for c in d.keys() if c < p))
best = b + 5 * (b // k) + 1
w = sum((d[c] for c in d.keys() if c <= p))
worst = w + 5 * ((w - 1) // k)
print(best, worst)


(n, m) = map(int, input().split())
mat = [0] * 101
st = set()
for _ in range(n):
	s = input()
	if s not in st:
		mat[len(s)] += 1
	else:
		st.add(s)
res = len(input())
print(sum(mat[0:res]) + sum(mat[0:res]) // m * 5 + 1, sum(mat[0:res + 1]) + (sum(mat[0:res + 1]) - 1) // m * 5)


ld = [int(i) for i in input().split()]
n = ld[0]
k = ld[1]
l = []
for i in range(n):
	a = input()
	l.append(a)
g = input()
s = []
for i in range(len(l)):
	s.append(len(l[i]))
s.sort()
f = set(s)
ls = []
for i in f:
	for j in l:
		if len(j) == i:
			ls.append(j)
ls2 = ls[:]
for i in ls2:
	if len(i) > len(g):
		ls.remove(i)
cnt = 0
for i in ls:
	if len(i) == len(g):
		cnt += 1
cnt = cnt - 1
cnt2 = 0
for i in ls:
	if len(i) < len(g):
		cnt2 += 1
mn = cnt2 // k * 5 + cnt2 + 1
mx = (cnt + cnt2) // k * 5 + cnt + cnt2 + 1
print(mn, mx)


from sys import stdin as fin
(n, k) = map(int, fin.readline().split())
lngs = [0] * 101
for i in range(n):
	lngs[len(fin.readline().strip())] += 1
l = len(fin.readline().strip())
imm = sum(lngs[1:l])
mut = lngs[l]
print(imm + imm // k * 5 + 1, imm + lngs[l] + (imm + lngs[l] - 1) // k * 5)


import sys
import array
(n, k) = (int(x) for x in sys.stdin.readline().split(' '))
arr = array.array('i', [0] * 103)
i = n
while i > 0:
	arr[len(sys.stdin.readline())] += 1
	i -= 1
p = len(sys.stdin.readline())
smin = 0
for i in range(p):
	smin += arr[i]
smax = smin + arr[p]
print(smin // k * 5 + smin + 1, (smax - 1) // k * 5 + smax)


def t(x):
	return x + 1 + x // k * 5
(n, k) = map(int, input().split())
(l, p) = (sorted((len(input()) for i in range(n))), len(input()))
print(t(l.index(p)), t(n - l[::-1].index(p) - 1))


(n, t) = map(int, input().split())
s = set()
for i in range(n):
	s.add(input().strip())
d = dict()
for i in s:
	if len(i) not in d:
		d[len(i)] = 0
	d[len(i)] += 1
k = sorted(d.items())
s = len(input().strip())
mn = 0
mx = 0
ans = 0
for i in k:
	if i[0] == s:
		mn = ans + 1
		mx = ans + i[1]
		break
	ans += i[1]
print(mn + max(0, (mn - 1) // t) * 5, mx + max(0, (mx - 1) // t) * 5)


(n, k) = map(int, input().split())
s = []
for i in range(n):
	x = input()
	s.append(x)
password = input()
cnt = 0
flag = False
s.sort(key=len)
best = worst = 0
for i in range(n):
	if len(s[i]) == len(password) and flag == False:
		best = i + 1
		flag = True
	elif len(s[i]) > len(password):
		worst = i
		break
if worst == 0:
	worst = n
print(best + (best - 1) // k * 5, worst + (worst - 1) // k * 5)


(n, k) = map(int, input().split())
val = [0 for i in range(105)]
ck = []
ml = []
for i in range(n):
	s = input()
	if s not in ck:
		ck += [s]
		ml += [len(s)]
		val[len(s)] += 1
s = input()
d = len(s)
c = 0
p = val[d]
for i in range(1, d + 1):
	c += val[i]
best = (c - p) // k * 5 + c - p + 1
worst = (c - 1) // k * 5 + c
print(best, worst)


from collections import defaultdict
(n, k) = map(int, input().split())
d = defaultdict(int)
for _ in range(n):
	s = input()
	d[len(s)] += 1
p = input()
wrong = 0
for (i, v) in sorted(d.items()):
	if i < len(p):
		wrong += v
	else:
		b = wrong // k * 5 + wrong + 1
		wrong += v - 1
		w = wrong // k * 5 + wrong + 1
		break
print(b, w)


def fnd1(s, x):
	hi = len(s) - 1
	lo = 0
	ans = -1
	while hi >= lo:
		mid = (hi + lo) // 2
		if s[mid] >= x:
			hi = mid - 1
			ans = mid + 1
		else:
			lo = mid + 1
	return ans

def fnd2(s, x):
	hi = len(s) - 1
	lo = 0
	ans = -1
	while hi >= lo:
		mid = (hi + lo) // 2
		if s[mid] <= x:
			lo = mid + 1
			ans = mid + 1
		else:
			hi = mid - 1
	return ans
(x, k) = map(int, input().split())
s = []
for n in range(x):
	p = input()
	s.append(len(p))
s.sort()
tar = len(input())
a = fnd1(s, tar)
b = fnd2(s, tar)
print(a + 5 * ((a - 1) // k), b + 5 * ((b - 1) // k))


(n, k) = map(int, input().split())
arr = [0] * 101
for i in range(n):
	arr[len(input())] += 1
val = len(input())
base = sum(arr[0:val])
extra = base // k
rem = base % k
mini = base + 1 + 5 * extra
maxi = base + arr[val] + 5 * extra + 5 * ((rem + arr[val] - 1) // k)
print(str(mini) + ' ' + str(maxi))


(kol_str, pass_ban) = input().split()
passwords = []
for i in range(int(kol_str)):
	passwords.append(input())
rpass = input()
passwords.sort(key=len)
time = 0
l = len(rpass)
i = 0
cnt = 0
passw = passwords[cnt]
while len(passw) < l:
	i += 1
	cnt += 1
	time += 1
	if i % int(pass_ban) == 0:
		time += 5
		i = 0
	passw = passwords[cnt]
time += 1
print(time, end=' ')
lpass = len([x for x in passwords if len(x) == l]) - 1
time2 = time + lpass
i += lpass
time2 += i // int(pass_ban) * 5
print(int(time2))


(n, k) = map(int, input().split())
s = set()
for i in range(n):
	s.add(input())
p = len(input())
s = list(s)
s = sorted(s, key=len)
for i in range(len(s)):
	if len(s[i]) == p:
		print(i + 1 + i // k * 5, end=' ')
		break
for i in range(len(s) - 1, -1, -1):
	if len(s[i]) == p:
		break
print(i + i // k * 5 + 1)


(n, k) = map(int, input().split())
psw = {}
for i in range(n):
	p = len(input())
	psw[p] = psw.get(p, 0) + 1
cor_len = len(input())
q1 = 1
q2 = 0
for key in psw.keys():
	if key < cor_len:
		q1 += psw[key]
	if key <= cor_len:
		q2 += psw[key]
print(q1 + (q1 - 1) // k * 5, q2 + (q2 - 1) // k * 5)


def string2list(x):
	x = x.split()
	i = 0
	for i in range(len(x)):
		x[i] = int(x[i])
	return x
data = string2list(input())
N = data[0]
k = data[1]
i = 0
paswd = []
while i < N:
	paswd.append(len(input()))
	i = i + 1
paswd.sort()
Rpaswd = len(input())
u = True
w = True
i = 0
time = 1
while len(paswd) > 0:
	if u and paswd[0] == Rpaswd:
		mtime = time
		u = False
	if len(paswd) > 1:
		w = not paswd[1] == Rpaswd
	if not u and (w or len(paswd) == 1):
		Mtime = time
		u = True
		break
	time = time + 1
	i = i + 1
	if i % k == 0:
		time = time + 5
	paswd.pop(0)
print(str(mtime) + ' ' + str(Mtime))


(n, k) = map(int, input().split())
l = []
mini = 1
maxi = 0
for i in range(n):
	l.append(len(input()))
passw = len(input())
l.sort()
a = l.index(passw) + 1
b = n - l[::-1].index(passw)
print(a + (a - 1) // k * 5, b + (b - 1) // k * 5)


import math
import sys
(n, k) = input().split()
n = int(n)
k = int(k)
A = [0] * 200
for i in range(200):
	A[i] = [0] * 200
for i in range(n):
	A[i] = input()
a = input()
size = len(a)
b = [0] * 200
for i in range(n):
	b[i] = len(A[i])
b = b[0:n]
b.sort()
print(int(b.index(size) / k) * 5 + b.index(size) + 1)
b.sort(reverse=True)
print(int((n - b.index(size) - 1) / k) * 5 + n - b.index(size))


(n, k) = map(int, input().split())
l = []
for i in range(n):
	s = input()
	l.append(s)
p = input()
l.remove(p)
l.append(p)
c = 0
d = 0
for i in l:
	if len(i) >= len(p):
		continue
	if len(i) < len(p):
		c += 1
		d += 1
	if d % k == 0 and d != 0:
		c += 5
c += 1
e = 0
d = 0
for i in l:
	if len(i) > len(p):
		continue
	if len(i) <= len(p):
		e += 1
		d += 1
	if d % k == 0 and i != p:
		e += 5
print(c, e)


(n, k) = map(int, input().split())
a = []
for i in range(n):
	s = input().rstrip()
	a.append((len(s), s))
s1 = input().rstrip()
a.sort()
time = 0
ans1 = ans2 = 10 ** 13
for i in range(n):
	time += 1
	if a[i][0] == len(s1):
		ans1 = min(ans1, time)
	if i == n - 1 or a[i + 1][0] > len(s1):
		ans2 = min(ans2, time)
	if (i + 1) % k == 0:
		time += 5
ans2 = min(ans2, time)
print(ans1, ans2)


import bisect
(n, k) = map(int, input().split())
x = n
l = []
p = []
while x:
	s = input()
	l.append(s)
	bisect.insort(p, len(s))
	x = x - 1
an = input()
ans = []
if n <= k:
	ans.append(bisect.bisect_left(p, len(an)) + 1)
	ans.append(bisect.bisect_right(p, len(an)))
else:
	t = bisect.bisect_left(p, len(an))
	y = int(t / k)
	o = t + y * 5
	ans.append(o + 1)
	r = bisect.bisect_right(p, len(an)) - 1
	z = int(r / k)
	ans.append(r + 1 + z * 5)
print(*ans)


(n, k) = [int(x) for x in input().split()]
passwords = []
for i in range(n):
	passwords.append(input())
password = input()
num1 = 0
num2 = 0
for i in passwords:
	if len(i) < len(password):
		num1 = num1 + 1
	elif len(i) == len(password):
		num2 = num2 + 1
print(num1 // k * 5 + num1 + 1, (num1 + num2 - 1) // k * 5 + num1 + num2)


[n, k] = [int(item) for item in input().split(' ')]
c = [0] * 1000
for _ in range(n):
	c[len(input())] += 1
m = len(input())
s = 0
for i in range(m):
	s += c[i]
a = s
s += c[m]
best_penalty = a // k * 5 + a + 1
worst_penalty = (s - 1) // k * 5 + s
print(best_penalty, worst_penalty)


(n, k) = map(int, input().split())
isThereExtraTime = True
if k >= n:
	isThereExtraTime = False
passwords = []
for i in range(n):
	passwords.append(input())
actualPassword = input()
pwdLengths = []
for i in passwords:
	pwdLengths.append(len(i))
x = list(sorted(zip(pwdLengths, passwords)))
passwords = [j for (i, j) in x]
for i in range(n):
	if len(passwords[i]) == len(actualPassword):
		bestCase = i + 1
		break
for i in range(n):
	if len(passwords[i]) == len(actualPassword):
		worstCase = i + 1
x = (bestCase - 1) // k
y = (worstCase - 1) // k
if isThereExtraTime:
	if bestCase > k:
		bestCase += 5 * x
	worstCase += 5 * y
print(bestCase, end=' ')
print(worstCase)


(num_pass, num_tries) = input().split()
pass_list = []
for i in range(int(num_pass)):
	pass_list.append(input())
correct_pass = input()
pass_list.sort(key=lambda x: (len(x), x == correct_pass))
max_time = 0
min_time = 0
if len(pass_list[0]) == len(correct_pass):
	min_time += 1
else:
	count = 0
	for i in pass_list:
		min_time += 1
		count += 1
		if len(i) == len(correct_pass):
			break
		if count == int(num_tries):
			min_time += 5
			count = 0
max_count = 0
for i in pass_list:
	max_time += 1
	max_count += 1
	if i == correct_pass:
		break
	if max_count == int(num_tries):
		max_time += 5
		max_count = 0
print(min_time, max_time)


(n, k) = map(int, input().split())
ps = []
for i in range(0, n):
	ps.append(input())
pwd = input()
ps.sort(key=lambda p: len(p))
c = sum((len(p) < len(pwd) for p in ps))
mn = c + c // k * 5 + 1
c = sum((len(p) <= len(pwd) for p in ps))
mx = c + (c - 1) // k * 5
print('%d %d' % (mn, mx))


def solution(passwords, correct_pass, k):
	n1 = n2 = 0
	for x in passwords:
		if x < correct_pass:
			n1 += 1
		elif x == correct_pass:
			n2 += 1
	print(n1 + n1 // k * 5 + 1, n2 + (n1 + n2 - 1) // k * 5 + n1)

def main():
	(p, q) = map(int, input().split())
	passwords = []
	for i in range(p):
		passwords.append(len(input()))
	correct_pass = len(input())
	solution(passwords, correct_pass, q)
main()


class CodeforcesTask721BSolution:

	def __init__(self):
		self.result = ''
		self.n_k = []
		self.passwords = []
		self.valid = ''

	def read_input(self):
		self.n_k = [int(x) for x in input().split(' ')]
		for x in range(self.n_k[0]):
			self.passwords.append(input())
		self.valid = input()

	def process_task(self):
		opt_pass = sum([1 for x in self.passwords if len(x) < len(self.valid)])
		pess_pass = sum([1 for x in self.passwords if len(x) <= len(self.valid)]) - 1
		opt_time = opt_pass + opt_pass // self.n_k[1] * 5 + 1
		pess_time = pess_pass + pess_pass // self.n_k[1] * 5 + 1
		self.result = '{0} {1}'.format(opt_time, pess_time)

	def get_result(self):
		return self.result
Solution = CodeforcesTask721BSolution()
Solution.read_input()
Solution.process_task()
print(Solution.get_result())


(n, k) = map(int, input().split())
password = []
for i in range(n):
	s = input()
	password.append(s)
res = input()
(lower, upper) = (0, 0)
for i in range(n):
	lower += len(password[i]) < len(res)
	upper += len(password[i]) <= len(res)
print(lower + lower // k * 5 + 1, upper + (upper - 1) // k * 5)


(n, k) = map(int, input().split())
ms = []
ans = []
for i in range(n):
	a = input()
	ms.append([a, len(a)])
prav = input()
lenp = len(prav)
ms.sort(key=lambda x: x[1])
for i in range(n):
	s = ms[i][0]
	dl = len(s)
	if dl == lenp:
		ans.append(i + 1 + i // k * 5)
		break
f = False
for i in range(n):
	s = ms[i][0]
	dl = len(s)
	if dl == lenp:
		f = True
	if dl != lenp and f:
		ans.append(i + (i - 1) // k * 5)
		break
if f and len(ans) == 1:
	ans.append((n - 1) // k * 5 + n)
print(*ans)


(n, k) = [int(x) for x in input().split()]
passes = [input() for _ in range(n)]
password = input()
l = len([p for p in passes if len(p) < len(password)]) + 1
h = len([p for p in passes if len(p) <= len(password)])
l += (l - 1) // k * 5
h += (h - 1) // k * 5
print(l, h)


(n, k) = map(int, input().split())
a = []

def min(a, b):
	if a < b:
		return a
	return b
for i in range(n):
	s = input()
	a.append((len(s), s))
s1 = input()
a.sort()
time = 0
ans1 = ans2 = 10 ** 15
for i in range(n):
	time += 1
	if a[i][0] == len(s1):
		ans1 = min(ans1, time)
	if i == n - 1 or a[i + 1][0] > len(s1):
		ans2 = min(ans2, time)
	if (i + 1) % k == 0:
		time += 5
ans2 = min(ans2, time)
print(ans1, ans2)


def find_pos(correct_len, len_list):
	pos = 0
	for i in range(correct_len):
		pos += len_list[i]
	return (pos + 1, pos + len_list[correct_len])

def find_time(pos, k):
	pauses = int((pos - 1) / k)
	return pauses * 5 + pos
N = 102
(n, k) = [int(x) for x in input().strip().split(' ')]
l = [0] * N
for x in range(n):
	l[len(input().strip())] += 1
correct_len = len(input().strip())
(best_pos, worst_pos) = find_pos(correct_len, l)
print('%d %d' % (find_time(best_pos, k), find_time(worst_pos, k)))


(n, k) = map(int, input().split())
cnt = [0] * 101
for i in range(n):
	temp = input()
	length = len(temp)
	cnt[length] += 1
s = input()
Min = Max = 0
length = len(s)
for i in range(length):
	Min += cnt[i]
Min += Min // k * 5
Min += 1
for i in range(length + 1):
	Max += cnt[i]
Max -= 1
Max += Max // k * 5
Max += 1
print(Min, Max)


(n, k) = map(int, input().split())
l = []
for i in range(n):
	l.append(input())
s = input()
d = len(s)
(x, y) = (0, 0)
for i in l:
	if len(i) < d:
		x = x + 1
	if len(i) == d and i != s:
		y = y + 1
xx = x + x // k * 5
yy = x + y + (x + y) // k * 5
print(xx + 1, yy + 1)


(n, k) = map(int, input().split())
pws = [input() for _ in range(n)]
p = input()
(l, e) = (0, 0)
for i in range(n):
	if len(pws[i]) == len(p):
		e += 1
	elif len(pws[i]) < len(p):
		l += 1
e -= 1
tm = lambda x: x // k * 5 + x + 1
print(tm(l), tm(l + e))


__author__ = 'Azad'
(n, k) = map(int, input().split())
l = []
for x in range(n):
	l.append(input())
p = input()
y = len(p)
l.sort(key=len)
l = [x for x in l if len(x) <= y]
mini = [x for x in l if len(x) <= y - 1]
time = int(len(mini) / k)
t = int((len(l) - 1) / k)
print(time * 5 + len(mini) + 1, end=' ')
print(t * 5 + len(l))


(n, k) = map(int, input().split())
a = list()
for i in range(n):
	a.append(input())
s = input()
p = q = 0
for i in range(n):
	if len(a[i]) < len(s) and a[i] != s:
		p += 1
		q += 1
	elif len(a[i]) == len(s) and a[i] != s:
		q += 1
p += 5 * round((p - p % k) / k)
p += 1
q += 5 * round((q - q % k) / k)
q += 1
print(p, q)


a = input().split(' ')
n = int(a[0])
k = int(a[1])
a = []
for i in range(n):
	a.append(len(input()))
a.sort()
tar = len(input())
res_min = 0
res_max = 0
for i in range(n):
	if a[i] == tar and (i == 0 or a[i - 1] != tar):
		t = i + 1
		res_min = t
		if t % k == 0:
			res_min += (t // k - 1) * 5
		else:
			res_min += t // k * 5
	if a[i] == tar and (i == n - 1 or a[i + 1] > tar):
		t = i + 1
		res_max = t
		if t % k == 0:
			res_max += (t // k - 1) * 5
		else:
			res_max += t // k * 5
print(res_min, res_max)


[n, k] = [int(x) for x in input().split()]
a = []
for i in range(n):
	a.append(len(input()))
d = len(input())
a.sort()
mi = 0
ma = n
for i in range(n):
	if a[i] == d and mi == 0:
		mi = i + 1
	if a[i] > d and ma == n:
		ma = i
		break
if mi % k == 0:
	mi += 5 * (mi // k) - 5
else:
	mi += 5 * (mi // k)
if ma % k == 0:
	ma += 5 * (ma // k) - 5
else:
	ma += 5 * (ma // k)
print(mi)
print(ma)


(n, k) = map(int, input().split())
dat = [len(input()) for i in range(n)]
p = len(input())
mi = sum(map(lambda x: x < p, dat))
ma = mi + sum(map(lambda x: x == p, dat)) - 1
print(mi + mi // k * 5 + 1, end=' ')
print(ma + ma // k * 5 + 1)


from collections import defaultdict
(n, k) = map(int, input().split())
arr = []
for _ in range(n):
	arr.append(input())
real_pass = input()
arr = sorted(arr, key=len)
flag = 0
best = 0
worst = 0
for i in range(1, n + 1):
	if len(arr[i - 1]) == len(real_pass):
		if flag == 0:
			best += 1
			flag = 1
	if len(real_pass) < len(arr[i - 1]):
		break
	if i % k == 0:
		if flag == 0:
			best += 5
		if i != n:
			if len(arr[i]) <= len(real_pass):
				worst += 5
	if flag == 0:
		best += 1
	worst += 1
print(best, worst)


def PositionLast(x, s):
	return next((i for (i, j) in list(enumerate(s))[::-1] if j == x))
(n, k) = [int(i) for i in input().split()]
arr = []
for i in range(n):
	st = input()
	arr.append(len(st))
b = input()
arr.sort()
len_b = len(b)
print(arr.index(len_b) // k * 5 + 1 + arr.index(len_b), PositionLast(len_b, arr) + PositionLast(len_b, arr) // k * 5 + 1)