Harryxun/sft_time huggingface dataset:
### BUGGY CODE ###

import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)


def main():
    n,p = LI()
    if n == 1:
        return p
    r = 1
    i = 2
    while 1:
        t = i**n
        if p < t:
            break
        if p % t == 0:
            r *= i
            p //= t
        elif i == 2:
            i += 1
        else:
            i += 2
    return r


print(main())


### FIXED CODE ###

import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)


def main():
    n,p = LI()
    if n == 1:
        return p
    if math.log(p) / math.log(2) < n - 1:
        return 1
    r = 1
    i = 2
    while 1:
        t = i**n
        if p < t:
            break
        if p % t == 0:
            r *= i
            p //= t
        elif i == 2:
            i += 1
        else:
            i += 2
    return r


print(main())
### BUGGY CODE ###

import numpy as np
n = int(input())
v = np.array([(0,0,0)]+[tuple(map(int, input().split( ))) for i in range(n)])


for i in range(n):
    if (v[i+1]+v[i]).sum()%2:
        print("No")
        exit()
    if v[i+1][0]-v[i][0]<abs(v[i+1][1:]-v[i][1:]).sum():
        print("No")
        exit()
print("Yes")

### FIXED CODE ###


n = int(input())
v = [(0,0,0)]+[tuple(map(int, input().split( ))) for i in range(n)]


for i in range(n):
    if (v[i+1][0]+v[i][0]+v[i+1][1]+v[i][1]+v[i+1][2]+v[i][2])%2:
        print("No")
        exit()
    if v[i+1][0]+v[i][0]<abs(v[i+1][1]-v[i][1])+abs(v[i+1][2]-v[i][2]):
        print("No")
        exit()
print("Yes")
### BUGGY CODE ###

import sys
import itertools
# import numpy as np
import time
import math

sys.setrecursionlimit(10 ** 7)

from collections import defaultdict

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

s = input()

ans = 0
for i in range(len(s)):
    for j in range(i + 1, len(s) + 1):
        # print(s[i:j])
        n = s[i:j]
        if int(n) % 2019 == 0:
            ans += 1
print(ans)

### FIXED CODE ###

import sys
import itertools
# import numpy as np
import time
import math

sys.setrecursionlimit(10 ** 7)

from collections import defaultdict

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

n = input()
n = reversed(n)

x = 1
count = [0 for _ in range(2019)]
MOD = 2019
acc = 0
count[0] = 1
ans = 0

for c in n:
    a = x * int(c)
    acc += a
    acc %= MOD
    ans += count[acc]
    count[acc] += 1
    x = (x * 10) % MOD

print(ans)
### BUGGY CODE ###



def gcd_core(a, b):
    while b != 0:
        a, b = b, a % b
    return a

def gcd(arr):
    g = gcd_core(arr[0], arr[1])
    for i in range(2, len(arr)):
        g = gcd_core(g, arr[i])
    return g


def lcm_core(a,b):
    g = gcd_core(a,b)
    return (a*b)//g

def lcm(arr):
    if len(arr) == 1:
        return arr[0]
    else:
        newl = []
        ind = 0
        while True:
            if ind + 1 < len(arr):
                newl.append(lcm_core(arr[ind],arr[ind+1]))
                ind += 2
            else:
                newl.append(arr[ind])
                ind += 1
            if ind >= len(arr):
                break
        return lcm(newl)


n = int(input())

if n == 1:
    print(1)
else:
    arr = list(map(int,input().split()))
    l = lcm(arr)
    m = 10**9+7
    l,mcnt = l%m,l//m
    # print(l)
    # buf = []
    # for i in range(n):
    #     buf.append(l/arr[i])
    # print(buf)
    ans = 0
    for i in range(n):
        temp1 = l // arr[i] + (m // arr[i]) * mcnt
        temp2 = l % arr[i] + (m % arr[i]) * mcnt
        # print(temp2%arr[i])
        temp2 = temp2 // arr[i]
        ans += temp1 + temp2
        ans %= m
    ans %= m
    print(ans)


### FIXED CODE ###

import fractions
from functools import reduce

def gcd(*numbers):
  return reduce(fractions.gcd, numbers)

def gcd_list(numbers):
  return reduce(fractions.gcd, numbers)

def lcm_base(x, y):
    return (x * y) // fractions.gcd(x, y)

def lcm(*numbers):
    return reduce(lcm_base, numbers, 1)

def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)

