peterverebics/CodeNet_Python_428 huggingface dataset:
# Judge status: Accepted
from collections import deque

N, M = map(int, input().split())
routes = [[] for _ in range(N+1)]
for _ in range(M):
  a, b = map(int, input().split())
  routes[a].append(b)
  routes[b].append(a)
checked = [0 for _ in range(N+1)]
route = deque(routes[1])
for r in routes[1]:
  checked[r] = 1
while(len(route) > 0):
  r = route.popleft()
  for rr in routes[r]:
    if checked[rr] == 0:
      checked[rr] = r
      route.append(rr)
for i in range(2, N+1):
  if checked[i] == 0:
    print('No')
    exit()
print('Yes')
for j in range(2, N+1):
  print(checked[j])
# Judge status: Accepted
n,m = map(int, input().split())
l = [list(map(int, input().split())) for _ in range(m)]
for i in range(10001):
    if len(str(i)) != n:
        continue
    for j in l:
        if str(i)[j[0]-1] != str(j[1]):
            break
    else:
        print(i)
        exit()
else:
    print(-1)
# Judge status: Accepted
n,m=map(int,input().split())

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

a.sort()

bc=[]
for i in range(m):
    bc.append(list(map(int,input().split())))

bc.sort(key=lambda x:x[1],reverse=True)

lis=[]
for i in range(m):
    if len(lis)>=n:
        break
    for _ in range(bc[i][0]):
        lis.append(bc[i][1])

while len(lis)<n:
    lis.append(0)

s=0
for i in range(n):
    s+=max(a[i],lis[i])

print(s)
# Judge status: Accepted
S = input()
T = input()

ans = 1000
for i in range(len(S) - len(T) + 1):
    tmp = 0
    for j in range(len(T)):
        if S[i+j] != T[j]:
            tmp += 1
    ans = min(ans, tmp)

print(ans)
# Judge status: Wrong Answer
#!/usr/bin/env python3

def main():
    n, k = map(int, input().split())
    i = 1
    while k ** i < n:
        i += 1
    print(i)

