Harryxun/stf_run huggingface dataset:
N = int(input())
SP = [list(map(int, input().split())) for i in range(N)]

sorted_SP = sorted(SP, key=lambda x:x[1], reverse=True)
sorted_SP = sorted(sorted_SP, key=lambda x:x[0])

for i in range(N):
  for j in range(N):
    if SP[i][0] == sorted_SP[j][0] and SP[i][1] == sorted_SP[j][1]:
      print(j+1)
      break


### FIXED CODE ###

N = int(input())
SP = [list(input().split()) for i in range(N)]

sorted_SP = sorted(SP, key=lambda x:int(x[1]), reverse=True)
sorted_SP = sorted(sorted_SP, key=lambda x:x[0])

for i in range(N):
  for j in range(N):
    if sorted_SP[i][0] == SP[j][0] and sorted_SP[i][1] == SP[j][1]:
      print(j+1)
      break
N,*A = map(int, open(0).read().split())
group = [0] * 3
ans = 1
for x in A:
    ans = (ans*group.count(x)) % (10**9+7)
    group[group.index(x)] += 1
print(ans)

### FIXED CODE ###

N,*A = map(int, open(0).read().split())
group = [0] * 3
ans = 1
for x in A:
    ans = (ans*group.count(x)) % 1000000007
    if ans == 0:
        print(0)
        break
    else:
        group[group.index(x)] += 1
else:
    print(ans)
n, k = map(int, input().split())

t = []
d = k
while(True):
  d = d / 2
  t.append(d)
  if d <= 1:
    break
# print(t)

t2 = []
nn = 1+n if n < k else n-k
for i in range(1, nn):
  for j in range(len(t)):
    if i >= t[j]:
      t2.append(j+1)
      break
# print(t2)

t3 = [0.5]
for i in range(1, len(t2)+2):
  t3.append(t3[i-1]*0.5)
# print(t3)

r = 0
for t in t2:
  r += t3[t-1]
r /= n
if n >= k:
  r += k / n
print(r)

### FIXED CODE ###

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

r = 0
for i in range(1, 1+n):
  t = i
  p = 1.0
  while(True):
    if t >= k:
      r += p
      break
    t *= 2
    p *= 0.5
print(r/n)
import math
a_h, b_m, hour, minute = map(int, input().split(" "))
pi = math.pi
arg_h = hour * 30 + minute * 0.5
arg_m = minute * 6

diff_arg_abs = abs(arg_h - arg_m)
if diff_arg_abs > 180:
    diff_arg = diff_arg_abs -180
    print(diff_arg)
elif diff_arg_abs < 180:
    diff_arg = diff_arg_abs
    print(diff_arg)
else:
    print(0)
    exit
    
ans_square = a_h**2 + b_m**2 - 2 * a_h * b_m * math.cos(math.radians(diff_arg)) 
ans = math.sqrt(ans_square)
print(ans)

### FIXED CODE ###

import math
a_h, b_m, hour, minute = map(int, input().split(" "))
pi = math.pi
arg_h = (hour + minute/60) * 360/12
arg_m = minute * 360/60

diff_arg = abs(arg_h - arg_m)
ans_square = a_h**2 + b_m**2 - 2 * a_h * b_m * math.cos(math.radians(diff_arg)) 
ans = math.sqrt(ans_square)
print(ans)
n = int(input())
a = []
for i in range(n):
  a.append(int(input()))
amax = max(a)
amax_id = a.index(amax)
amax2 = max(a.pop(amax_id))
for i in range(n):
  if i == amax_id:
    print(amax2)
  else:
    print(amax)

### FIXED CODE ###

n = int(input())
a = []
for i in range(n):
  a.append(int(input()))
amax = max(a)
amax_id = int(a.index(amax))
a.pop(amax_id)
amax2 = max(a)
for i in range(n):
  if i == amax_id:
    print(amax2)
  else:
    print(amax)
if a='H' and b='H':print(H)
elif a='D' and b='D':print(H)
else:print(D)

### FIXED CODE ###

a, b = input().split()

