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

if M % 2 == 1:
    print(-1)
    exit()

E = [[] for i in range(N + 1)]
used_e = [False] * M
ans = []

for i in range(M):
    A, B = map(int, input().split())
    E[A].append((B, i))
    E[B].append((A, i))

visited = [False] * (N + 1)


def dfs(prev, v):
    if visited[v]: return
    visited[v] = True
    cnt = 0

    for to, i in E[v]:
        dfs(v, to)
        if not used_e[i]: cnt += 1

    for to, i in E[v]:
        if cnt % 2 == 1 and to == prev: continue
        if not used_e[i]:
            ans.append((v, to))
            used_e[i] = True


dfs(0, 1)

for a in ans: print(*a)


### FIXED CODE ###

from sys import setrecursionlimit
setrecursionlimit(10**8)

N, M = [int(i) for i in input().split()]

if M % 2 == 1:
    print(-1)
    exit()

E = [[] for i in range(N + 1)]
used_e = [False] * M
ans = []

for i in range(M):
    A, B = map(int, input().split())
    E[A].append((B, i))
    E[B].append((A, i))

visited = [False] * (N + 1)


def dfs(prev, v):
    if visited[v]: return
    visited[v] = True
    cnt = 0

    for to, i in E[v]:
        dfs(v, to)
        if not used_e[i]: cnt += 1

    for to, i in E[v]:
        if cnt % 2 == 1 and to == prev: continue
        if not used_e[i]:
            ans.append((v, to))
            used_e[i] = True


dfs(0, 1)

for a in ans: print(*a)
import math

N = int(input())
end = int(math.sqrt(N))+1
ans = len(str(N))