N = int(input())
A = tuple(map(int, input().split()))

mod = 10 ** 9 + 7

l = lcm_list(A)

ans = 0

for i in range(N):
  ans += l // A[i]

ans = ans % mod

print(ans)
### BUGGY CODE ###

N,K=map(int,input().split())
h=[int(i) for i in input().split()]
dp=[0]
for i in range(1,N):
    dp.append(1000000000)
for i in range(0,N):
    for j in range(1,K+1):
        if(j+i<N):
            dp[j+i]=min(dp[j+i],dp[i]+abs(h[i]-h[j+i]))
#print(dp)
print(dp[N-1])

### FIXED CODE ###

N,K=map(int,input().split())
h=[int(i) for i in input().split()]
dp=[0]
for i in range(1,N):
    dp.append(1000000000)
for i in range(0,N):
    li=[j+i for j in range(1,K+1)]
    #print(li)
    for j in li:
        if(j<N):
            dp[j]=min(dp[j],dp[i]+abs(h[i]-h[j]))
#print(dp)
print(dp[N-1])
### BUGGY CODE ###

def solve(string):
    from functools import reduce
    from operator import mul
    n, *a = map(int, string.split())
    a = reduce(mul, a)
    return "-1" if a > 10**18 else str(a)


if __name__ == '__main__':
    import sys
    print(solve(sys.stdin.read().strip()))


### FIXED CODE ###

def solve(string):
    n, *a = map(int, string.split())
    a = sorted(a)
    ans = 1
    for _a in a:
        ans *= _a
        if ans > 10**18:
            return "-1"
        if ans == 0:
            return "0"
    return str(ans)


if __name__ == '__main__':
    import sys
    print(solve(sys.stdin.read().strip()))
### BUGGY CODE ###

#https://atcoder.jp/contests/abc098/tasks/arc098_a

n = int(input())
def process(x):
    if x=='E':
        return 0
    else:
        return 1
data = list(map(process, list(input())))

l = [0 for _ in range(n-1)]
for i in range(n-1):
    t = 0
    if data[i]==1:
        t += 1
    if data[i+1]==0:
        t -= 1
    l[i] = t

def default():
    cost = 0
    for value in data[1:]:
        if value == 0:
            cost += 1
    return cost
d = default()

if min([sum(l[:j+1]) for j in range(n-1)]) < 0:
    print(d + min([sum(l[:j+1]) for j in range(n-1)]))
else:
    print(d)


### FIXED CODE ###

#https://atcoder.jp/contests/abc098/tasks/arc098_a

n = int(input())
d = input()

pre = d[1:].count('E')
minimum = pre
for i in range(1,n):
    if d[i-1]=='W':
        pre = pre+1
    if d[i]=='E':
        pre = pre-1
    minimum = min(pre, minimum)

print(minimum)
### BUGGY CODE ###

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

def getNum(a, b):
    while(True):
        a, b = max(a, b), min(a, b)
        if a == b:
            return a
        a -= b

leftGBC, rightGBC= [AList[0]], [AList[-1]]
for i in range(1, N):
    leftGBC.append(getNum(leftGBC[i - 1], AList[i]))
for i in range(1, N):
    rightGBC.append(getNum(rightGBC[i - 1], AList[N - i - 1]))

rightGBC.reverse()

ans = max(leftGBC[-2], rightGBC[1])
for i in range(0, N-2):
    ans = max(getNum(leftGBC[i], rightGBC[i + 2]), ans)

print(ans)



### FIXED CODE ###

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

def getNum(a, b):
    while(True):
        if a == 0:
            return b
        a, b = max(a, b), min(a, b)
        a %= b

leftGBC, rightGBC= [AList[0]], [AList[-1]]
for i in range(1, N):
    leftGBC.append(getNum(leftGBC[i - 1], AList[i]))
for i in range(1, N):
    rightGBC.append(getNum(rightGBC[i - 1], AList[N - i - 1]))

rightGBC.reverse()

ans = max(leftGBC[-2], rightGBC[1])
for i in range(0, N-2):
    ans = max(getNum(leftGBC[i], rightGBC[i + 2]), ans)

print(ans)
### BUGGY CODE ###

n=int(input())
a=list(map(int,input().split()))
ans=[0]*(n+1)

for i in range(0,n+1):
    for j in range(0,n-1):
        if a[j]==i:
            ans[i]+=1
ans=ans[1:]
ansstr=''
for i in range(len(ans)):
    print(ans[i])