if a=='H' and b=='H':print('H')
elif a=='D' and b=='D':print('H')
else:print('D')
import sys

read = sys.stdin.read
readline = sys.stdin.readline

N, M, *A = map(int, read().split())
A = tuple(zip(*[iter(A)] * M))

# 各スポーツに参加している人数
p = [0] * (M + 1)
# 人iはn番目に好きなスポーツに参加している
sports = [0] * (N + 1)
answer = []


def solve(s, n, p, sports):
    # nは開催しているスポーツの数
    # sは新たに開催をやめるスポーツ
    p[s] = 0
    if n == M:
        for i in A:
            p[i[0]] += 1
        p_max = max(p)
        answer.append(p_max)
        cancel = p.index(p_max)
        solve(cancel, n - 1, p, sports)
    elif n == 1:
        answer.append(N)
    else:
        for idx, i in enumerate(A, 1):
            if i[sports[idx]] == s:
                sports[idx] += 1
                p[i[sports[idx]]] += 1
        p_max = max(p)
        answer.append(p_max)
        cancel = p.index(p_max)
        solve(cancel, n - 1, p, sports)


solve(0, M, p, sports)
print(min(answer))


### FIXED CODE ###

import sys

read = sys.stdin.read
readline = sys.stdin.readline

N, M, *A = map(int, read().split())
A = list(map(list, map(reversed, zip(*[iter(A)] * M))))

# 各スポーツに参加している人数
p = [0] * (M + 1)
canceled = set()
answer = []


def solve(s, n):
    # nは開催しているスポーツの数
    # sは新たに開催をやめるスポーツ
    if n == 1:
        answer.append(N)
    elif n == M:
        for i in A:
            p[i[-1]] += 1
        p_max = max(p)
        answer.append(p_max)
        cancel = p.index(p_max)
        solve(cancel, n - 1)
    else:
        canceled.add(s)
        p[s] = 0
        for i in range(N):
            if A[i][-1] in canceled:
                while A[i][-1] in canceled:
                    A[i].pop()
                p[A[i][-1]] += 1
        p_max = max(p)
        answer.append(p_max)
        cancel = p.index(p_max)
        solve(cancel, n - 1)


solve(0, M)
print(min(answer))
s = input()
k = int(input())
def ss(s,k):
    M=len(s)
    sss=set()
    for i in range(M):
        for j in range(i+1,M+1):
            tmp = s[i:j]
            sss.update(tmp)
    l = list(sss)
    l.sort()
    #print(l)
    ret = l[k-1]
    return(ret)
 
res=ss(s,k)
print(res)

### FIXED CODE ###

s = input()
k = int(input())

M=len(s)
sss=set()
for i in range(M):
    for j in range(i+1,i+k+1):
        tmp = s[i:j]
        sss.add(tmp)
l = list(sss)
l.sort()
print(l[k-1])
a = input().split(" ")
b = {"A":11,"B":12,"C":13,"D":14,"E":15:"F":16}

if b[a[0]] == b[a[1]]:
  print("=")
elif b[a[0]] < b[a[1]]:
  print("<")
else:
  print(">")

### FIXED CODE ###

a = input().split(" ")
b = {"A":11,"B":12,"C":13,"D":14,"E":15,"F":16}

if b[a[0]] == b[a[1]]:
  print("=")
elif b[a[0]] < b[a[1]]:
  print("<")
else:
  print(">")
import math
a,b = map(int, input().split())
ans = 1
count = 2
num = math.gcd(a,b)

while True:
    if num==1:
        print(ans)
        exit()
    else:
        if num%count==0:
            ans+=1
            while num%count==0:
                num= num/count
            count+=1
        else:
            count+=1


### FIXED CODE ###

from fractions import gcd
a,b = map(int, input().split())
# ans = 1
count = 2
n=gcd(a,b)

ans = set([1])
while n % 2 == 0:
    ans.add(2)
    n //= 2
f = 3
while f * f <= n:
    if n % f == 0:
        ans.add(f)
        n //= f
    else:
        f += 2
