Harryxun/stf_run huggingface dataset:
import functools

def sign(x):
    if x>0:
        return 1
    elif x==0:
        return 0
    else:
        return -1

N,K = map(int,input().split())
A = list(map(int,input().split()))
A.sort()

if A[-1]<0 and K%2==1:
    combi = A[-K:]
    answer =  functools.reduce(lambda x,y: x*y%(10**9+7),map(abs,combi[-1]))
    answer *= combi[-1]
    answer %= 10**9+7
else:
    combi = []

    for i in range(K):
        if abs(A[0]) > abs(A[-1]):
            combi.insert(0,A.pop(0))
        else:
            combi.append(A.pop(-1))

    signs = functools.reduce(lambda x,y: x*y,map(sign,combi))

    if signs == -1:
        if combi[-1] <0:
            del combi[0]
            combi.append(A[-1])
        else:
            if A[0]>0:
                del combi[0]
                combi.append(A[-1])
            elif A[0]<0 and A[-1] >0:
                if combi[0]*A[0] > combi[-1]*A[-1]:
                    del combi[-1]
                    combi.insert(0,A[0])
                else:
                    del combi[0]
                    combi.append(A[-1])
            else:
                del combi[-1]
                combi.insert(0,A[0])

    answer =  functools.reduce(lambda x,y: x*y%(10**9+7),map(abs,combi))
print(answer)

### FIXED CODE ###

import functools

def sign(x):
    if x>0:
        return 1
    elif x==0:
        return 0
    else:
        return -1
    
def multiply(x,y):
    ans = x*y
    if ans>=10**9+7 or ans<0:
        ans %= (10**9+7)
    return ans

N,K = map(int,input().split())
A = list(map(int,input().split()))
A.sort()

if (A[-1]<0 and K%2==1):
    combi = A[-K:]
    if K >1:
        answer =  functools.reduce(multiply,combi)

elif K == N:
    answer = functools.reduce(multiply,A)
    
else:
    signs = 1
    i,j = 0,0
    for _ in range(K):
        if abs(A[i]) > abs(A[N-j-1]):
            signs *= sign(A[i])
            i += 1
            
        else:
            signs *= sign(A[N-j-1])
            j += 1
    combi = A[N-j:] + A[:i]
    del A[N-j:]
    del A[:i]
    combi = combi[::-1]     
       
    if signs == -1:
        if A:
            if combi[-1]<0:
                del combi[0]
                combi.append(A[-1])
            elif A[0]>=0:
                del combi[0]
                combi.append(A[-1])
            elif A[0]<0 and A[-1] >0:
                if combi[0]*A[0] > combi[-1]*A[-1]:
                    del combi[-1]
                    combi.insert(0,A[0])
                else:
                    del combi[0]
                    combi.append(A[-1])
            elif A[-1] <= 0:
                del combi[-1]
                combi.insert(0,A[0]) 
                
    answer =  functools.reduce(multiply,combi)
print(answer)
a = raw_input().split();
print((int(a[0])-1)*(int(a[1])-1));


### FIXED CODE ###

a=input().split();print((int(a[0])-1)*(int(a[1])-1));
import sys
def cur(i):
    if p[i]!=False: return p[i]
    if s[i]=="R":
        if s[i+1]=="L": p[i]=1
        else: p[i]=cur(i+1)+1
    if s[i]=="L":
        if s[i-1]=="R": p[i]=-1
        else: p[i]=cur(i-1)-1 
    return p[i]

s=input()
n=len(s)
p=[False for _ in range(n)]

for i in range(n):
    cur(i)