### FIXED CODE ###

n=int(input())
a=list(map(int,input().split()))
ans=[0]*(n+1)

for i in range(len(a)):
    ans[a[i]]+=1
ans=ans[1:]
ansstr=''
for i in range(len(ans)):
    print(ans[i])
### BUGGY CODE ###

import bisect
def main():
  N=int(input())
  A=list(map(int,input().split()))
  B=list(map(int,input().split()))
  ans=[]
  for i in range(29):
    T=2**i
    B_=list(B)
    A_=list(A)
    t=0
    for j in range(N):
      B_[j]%=2*T
      A_[j]%=2*T
    B_.sort()
    for j in range(N):
      a=A_[j]
      p=bisect.bisect_left(B_,T-a)
      q=bisect.bisect_left(B_,2*T-a)
      r=bisect.bisect_left(B_,3*T-a)
      t+=(q-p)+(N-r)
    ans.append(t%2)
  a=0
  for i in range(29):
    a+=2**i*ans[i]
  print(a)
if __name__=='__main__':
  main()


### FIXED CODE ###

def main():
  N=int(input())
  A=list(map(int,input().split()))
  B=list(map(int,input().split()))
  ans=[]
  for i in range(29):
    T=2**i
    B_=list(B)
    A_=list(A)
    t=0
    for j in range(N):
      B_[j]%=2*T
      A_[j]%=2*T
    A_.sort()
    B_.sort()
    p=q=r=0
    for a in A_[::-1]:
      while p<N and a+B_[p]<T:
        p+=1
      while q<N and a+B_[q]<2*T:
        q+=1
      while r<N and a+B_[r]<3*T:
        r+=1
      t+=(q-p)+(N-r)
    ans.append(t%2)
  a=0
  for i in range(29):
    a+=2**i*ans[i]
  print(a)
if __name__=='__main__':
  main()
### BUGGY CODE ###

import numpy as np

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

count = 0
ans = np.array([np.array(a) % a[0]])
for i in range(1, n):
    ans = np.insert(ans, i, np.array(a) % a[i], axis=0)

count = 0
for i in range(n):
    if np.count_nonzero(ans.T[i] == 0) == 1:
        count += 1

print(count)

### FIXED CODE ###

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

a_max = a[-1]
dp = [1]*a_max

for i in set(a):
    j = 2
    while i*j <= a_max:
        dp[i*j-1] = 0
        j += 1

a.append(0)
ans = 0
for i in range(n):
    if dp[a[i]-1] and a[i-1] != a[i] and a[i] != a[i+1]:
        ans += 1
print(ans)
### BUGGY CODE ###

n, k, q = [int(i) for i in input().split()]
point = [k] * n
for _ in range(q):
    a = int(input())
    point = [p-1 if i != a-1 else p for i,p in enumerate(point)]
[print('Yes') if i > 0 else print('No') for i in point]


### FIXED CODE ###

from collections import Counter

n, k, q = [int(i) for i in input().split()]
a = []
for i in range(q):
    a.append(int(input()))

c = Counter(a)
for i in range(1, n+1):
    print('Yes') if k-q+c[i] > 0 else print('No')
### BUGGY CODE ###

import bisect
import copy

def check(a, b, bar):
    sm = 0
    cnt = 0
    n = len(a)
    for x in a:
        i = bisect.bisect_left(a, bar - x)
        if i == n:
            continue

        cnt += n - i
        sm += b[i] + x * (n-i)
        
    return cnt, sm

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

b = copy.deepcopy(a)
for i,_ in enumerate(b[:-1]):
    b[n-i-2] += b[n-i-1]
    
left = 0
right = b[0] * 2

while right - left > 1:
    middle = ( right + left ) // 2    
    if check(a, b, middle)[0] < m:
        right = middle
    else:
        left = middle
             
print(check(a, b, left)[1] - left * (check(a, b, left)[0]-m) ) 

### FIXED CODE ###

import bisect
import copy

def check(a, b, bar):
    sm = 0
    cnt = 0
    n = len(a)
    for x in a:
        i = bisect.bisect_left(a, bar - x)
        if i == n:
            continue

        cnt += n - i
        sm += b[i] + x * (n-i)
        
    return cnt, sm

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

b = copy.deepcopy(a)
for i,_ in enumerate(b[:-1]):
    b[n-i-2] += b[n-i-1]
    
left = 0
right = b[0] * 2