for a in range(1,end):
  if N%a == 0:
    b = N//i
    ans = min(ans, len(str(max(a,b)))
print(ans)


### FIXED CODE ###

N = int(input())

import math

end = int(math.sqrt(N))+1
ans = len(str(N))

for a in range(1,end):
  if N % a ==0:
    b = N//a
    ans = min(ans, len(str(max(a,b))))
print(ans)
print(x*3)

### FIXED CODE ###

x = int(input())
print(x**3)
a, b, q = map(int, input().split())
s = sorted(int(input()) for _ in range(a))
t = sorted(int(input()) for _ in range(b))

st = []
(i, j) = (0, 0)
while i < len(s) or j < len(t):
    if j == len(t) or (i < len(s) and s[i] < t[j]):
        st.append((s[i], min(abs(s[i] - t[max(j - 1, 0)]),
                             abs(s[i] - t[min(j, len(t) - 1)]))))
        i += 1
    else:
        st.append((t[j], min(abs(t[j] - s[max(i - 1, 0)]),
                             abs(t[j] - s[min(i, len(s) - 1)]))))
        j += 1
    print(i, j, s, t, st)
print(st)

def doit(x):
    lo, hi = 0, len(st) - 1
    while hi - lo > 1:
        mid = (lo + hi) // 2
        if st[mid][0] < x:
            lo = mid
        else:
            hi = mid
    mid = (lo + hi) // 2
    return min(abs(st[mid][0] - x) + st[mid][1], abs(st[mid + 1][0] - x) + st[mid + 1][1])

for _ in range(q):
    print(doit(int(input())))

### FIXED CODE ###

a, b, q = map(int, input().split())
s = [int(input()) for _ in range(a)]
t = [int(input()) for _ in range(b)]

s = sorted(s)
t = sorted(t)
st = []
(i, j) = (0, 0)
while i < len(s) or j < len(t):
    if j == len(t) or (i < len(s) and s[i] < t[j]):
        st.append((s[i], min(abs(s[i] - t[max(j - 1, 0)]),
                             abs(s[i] - t[min(j, len(t) - 1)]))))
        i += 1
    else:
        st.append((t[j], min(abs(t[j] - s[max(i - 1, 0)]),
                             abs(t[j] - s[min(i, len(s) - 1)]))))
        j += 1

def doit(x):
    lo, hi = 0, len(st) - 1
    while hi - lo > 1:
        mid = (lo + hi) // 2
        if st[mid][0] < x:
            lo = mid
        else:
            hi = mid
    mid = (lo + hi) // 2
    return min(abs(st[mid][0] - x) + st[mid][1], abs(st[mid + 1][0] - x) + st[mid + 1][1])

for _ in range(q):
    print(doit(int(input())))
S = input()
for i in range(len(S)):
  c = S[i]
  if c == "A" and s is None :s = i
  if c == "Z":e = i
print(e-s+1)


### FIXED CODE ###

S = input()
L = len(S)
for i in range(L):
  c = S[i]
  if c == "A":
    s = i
    break
for i in range(L):
  c = S[-(i+1)]
  if c == "Z":
    e = L - (i+1)
    break
print(e-s+1)
[x, y] = map(int, raw_input().strip().split())
a = raw_input().strip()
b = raw_input().strip()
print "#" * (y + 2)
print "#" + a + "#"
print "#" * (y + 2)

### FIXED CODE ###

[x, y] = map(int, raw_input().strip().split())
st = []
for i in range(x):
    st.append(raw_input().strip())
print "#" * (y + 2)
for i in range(x):
    print "#" + st[i] + "#"
print "#" * (y + 2)
N, M = map(int, input().split())
ab = [tuple(map(lambda x:int(x)-1, input().split())) for _ in range(M)]
 
 
class UnionFind:
    def __init__(self, n):
        self.parents = [i for i in range(n)]
        self.sizes = [1] * n
    def find(self, i):
        if self.parents[i] == i:
            return i
        else:
            self.parents[i] = self.find(self.parents[i])
            return self.parents[i]
    def unite(self, i, j):
        pi = self.find(i)
        pj = self.find(j)
        self.sizes[pj] += self.sizes[pi]
        self.parents[pi] = pj 
        
 
def main():
    uf = UnionFind(N)
    p = N * (N - 1) // 2
    ans = [p]
    for x, y in reversed(ab):
        px = uf.find(x)
        py = uf.find(y)
        if px != py:
            p -= uf.sizes[px] * uf.sizes[py]
            uf.unite(px, py)
        ans.append(p)
 
    for a in reversed(ans[:-1]):
        print(a)
 
 
main()


### FIXED CODE ###

N, M = map(int, input().split())
ab = [tuple(map(lambda x:int(x)-1, input().split())) for _ in range(M)]
 
 
class UnionFind:
    def __init__(self,size):
        self.rank = [-1 for _ in range(size)]
        self.number = [1 for _ in range(size)]
 
    def find(self,x):
        while self.rank[x] >= 0:
            x = self.rank[x]
        return x
 
    def union(self,x,y):
        s1 = self.find(x)
        s2 = self.find(y)
        if s1 == s2:
            return
        if self.rank[s1] == self.rank[s2]:
            self.rank[s1] -= 1
            self.rank[s2] = s1
            self.number[s1] += self.number[s2]
        elif self.rank[s1] < self.rank[s2]:
            self.rank[s2] = s1
            self.number[s1] += self.number[s2]
        else:
            self.rank[s1] = s2
            self.number[s2] += self.number[s1]
 
 
def main():
    uf = UnionFind(N)
    p = N * (N - 1) // 2
    ans = [p]
    for x, y in reversed(ab):
        px = uf.find(x)
        py = uf.find(y)
        if px != py:
            p -= uf.number[px] * uf.number[py]
            uf.union(px, py)
        ans.append(p)
 
    for a in reversed(ans[:-1]):
        print(a)
 
 
main()
if W >= S:
  print("unsafe")
else:
  print("safe")

### FIXED CODE ###

S, W = [int(x) for x in input().split()]
 
if W >= S:
  print('unsafe')
else:
  print('safe')
a = int(input())
b = int(input())
c = int(input())
d = int(input())

if a >= c and a <= d or b >= c and b <= d:
  print("Yes")
else:
  print("No")




### FIXED CODE ###

n = int(input())
s = "ACL"
print(s*n)
N = int(input())
v = list(map(int,input().split()))
v1 = v.sort()
ans=v1[0]
for i in v[1:]:
    ans=(ans+i)/2
print(ans)

### FIXED CODE ###

a = int(input())
s = str(input())
if(a >= 3200):
    print(s)
else:
    print("red")
スコード 

Copy
Copy
def main():
  X, Y, A, B, C  = map(int, input().split())
  aka_list = sorted([int(t) for t in input().split()],reverse=True)[:X]
  midori_list = sorted([int(t) for t in input().split()],reverse=True)[:Y]
  mu_list = sorted([int(t) for t in input().split()],reverse=True)
  
  sum_list = sorted(aka_list + midori_list + mu_list)[:X+Y]
  print(sum(sum_list))
  

### FIXED CODE ###

def main():
  X, Y, A, B, C  = map(int, input().split())
  aka_list = sorted([int(t) for t in input().split()],reverse=True)[:X]
  midori_list = sorted([int(t) for t in input().split()],reverse=True)[:Y]
  mu_list = sorted([int(t) for t in input().split()],reverse=True)
  
  sum_list = sorted(aka_list + midori_list + mu_list ,reverse=True)[:X+Y]
  print(sum(sum_list))

main()
sys.setrecursionlimit(10 ** 9)
N,K=map(int,input().split())
S=input()

#N=14
#K=2
#S="11101010110011"

LIST=[[[0] for j in range (2)]for i in range(N)]

t=S[0]
c=0
k=0
for i in range(N):
    if(t!=S[i]):
        LIST[k][0]=c
        LIST[k][1]=t
        t=S[i]
        k+=1
        c=0
    c+=1

LIST[k][0]=c
LIST[k][1]=t
LIST=LIST[0:k+1]
MAX=0

def calc(i,s,K):
    global MAX
    MAX=max(MAX,s)
    if(i==len(LIST)):
        return

    if(LIST[i][1]=="1"):
        s+=LIST[i][0]
        MAX=max(MAX,s)
        i+=1
        if(i==len(LIST)):
            return
    
    if(K>=1):
        calc(i+1,s+LIST[i][0],K-1)
    calc(i+1,0,K)

calc(0,0,K)
print(MAX)


### FIXED CODE ###

N,K=map(int,input().split())
S=input()

#K=1
#S="01100"
#N=len(S)

LIST=[[[0] for j in range (2)]for i in range(N)]

t=S[0]
c=0
k=0
for i in range(N):
    if(t!=S[i]):
        LIST[k][0]=c
        LIST[k][1]=t
        t=S[i]
        k+=1
        c=0
    c+=1

LIST[k][0]=c
LIST[k][1]=t
LIST=LIST[0:k+1]
MAX=0

s=0
l=0
r=0

if(LIST[r][1]=="1"):
    s+=LIST[r][0]
    r+=1
x=0
while(K>0 and len(LIST)>r):
    s+=LIST[r][0]
    K-=1
    if(len(LIST)-1==r):
        x=1
        break
    r+=1
    s+=LIST[r][0]
    if(len(LIST)-1==r):
        x=1
        break
    r+=1

MAX=max(s,MAX)

f=0
if(x==0):
    while(r<len(LIST)):
        if(l< len(LIST)-1):
            s-=LIST[l][0]
            l+=1
            f=1
        if(l<len(LIST)-1 and LIST[l][1]=="0"):
            s-=LIST[l][0]
            l+=1

        if(f==0):
            break
        

        s+=LIST[r][0]
        MAX=max(s,MAX)
        r+=1
        if(len(LIST)==r):
            break
        
        s+=LIST[r][0]
        MAX=max(s,MAX)
        r+=1
        if(len(LIST)==r):
            break

print(MAX)
%%time
import numpy as np
h, w = list(map(int, input().split()))
ss = []
for _ in range(h):
    s = input()
#     s = s.replace(".", "0").replace("#", "1")
#     s = list(map(int, list(s)))
    ss.append(s)
# ss = np.array(ss)
    

from collections import deque
def find(now_h, now_w):
    dp = np.zeros([h, w], dtype = np.int32) + 9999
    dp[now_h, now_w] = 0
    que = deque()
    que.append((now_h, now_w))
    while len(que) > 0:
        now_h, now_w = que.popleft()
        if (now_h, now_w) in que:
            continue
        for mh, mw in ([0,1], [0,-1], [1,0], [-1,0]):
            next_h = now_h + mh
            next_w = now_w + mw
            if next_h < 0 or next_h >= h or next_w < 0 or next_w >= w:
                continue
            if ss[next_h][next_w] == "#":
                continue
            a = dp[now_h, now_w] + 1
            if dp[next_h, next_w] > a:
                dp[next_h, next_w] = a
                que.append((next_h, next_w))
#             print(que)
    score = np.max(dp[dp != 9999])
    return score

maximum = 0
for sh in range(h):
    for sw in range(w):
        if ss[sh][sw] == ".":
            if sh > 0 and sh < h - 1 and sw > 0 and sw < w - 1:
                if 0 + (ss[sh + 1][sw] == ".") + (ss[sh - 1][sw] == ".") + (ss[sh][sw + 1] == ".") + (ss[sh][sw - 1] == ".") >= 3:
                    continue
            score = find(sh, sw)
            if maximum < score:
                maximum = score

print(maximum)

### FIXED CODE ###

import numpy as np
h, w = list(map(int, input().split()))
ss = []
for _ in range(h):
    s = input()
#     s = s.replace(".", "0").replace("#", "1")
#     s = list(map(int, list(s)))
    ss.append(s)
# ss = np.array(ss)
    

from collections import deque
def find(now_h, now_w):
    dp = np.zeros([h, w], dtype = np.int32) + 9999
    dp[now_h, now_w] = 0
    que = deque()
    que.append((now_h, now_w))
    while len(que) > 0:
        now_h, now_w = que.popleft()
        if (now_h, now_w) in que:
            continue
        for mh, mw in ([0,1], [0,-1], [1,0], [-1,0]):
            next_h = now_h + mh
            next_w = now_w + mw
            if next_h < 0 or next_h >= h or next_w < 0 or next_w >= w:
                continue
            if ss[next_h][next_w] == "#":
                continue
            a = dp[now_h, now_w] + 1
            if dp[next_h, next_w] > a:
                dp[next_h, next_w] = a
                que.append((next_h, next_w))
#             print(que)
    score = np.max(dp[dp != 9999])
    return score

maximum = 0
for sh in range(h):
    for sw in range(w):
        if ss[sh][sw] == ".":
            if sh > 0 and sh < h - 1 and sw > 0 and sw < w - 1:
                if 0 + (ss[sh + 1][sw] == ".") + (ss[sh - 1][sw] == ".") + (ss[sh][sw + 1] == ".") + (ss[sh][sw - 1] == ".") >= 3:
                    continue
            score = find(sh, sw)
            if maximum < score:
                maximum = score

print(maximum)
import math
a, b, h, m = map(int, input().split())

n = 60 * h + m

r = n * math.pi * 11 / 360

ans = math.sqrt(a ** 2 + b ** 2 - 0.5 * a * b * math.cos(r))

print(ans)


### FIXED CODE ###

n = int(input())

while n >= 10:
    n -= 10

if n == 3:
    print("bon")

elif n == 0 or n == 1 or n == 6 or n == 8:
    print("pon")

else:
    print("hon")
import pandas as pd
n = int(input())
s = [input() for _ in range(n)]
x = set(s)
print(len(x))


### FIXED CODE ###

n = int(input())
s = [input() for _ in range(n)]
x = set(s)
print(len(x))
import numpy as np
N, C = map(int, input().split())

xv = [(0, 0)]
for i in range(N):
    x, v = map(float, input().split())
    xv.append((x, v))
sumA = np.zeros(N+1, dtype=float)
sumB = np.zeros(N+1, dtype=float)

xv.sort(key=lambda tup:tup[0])
for i in range(N):
    sumA[i+1] = sumA[i] + xv[i+1][1]
    sumB[i+1] = sumB[i] + xv[N-i][1]

for i in range(N):
    if sumA[i+1] < xv[i+1][0]: sumA[i+1] = 0
    else: sumA[i+1] -= xv[i+1][0]
    if sumB[i+1] < C - xv[N-i][0]: sumB[i+1] = 0
    else: sumB[i+1] -= C - xv[N-i][0]

ans = 0
for i in range(N):
    #when to turn back?
    valB = -xv[i][0] + max(sumB[:N-i+1])
    if valB < 0:
        ans = max(ans, sumA[i])
    else:
        ans = max(ans, sumA[i] + valB)

print(int(ans))


### FIXED CODE ###

import numpy as np
N, C = map(int, input().split())

xv = [(0, 0)]
for i in range(N):
    x, v = map(float, input().split())
    xv.append((x, v))

sumA = np.zeros(N+2, dtype=float)
sumB = np.zeros(N+2, dtype=float)

xv.sort(key=lambda tup:tup[0])
xv.append((C,0))

for i in range(N+1):
    sumA[i+1] = sumA[i] + xv[i+1][1]
    sumB[i+1] = sumB[i] + xv[N-i][1]

maxA = [0]*(N+1)
maxB = [0]*(N+1)
for i in range(N):
    if sumA[i+1] < xv[i+1][0]: sumA[i+1] = 0
    else: sumA[i+1] -= xv[i+1][0]
    if sumB[i+1] < C - xv[N-i][0]: sumB[i+1] = 0
    else: sumB[i+1] -= C - xv[N-i][0]

    maxA[i + 1] = maxA[i]
    if sumA[i+1] > maxA[i]:
        maxA[i+1] = sumA[i+1]
    maxB[i + 1] = maxB[i]
    if sumB[i+1] > maxB[i]:
        maxB[i+1] = sumB[i+1]

ans = 0
for i in range(N):
    #when to turn back?
    #valB = -xv[i][0] + max(sumB[:N-i+1])
    valB = -xv[i][0] + maxB[N - i]
    if valB < 0:
        ans = max(ans, sumA[i])
    else:
        ans = max(ans, sumA[i] + valB)

    #when to turn back?
    valA = -C+xv[N-i+1][0] + maxA[N-i]
    if valA < 0:
        ans = max(ans, sumB[i])
    else:
        ans = max(ans, sumB[i] + valA)

print(int(ans))
import sys


def input(): return sys.stdin.readline().strip()
def I(): return int(input())
def LI(): return list(map(int, input().split()))
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def S(): return input()
def LS(): return input().split()


def rle(s):
    t = s[0]
    cnt = 1
    res = []
    for i in range(1, len(s)):
        if t == s[i]:
            cnt += 1
        else:
            res.append([t, cnt])
            t = s[i]
            cnt = 1
    res.append([t, cnt])
    return res


INF = float('inf')


n = I()
c = S()
if len(set(list(c))) < 2:
    print(0)
    exit()

# R と W のまとまり
rw = rle(c)
# print(rw)
ans = 0
for i, elem in enumerate(rw):
    if i < n - 1 and elem[0] == 'W' and rw[i+1][0] == 'R':
        ans += min(elem[1], rw[i+1][1])
print(ans)


### FIXED CODE ###

from collections import Counter
import sys


def input(): return sys.stdin.readline().strip()
def I(): return int(input())
def LI(): return list(map(int, input().split()))
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def S(): return input()
def LS(): return input().split()


INF = float('inf')


n = I()
c = S()
# 最終的に RR...RWW...WWW という状態になる
# R の個数を r とすると、左から r 個の石のうち R はそのままで W だけ入れ替えたら良い
r = Counter(list(c))['R']
ans = 0
for elem in c[:r]:
    if elem == 'W':
        ans += 1
print(ans)
from functools import reduce
from fractions import gcd
N = int(input())
A = list(map(int,input().split()))
gcd_max = 0
for i in range(N):
    gcd_now = reduce(gcd, list(x for x in A if x != A[i]))
    if (gcd_max < gcd_now): gcd_max = gcd_now
    
print(gcd_max)

### FIXED CODE ###

from fractions import gcd
# input
N = int(input())
A = list(map(int,input().split()))
L_A = [0] * (N+1)
R_A = [0] * (N+1)
for i in range(N):
    L_A[1+i] = gcd(L_A[i], A[i])
for i in reversed(range(N)):
    R_A[i] = gcd(R_A[i+1], A[i])
print(max(gcd(L_A[i], R_A[i+1]) for i in range(N)))
N=int(input())
a=[0]*N
for i in range(1,100):
    for j in range(1,100):
        for k in range(1,100):
            n=i*i+j*j+k*k+i*j+i*k+j*k
            if(n>N):
               continue
            a[n-1]+=1
for i in range(1,N+1):
    print(a[i])
    

### FIXED CODE ###

N = int(input())

ans = [0]*N

for i in range(1,101,1):
  for j in range(1,101,1):
    for k in range(1,101,1):
      n = i**2+j**2+k**2+i*j+j*k+k*i
      if n > N:
        continue
      else:
        ans[n-1]+=1
      
for i in range(N):
  print(ans[i])
N = int(input())
A = [int(i) for i in input().split()]
B = [int(i) for i in input().split()]
C = [int(i) for i in input().split()]

def sunuke(ai, bi, ci, ans):

    if ai > N-1:
        print(ans)
    elif bi > N-1:
        sunuke(ai+1, 0, 0, ans)
    elif ci > N-1:
        sunuke(ai, bi+1, 0, ans)

    elif A[ai] >= B[bi]:
        sunuke(ai,bi+1,ci, ans)
    elif B[bi] >= C[ci]:
        sunuke(ai, bi, ci+1, ans)
    else:
        ans += 1
        sunuke(ai, bi, ci+1, ans)

ans = 0
sunuke(0,0,0, ans)


### FIXED CODE ###

import bisect

N = int(input())
A = [int(i) for i in input().split()]
B = [int(i) for i in input().split()]
C = [int(i) for i in input().split()]

A.sort()
C.sort()
#ある一つのBについて、それ以下のAの個数とそれ以上のCの個数を二分探索で求める
ans = 0
for i in range(N):
    lw_a = bisect.bisect_left(A, B[i])
    up_c = N - bisect.bisect_right(C, B[i])
    ans += lw_a * up_c
print(ans)
x = int(input())
ans = []
for i in range(1,x):
    for j in range(2,10):
        if i**j > x:
            break
        else:
            ans.append(i**j)
print(max(ans))

### FIXED CODE ###

x = int(input())
ans = 1
if x < 4:
    print(1)
else:
    for i in range(2,int(x**(1/2)+1)):
        j = 2
        a = -1
        while a <= x:
            ans = max(ans,a)
            a = i**j
            j += 1
    print(ans)
def main():
    a,b,c = map(int, input().split(" "))

    if (4 * a * b) < (c - a - b) * (c - a - b) 2 and (c - a - b) > 0:
        print('Yes')
    else:
        print('No')
main()

### FIXED CODE ###

from decimal import Decimal

def main():
    a,b,c = map(int, input().split(" "))

    if Decimal(a).sqrt() + Decimal(b).sqrt() < Decimal(c).sqrt():
        print('Yes')
    else:
        print('No')
main()
n=input()
s=list(map(int,input().split())
sum=1
for i in s
   sum=sum*i
if sum>10**18:
       print(-1)
else:
       print(sum)
       

### FIXED CODE ###

n=int(input())
x=list(map(int,input().split()))
ans=1
for i in x:
  if i==0:
    print(0)
    exit()

for i in x:
    ans=ans*i
    if ans>10**18:
      ans=-1
      break
print(ans)
from itertools import permutations as perm

n, m, r = map(int, input().split())
r = list(map(lambda x: int(x) - 1, input().split()))
d = [[10 ** 5] * m for _ in range(m)]
for i in range(m):
    abc = tuple(map(int, input().split()))
    a = abc[0] - 1
    b = abc[1] - 1
    c = abc[2]
    d[a][b] = c
    d[b][a] = c
for k in range(m):
    for i in range(m):
        for j in range(m):
            d[i][j] = min(d[i][j], d[i][k] + d[k][j])
            d[j][i] = min(d[j][i], d[i][k] + d[k][j])

ans = 8 * (10 ** 5)
for arr in perm(r, len(r)):
    rep = 0
    for i in range(len(arr) - 1):
        rep += d[arr[i]][arr[i + 1]]
    ans = min(ans, rep)
print(ans)


### FIXED CODE ###

from itertools import permutations as perm

n, m, r = map(int, input().split())
r = list(map(lambda x: int(x) - 1, input().split()))
d = [[10 ** 9] * n for _ in range(n)]
for i in range(m):
    abc = tuple(map(int, input().split()))
    a = abc[0] - 1
    b = abc[1] - 1
    c = abc[2]
    d[a][b] = c
    d[b][a] = c
for k in range(n):
    for i in range(n):
        for j in range(n):
            d[i][j] = min(d[i][j], d[i][k] + d[k][j])
            d[j][i] = d[i][j]

ans = 10 ** 9
for arr in perm(r):
    rep = 0
    for i in range(len(arr) - 1):
        rep += d[arr[i]][arr[i + 1]]
    ans = min(ans, rep)
print(ans)
N = int(input())
S = [int(input()) for i in range(N)]

if "Y" in S:
    print("Four")
else:
    print("Three")

### FIXED CODE ###

N = int(input())
S = [i for i in input().split()]

if "Y" in S:
    print("Four")
else:
    print("Three")
#1A:white
#0B:black
import math
I,J=map(int,input().split())
B=max(I,J)
A=min(I,J)
X=A+B
K=(B-A)//3
P=(B-A)%3
if P==0:
    X+=K
else:
    X+=K+1
n=int(math.sqrt(X))
p,q=0,0
for i in range(1,n+1):
    if X%i==0:
        p=i
        q=X//i
C=[[(i+j)%2 for i in range(p)] for j in range(q)]
N=0;M=0
for i in range(p):
    for j in range(q):
        if (i+j)%2==0:
            M+=1
        else:
            N+=1
flag=0
for i in range(1,p-1):
    for j in range(1,q-1):
        if C[i][j]==0:
            if A<N-3:
                C[i][j]=1
            else:
                flag=1
                break
    if flag==1:
            break
if P==1:
    for i in range(1,p-1):
        if C[0][i]==0:
            C[0][i]=1
            break
elif P==2:
    flag2=0
    for i in range(1,p-1):
        if C[0][i]==0:
            C[0][i]=1
            flag2+=1
        if flag2==2:
            break
print(p,q)
for i in range(p):
    st=""
    for j in range(q):
        if (C[j][i]==0 and J>I) or (C[j][i]==1 and I>=J):
            st+="#"
        else:
            st+="."
        print(st)


### FIXED CODE ###

A,B=map(int,input().split())
C=[[0 for i in range(100)] for i in range(100)]
for i in range(50,100):
    for j in range(100):
        C[i][j]=1
k=0
for i in range(50):
    for j in range(100):
        if (i*j)%2 ==1:
            if k<A-1:
                C[i][j]=1
                k+=1
            else:
                break
k=0
for i in range(50,100):
    for j in range(100):
        if (i*j)%2 ==1:
            if k<B-1:
                C[i][j]=0
                k+=1
            else:
                break
print(100,100)
for i in range(100):
    st=""
    for j in range(100):
        if C[i][j]==0:
            st+="#"
        else:
            st+="."
    print(st)
h,w = map(int,input().split())
HW = [list(map(str,input().split())) for _ in range(h)]
sharp = 0
for i in range(w):
  for j in range(h):
    if HW[i][j] == '#':
      sharp += 1

min_root = h + w - 1
if sharp == min_root:
  print('Possible')
else:
  print('Impossible')


### FIXED CODE ###

def main():
  H, W = list(map(int, input().split()))

  count = 0

  for i in range(H):
    row = input()
    for j in range(W):
      if(row[j] == '#'):
        count += 1

  print("Possible" if W + H - 1 == count else "Impossible")

if __name__ == "__main__":
  main()
dat = input().split()

for i in dat:
      dat[i] = int(dat[i])

dat.sort(reverse=True)

asum=0
bsun=0

for i in range(len(dat):
	if i%2==0:
		asum = asum + dat[i]
	else:
		bsum bsum + dat[i]
		
print(asum-bsum)

### FIXED CODE ###

n = int(input())
dat = list(input().split())

dat = list(map(int,dat))

dat.sort(reverse=True)

asum = 0
bsum = 0

for i in range(n):
	if i % 2 == 0:
		asum = asum + dat[i]
	else:
		bsum = bsum + dat[i]
		
print(asum-bsum)
a = [list(map(int, input().split())) for i in range(3)]
print(a[0][0]+a[1][1]+a[2][2])

### FIXED CODE ###

a = [input() for i in range(3)]
print(a[0][0]+a[1][1]+a[2][2])
n=int(input())
count=0
while n>0:
  count=count+1
  n=n//10
if n=2 or n=4 or n=5 or n=7 or n=9:
  print ("hon")
if n=0 or n=1 or n=6 or n=8:
  print ("pon")
if n=3:
  print("bon")
  

### FIXED CODE ###

n = int(input())
l = int(repr(n)[-1])
if l ==2 or l==4 or l==5 or l==7 or l==9:
    print('hon')
if l==0 or l==1 or l==6 or l==8:
    print('pon')
if l ==3:
    print('bon')