main()
# Judge status: Wrong Answer
import math
x,y = map(int,input().rstrip().split(' '))
n = int(math.log2(y//x))
print(n)
# Judge status: Accepted
n = int(input())
a = list(map(int, input().split()))

if n > 0 and a[0] != 0: print(-1); exit()

s = [0] * (n+2)
for i in range(n+1)[::-1]:
    s[i] = s[i+1]+a[i]

x = 1
ans = 0
for i in range(n+1):
    ans += x
    if x == s[i]:
        x -= a[i]
        continue
    x -= a[i]
    if (x <= 0 and i != n) or x < 0: print(-1); exit()
    if x*2 >= s[i+1]: x = s[i+1]
    else: x *= 2

print(ans)
# Judge status: Accepted
k = int(input())
even = k // 2
odd = (k+1) // 2
print(even*odd)
# Judge status: Accepted
a = int( input() )
s = input()
if a >= 3200:
  print( s )
else:
  print( "red" )
# Judge status: Accepted
x = int(input())
dp = [0]*(x + 105 + 1)
dp[100] = 1 
dp[101] = 1
dp[102] = 1
dp[103] = 1
dp[104] = 1
dp[105] = 1

for i in range(100,x-105+6):
    for j in range(100,106):
        dp[i+j] = max(dp[i] , dp[i+j])

print(dp[x])
# Judge status: Accepted
a, b, c, d = map(int, input().split())

x = [i for i in range(a, b)]
y = [i for i in range(c, d)]
s = 0
for i in x:
    if i in y:
        s += 1
print(s)
# Judge status: Wrong Answer
w, h, n = map(int, input().split())
num_w = 0
num_h = 0

for i in range(n):
  x, y, a = map(int, input().split())
  if a == 1:
    if num_w < x:
      num_w = x
  elif a == 2:
    if w > x:
      w = x
  elif a == 3:
    if num_h < y:
      num_h = y
  else:
    if h > y:
      h = y
  
print((w-num_w)*(h-num_h))
# Judge status: Wrong Answer
s = input()


def solve(query):
    if query == "":
        print("YES")
        exit()
    for frag in ("eraser", "erase", "dream", "dreamer"):
        if query.startswith(frag):
            solve(query[len(frag):])


solve(s)
print("NO")
# Judge status: Accepted
N = int(input())

S = ""
for i in range(100):
    if abs(N) % (2 ** (i+1)) != 0:
        S += "1"
        N -= (-2) ** (i)
    else:
        S += "0"
    if N == 0:
        break

print(S[::-1])
# Judge status: Accepted
K, X = map(int,input().split())

if (X <= 500*K):
    print("Yes")
else:
    print("No")
# Judge status: Wrong Answer
N = int(input())
T,A = map(int,input().split())
a = list(map(int,input().split()))
min_val = T-A
min_num=0
for i in range(len(a)):
    if abs(T-0.006*a[i]-A) <= min_val:
        min_val = abs(T-0.006*a[i]-A)
        min_num = i
print(min_num+1)
# Judge status: Accepted
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
a1 = sum(A)

for i in range(N):
  b = B[i]
  if A[i] >= b:
    A[i] -= b
  else:
    if A[i+1]+A[i] >= b:
      A[i+1] = A[i+1]+A[i]-b
      A[i] = 0
    else:
      A[i], A[i+1] = 0, 0
      
a2 = sum(A)
print(a1-a2)
# Judge status: Accepted
D = int(input())
C = list(map(int, input().split()))
S = [list(map(int, input().split())) for _ in range(D)]

N = 26
L = [0] * N
for d in range(1, D + 1):
    mx = -10**18
    nx = -1

    for i, (c, l) in enumerate(zip(C, L)):
        r = c * (d - l) - S[d - 1][i]
        if mx < r:
            mx = r
            nx = i

    L[nx] = d
    print(nx + 1)
# Judge status: Wrong Answer
line = input()
a, b, c = [int(n) for n in line.split()]
print(a + b if a+b<=a+c else a+c )
# Judge status: Accepted
x, y = map(int, input().split())

X = [1,3,5,7,8,10,12]
Y = [4,6,9,11]
Z = [2]

ax = 0
ay = 0

if x in X:
  ax = 1
elif x in Y:
  ax = 2
else:
  ax = 3
if y in X:
  ay = 1
elif y in Y:
  ay = 2
else:
  ay = 3
  
print('Yes') if ax == ay else print('No')
# Judge status: Wrong Answer
def resolve():
    import sys
    input = sys.stdin.readline
    
    S = input()
    res = "x" * len(S)
    print(res)


if __name__ == "__main__":
    resolve()
# Judge status: Accepted
N, A, B, C, D = map(int, input().split())
S = input()
p = 0
t = 0
sti = 0
for i in range(A-1, max(C, D) - 1):
  if S[i:i+2] == '##':
    p = 1
for j in range(B-1, min(C, D) - 1):  
  if S[j:j+3] == '...':
    if sti == 0:
      sti = j + 1
    t = 1
if S[B] == '.' and S[B-2] == '.':
  t = 1
if (C < D and p == 0) or (C > D and p == 0 and t == 1 and sti <= D-1):
  print('Yes')
else:
  print('No')
# Judge status: Accepted
n = int(input())
s = 0
b = False
for _ in range(n):
    w = input().split()
    if w[0] == w[1]:
        s += 1
        if s == 3:
            b = True
            break
    else:
        s = 0
print('Yes' if b else 'No')
# Judge status: Accepted
S=input()
for i in range(1,len(S)//2+1):
    check=0
    T=S[:len(S)-2*i]
    for j in range(0,len(T)//2):
        if T[j]!=T[j+len(T)//2]:
            check=1
    if check==0:
        print(len(T))
        break
if check==1:
    print(0)
# Judge status: Accepted
N,K = map(int,input().split()) 
A = list(map(int,input().split()))
A.sort()
temp = 1
V = [] 
for i in range(N-1):
    if A[i] == A[i+1]:
        temp+=1 
    else:
        V.append(temp)
        temp = 1

V.append(temp)
V.sort() 
ans = N- sum(V[-K:])
print(ans)
# Judge status: Accepted
n,m = map(int,input().split())
ipyx=[]
for _ in range(m):
  p_,y_ = map(int,input().split())
  ipyx.append([_+1,p_,y_,0])
"""
2 3
1 32
2 63
1 12
->
000001000002
000002000001
000001000001

2 3
2 5
2 77
2 99
->
000002000001
000002000002
000002000003
"""
# ipyx = [i,p,y,x]
A=[1]*(n+1)
ipyx.sort(key=lambda x:x[2])
for j in ipyx:
  j[3] = A[j[1]]
  A[j[1]] += 1
ipyx.sort(key=lambda x:x[0])
for j in ipyx:
  print(('00000'+str(j[1]))[-6:]+('00000'+str(j[3]))[-6:])
# Judge status: Accepted
import itertools
import math

N = int(input())
X = []
Y = []
for _ in range(N):
    x,y = map(int,input().split())
    X.append(x); Y.append(y)

num = [i for i in range(N)]
distance_list = []
for perm in itertools.permutations(num):
    prev = None
    distance = 0
    for v in perm:
        if prev is None:
            prev = v
        else:
            distance += math.sqrt((X[prev] - X[v]) ** 2 + (Y[prev] - Y[v]) ** 2)
    distance_list.append(distance)

print(sum(distance_list) / len(distance_list))
# Judge status: Accepted
s = input()
a = [0 for _ in range(len(s)+1)]

cur = 0
for i in range(len(s)):
    if s[i] == '<':
        cur += 1
    else:
        cur = 0
    a[i+1] = max(a[i+1], cur)
    
cur = 0
for i in range(len(s)):
    j = len(s)-1 - i
    if s[j] == '>':
        cur += 1
    else:
        cur = 0
    a[j] = max(a[j], cur)
    
print(sum(a))
# Judge status: Accepted
import math
A, B = map(int, input().split())
print(math.ceil((B-1)/(A-1)))
# Judge status: Accepted
a, b, c, x, y = map(int,input().split())
 
if a+b <= c * 2:
    print(x*a + y*b)
    exit()
    
ans = 0
 
ans += min(x,y) * c * 2
 
if x >= y:
    ans += min((x-y)*a, (x-y)*2*c)
else:
    ans += min((y-x)*b, (y-x)*2*c)
    
print(ans)
# Judge status: Accepted
# C - Many Medians
# https://atcoder.jp/contests/abc094/tasks/arc095_a

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

sortedX = sorted(X)

l = sortedX[n // 2 - 1]
r = sortedX[n // 2]

for x in X:
  if x <= l:
    print(r)
  else:
    print(l)
# Judge status: Wrong Answer
import sys
#sys.exit()
#sorted( ,reverse=True)
N = int(input())
if N ==1:
    print(0)
    sys.exit()
#S,T = map(int, input().split())
#A = list(map(int, input().split()))
#A = [int(input()) for _ in range(N)]
c = 10**9+7
total = 10**N 
#0と9のみ
a= 8**N
#0のみ、9のみ
b= 1
d = N
for i in range (N-1):
    d = d*8
    b += d
ans = total - a - b*2

ans2 = ans % c 

#cnt = 0
#cnt += 1

print(ans2)

#print(N)
#print(S,T)
#print(A)
#print('Yes')
#print('No')
#print(cnt)
# Judge status: Accepted
# 全て1食800円のレストラン
# 15食食べるごとにその場で200円もらえる
# 合計N食たべた。払った金額=x円、もらった金額をy円としてx-yを求める

# 入力されたNを数値に変換
N = int(input())

# 払った金額=x円を求める
x = 800 * N

# もらった金額=y円を求める
# 200円 * 回数Nを15で割った時の整数の商
y = 200 * (N // 15)

print(x-y)
# Judge status: Accepted
n, k = map(int, input().split())
total_prob = 0
for i in range(1, n+1):
  dice_count = 0
  while (i << dice_count) < k:
    dice_count += 1
  
  total_prob += (1 / n) * (0.5 ** dice_count)
  
print(round(total_prob, 12))
# Judge status: Accepted
n,k = map(lambda x: int(x),input().split())
p = list(map(lambda x: (int(x) + 1)/2,input().split()))
ruiseki = [0]
max = 0
for i in range(n) :
    ruiseki.append(ruiseki[i]+p[i])

for j in range(n - k + 1):
    if max < (ruiseki[j+k] - ruiseki[j]) :
        max = (ruiseki[j+k] - ruiseki[j])


print(max)
# Judge status: Accepted
n,k,s=map(int,input().split())

for i in range(n):
    if i+1 <= k:
        print(s,end=" ")
    else:
        if s==10**9:
            print(10**9-1,end=" ")
        else:
            print(10**9,end=" ")
# Judge status: Accepted
import sys
import numpy as np
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 8)
INF = float('inf')
MOD = 10 ** 9 + 7

def main():
    N = int(input())
    A = np.array(input().split(), np.int64)
    B = np.append(0, A.cumsum())
    C = A[::-1].cumsum()
    C = np.append(C[::-1], 0)
    print(np.abs(B-C).min())



if __name__ == '__main__':
    main()
# Judge status: Accepted
N = int(input())
w = [input()]
ans = 'Yes'
for i in range(N-1):
  tmp = input()
  if (tmp in w) or (w[-1][-1] != tmp[0]):
    ans = 'No'
    break
  w.append(tmp)
print(ans)
# Judge status: Wrong Answer

n=int(input())
st=input()
if n>=len(st):
    print(st)
else:
    print(st[0:n-1])
# Judge status: Accepted
n=int(input())
f=0
for i in range(30):
    for j in range(30):
        if 4*i+7*j==n:
            f=1
print("Yes" if f==1 else "No")
# Judge status: Accepted
from collections import Counter
n = int(input())
s = input()
mod = 10**9+7

s_c = Counter(s)

ans = 1
for c in s_c.values():
    ans*=c+1
print((ans-1)%mod)
# Judge status: Wrong Answer
N = input()
ans = 0
flag = False
for i in range(len(N)-1, -1, -1):
    if flag and i != 0:
        ans -= 1
    if int(N[i]) < 11-int(N[i]):
        ans += int(N[i])
        flag = False
    else:
        ans += 11-int(N[i])
        flag = True
print(ans)
# Judge status: Accepted
s = input()
if len(''.join(set(s)))==2:
    print("Yes")
else:
    print("No")
# Judge status: Wrong Answer
s = input()
t = input()
if s < t: 
    print('Yes')
else:
    print('No')
# Judge status: Accepted
a=input()
b=["a","i","u","e","o"]
if a in b:
    print("vowel")
else:
    print("consonant")
# Judge status: Accepted
N = int(input())
A = list(map(int, input().split()))

s = 0
t = 0

ans = 10 ** 12

for i in range(N):
  t += A[i]

for n in range(N-1):
  s += A[n]
  t -= A[n]
  ans = min(ans, abs(s - t))

print(ans)
# Judge status: Accepted
W,H,x,y = list(map(float,input().split()))

ans = W * H
ans = float(float(ans) / 2.0)
ans2 = 0
if x == float(float(W) / 2) and y == float(float(H) / 2):
    ans2 = 1

print(str(ans) + " " + str(ans2))
# Judge status: Accepted
n = int(input())
s = list(input())

c0 = 0
c1 = 0
z0 = 0
z1 = 0
for i in range(n):
    if s[i] == "(":
        c0 += 1
    else:
        if c0 > 0:
            c0 -= 1
        else:
            c1 += 1
ans = ["("]*c1 + s + [")"]*c0
print("".join(ans))
# Judge status: Accepted
n=int(input())
d=[int(x) for x in input().rstrip().split()]
d.sort()
if d[n//2-1]==d[n//2]:
  print(0)
else:
  print(d[n//2]-d[n//2-1])
# Judge status: Accepted
n = int(input())
a = int(input())
print("Yes" if (n % 500) <= a else "No")
# Judge status: Accepted
n, m = map(int, input().split())

import math
gs = []
for i in range(1, int(math.sqrt(m))+1):
  if m%i == 0:
    gs.append(i)
    if i != m//i:
      gs.append(m//i)

gs.sort(reverse=True)

#print(gs)
for j in gs:
  if m//j >= n:
    print(j)
    exit()
# Judge status: Wrong Answer
N, M = map(int, input().split())
AB = {}
for i in range(N):
  a, b = map(int, input().split())
  AB[a] = b

ans = 0
for ab in sorted(AB.keys()):
  if M >= AB[ab]:
    ans += ab * AB[ab]
    M -= AB[ab]
  else:
    ans += ab * M
    break
print(ans)
# Judge status: Wrong Answer
def solve():
    s = list(input())

    ans = []
    for i in range(len(s)):
        if s[i] != 'B':
            ans.append(s[i])
        elif s[i] == 'B' and ans:
            ans.remove(ans[-1])
        

    return ''.join(ans)

    
print(solve())
# Judge status: Wrong Answer
k, a, b = map(int, input().split())

if a >= b-1:
    print(k+1)
else:
    if k <= a:
        print(k+1)
    else:
        if k-a % 2 == 1:
            print((k-a+1)//2*(b-a)+a)
        else:
            print((k-a)//2*(b-a)+a+1)
# Judge status: Accepted
c = input()

ans = chr(ord(c) + 1)
print(ans)
# Judge status: Wrong Answer
a,b,c,d = (int(x) for x in input().split())
if b and d >= 0:
    if a*c > b*d :
        print(a*c)
    else:
        print(b+d)
elif b and d < 0:
    print(a*c)
elif b >=0 and d < 0:
    if a*d > b*c :
        print(a*d)
    else:
        print(b*c)
elif b <0 and d >= 0:
    if a*d > b*c :
        print(a*d)
    else:
        print(b*c)
# Judge status: Accepted
n = int(input())
p = [int(x) for x in input().split()]

cnt=1
saisyouti=p[0]
for i in range(1,n):
    if p[i]<saisyouti:
        cnt+=1
        saisyouti=p[i]

print(cnt)
# Judge status: Accepted
s = input()
t = input()
sl = []
tl = []
for c in s:
    sl.append(c)
for c in t:
    tl.append(c)
sl.sort()
tl.sort(reverse=True)
s = "".join(sl)
t = "".join(tl)
print("Yes" if s < t else "No")
# Judge status: Accepted
L = int(input())
L /= 3
print(L**3)
# Judge status: Accepted
def ABC_119_A():
    S = input()

    toshi = S[0]+S[1]+S[2]+S[3]
    tuki = S[5]+S[6]
    hi = S[8]+S[9]

    if (int(toshi) <= 2019) and (int(tuki) <= 4) and (int(hi) <= 30):
        print('Heisei')
    else:
        print('TBD')

if __name__ == '__main__':

    ABC_119_A()
# Judge status: Accepted
ary=[list(map(int,input().split()))for p in range(3)]
for i in range(int(input())):
  data=int(input())
  for j in range(3):
    for k in range(3):
      if ary[j][k]==data:
          ary[j][k]=0
ans="No"
for i in range(3):
  if ary[i][0]==ary[i][1]==ary[i][2]==0 or ary[0][i]==ary[1][i]==ary[2][i]==0:
      ans="Yes"
if ary[0][0]==ary[1][1]==ary[2][2]==0 or ary[2][0]==ary[1][1]==ary[0][2]==0:
    ans="Yes"
print(ans)
# Judge status: Accepted
N, K = map(int, input().split())
x = list(map(int, input().split()))
ans = float('inf')
for i in range(N-K+1):
    ans = min(ans, abs(x[i]) + abs(x[i]-x[i+K-1]))
    ans = min(ans, abs(x[i+K-1]) + abs(x[i]-x[i+K-1]))
print(ans)
# Judge status: Accepted
import sys


stdin = sys.stdin
def ns(): return stdin.readline().rstrip()
def ni(): return int(stdin.readline().rstrip())
def nm(): return map(int, stdin.readline().split())
def nl(): return list(map(int, stdin.readline().split()))


def main():
    s = input()
    t = input()
    S = sorted(map(s.count, set(s)))
    T = sorted(map(t.count, set(t)))
    print("Yes" if S == T else "No")


if __name__ == '__main__':
    main()
# Judge status: Wrong Answer
n=int(input())
a=list(map(int,input().split()))
al=[a[2*i] for i in range(n//2)]
bo=[a[2*i+1] for i in range(n//2)]
print(sum(al)-sum(bo))
# Judge status: Accepted
#!/usr/bin/env python3
import sys
sys.setrecursionlimit(10**6)

a, b = list(map(int, input().split()))
s = str(input())

x = s.split("-")

if len(x[0]) == a and len(x[1]) == b:
    print("Yes")
else:
    print("No")
# Judge status: Accepted
n,m = list(map(int,input().split()))

if n == m:
  print('Yes')
else:
  print('No')
# Judge status: Accepted
# 解説AC

N = (-1) * int(input())

if N == 0:
    print(0)
    exit()

ans = ""

while N != 0:
    N, r = divmod(N, -2)

    ans += "1" if r else "0"

print(ans[::-1])
# Judge status: Wrong Answer
N=int(input())

if N >= 0:
  n = N
  b = bin(N)[2:]
  for i in range(len(b)):
    if i%2==1 and b[-i-1]=='1':
      n += 2**(i+1)
  print(bin(n)[2:])
  
else:
  n = -N
  b = bin(-N)[2:]
  for i in range(len(b)):
    if i%2==0 and b[-i-1]=='1':
      n += 2**(i+1)
  print(bin(n)[2:])
# Judge status: Accepted
N, K  = map(int, input().split())

print(0 if N%K==0 else 1)
# Judge status: Wrong Answer
import numpy as np
def main():
    N,M = map(int,input().split())
    A = [int(x) for x in input().split()]
    for _ in range(M):
        b,c = map(int, input().split())
        for i in range(b):
            A.append(c)
    np.array(A).sort()
    print(sum(A[-N:]))
main()
# Judge status: Accepted
import math
t=[0]*5
s=[0]*5
ans=0
for i in range(5):
    t[i]=int(input())
    s[i]=math.ceil(t[i]/10)*10-t[i]
    ans+=math.ceil(t[i]/10)*10
print(ans-max(s))
# Judge status: Accepted
a,b,c,d = map(int, input().split())
print(max(0, min(b,d) - max(a,c)))
# Judge status: Accepted
a, b, x = list(map(int, input().split()))
if a <= x <= a + b:
    print('YES')
else:
    print('NO')
# Judge status: Accepted
N,K = map(int,input().split())
S = input()
hapiness = [0 for i in range(N)]
if S[0] == 'R' and S[1]=='R':
    hapiness[0]=1
for i in range(1,N-1):
    if S[i]=='L' and S[i-1]=='L':
        hapiness[i]=1
    if S[i]=='R' and S[i+1]=='R':
        hapiness[i]=1
if S[N-1]=='L' and S[N-2]=='L':
    hapiness[N-1]=1
ans = sum(hapiness)+K*2
print(min(ans,N-1))
# Judge status: Accepted
r,g,b = input().split()
print("YES" if int(r+g+b) % 4 == 0 else "NO")
# Judge status: Accepted
a,b = map(int, input().split())
if a > 9 or b > 9:
    print(-1)
else:
    print(a*b)
# Judge status: Accepted
n,k=map(int,input().split())
a=list(map(int,input().split()))

old = 0

for i in range(k,n+1):
  if i == k:
    new = 1
  elif i != k:
    new = a[i-1] / a[i-k-1]
    if new > 1:
      print("Yes")
    else:
      print("No")
  old = new
# Judge status: Accepted
X=int(input())
if X>=30:print("Yes")
else:print("No")
# Judge status: Accepted

N = int(input())
X = list(map(int, input().split()))

ans = 0
cnt = 0
cur = X[0]
for i in range(1, N):
    if cur < X[i]:
        ans = max(ans, cnt)
        cnt = 0
    else:
        cnt += 1
    cur = X[i]

print(max(ans, cnt))
# Judge status: Accepted
#coding: utf-8
import math
import heapq
import bisect
import numpy as np
from collections import Counter, deque
import itertools
#from scipy.misc import comb

sx,sy,tx,ty = map(int, input().split())
ans = 'U'*(ty-sy) + 'R'*(tx-sx) + 'D'*(ty-sy) + 'L'*(tx-sx+1) + 'U'*(ty-sy+1) + 'R'*(tx-sx+1) + "DR" + 'D'*(ty-sy+1) + 'L'*(tx-sx+1) + 'U'
print(ans)
# Judge status: Accepted
import sys
N = int(input())
for i in range(1, 10):
    for j in range(1, 10):
        if i*j == N:
            print('Yes')
            sys.exit()
print('No')
# Judge status: Accepted
N = int(input())
print(N * (N - 1) // 2)
# Judge status: Accepted
a,b = map(int, input().split())
if a%3 == 0 or b%3 == 0 or (a+b)%3 == 0:
  print("Possible")
else:
  print("Impossible")
# Judge status: Accepted
import math
n, m = map(int, input().split())
fact = []
ans = 1
MAX = int(math.sqrt(m)) + 1
for i in range(1, MAX):
    if m % i == 0:
        fact.append(i)
        if i != m // i:
            fact.append(m//i)
fact.sort()
for x in fact:
    if m < n * x:
        break
    ans = x
print(ans)
# Judge status: Accepted
def resolve():
    n = int(input())
    h = list(map(int, input().split()))
    dp = [float("inf") for i in range(n)]
    dp[0] = 0

    for i in range(n-1):
        dp[i+1] = min(dp[i+1], dp[i] + abs(h[i+1] - h[i]))
        if i < n-2:
            dp[i+2] = min(dp[i+2], dp[i] + abs(h[i+2] - h[i]))

    print(dp[n-1])
    
resolve()
# Judge status: Accepted
from collections import deque
f=input
s=deque(f())
n=int(f())
t=0
for i in range(n):
  q=f()
  if q[0]=='1': t=1-t
  elif int(q[2])+t==2: s.append(q[4])
  else: s.appendleft(q[4])
print(''.join([s,list(s)[::-1]][t]))
# Judge status: Accepted
n,*a=map(int,open(0).read().split())
b=sum(a)
c=1
ans=1
if a[0]==1 and n==0:
    print(1)
    exit()
if a[0]>0:
    print(-1)
    exit()
for i in a[1:]:
    b-=i
    c=min(c*2-i,b)
    ans+=c
    if c<0:
        print(-1)
        exit()
print(ans+sum(a))
# Judge status: Accepted
from collections import Counter

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

c=Counter(a)
s=0
for key in c:
    s+=c[key]*(c[key]-1)//2
for item in a:
    print(s-c[item]+1)
# Judge status: Accepted
A,B,C,K=map(int,input().split())

if K%2==1:
    ans=B-A
else:
    ans=A-B

print(ans)
# Judge status: Accepted
n=int(input())
s=input()

sumBlack = [0]*(n+1)
sumWhite = [0]*(n+1)
for i in range(1,n+1):
    sumBlack[i] = sumBlack[i-1]
    if s[i-1] == '#':
        sumBlack[i] += 1

for i in range(n-1,-1,-1):
    sumWhite[i] = sumWhite[i+1]
    if s[i] == '.':
        sumWhite[i] += 1

ans = 12345678901234
for i in range(n+1):
    ans = min(ans,sumBlack[i]+sumWhite[i])
print(ans)
# Judge status: Wrong Answer
import sys
a, b =map(int, input().split())
if a == b or b == 1:
  print(1)
  sys.exit()
 
c = b//a
if a*c == b:
  print(c)
else:
  print(c +1)
# Judge status: Accepted
import sys
input = lambda: sys.stdin.readline().rstrip()

N, M = map(int, input().split())

def divisor(a):
    res = []
    for i in range(1, int(a**0.5)+1):
        if a % i == 0:
            res.append(i)
            res.append(a//i)
    return res
    
div = divisor(M)
div.sort(reverse=True)

for d in div:
    if d * N <= M:
        print(d)
        exit()
# Judge status: Wrong Answer
D = int(input())
print("Christmas" + "Eve "*(25-D))
# Judge status: Accepted
x, a, b = map(int, input().split())

A = abs(x - a)
B = abs(x - b)

if A < B:
  print("A")
else:
  print("B")
# Judge status: Accepted
def main():
    N, K = map(int, input().split())
    D = list(input().split())
    
    for i in range(N,100000):
        a = str(i)
        flag = True
        for d in D:
            if d in a:
                flag = False
                break
        if flag:
            print(i)
            exit()



if __name__ == "__main__":
    main()
# Judge status: Accepted
N,M,K=map(int, input().split())
print("YNeos"[not any(K==i*j+(N-i)*(M-j) for i in range(N+1) for j in range(M+1))::2])
# Judge status: Accepted
N,M,K = map(int,input().split())

ans = "No"
for i in range(N+1):
    for j in range(M+1):
        black = i*M + j*N -2*i*j
        if black == K:
            ans = "Yes"
            break
    if ans == "Yes":
        break

print(ans)
# Judge status: Accepted
def main():
    import sys
    input = sys.stdin.readline
    N = int(input())
    if N % 10 in (2,4,5,7,9):
        print("hon")
    elif N % 10 in (0,1,6,8):
        print("pon")
    else:
        print("bon")

if __name__ == '__main__':
    main()
# Judge status: Accepted
N=int(input())
A=list(map(int,input().split()))

_sum=sum(A[1:])
mod=10**9+7
re=0
for i in range(0,N-1):
    re+=A[i]*_sum
    _sum-=A[i+1]
    re%=mod
    _sum%=mod
print(re%mod)
# Judge status: Wrong Answer
n = int(input())

if int(round(n/1.08)*1.08) == n :
    print(round(n/1.08))
else:
    print(":(")
# Judge status: Accepted
N,M=map(int,input().split(" "))
A=[int(s) for s in input().split(" ")]

Ans=0
for i in range(M):
    Ans+=A[i]

print(N-Ans if Ans<=N else -1)