while right - left > 1:
    middle = ( right + left ) // 2    
    if check(a, b, middle)[0] < m:
        right = middle
    else:
        left = middle
             
print(check(a, b, left)[1] - left * (check(a, b, left)[0]-m) )
### BUGGY CODE ###


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

edge = [[] for _ in range(n)]

counter = [0] * n

for _ in range(n-1):
    a, b = map(int, input().split())
    edge[a-1].append(b-1)
    edge[b-1].append(a-1)

for _ in range(q):
    a, b = map(int, input().split())
    counter[a-1] += b

parent = [0]
s_next = {0}

for i in parent:
    for v in edge[i]:
        # if v in parent:
        #     continue
        if v in s_next:
            continue
        s_next.add(v)
        parent.append(v)
        counter[v] += counter[i]
        
print(" ".join(map(str, counter)))

### FIXED CODE ###


# n, q = map(int, input().split())

# edge = [[] for _ in range(n)]

# counter = [0] * n

# for _ in range(n-1):
#     a, b = map(int, input().split())
#     edge[a-1].append(b-1)
#     edge[b-1].append(a-1)

# for _ in range(q):
#     a, b = map(int, input().split())
#     counter[a-1] += b

# parent = [0]
# visited = []

# for i in parent:
#     visited.append(i)
#     for v in edge[i]:
#         if v in visited:
#             continue
#         parent.append(v)
#         counter[v] += counter[i]
        
# for i in range(n):
#     print(counter[i], end=" ")
# print("")

import sys
input = sys.stdin.readline
 
N, Q = [int(x) for x in input().split()]
 
edge = [[] for _ in range(N)]
for _ in range(N - 1):
    a, b = [int(x) for x in input().split()]
    edge[a - 1].append(b - 1)
    edge[b - 1].append(a - 1)
 
cost = [0] * N
for _ in range(Q):
    p, x = [int(x) for x in input().split()]
    cost[p - 1] += x
 
next = [0]
s_next = {0}
for i in next:
    for v in edge[i]:
        if v in s_next:
            continue
        s_next.add(v)
        next.append(v)
        cost[v] += cost[i]
 
print(" ".join(map(str, cost)))
### BUGGY CODE ###

from itertools import product, combinations
import numpy as np

N = int(input())

dp = np.zeros(shape=(N, N), dtype=int)

for i in range(N):
    dp[i] = np.array(list(map(int, input().split(' '))))

original = dp.copy()

for k, i in product(range(N), repeat=2):
    dp[i] = np.minimum(dp[i], dp[i][k] + dp[k])

if not np.all(dp == original):
    print(-1)
else:
    costs = []
    for i in range(N):
        for j in range(i + 1, N):
            costs.append(dp[i][j])
    sum_set = set(map(sum, combinations(costs, r=2)))
    result = 0
    for cost in costs:
        if cost not in sum_set:
            result += cost
    print(result)


### FIXED CODE ###

import copy
from itertools import product, combinations

N = int(input())

dp = []
for _ in range(N):
    dp.append(list(map(int, input().split(' '))))

original = copy.deepcopy(dp)

for k, i, j in product(range(N), repeat=3):
    dp[i][j] = min(dp[i][j], dp[i][k] + dp[k][j])

if dp == original:
    cost = 0
    for i in range(N):
        for j in range(i + 1, N):
            for k in range(N):
                if k == i or k == j:
                    continue
                if dp[i][j] == dp[i][k] + dp[k][j]:
                    break
            else:
                cost += dp[i][j]
    print(cost)
else:
    print(-1)
### BUGGY CODE ###

# coding: utf-8
num = int(input())


def make_sum(ind):
    num_sum = 0
    for i in range(1, ind + 1):
        num_sum += i
    return num_sum

ans = 0

if num == 1:
    print(1)
else:
    while True:
        ans += 1
        if make_sum(ans) < num <= make_sum(ans + 1):
            break

    print(ans + 1)

### FIXED CODE ###

# coding: utf-8
num = int(input())


# def make_sum(ind):
#     return sum(range(1, ind + 1))

ans = 0
sum_num = 0

if num == 1:
    print(1)
else:
    while True:
        ans += 1
        sum_num += ans
        if sum_num < num <= (sum_num + ans + 1):
            break

    print(ans + 1)
### BUGGY CODE ###

n = int(input())
a = list(map(int,input().split()))
    
#dics min max
dicsmin = min(a)
dicsmax = max(a)