sys.exit()
ans=[0]*n
for i in range(n):
    if p[i]>0:
        ans[i+(p[i]//2)*2]+=1
    else: ans[i+p[i]+p[i]%2]+=1
print(*ans)

### FIXED CODE ###

import sys
s=input()
n=len(s)
p=[0 for _ in range(n)]

for i in range(n):
    if s[i]=="L": p[i]=p[i-1]-1 if s[i-1]=="L" else -1
for i in range(n-1,-1,-1):
    if s[i]=="R": p[i]=p[i+1]+1 if s[i+1]=="R" else 1

ans=[0]*n
for i in range(n):
    if p[i]>0:
        ans[i+(p[i]//2)*2]+=1
    else:
        if p[i]%2==0: ans[i+p[i]]+=1
        else: ans[i+p[i]+1]+=1
print(*ans)
h,w=map(int,input().split())
s=[list(input()) for i in range(h)]

dx=[0,1,0,-1]
dy=[1,0,-1,0]
for i in range(h):
    for j in range(w):
        if s[i][j]=='#':
            ans=False
            for k in range(4):
                nx = i+dx[k]
                ny = j+dy[k]
                if nx>=0 and nx <h and ny>=0 and ny<w and s[nx][ny]=='#':
                    ans = True
                    break
            if ans ==False:
                print('No')
                exit()
if ans:
    print('Yes')
            
                

### FIXED CODE ###

h,w=map(int,input().split())
s=[list(input()) for i in range(h)]

dx=[0,1,0,-1]
dy=[1,0,-1,0]
ans=True
for i in range(h):
    for j in range(w):
        if s[i][j]=='#':
            ans=False
            for k in range(4):
                nx = i+dx[k]
                ny = j+dy[k]
                if nx>=0 and nx <h and ny>=0 and ny<w and s[nx][ny]=='#':
                    ans = True
                    break
            if ans ==False:
                print('No')
                exit()
if ans:
    print('Yes')
c = input()
print(str(c+1))

### FIXED CODE ###

c = input()
print(chr(ord(c) + 1))
import itertools
N=int(input())
l=[]
for i in range(N):
  x,y,h=map(int,input().split())
  l.append([x,y,h])
s=list(itertools.product(range(0,101),repeat=2))
for A,B in itertools.combinations(range(N),2):
  if len(s)==1:
    break
  t=[]
  if l[A][2]<l[B][2]:
    A,B=B,A
  if l[A][2]>l[B][2]:
    if l[B][2]==0:
      gap=l[A][2]-l[B][2]
      for X,Y in s:
        if abs(X-l[A][0])+abs(Y-l[A][1])+gap<=abs(X-l[B][0])+abs(Y-l[B][1]):
          t.append((X,Y))
    else:
      gap=l[A][2]-l[B][2]
      for X,Y in s:
        if abs(X-l[A][0])+abs(Y-l[A][1])+gap==abs(X-l[B][0])+abs(Y-l[B][1]):
          t.append((X,Y))
  
  elif l[A][2]!=0:
    for X,Y in s:
      if abs(X-l[A][0])+abs(Y-l[A][1])==abs(X-l[B][0])+abs(Y-l[B][1]):
        t.append((X,Y))
  s=t[:]
a,b=s[0][0],s[0][1]
h=abs(a-l[0][0])+abs(b-l[0][1])+l[0][2]
print(a,b,h)

### FIXED CODE ###

import itertools
N=int(input())
l=[]
#l:調査情報のリスト
for i in range(N):
  x,y,h=map(int,input().split())
  l.append([x,y,h])
M=max(item[2] for item in l)#高さの最大値(暫定)
s=list(itertools.product(range(0,101),repeat=2))
#s:中心座標の候補リスト
for A,B in itertools.combinations(range(N),2):
  #調査情報の全ての2つ組を用いて絞り込む
  if len(s)==1:
    break
  t=[]
  #t:新たな中心座標の候補リスト
  if l[A][2]<l[B][2]:
    A,B=B,A
  if l[A][2]>l[B][2]:
    #2地点の高さが異なる場合
    if l[B][2]==0:
      #B地点の高さが0ならB地点は中心から[Aの高さ]以上離れている
      gap=l[A][2]-l[B][2]
      for X,Y in s:
        if abs(X-l[A][0])+abs(Y-l[A][1])+gap<=abs(X-l[B][0])+abs(Y-l[B][1]):
          t.append((X,Y))
    else:
      #B地点の高さが0でなければA地点は中心から[Aの高さ-Bの高さ]だけ離れている
      gap=l[A][2]-l[B][2]
      for X,Y in s:
        if abs(X-l[A][0])+abs(Y-l[A][1])+gap==abs(X-l[B][0])+abs(Y-l[B][1]):
          t.append((X,Y))
  
  elif l[A][2]!=0:
    #2地点の高さが等しく0ではない場合
    #2地点からM-[Aの高さ]以上離れた地点のみ残す
    for X,Y in s:
      MM=max(1,M-l[A][2])
      if abs(X-l[A][0])+abs(Y-l[A][1])==abs(X-l[B][0])+abs(Y-l[B][1]) and abs(X-l[A][0])+abs(Y-l[A][1])>=MM and abs(X-l[B][0])+abs(Y-l[B][1])>=MM:
        t.append((X,Y))
  else:
    #2地点の高さが等しく0の場合
    #2地点からM以上離れた地点のみ残す
    for X,Y in s:
      if abs(X-l[A][0])+abs(Y-l[A][1])>=M and abs(X-l[B][0])+abs(Y-l[B][1])>=M:
        t.append((X,Y))
  s=t[:]
#sの要素は唯一だと思いたい
a,b=s[0][0],s[0][1]
i=0
while l[i][2]==0:
  i+=1

h=abs(a-l[i][0])+abs(b-l[i][1])+l[i][2]
print(a,b,h)
H, W = map(int, input().split())
S = [input() for i in range(W)]
dd = ((0, -1), (-1, 0), (0, 1), (1, 0))
for i in range(H):
  for j in range(W):
    if S[i][j] == '.':
      continue
    for dx, dy in dd:
      nx = j + dx
      ny = i + dy
      if 0 <= nx < W and 0 <= ny < H:
        if S[ny][nx] == '#':
          break
    else:
      print('No')
      quit()
print('Yes')


### FIXED CODE ###

H, W = map(int, input().split())
S = [input() for i in range(H)]
dd = ((0, -1), (-1, 0), (0, 1), (1, 0))
for i in range(H):
  for j in range(W):
    if S[i][j] == '.':
      continue
    for dx, dy in dd:
      nx = j + dx
      ny = i + dy
      if 0 <= nx < W and 0 <= ny < H and S[ny][nx] == '#':
        break
    else:
      print('No')
      quit()
print('Yes')
n = int(input())
a = map(int,input().split(" "))
order = ""
for i in range(n):
  for j in a:
    if j == i+1:
      order += j + " "
print(order.rstrip)  

### FIXED CODE ###

import numpy as np
n = int(input())
a = list(map(int,input().split(" ")))
b = [0]*n
order = ""
for i in range(n):
	b[a[i]-1]= i+1
for i in b:
  order += str(i) + " "
order.rstrip
print(order)
(N, K) = list(map(int,input().split()))
P = list(map(int, input().split()))

def max_expected(L, K):
  length = len(L)
  if (length < K):
    return -1
  mid = length // 2
  s_left = max_expected(L[0:mid], K)
  #print("left array:{}, max: {}".format(L[0:mid], s_left))
  s_right = max_expected(L[mid:], K)
  #print("right array:{}, max: {}".format(L[mid:], s_right))
  offset = 0

  if (mid - K + 1 < 0):
    offset = - (mid - K + 1)
  end_offset = 0
  if (mid + K - 1 >= length):
    end_offset = mid + K - 1 - length
  max_p = sum(L[mid - K + 1 + offset:mid + 1 + offset])
  for i in range(mid - K + 1 + offset, mid - end_offset):
    j = sum(L[i:(i + K)])
    #print("{}[{}]..{}[{}]: {}".format(L[i], i, L[i + K - 1], i + K - 1, j))
    if max_p < j:
      max_p = j
  #print("mid: {}".format((max_p + K) / 2));
  
  return max((max_p + K) / 2, s_left, s_right)
print("{}".format(max_expected(P, K)))

### FIXED CODE ###

(N, K) = list(map(int,input().split()))
P = list(map(int, input().split()))

def max_expected(L, K):
  length = len(L)
  if (length < K):
    return -1
  if (length == K):
    return (sum(L) + K) / 2
  mid = length // 2
  s_left = max_expected(L[0:mid], K)
  s_right = max_expected(L[mid:], K)
  offset = 0

  if (mid - K + 1 < 0):
    offset = - (mid - K + 1)
  end_offset = 0
  if (mid + K - 1 >= length):
    end_offset = mid + K - 1 - length
  max_p = sum(L[mid - K + 1 + offset:mid + 1 + offset])
  prev = max_p
  for i in range(mid - K + 1 + offset + 1, mid - end_offset):
    prev = prev - L[i - 1] + L[i + K - 1]
    if max_p < prev:
      max_p = prev
  
  return max((max_p + K) / 2, s_left, s_right)
print("{}".format(max_expected(P, K)))
h,w,k = map(int,input().split())

cake = []
for i in range(h):
    x = list(input())
    cake.append(x)

ans = [[0]*w for _ in range(h)]

raw_ind = []

c = 1
for i in range(h):
    if cake[i].count('#') == 1:
        for j in range(w):
            ans[i][j] += c
        c = min(c+1,k)
    elif '#' in cake[i]:
        for j in range(w):
            if cake[i][j] =='.':
                ans[i][j] = c
            else:
                ans[i][j] = c
                c = min(c+1,k)
    else:
        raw_ind.append(i)

for x in raw_ind:
    j = 0
    while (x+j) in raw_ind and x+j <= h-1:
        j += 1
    if x+j == h:
        break
    for l in range(j):
        ans[x+l] = ans[x+j]

raw_ind = sorted(raw_ind, reverse =True)

for x in raw_ind:
    j = 0
    while (x-j) in raw_ind and x+j >= 0:
        j +=1
    if x+j == -1:
        break
    for l in range(j):
        if x-j >= 0:
            ans[x+l] = ans[x-j]


for i in range(h):
    print(*(ans[i]))

### FIXED CODE ###

h,w,k = map(int,input().split())

cake = []
for i in range(h):
    x = list(input())
    cake.append(x)

ans = [[0]*w for _ in range(h)]

c = 1
for i in range(h):
    if cake[i].count('#') == 1:
        for j in range(w):
            ans[i][j] += c
        c = min(c+1,k)
    elif '#' in cake[i]:
        ss = c
        s = cake[i].count('#')
        for j in range(w):
            if cake[i][j] =='.':
                ans[i][j] = c
            else:
                ans[i][j] = c
                c = min(c+1,ss+s-1)
        c = c+1

j = 0
while not '#' in cake[j]:
    j += 1

for l in range(j):
    ans[l] = ans[j]

for i in range(h):
    if min(ans[i]) == 0:
        ans[i] = ans[i-1]

for i in range(h):
    print(*(ans[i]))
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import heapq


def solve():
    N = int(input())
    A = []
    heads = []
    for _ in range(N):
        A.append(int(input()))
    a = A.pop()
    heapq.heappush(heads, -a)
    while A:
        a = A.pop()
        h = -heapq.heappop(heads)
        if a < h:
            for b in heads[::-1]:
                if - b > a:
                    heads.remove(b)
                    heapq.heappush(heads, -a)
                    break
        else:
            heapq.heappush(heads, -a)
            heapq.heappush(heads, -h)
    return len(heads)
  

def main():
    print(solve())


if __name__ == "__main__":
    main()


### FIXED CODE ###

#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import bisect as bi


def solve():
    N = int(input())
    A = []
    heads = []
    for _ in range(N):
        A.append(int(input()))
    a = A.pop()
    bi.insort(heads, a)
    while A:
        a = A.pop()
        if a < heads[-1]:
            j = bi.bisect(heads, a)
            del heads[j]
        bi.insort(heads, a)
    return len(heads)
  

def main():
    print(solve())


if __name__ == "__main__":
    main()
def solve():
    N, M = map(int, input().split())
        
    d = {}
    for i in range(M):
        s, c = map(int, input().split())
        if (s in d and d[s] != c) or (s == 1 and c == 0):
            return -1
        else:
            d[s] = c
    
    ans = [0] * N
    for key, val in d.items():
        ans[key - 1] = val

    if ans[0] == 0:
        ans[0] = 1
    ans = [str(c) for c in ans]

    return "".join(ans[i:])

print(solve())

### FIXED CODE ###

N, M = map(int, input().split())
sc = []
for i in range(M):
    sp, cp = map(int, input().split())
    sc.append((sp, cp))

ans = 10000

if N == 1:
    for i in range(10):
        num = str(i)
        flag = True
        for pair in sc:
            if (num[pair[0] - 1] != str(pair[1])):
                flag = False
                break
        if flag:
            ans = min(ans, i)
else:
    for i in range(10 ** (N - 1), 10 ** N):
        num = str(i)
        flag = True
        for pair in sc:
            if (num[pair[0] - 1] != str(pair[1])) or len(num) < pair[0]:
                flag = False
                break
        if flag:
            ans = min(ans, i)

if ans == 10000:
    ans = -1
print(ans)
n, k = map(int, input().split())
s = input()
cnt = 1
li = []
li2 = []
ind_R = []
ind_L = []
for i in range(n-1):
    if s[i] == s[i+1] and s[i] == "R":
        cnt += 1
    elif s[i] == s[i+1] and s[i] == "L":
        cnt += 1
    else:
        li.append((s[i], cnt))
        cnt = 1
li.append((s[i], cnt))
cut = len(li) - 1

print(min(n-1, n - cut - 1 + 2 * k))

### FIXED CODE ###

n, k = map(int, input().split())
s = input()
cnt = 1
li = []
for i in range(n-1):
    if s[i] == s[i+1] and s[i] == "R":
        cnt += 1
    elif s[i] == s[i+1] and s[i] == "L":
        cnt += 1
    else:
        li.append((s[i], cnt))
        cnt = 1
if n > 1:
   li.append((s[i], cnt))
cut = len(li) - 1

print(min(n-1, n - cut - 1 + 2 * k))
import copy
from collections import Counter

N, M, X = map(int, input().split())
CA = [list(map(int, input().split())) for _ in range(N)]

cc = 0
MM = 0
for ca in CA:
    cc += ca[0]

    if MM < max(ca[1:]):
        MM = max(ca[1:])

U = 10**5 * cc + 1

dp = []
for i in range(M):
    p_dp = [U for _ in range(MM * M + 1)]
    p_dp[0] = 0
    dp.append(p_dp)

for ca in CA:
    c = ca[0]
    a = ca[1:]

    for i, v in enumerate(a):
        p_dp = copy.deepcopy(dp)
        for j in range(MM * M + 1 - v):
            if dp[i][j] < U:
                dp[i][j + v] = min(p_dp[i][j + v], p_dp[i][j] + c)

ans_list = list(set(dp[0][X:]))

for i in range(1, M):
    ans_list = list(set(ans_list) & set(dp[i][X:]))

print(min(ans_list) if min(ans_list) < U else -1)


### FIXED CODE ###

import itertools

N, M, X = map(int, input().split())
CA = [list(map(int, input().split())) for _ in range(N)]

ans = []

for s in itertools.product(range(2), repeat=N):

    li = [0 for _ in range(M)]
    cum = 0
    for i, v in enumerate(s):
        if v == 1:
            ca = CA[i]
            cum += ca[0]

            for j, x in enumerate(ca[1:]):
                li[j] += x

        q = [p >= X for p in li]
        if all(q):
            ans.append(cum)

print(min(ans) if ans else -1)
N = int(input())
V = map(int, input().split())
C = map(int, input().split())

answer = 0
for i in range(N):
  if V[i] > C[i]:
    answer += V[i] - C[i]

print(int(answer))

### FIXED CODE ###

N = int(input())
V = list(map(int, input().split()))
C = list(map(int, input().split()))

answer = 0
for i in range(N):
  if V[i] > C[i]:
    answer += V[i] - C[i]

print(int(answer))
N = int(input())
y = x % 10

if y == 3:
  print('bon')
elif y == 0:
  print('pon')
elif y == 1:
  print('pon')
elif y == 6:
  print('pon')
elif y == 8:
  print('pon')
else:
  print('hon')


### FIXED CODE ###

x = int(input())
y = x%10
if y == 3:
  print("bon")
elif y == 0:
  print("pon")
elif y == 1:
  print("pon")
elif y == 6:
  print("pon")
elif y == 8:
  print("pon")
else:
  print("hon")
x = abs(int(input()))
total = 0
for i in range(x+1):
    total += i
    if total >= x:
        print(i)
        break

### FIXED CODE ###

arg = input().split(' ')
a = arg[0]
b = arg[1]

if a=='D':
    b = 'D' if b=='H' else 'H'
    
print(b)
N, M = map(int, input().split())
P = list(map(lambda x: int(x) - 1, input().split()))
rank = [0] * N
parent = [i for i in range(N)]


def find(i):
    if parent[i] == i:
        return i
    else:
        parent[i] = find(parent[i])
        return parent[i]


def same(x, y):
    return find(x) == find(y)


def unite(x, y):
    x = parent[x]
    y = parent[y]
    if x == y:
        return

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


for i in range(M):
    x, y = map(int, input().split())
    unite(x - 1, y - 1)

num = 0
for i in range(N):
    num += same(i, P[i])

print(num)

### FIXED CODE ###

N, M = map(int, input().split())
P = list(map(lambda x: int(x) - 1, input().split()))
rank = [0] * N
parent = [i for i in range(N)]


def find(i):
    if parent[i] == i:
        return i
    else:
        parent[i] = find(parent[i])
        return parent[i]


def same(x, y):
    return find(x) == find(y)


def unite(x, y):
    x = find(x)
    y = find(y)
    if x == y:
        return

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


for i in range(M):
    x, y = map(int, input().split())
    unite(x - 1, y - 1)

num = 0
for i in range(N):
    num += same(i, P[i])

print(num)
print(a[0],end=""for a in input().upper().split())

### FIXED CODE ###

a,b,c=input().split()
print(a[0].upper()+b[0].upper()+c[0].upper())
count = input()
numbers = list(map(int, input().split(' ')))

counter = 0
while True:
  tmp = 0
  for item in numbers:
    tmp += item % 2
  if tmp > 0:
    break
  counter ++
  numbers = [item / 2 for item in numbers]
print(counter)

### FIXED CODE ###

count = int(input())
numbers = [int(num) for num in input().split()]

counter = 0
while True:
  tmp = 0
  for item in numbers:
    tmp += item % 2
  if tmp > 0:
    break
  counter += 1
  numbers = [item / 2 for item in numbers]
print(counter)
k = int(input())
i = len(str(k))
cnt = 0
kanou = ["1","3","7","9"]
hukanou = ["0","2","4","5","6","8"]
if (str(k)[len(str(k))-1]) in kanou:
    cnt = 0
    for i in range(i):
        if str(k)[i] in hukanou:
            cnt = 1
            break
    if cnt == 0:
        while True:
            if(int('7'*i))%k==0:
                cnt = 1
                break
            else:
                i += 1
        print(i)
    elif cnt == 1:
        if k%7==0 and k%3==0:
            print(k)
        else:
            print(k-1)
else:
    print(-1)

### FIXED CODE ###

def calc(k):
    cur = 0
    for i in range(1, 10 ** 7):
        cur *= 10
        cur += 7
        cur %= k
        if cur == 0:
            return i

    return -1


k = int(input())
print(calc(k))
import collections

n = int(input())
s = np.array([[str(i) for i in input().split()] for i in range(n)])
s = np.ravel(s)
ans = 0
sorted_list = [''.join(sorted(e)) for e in s]
# dict
c = collections.Counter(sorted_list)
for i in c.values():
  for j in range(0, i):
    ans += j

print(ans)

### FIXED CODE ###

import numpy as np
import collections

n = int(input())
s = np.array([[str(i) for i in input().split()] for i in range(n)])
s = np.ravel(s)
ans = 0
sorted_list = [''.join(sorted(e)) for e in s]
# dict
c = collections.Counter(sorted_list)
for i in c.values():
  for j in range(0, i):
    ans += j

print(ans)
s = input()
r = 3 if s == 'RRR' else r = 1
if 'RR' in s:
  r = 2
print(r)

### FIXED CODE ###

s = input()
r = 3 if s == 'RRR' else 1
if 'RR' in s and s != 'RRR':
    r = 2
elif not 'R' in s:
    r = 0
print(r)
A = input()
B = input()
C = input()
a_len = len(A)
b_len = len(B)
c_len = len(C)
next = "A"

while a_len>=0 and b_len>=0 and c_len>=0:
    if next=="A":
        next = A[0]
        A.pop(0)
        a_len -= 1
    elif next=="B":
        next = B[0]
        A.pop(0)
        b_len -= 1
    else:
        next = C[0]
        B.pop(0)
        c_len -= 1
print(next.upper())

### FIXED CODE ###

A = list(str(input()))
B = list(str(input()))
C = list(str(input()))
a_len = len(A)
b_len = len(B)
c_len = len(C)
next = "a"

while a_len>=0 and b_len>=0 and c_len>=0:
    if next=="a":
        if a_len>=1:
            next = A[0]
            del A[0]
        a_len -= 1
    elif next=="b":
        if b_len>=1:
            next = B[0]
            del B[0]
        b_len -= 1
    else:
        if c_len>=1:
            next = C[0]
            del C[0]
        c_len -= 1
print(next.upper())
N,K=map(int,input().split())
L=list(map(int,input().split()))
L=sorted(L)
sum(L[:K])


### FIXED CODE ###

N=int(input())
cnt=0
while N>0:
  N//=2
  cnt=cnt*2+1
print(cnt)
while True:
 h,w=map(int,input().split())
 if h==0:break
 print("".join(['#']*w))
 for _ in range(h-2):print("#".join(['.']*(w-2)))
 print(f'{"".join(['#']*w)}\n')

### FIXED CODE ###

while 1:
 h,w=map(int,input().split())
 if h==0:break
 print(('#'*w)+'\n'+('#'+'.'*(w-2)+'#\n')*(h-2)+('#'*w)+'\n')
H, W = list(map(int, input().split()))
grid = [[c for c in input()] for r in range(H)]
paths = [[-1 for r in range(W)] for c in range(H)]
paths[0][0] = 1

def calc(r, c):
    if not ((0 <= r <= H-1) and (0 <= c <= W-1)): return 0
    if paths[r][c] == -1:
        if grid[r][c] == "#":
            v = 0
        else:
            v = (calc(r-1, c) + calc(r, c-1)) % (10**9+7)
    paths[r][c] = v
    return paths[r][c]

print(calc(H-1, W-1))


### FIXED CODE ###

h, w = map(int, input().split())
a = [input() for _ in range(h)]
dp = [[0] * w for _ in range(h)]
 
for i in range(h):
    if a[i][0] == ".":
        dp[i][0] = 1
    else:
        break
 
for i in range(w):
    if a[0][i] == ".":
        dp[0][i] = 1
    else:
        break
 
for i in range(1, h):
    for j in range(1, w):
        if a[i][j] == "#":
            dp[i][j] = 0
        else:
            dp[i][j] = (dp[i - 1][j] + dp[i][j - 1]) % (10 ** 9 + 7)
 
print(dp[h - 1][w - 1])
a,b=map(int,input().split())
print(a//b,a%b."{0:10.10f}".format(a/b))


### FIXED CODE ###

a,b=map(int,input().split());print(a//b,a%b,"{:.10f}".format(a/b))