file = open('24-s1.txt')
cnt, ans = 0, 0

for i, line in enumerate(file):
    cntLine = line.count('Q')
    if cntLine >= cnt:
        cnt, ans = cntLine, i


file.close()
file = open('24-s1.txt')
lines = [line[:-1] for line in file.readlines()]
cntSymb, ansSymb = float('inf'), ''

for s in set(lines[ans]):
    if (lines[ans].count(s) < cntSymb) or (lines[ans].count(s) == cntSymb and s < ansSymb):
        cntSymb, ansSymb = lines[ans].count(s), s
file.close()

file = open('24-s1.txt')
print(ansSymb, file.read().count(ansSymb))
file.close()

1a3513d4cfd3494d17031c56b5d1251d4a843dca
<mask token>

<mask token>
for i, line in enumerate(file):
    cntLine = line.count('Q')
    if cntLine >= cnt:
        cnt, ans = cntLine, i
file.close()
<mask token>
for s in set(lines[ans]):
    if lines[ans].count(s) < cntSymb or lines[ans].count(s
        ) == cntSymb and s < ansSymb:
        cntSymb, ansSymb = lines[ans].count(s), s
file.close()
<mask token>
print(ansSymb, file.read().count(ansSymb))
file.close()

file = open('24-s1.txt')
cnt, ans = 0, 0
for i, line in enumerate(file):
    cntLine = line.count('Q')
    if cntLine >= cnt:
        cnt, ans = cntLine, i
file.close()
file = open('24-s1.txt')
lines = [line[:-1] for line in file.readlines()]
cntSymb, ansSymb = float('inf'), ''
for s in set(lines[ans]):
    if lines[ans].count(s) < cntSymb or lines[ans].count(s
        ) == cntSymb and s < ansSymb:
        cntSymb, ansSymb = lines[ans].count(s), s
file.close()
file = open('24-s1.txt')
print(ansSymb, file.read().count(ansSymb))
file.close()

file = open('24-s1.txt')
cnt, ans = 0, 0

for i, line in enumerate(file):
    cntLine = line.count('Q')
    if cntLine >= cnt:
        cnt, ans = cntLine, i


file.close()
file = open('24-s1.txt')
lines = [line[:-1] for line in file.readlines()]
cntSymb, ansSymb = float('inf'), ''

for s in set(lines[ans]):
    if (lines[ans].count(s) < cntSymb) or (lines[ans].count(s) == cntSymb and s < ansSymb):
        cntSymb, ansSymb = lines[ans].count(s), s
file.close()

file = open('24-s1.txt')
print(ansSymb, file.read().count(ansSymb))
file.close()