counter = []
for i in range(dicsmin,dicsmax + 1):
    xcount = 0
    x = i
    for k in range(len(a)):
        if a[k] == x or a[k] == x-1 or a[k] == x + 1:
            xcount = xcount + 1
    counter.append(xcount)

print(max(counter))

### FIXED CODE ###

n = int(input())
a = list(map(int,input().split()))
aa = []
amax = max(a) + 100


for i in range(amax + 1):
    aa.append(0)

for i in range(len(a)):
    aa[a[i]] = aa[a[i]] + 1
    
kouho = 1    
for j in range(len(aa) - 2):
    if kouho < aa[j] + aa[j + 1] + aa[j + 2]:
        kouho = aa[j] + aa[j + 1] + aa[j + 2]

print(kouho)
### BUGGY CODE ###

s = input()
n = len(s)

countdic = {}
mod = 2019

for i in range(1,n+1):
    num = int(s[n-i:n])
    remainder = num%mod
    if remainder in countdic:
        countdic[remainder] += 1
    if remainder not in countdic:
        countdic[remainder] = 1

ans = 0
for key in countdic:
    ans += countdic[key]*(countdic[key]-1)//2

if 0 in countdic:
    ans += countdic[0]

print(ans)

### FIXED CODE ###

s = list(map(int, list(input())))
n = len(s)

countdic = {}
mod = 2019

num = 0
d = 1
for i in range(1,n+1):
    num += s[n-i]*d
    num %= mod
    if num in countdic:
        countdic[num] += 1
    if num not in countdic:
        countdic[num] = 1
    d = (10*d)%mod

ans = 0
for key in countdic:
    ans += countdic[key]*(countdic[key]-1)//2

if 0 in countdic:
    ans += countdic[0]

print(ans)
### BUGGY CODE ###

def GCD(a, b):
    """ Euclidean algorithm"""
    if a < b: (a, b) = (b, a)
    m = a % b
    while m != 0:
        a = b
        b = m
        m = a % b
    return b

def GCD_of(a):
    """ Calc gcd of an array a"""
    allgcd = a[0]
    for value in a:
        allgcd = GCD(allgcd, value)
    return allgcd

N = int(input())
A = [ int(v) for v in input().split() ]

if N < 2 and 1e5 < N: raise()
for v in A:
    if v < 1 and v < 1e9: raise()

result = 0
for skip in range(N):
    tmp_max = GCD_of( [ A[i] for i in range(N) if not i == skip ] )
    if result < tmp_max: result = tmp_max
print(result)


### FIXED CODE ###

def GCD(a, b):
    """ Euclidean algorithm"""
    if a < b: (a, b) = (b, a)
    if b == 0: return a
    m = a % b
    while m != 0:
        a = b
        b = m
        m = a % b
    return b

N = int(input())
A = [ int(v) for v in input().split() ]

if N < 2 and 1e5 < N: raise()
for v in A:
    if v < 1 and v < 1e9: raise()


l_list = []
l = 0
for i in range(0, N):
    l = GCD(l, A[i])
    l_list.append( l )

r_list = []
r = 0
for i in range(-1, -(N+1), -1):
    r = GCD(r, A[i])
    r_list.append( r )

n = []    
for i in range(0, N):
    if i-1 < 0:
        l = 0
    else:
        l = l_list[i-1]
    if N-i-2 < 0:
        r = 0
    else:
        r = r_list[N-i-2]
    n.append(GCD(l, r))
print(max(n))
### BUGGY CODE ###

f=lambda:map(int,input().split())
N,Q=f()
a,b=N,N
black=(N-2)*(N-2)
B=[-1]*(N+1)
W=[-1]*(N+1)
for _ in range(Q):
    q,x=f()
    if q==1:
        if B[x]>0:
            black-=B[x]
            B[x]=0
        else:
            black-=b-2
            a=x
            for j in range(a+1,N+1):
                if B[j]==-1:
                    B[j]=b-2
                if j==N-1:
                    break
    else:
        if W[x]>0:
            black-=W[x]
            W[x]=0
        else:
            black-=a-2
            b=x
            for j in range(b+1,N+1):
                if W[j]==-1:
                    W[j]=a-2
                if j==N-1:
                    break
print(black)

### FIXED CODE ###