if n != 1:
    ans.add(n)
print(len(ans))
def make_divisors(n):
    divisors = []
    for i in range(2, int(n**0.5) + 1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n // i)
    return divisors


def furui(data):
    for d in data:
        data = [x for x in data if (x == d or x % d != 0)]
    return data


a, b = map(int, input().split())
# a, b = 100000000000000, 1000000000000000
a = make_divisors(a)
a = furui(a)
b = make_divisors(b)
b = furui(b)
print(len(set(a) & set(b)) + 1)


### FIXED CODE ###

from collections import defaultdict

A, B = map(int, input().split())


def gcd(a, b):
    return a if b == 0 else gcd(b, a % b)


d = gcd(A, B)
# print(d)


def f(v):
    dic = defaultdict(int)
    if v == 1:
        dic[1] = 1
        return dic
    for i in range(2, v):
        if i * i > v:
            break
        while v % i == 0:
            v //= i
            dic[i] += 1
    if v != 1:
        dic[v] += 1
    dic[1] = 1
    return dic


divisor = f(d)
# print(divisor)
print(len(divisor))
from collections import Counter


def main():
    n = int(input())
    cnt = Counter()
    ans = 0
    for i in range(n):
        s = sorted(input())

        if cnt[s] == 0:
            cnt[s] = 1
        else:
            ans += cnt[s]
            cnt[s] += 1
    print(ans)


if __name__ == "__main__":
    main()


### FIXED CODE ###

from collections import Counter


def main():
    n = int(input())
    cnt = Counter()
    ans = 0
    for i in range(n):
        s = "".join(sorted(input()))
        if cnt[s] == 0:
            cnt[s] = 1
        else:
            ans += cnt[s]
            cnt[s] += 1
    print(ans)


if __name__ == "__main__":
    main()
N = int(input())
H = [int(x) for x in input().split()]

ans = []
c = 0
for i in range(N - 1):
  if H[i] >= H[i + 1]:
    c += 1
    if i == N - 2:
      ans.append(c)
  elif H[i] < H[i + 1]:
    ans.append(c)
    c = 0
  
print(max(ans))

### FIXED CODE ###

N = int(input())
H = [int(x) for x in input().split()]

if N == 1:
  print(0)
else:
  ans = []
  c = 0
  for i in range(N - 1):
    if H[i] >= H[i + 1]:
      c += 1
      if i == N - 2:
        ans.append(c)
    elif H[i] < H[i + 1]:
      ans.append(c)
      c = 0
  print(max(ans))
X, Y = map(int, input().split())
ans = 'No'
    for a in range(X + 1):
        b = X - a
        if 2 * a + 4 * b == Y:
        ans = 'Yes'
print(ans)

### FIXED CODE ###

x,y = map(int,input().split())
kame=(y//2)-x
if y%2!=0:
    print("No")
elif (kame>=0)&(kame<=x):
    print("Yes")
else:
    print("No")
a = []

for i in range(5):
    a.append(int(input()))


def ceil10(n):
    if n % 10 == 0:
        return n
    else:
        return ((n // 10) + 1) * 10


def min_1(a):
    a2 = list(filter(lambda a: a > 0, (map(lambda e: e % 10, a))))

    return min(a2)


ans = sum(map(ceil10, a)) - 10 + min_1(a)
print(ans)


### FIXED CODE ###

a = []

for i in range(5):
    a.append(int(input()))


def ceil10(n):
    if n % 10 == 0:
        return n
    else:
        return ((n // 10) + 1) * 10


def min_1(a):
    a2 = list(filter(lambda a: a > 0, list(map(lambda e: e % 10, a))))

    if len(a2) == 0:
        return 10

    return min(a2)


ans = sum(map(ceil10, a)) - 10 + min_1(a)
print(ans)
from collections import defaultdict
def root(uft, x):
    if uft[x] == x: return x
    uft[x] = root(uft, uft[x])
    return uft[x]

def union(uft, x, y):
    x = root(uft, x)
    y = root(uft, y)
    if x == y:
        return
    uft[x] = y

def answer():
    n, m, k = map(int, input().split())
    friend = defaultdict(set)
    block = defaultdict(set)
    group = defaultdict(set)
    uft = [i for i in range(n+1)]
    for i in range(m):
        a, b = map(int, input().split())
        friend[a].add(b)
        friend[b].add(a)
    for j in range(k):
        c, d = map(int, input().split())
        block[c].add(d)
        block[d].add(c)
    for i in range(1, n+1):
        for j in friend[i]:
            union(uft, j, i)
    for i in range(1, n+1):
        group[root(uft, i)].add(i)
    return ' '.join(str(len(group[uft[i]]-friend[i]-block[i])-1) for i in range(1, n+1))

print(answer())



### FIXED CODE ###

from collections import defaultdict, Counter
import sys

def root(uft, x):
    if uft[x] == x: return x
    uft[x] = root(uft, uft[x])
    return uft[x]

def union(uft, rank, x, y):
    x = root(uft, x)
    y = root(uft, y)
    if x == y:
        return

    if rank[x] >= rank[y]:
        uft[y] = x
        if rank[x] == rank[y]:
            rank[x] += 1
    else:
        uft[x] = y

def same(uft, x, y):
    return root(uft, x) == root(uft, y)

def answer():
    n, m, k = map(int, input().split())
    friend = defaultdict(int)
    block = defaultdict(int)
    group = defaultdict(set)
    uft = [i for i in range(n+1)]
    rank = [0] * (n+1)
    for i in range(m):
        a, b = map(int, input().split())
        union(uft, rank, a, b)
        friend[a] += 1
        friend[b] += 1
    for j in range(k):
        c, d = map(int, input().split())
        if not same(uft, c, d):
            continue
        block[c] += 1
        block[d] += 1
    for i in range(1, n+1):
        root(uft, i)
    c = Counter(uft)
    return [c[uft[i]]-block[i]-friend[i]-1 for i in range(1, n+1)]

print(*answer())
a,b,c,d,e,f=map(int,input().split())
a*=100
b*=100
x=set()
for i in range(f//a+2):
    for j in range(f//b+2):
        if 0<(a*i+b*j)<=f:
            x.add(a*i+b*j)
y=set()
for i in range(f//c+2):
    for j in range(f//d+2):
        if 0<(c*i+d*j)<=f:
            y.add(c*i+d*j)

ans=[]
noudoma=e/100
for n in x:
    for m in y:
        if n==0:
            continue
        if m/n<=noudoma and (n+m)<=f:
            ans.append([n+m,m,m/(n+m)])

ans.sort(key=lambda x:x[2], reverse=True)


print(ans[0][0],ans[0][1])


### FIXED CODE ###

a,b,c,d,e,f=map(int,input().split())
a*=100
b*=100
x=set()
for i in range(0,f+1,a):
    for j in range(0,f+1,b):
        if 0<(i+j)<=f:
            x.add(i+j)
y=set()
for i in range(0,f+1,c):
    for j in range(0,f+1,d):
        if 0<(i+j)<=f:
            y.add(i+j)

ans=[]
for n in x:
    for m in y:
        if n+m>f:
            continue
        if n*e<m*100:
            continue
        ans.append([n+m,m,m/n])
if not ans:
    print(a,0)
    exit()
ans.sort(key=lambda x:x[2], reverse=True)

print(ans[0][0],ans[0][1])
n = int(input())
b = int(x) for x in input().split()
a = list(b)
x = 0
for i in range(n):
    if a.count(a[i]) >= 2:
        print("No")
        x = 1
        break

if x == 0:
    print("Yes")


### FIXED CODE ###

n = int(input())
a = list(int(x) for x in input().split())
x = 0
 
a.sort()
for i in range(n-1):
    if a[-1] - a[-2] == 0:
        print("NO")
        x = 1
        break
    a.pop()
 
if x == 0:
    print("YES")
a=input()
b=int(a)
c=b%1000
if c=0:
  print(0)
  else print(c)

### FIXED CODE ###

N=int(input())
if  N % 1000 == 0:
  print(0)
else:
    print(1000 - N % 1000)
#!/usr/bin/env python3
import sys
from collections.abc import Iterable
from math import *
from itertools import *
from collections import *
from functools import *
from operator import *
try:
    from math import gcd
except Exception:
    from fractions import gcd


def solve(N: int):
    ret = 0

    for i in range(1, int(sqrt(N)) + 1):
        if N % i != 0:
            continue

        m = (N // i) - 1
        if (N // m) == (N % m):
            ret += m
    return ret


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    result = solve(N)
    if isinstance(result, Iterable):
        result = '\n'.join([str(v) for v in result])
    print(result)

if __name__ == '__main__':
    main()


### FIXED CODE ###

#!/usr/bin/env python3
import sys
from collections.abc import Iterable
from math import *
from itertools import *
from collections import *
from functools import *
from operator import *
try:
    from math import gcd
except Exception:
    from fractions import gcd


def solve(N: int):
    ret = 0

    for i in range(1, int(sqrt(N)) + 1):
        m = (N-1) // i
        if m == 0:
            continue
        if (N // m) == (N % m):
            ret += m
    return ret


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    result = solve(N)
    if isinstance(result, Iterable):
        result = '\n'.join([str(v) for v in result])
    print(result)

if __name__ == '__main__':
    main()
N, D = map(int, input().split())
cnt =0
for _ in range(N):
    a, b = map(int, input().split())
    if np.sqrt(a**2+b**2)<=D:
        cnt+=1
print(cnt)

### FIXED CODE ###

import numpy as np
N, D = map(int, input().split())
cnt =0
for _ in range(N):
    a, b = map(int, input().split())
    if np.sqrt(a**2+b**2)<=D:
        cnt+=1
print(cnt)
while True:
    if "-"in inputEnzan or "+"in inputEnzan or "*"in inputEnzan :
        index=0
        while index <len(inputEnzan):
            if inputEnzan[index]=="-" or inputEnzan[index]=="+" or inputEnzan[index]=="*":
                if stack!=[]:
                    if inputEnzan[index]=="-":
                        inputEnzan[index]=stack[0]-stack[1]
                    elif inputEnzan[index]=="+":
                        inputEnzan[index]=stack[0]+stack[1]
                    else:
                        inputEnzan[index]=stack[0]*stack[1]
                    inputEnzan[index-1]="null"
                    inputEnzan[index-2]="null"
                    stack.clear()
                else:
                    pass
            else:
                stack.append(int(inputEnzan[index]))
                
            index+=1
        while True:
            if not "null" in inputEnzan:
                break
            inputEnzan.remove("null")   
    else:
        print(inputEnzan[0])
        break


### FIXED CODE ###

class stack:
    def __init__(self):
        self.s = []
    def push(self, x):
        self.s.append(x)
    def pop(self):
        ret = self.s[-1]
        del self.s[-1]
        return ret
    def size(self):
        return len(self.s)

inputL = input().split()
s = stack()
for char in inputL:
    if char == '+':
        b = s.pop()
        a = s.pop()
        s.push(a+b)
    elif char == '-':
        b = s.pop()
        a = s.pop()
        s.push(a-b)
    elif char == '*':
        b = s.pop()
        a = s.pop()
        s.push(a*b)
    elif char == '/':
        b = s.pop()
        a = s.pop()
        s.push(a/b)
    else:
        s.push(int(char))
print(s.pop())
#coding: utf-8
import numpy as np
import math
from functools import reduce

n,x = list(map(int,input().split()))

y = np.asarray(list(map(int,input().split())))
y -= x

print(reduce(math.gcd, y))


### FIXED CODE ###


#coding: utf-8
import numpy as np
from functools import reduce

def gcd(a, b):
    while b:
        a, b = b, a % b
    return a

n,x = list(map(int,input().split()))

y = np.asarray(list(map(int,input().split())))
y -= x
y = map(abs,y)

print(reduce(gcd, y))
#!/usr/bin/env python


def main():
    n = int(input())
    a = list(map(int, input().split()))
    b = list(map(int, input().split()))
    b = list(reversed(b))
    bad = next((x for x, y in zip(a, b) if x == y), None)
    if bad is None:
        print(' '.join(map(str, b)))
    else:
        l_1 = sum(1 for x, y in zip(a, b) if x < y and y != bad)
        l_2 = sum(1 for x, y in zip(a, b) if x < y and y == bad)
        l_3 = sum(1 for x, y in zip(a, b) if x == y)
        l_4 = sum(1 for x, y in zip(a, b) if x > y and x == bad)
        l_5 = sum(1 for x, y in zip(a, b) if x > y and x != bad)
        if l_3 > l_1 + l_5:
            print('No')
        else:
            good_part = b[:l_1] + b[l_1 + l_2 + l_3 + l_4:]
            bad_part = b[l_1 + l_2:l_1 + l_2 + l_3]
            b[l_1 + l_2:l_1 + l_2 + l_3] = good_part[:l_3]
            good_part[:l_3] = bad_part
            b[:l_1] = good_part[:l_1]
            b[l_1 + l_2 + l_3 + l_4:] = good_part[l_1:]
            assert all(x != y for x, y in zip(a, b))
            print('Yes')
            print(' '.join(map(str, b)))


if __name__ == '__main__':
    main()


### FIXED CODE ###

#!/usr/bin/env python


def main():
    n = int(input())
    a = list(map(int, input().split()))
    b = list(map(int, input().split()))
    b = list(reversed(b))
    bad = next((x for x, y in zip(a, b) if x == y), None)
    if bad is None:
        print('Yes')
        print(' '.join(map(str, b)))
    else:
        l_1 = sum(1 for x, y in zip(a, b) if x < bad < y)
        l_2 = sum(1 for x, y in zip(a, b) if x < y and bad in (x, y))
        l_3 = sum(1 for x, y in zip(a, b) if x == y)
        l_4 = sum(1 for x, y in zip(a, b) if x > y and bad in (x, y))
        l_5 = sum(1 for x, y in zip(a, b) if x > bad > y and x != bad)
        if l_3 > l_1 + l_5:
            print('No')
        else:
            good_part = b[:l_1] + b[l_1 + l_2 + l_3 + l_4:]
            bad_part = b[l_1 + l_2:l_1 + l_2 + l_3]
            b[l_1 + l_2:l_1 + l_2 + l_3] = good_part[:l_3]
            good_part[:l_3] = bad_part
            b[:l_1] = good_part[:l_1]
            b[l_1 + l_2 + l_3 + l_4:] = good_part[l_1:]
            assert all(x != y for x, y in zip(a, b))
            print('Yes')
            print(' '.join(map(str, b)))


if __name__ == '__main__':
    main()
import math

n = int(input())
a = 1

for b in range(n):
    b = int(input())
    a = a*b//math.gcd(a, b)

print(a)


### FIXED CODE ###

import fractions

n = int(input())
a = 1

for b in range(n):
    b = int(input())
    a = a*b//fractions.gcd(a, b)
print(a)
# encoding:utf-8
 
import fractions
 
def check(l):
	l = list(map(int, l.split()))
 
	if max(l) >= 30001:
		return False
	tmp = l[0]
 
	for i in range(len(l) - 1):
		tmp = fractions.gcd(tmp, l[i+1])
	if tmp != 1:
		return False 
 
	for i in range(len(l)):
		if fractions.gcd(l[i], sum(l) - l[i]) == 1:
			return False
 
	return True
 
 
def main(n):
	if n == 3:
		return "2 5 63"
	if n <= 5003:
		sub = [i * 3 for i in range(1, 10001) if i % 2 == 1]
		if n % 2 == 0:
			s = "2 4 " + " ".join([str(x) for x in sub[0:(n-2)]])
			return(s)
		else:
			s = "2 4 6 " + " ".join([str(x) for x in sub[0:(n-3)]])
			return(s)
	else:
		sub = [i * 3 for i in range(1, 10001) if i % 2 == 1]
		if n % 2 == 0:
			s = " ".join([str(i) for i in range(1, 30000) if i % 2 == 0 and i % 3 != 0][0:(n-5000)]) + " " +  " ".join([str(x) for x in sub])
			return(s)
		else:
			s = " ".join([str(i) for i in range(1, 30000) if i % 2 == 0 and i % 3 != 0][0:(n-5001)]) + " 6 " +  " ".join([str(x) for x in sub])
			return(s)
if __name__ == '__main__':
	n = int(input())
	print(main(n))
	#for i in range(5001, 30000):
	#	print(i, check(main(i)))

### FIXED CODE ###

# encoding:utf-8


def main(s):
	alphabet = "abcdefghijklmnopqrstuvwxyz"
	d = {alphabet[i]:i for i in range(26)}
	if s == "zyxwvutsrqponmlkjihgfedcba":
		print("-1")
	elif len(s) < 26:
		for i in range(26):
			if alphabet[i] not in s:
				print(s + alphabet[i])
				break
	else:
		tail = [d[s[25]]]
		for i in range(0, 25):
			if d[s[24 - i]] >= max(tail):
				tail.append(d[s[24 - i]])
				continue
			else:
				tmp = min([x for x in tail if x >= d[s[24-i]]])
				print(s[0:(24-i)] + alphabet[tmp])
				break


if __name__ == '__main__':
	s = input()
	main(s)
a,b = map(int,input().split())
a,b = a-1,b-1
grid_b = [list('#'*100) for _ in range(50)]
grid_w = [list('.'*100) for _ in range(50)]
for i in range(a):
    grid_b[2*(i//10)+1][2*(i%10)+1] = '.'
for i in range(b):
    grid_w[2*(i//10)+1][2*(i%10)+1] = '#'

grid = grid_b + grid_w

print(100, 100)
for g in grid:
    print(*g)


### FIXED CODE ###

a,b=map(int,input().split())
ans=[['#' for i in range(100)] for j in range(50)]
ans+=[['.' for i in range(100)] for j in range(50)]
for i in range(a-1):
    ans[(i//50)*2][(i%50)*2]='.'
for i in range(b-1):
    ans[(i//50)*2+52][(i%50)*2]='#'
print(100,100)
for i in range(100):
    print(''.join(ans[i]))
a,b = map(int,input().split())
k = [2,5,5,4,5,6,3,7,6]

c = list(map(int,input().split()))

c.sort()
cc = [[c[i],k[c[i]-1]] for i in range(b)]
ccc = [[c[i],k[c[i]-1]] for i in range(b)]
dp = [-1 for i in range(a+1)]
cc.sort(key = lambda x:x[1])
for j in range(b):
	for i in range(a+1):
		if cc[j][1] <= i:
			dp[i] = max(dp[i-cc[j][1]]+1,1,dp[i])

k = a
co = ''
for i in range(dp[a]):
	for j in range(b):
		if dp[k-ccc[j][1]] == dp[k]-1:
			co = str(ccc[j][0]) + co
			k -= ccc[j][1]
			break
print(co)

### FIXED CODE ###

a,b = map(int,input().split())
k = [2,5,5,4,5,6,3,7,6]

c = list(map(int,input().split()))

c.sort()
cc = [[c[i],k[c[i]-1]] for i in range(b)]
ccc = [[c[i],k[c[i]-1]] for i in range(b)]
dp = [-1 for i in range(a+1)]
dp[0] = 0
cc.sort(key = lambda x:x[1])
for j in range(b):
	for i in range(a+1):
		if i-cc[j][1] >= 0 and dp[i-cc[j][1]] >= 0:
			dp[i] = max(dp[i-cc[j][1]]+1,dp[i])
ccc.reverse()
k = a
co = ''
for i in range(dp[a]):
	for j in range(b):
		if k-ccc[j][1] >= 0 and dp[k-ccc[j][1]] == dp[k] - 1:
			co += str(ccc[j][0])
			k -= ccc[j][1]
			break
print(co)