f=lambda:map(int,input().split())
N,Q=f()
a,b=N,N
black=(N-2)*(N-2)
B=[-1]*(N+1)
W=[-1]*(N+1)
for _ in range(Q):
    q,x=f()
    if q==1:
        if B[x]>0:
            black-=B[x]
            B[x]=0
        else:
            black-=b-2
            a=x
            for j in range(a+1,N+1):
                if B[j]==-1:
                    B[j]=b-2
                else:
                    break
                if j==N-1:
                    break
    else:
        if W[x]>0:
            black-=W[x]
            W[x]=0
        else:
            black-=a-2
            b=x
            for j in range(b+1,N+1):
                if W[j]==-1:
                    W[j]=a-2
                else:
                    break
                if j==N-1:
                    break
print(black)
### BUGGY CODE ###

s = input()
n = int(input())
f = 1
for i in range(n):
  l = list(map(str, input().split()))
  if l[0] == "2":
    tmp = int(l[1])*f
    if tmp == 1 or tmp == -2:
      s = l[2] + s
    else:
      s = s + l[2]
  else:
    f *= -1


print(s if f == 1 else s[::-1])


### FIXED CODE ###

from collections import deque
s = deque(input())
#s = input()
n = int(input())
f = 1
for i in range(n):
  l = list(map(str, input().split()))
  if l[0] == "2":
    tmp = int(l[1])*f
    if tmp == 1 or tmp == -2:
      s.appendleft(l[2])
    else:
      s.append(l[2])
  else:
    f *= -1

if f == -1:
  s.reverse()
print("".join(s))
### BUGGY CODE ###

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

if P == 2 or P == 5:
    ans = 0
    for i in range(N):
        if int(S[i]) % P == 0:
            ans += i+1
    print(ans)
else:
    mod_cnt = [0]*P
    mod_cnt[0] = 1
    k = 0
    for i in range(1, N+1):
        k += 10**(i-1) * int(S[-i])
        mod_cnt[k % P] += 1
    ans = 0
    for cnt in mod_cnt:
        ans += (cnt * (cnt-1)) // 2
    print(ans)


### FIXED CODE ###

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

if P == 2 or P == 5:
    ans = 0
    for i in range(N):
        if int(S[i]) % P == 0:
            ans += i+1
    print(ans)
else:
    mod_cnt = [0]*P
    mod_cnt[0] = 1
    k = 0.1
    t = 0
    for i in range(1, N+1):
        k = int(k * 10) % P
        t = (t + k * int(S[-i])) % P
        mod_cnt[t] += 1
    ans = 0
    for cnt in mod_cnt:
        ans += (cnt * (cnt-1)) // 2
    print(ans)
### BUGGY CODE ###

k = int(input())
if k % 2 == 0:
    print(-1)
else:
    mod = 7 % k
    counter = 1
    memo = 1
    while mod != 0:
        memo = ((memo % k) * (10 % k)) % k
        mod = (mod + 7 * memo) % k
        counter += 1
        if mod == 0:
            break
    print(counter)


### FIXED CODE ###

k = int(input())
if k % 2 == 0:
    print(-1)
else:
    mod = 7 % k
    counter = 1
    memo = 1
    mod_map = set()
    mod_map.add(mod)
    while mod != 0:
        memo = ((memo % k) * (10 % k)) % k
        mod = (mod + 7 * memo) % k
        if mod not in mod_map:
            mod_map.add(mod)
        else:
            counter = -1
            break
        counter += 1
        if mod == 0:
            break
    print(counter)
### BUGGY CODE ###

import networkx as nx
n,m=map(int,input().split())
s=[list(map(int,input().split())) for i in range(m)]

g=nx.Graph()
g.add_nodes_from([i for i in range(1,n+1)])

for x in s:
    g.add_edge(x[0],x[1])
di=nx.predecessor(g,source=1)

if len(di)!=n:
    print("No")
    exit()

print("Yes")
for x in range(2,n+1):
    print(di[x][0])


### FIXED CODE ###

N, M = map(int, input().split())
link = [[] for i in range(N)]
for i in range(M):
    A, B = map(int, input().split())
    link[A-1].append(B-1)
    link[B-1].append(A-1)
visited = [False for i in range(N)]
result = [0] * N
Q = [0]
visited[0] = True
#Qに要素がなくなるまで
while Q:
    #一番上の要素をpop
    v = Q.pop(0)
    for i in link[v]:
        if visited[i] == False:
            visited[i] = True
            result[i] = v
            Q.append(i)
print("Yes")
for i in range(1, N):
    print(result[i] + 1)