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

def check_road(start, road_array, mark_array):
    search_target = []
    search_target.append(start)

    while len(search_target) > 0:
        target = search_target[0]
        for road in road_array:
            if target in road and mark_array[road[abs(1-road.index(target))]] is None and road[abs(1-road.index(target))] != 1:
                # 逆側の要素を返す
                # print('{}を探している、次は{}へ移動'.format(
                #     target, road[abs(1-road.index(target))]))
                mark_array[road[abs(1-road.index(target))]] = target
                search_target.append(road[abs(1-road.index(target))])
        del search_target[0]


# 部屋の数 通路の数
N, M = map(int, input().split())
road_array = []
for i in range(M):
    road_array.append(list(map(int, input().split())))
mark_array = [None] * (N+1)
check_road(1, road_array, mark_array)
mark_array = mark_array[2:]

if None in mark_array:
    print('No')
else:
    print('Yes')
    for mark in mark_array:
        print(mark)


### FIXED CODE ###

def check_road(start, road_array, mark_array):
    search_target = []
    search_target.append(start)

    while len(search_target) > 0:
        target = search_target[0]
        if len(road_array[target]) != 0:
            for road in road_array[target]:
                if road is not None and mark_array[road] is None and road != 1:
                    # 逆側の要素を返す
                    # print('{}を探している、次は{}へ移動'.format(
                    #     target, road[abs(1-road.index(target))]))
                    mark_array[road] = target
                    search_target.append(road)
        del search_target[0]


# 部屋の数 通路の数
N, M = map(int, input().split())
road_array = [[None] for i in range(N+1)]
# for i in road_array:
#     print(i)
#     print(len(road_array))
for i in range(M):
    a, b = map(int, input().split())
    tmp_a = road_array[a]
    tmp_b = road_array[b]
    # print('チェック{}'.format(i))
    # print('チェック{}'.format(tmp_a))
    # print('チェック{}'.format(tmp_b))
    tmp_a.append(b)
    tmp_b.append(a)
    road_array[a] = tmp_a
    road_array[b] = tmp_b

mark_array = [None] * (N+1)
check_road(1, road_array, mark_array)
mark_array = mark_array[2:]

if None in mark_array:
    print('No')
else:
    print('Yes')
    for mark in mark_array:
        print(mark)
### BUGGY CODE ###

_=input();a=list(map(int,input().split(' ')));q=int(input())
for _ in range(q):
    b,c = map(int,input().split(' '))
    a = list(map(lambda i: c if i == b else i, a))
    print(sum(a))

### FIXED CODE ###

from collections import Counter
n = int(input())
a = list(map(int, input().split()))
q = int(input())
counter = Counter(a)
sum_res = sum(a)
for _ in range(q):
    before, after = map(int, input().split())
    sum_res -= before * counter[before]
    sum_res += after * counter[before]
    counter[after] += counter[before]
    counter[before] = 0
    print(sum_res)
### BUGGY CODE ###

#!/usr/bin/python
# -*- coding: utf-8 -*-
import sys
import math
import collections
import heapq

INF = 10 ** 10

Q, = map(int, sys.stdin.readline().rstrip().split(" "))
b_all = 0
sum_value = 0
k_value = 0
tree = None
qs = [list(map(int, sys.stdin.readline().rstrip().split(" "))) for _ in range(Q)]
# for _ in range(Q):
#     query = list(map(int, sys.stdin.readline().rstrip().split(" ")))

left = []
right = []
a_s = []
current_median = None
heapq.heappush(left, INF)
heapq.heappush(right, INF)
for query in qs:
    if query[0] == 1:
        _, a, b = query
        a_s.append(a)
        b_all += b

        heapq.heappush(left, -a)
        heapq.heappush(right, a)
        heapq.heappush(left, -heapq.heappop(right))
        heapq.heappush(right, -heapq.heappop(left))
        current_median = -left[0]
    else:
        value = 0
        for a in a_s:
            value += abs(a - current_median)
        print(current_median, value+b_all)

exit(0)


### FIXED CODE ###

#!/usr/bin/python
# -*- coding: utf-8 -*-
import sys
import math
import collections
import heapq

INF = 10 ** 10

Q, = map(int, sys.stdin.readline().rstrip().split(" "))
b_all = 0
sum_value = 0
k_value = 0
tree = None
qs = [list(map(int, sys.stdin.readline().rstrip().split(" "))) for _ in range(Q)]

left = []
right = []
a_s = []
current_median = None
heapq.heappush(left, INF)
heapq.heappush(right, INF)
a_current = 0
for query in qs:
    if query[0] == 1:
        _, a, b = query
        a_s.append(a)
        b_all += b

        last_left, last_right = -left[0], right[0]
        heapq.heappush(left, -a)
        heapq.heappush(right, a)
        heapq.heappush(left, -heapq.heappop(right))
        heapq.heappush(right, -heapq.heappop(left))
        current_median = -left[0]
        if last_left <= a and a <= last_right:
            pass
        else:
            # a_current += abs(left[0] + right[0])
            a_current += min(abs(last_right - a), abs(last_left - a))
    else:
        print(current_median, a_current+b_all)

exit(0)
### BUGGY CODE ###

n=int(input())
a = input()

c = 0
for i in range(1,n//2 +1):
  for j in range(n):
    if j + 2*i < n:
      if a[j] != a[j+i] and a[j+i] != a[j+2*i] and a[j] != a[j+2*i]:
        c+=1

ans = a.count("R") * a.count("G") * a.count("B") - c
print(ans)

### FIXED CODE ###

n=int(input())
a = input()

c = 0
for i in range(1,n//2 +1):
  for j in range(n-2*i):
    if a[j] != a[j+i] and a[j+i] != a[j+2*i] and a[j] != a[j+2*i]:
      c+=1

ans = a.count("R") * a.count("G") * a.count("B") - c
print(ans)
### BUGGY CODE ###

N = int(input())
a = sorted(list(map(int, input().split())))
b = list(map(int, input().split()))
c = sorted(list(map(int, input().split())))

a_b = 0
b_c = 0
count = 0
for b_item in b:
    while a_b < N and a[a_b] < b_item:
        if a[a_b] >= b_item:
            break
        a_b += 1
    while b_c < N and c[b_c] <= b_item:
        if c[b_c] > b_item:
            break
        b_c += 1
    b_c = N - b_c
    count += (a_b * b_c)
    a_b = 0
    b_c = 0

print(count)


### FIXED CODE ###

from bisect import bisect_left, bisect_right # 2文探索法モジュール
N = int(input())
a = sorted(list(map(int, input().split()))) # ソートしておく
b = list(map(int, input().split()))
c = sorted(list(map(int, input().split()))) # ソートしておく

count = 0
for b_item in b:
    i = bisect_left(a, b_item) # リストaのb_itemより小さい要素の数
    j = N - bisect_right(c, b_item) # リストcのb_itemより大きい要素の数
    count += (i * j)
print(count)
### BUGGY CODE ###


n,x,y=map(int,input().split())
graph={i:{} for i in range(1,n+1)}


#graphの隣接行列表示
for i in range(1,n):
    graph[i][i+1]=1
    graph[i+1][i]=1
    
graph[x][y]=1
graph[y][x]=1

#graph表示完成
import heapq
def dijkstra(s,graph,n):
    #ｓからのグラフの最短最短距離をまとめたデータを返す
    dist=[10**20 for i in range(n+1)]
    dist[s]=0
    pq=[]
    heapq.heapify(pq)
    #全ての接点を一度優先度付きキューに挿入する
    heapq.heappush(pq,(0,s))
    while pq:
        x=heapq.heappop(pq)
        node,mini_dis=x[1],x[0]
        for point in graph[node].keys():
            w=graph[node][point]
            #nodeからpointに対して伸びる辺の長さ
            newlen=dist[node]+w
            if newlen<dist[point]:
                heapq.heappush(pq,(newlen,point))
                dist[point]=newlen

    return dist

ans_dis=[0 for i in range(n)]

for i in range(1,n+1):
    sub=dijkstra(i,graph,n)
    for j in range(1,n+1):
        dis=sub[j]
        ans_dis[dis]+=1

for i in range(1,n):
    print(ans_dis[i]//2)
        




### FIXED CODE ###

###############################################################
#ダイクストラ法
#計算量O(logV*(V+E)) （V=頂点の個数 E=辺の個数）
#辺の重みが負である場合には使えない
n,x,y=map(int,input().split())
graph={i:{} for i in range(1,n+1)}


#graphの隣接行列表示
for i in range(1,n):
    graph[i][i+1]=1
    graph[i+1][i]=1
    
graph[x][y]=1
graph[y][x]=1

#graph表示完成
import heapq
def dijkstra(s,graph,n):
    #ｓからのグラフの最短最短距離をまとめたデータを返す
    dist=[10**20 for i in range(n+1)]
    dist[s]=0
    pq=[]
    heapq.heapify(pq)
    #全ての接点を一度優先度付きキューに挿入する
    heapq.heappush(pq,(0,s))
    while pq:
        x=heapq.heappop(pq)
        node,mini_dis=x[1],x[0]
        for point in graph[node].keys():
            w=graph[node][point]
            #nodeからpointに対して伸びる辺の長さ
            newlen=dist[node]+w
            if newlen<dist[point]:
                heapq.heappush(pq,(newlen,point))
                dist[point]=newlen

    return dist

ans_dis=[0 for i in range(n)]

for i in range(1,n+1):
    sub=dijkstra(i,graph,n)
    for j in range(1,n+1):
        dis=sub[j]
        ans_dis[dis]+=1

for i in range(1,n):
    print(ans_dis[i]//2)
### BUGGY CODE ###

import sys
input = sys.stdin.readline

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

A.append(1)

B = [A[0]]
B_cnt = [1]
for i,(x,y) in enumerate(zip(A[:-1],A[1:])):
    if x < y and y < A[i+2]:
        continue
    if x == y:
        B_cnt[-1] += 1
    else:
        B.append(y)
        B_cnt.append(1)

def test(x):
    digit = [0]
    cnt = [0]
    for a,a_cnt in zip(B,B_cnt):
        if digit[-1] < a:
            digit.append(a)
            cnt.append(a_cnt)
            continue
        if digit[-1] == a:
            cnt[-1] += a_cnt
            continue
        while True:
            # 繰り上がり処理をしながら左に戻る
            if digit[-1] <= a:
                break
            n = digit.pop()
            k = cnt.pop()
            if k <= x:
                continue
            if digit[-1] == n-1:
                cnt[-1] += (k-1)//x
            else:
                digit.append(n-1)
                cnt.append((k-1)//x + 1)
        if digit[-1] == a:
            cnt[-1] += a_cnt
        else:
            digit.append(a)
            cnt.append(1+a_cnt)
    return cnt[1] <= x+1

if all(x<y for x,y in zip(A[:-2],A[1:-1])):
    print(1)
    exit()

left = 1 # 無理
right = N # 可能
while right > left + 1:
    mid = (left+right)//2
    if test(mid):
        right = mid
    else:
        left = mid

answer = right
print(answer)

### FIXED CODE ###

import sys
input = sys.stdin.readline

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

A.append(1)

def test(x):
    digit = [0]
    cnt = [0]
    for a in A:
        if digit[-1] < a:
            digit.append(a)
            cnt.append(1)
            continue
        if digit[-1] == a:
            cnt[-1] += 1
            continue
        while True:
            # 繰り上がり処理をしながら左に戻る
            if digit[-1] <= a:
                break
            n = digit.pop()
            k = cnt.pop()
            if k <= x:
                continue
            if digit[-1] == n-1:
                cnt[-1] += (k-1)//x
            else:
                digit.append(n-1)
                cnt.append((k-1)//x + 1)
        if digit[-1] == a:
            cnt[-1] += 1
        else:
            digit.append(a)
            cnt.append(2)
    return cnt[1] <= x+1

if all(x<y for x,y in zip(A[:-2],A[1:-1])):
    print(1)
    exit()

left = 1 # 無理
right = N # 可能
while right > left + 1:
    mid = (left+right)//2
    if test(mid):
        right = mid
    else:
        left = mid

answer = right
print(answer)
### BUGGY CODE ###

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

result = []
for i in range(n):
    x = i+1
    val = a*x//b - a*(x//b)
    result.append(val)

print(max(result))

### FIXED CODE ###

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

print(int(a*min(n,b-1)/b))
### BUGGY CODE ###

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

a=input().split()

l=len(a)

for i in range(0,l):
    a[i]=int(a[i])

p=1
h=[]
go=0
for i in range(1,k+1):
    
    
    
    

    h.append(p)
    p=a[p-1]
    if i==k:
        break
    if p in h:
        j=h.index(p)
        amari=(k-i-1)%(i-j)
        p=h[j+amari]
        go=1
        break

if go==1:
    p=a[p-1]

print(p)


### FIXED CODE ###

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


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

ar=[-1 for i in range(n+1)]
p=1

go=0


for i in range(1,k+1):
    
    
    
    

    ar[p]=i-1
    p=a[p-1]
    
    if ar[p]>0:
        j=ar[p]
        amari=(k-i)%(i-j)
        
        go=1
        break

if go==1:
    p=ar.index(j+amari)
    
    


print(p)
### BUGGY CODE ###

N=int(input())
ans=0
for i in range(1,N+1):
    for j in range(i,N+1,i):
        ans += j
print(ans)

### FIXED CODE ###

N=int(input())
ans=0
for i in range(1,N+1):
    for j in range(i,N+1,i):
        ans += j
print(ans)
### BUGGY CODE ###

import math
from functools import reduce

k = int(input())
ans = 0


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


for a in range(1, k+1):
    for b in range(1, k+1):
        for c in range(1, k+1):
            ans += gcd(a, b, c)

print(ans)

### FIXED CODE ###

import math

k = int(input())
ans = 0

for a in range(1, k+1):
    for b in range(1, k+1):
        tmp = math.gcd(a, b)
        for c in range(1, k+1):
            ans += math.gcd(tmp, c)

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

from itertools import combinations

n,k = map(int,input().split())
P = sorted([list(map(int,input().split())) for i in range(n)])

area = float('inf')

for x1,x2 in combinations(range(n),2):
  for y1,y2 in combinations(range(n),2):
    
    point = 0
    for i in range(n):
      if (min(P[x1][0],P[x2][0])<= P[i][0] <=max(P[x1][0],P[x2][0]) 
      and min(P[y1][1],P[y2][1])<= P[i][1] <=max(P[y1][1],P[y2][1])):
        point += 1
    if point==k:
      area = min(area,abs(P[x1][0]-P[x2][0])*abs(P[y1][1]-P[y2][1]))
      
print(area)

### FIXED CODE ###

from itertools import combinations

n,k = map(int,input().split())
Px = sorted([list(map(int,input().split())) for i in range(n)])
Py = sorted(Px,key=lambda p:p[1])

area = float('inf')

for x1 in range(n-1):
    for x2 in range(x1+1,n):
        for y1 in range(n-1):

            point = 0
            for y in range(y1,n):
                if Px[x1][0]<=Py[y][0]<=Px[x2][0]:
                    point += 1
                    if point == k:
                        area = min(area,(Px[x2][0]-Px[x1][0])*(Py[y][1]-Py[y1][1]))
                        break

print(area)
### BUGGY CODE ###

def mpow(x,n):
    if n == 0:
        return 1
    if n % 4 == 0:
        return mpow(x**4,int(n/4))
    elif n%4 == 1:
        return mpow(x,int(n-1))*x
    elif n%4 == 2:
        return mpow(x,int(n-2))*x*x
    elif n%4 == 3:
        return mpow(x,int(n-3))*x*x*x
n,m = map(int,input().split())
x = 1000000007
print(mpow(n,m)%x)

### FIXED CODE ###

def mpow(x,n,mod):
    if n == 0:
        return 1
    if n % 4 == 0:
        return mpow((x**4)%mod,int(n/4),mod)
    elif n%4 == 1:
        return (mpow(x,int(n-1),mod)*x)%mod
    elif n%4 == 2:
        return (mpow(x,int(n-2),mod)*(x**2))%mod
    elif n%4 == 3:
        return (mpow(x,int(n-3),mod)*(x**3))%mod
n,m = map(int,input().split())
mod = 1000000007
print(mpow(n,m,mod))
### BUGGY CODE ###

#d=["a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"]
#import numpy as np
#n=int(input())
#import fractions
#import math
#lis=list(input().split())
#lis=list(map(float,input().split()))
#n=int(input())
#S=input()

import itertools

lis=list(map(int,input().split()))
alist=[-1]
ans=1
for i in range(lis[1]):
    alist.append(int(input()))
alist.append(lis[0]+1)

for i in range(lis[1]+1):
    l=alist[i+1]-alist[i]-2
    tmp=0
    t=int((l+l%2)/2)
    h=int((l-l%2)/2)
    for j in range(h+1):
        tmp+=len(list(itertools.combinations(range(t+j),h-j)))
    ans=ans*tmp
ans=ans%((10**9)+7)
print(ans)


### FIXED CODE ###

lis=list(map(int,input().split()))
alist=[0]*(lis[0]+1)
for i in range(lis[1]):
    a=int(input())
    alist[a]=1
steps=[0]*(lis[0]+2)
steps[1]=1
mod=(10**9)+7
for i in range(2,lis[0]+2):
    if alist[i-1]==0:
        steps[i]=(steps[i-1]+steps[i-2])%mod
ans=steps[-1]
print(ans)
### BUGGY CODE ###

s=input()
s=s[::-1]
n=len(s)
cnt=[0]*2019
cnt[0]+=1
c=0
for i in range(n):
  c+=int(s[i])*(10**i)%2019
  cnt[c%2019]+=1
ans=0
for i in cnt:
  if i<=1:
    pass
  else:
    ans+=i*(i-1)//2
print(ans)

### FIXED CODE ###

s=list(map(int,list(input())[::-1]))
n=len(s)
cnt=[0]*2019
cnt[0]+=1
c=0
for i in range(n):
  c+=s[i]*pow(10,i,2019)%2019
  cnt[c%2019]+=1
ans=0
for i in cnt:
  if i<=1:
    pass
  else:
    ans+=i*(i-1)//2
print(ans)
### BUGGY CODE ###

n = int(input())

ans = 0

for i in range(1, n):
    ans += i

print(ans)


### FIXED CODE ###

n = int(input())

print((n*(n-1))//2)
### BUGGY CODE ###

import fractions
import math

A, B = map(int, input().split())
saidai = fractions.gcd(A, B)

kosuu = 1  # 1

if saidai % 2 == 0:
    kosuu += 1

while saidai % 2 == 0:
    saidai = saidai // 2

for i in range(3, 100000000000000000000, 2):
    if saidai <= 1:
        break

    if saidai % i == 0:
        kosuu += 1

    while saidai % i == 0:
        saidai = saidai // i

print(kosuu)


### FIXED CODE ###

import fractions
import math

A, B = map(int, input().split())
gcd = fractions.gcd(A, B)
saidai = gcd

kosuu = 1  # 1

if saidai % 2 == 0:
    kosuu += 1

while saidai % 2 == 0:
    saidai = saidai // 2

# sqrt = int(math.sqrt(gcd))
# for i in range(3, sqrt+1+1, 2):
#     if saidai <= 1:
#         break

#     if saidai % i == 0:
#         kosuu += 1

#     while saidai % i == 0:
#         saidai = saidai // i

i = 3
while True:
    if saidai <= 1:
        break

    if i > math.sqrt(saidai):
        break

    if saidai % i == 0:
        kosuu += 1

    while saidai % i == 0:
        saidai = saidai // i

    i += 2

if saidai != 1:
    kosuu += 1

print(kosuu)
### BUGGY CODE ###

# coding: utf-8
# Your code here!
import numpy as np
N = int(input())
A = np.array(list(map(int,input().split())))
table = []
 
for i, a in enumerate(A):
    table.append([a,i])
table.sort()
dp = np.zeros((N+1,N+1))
for i in range(1,N+1):
    baby,pos = table.pop()
    dp[i][0]=dp[i-1][0]+baby*abs(pos-i+1)
    dp[0][i] = dp[0][i-1] + baby * abs(pos-(N-i))
    for x in range(1,i):
        y = i-x
        dp[x][y]= max(dp[x-1][y] + baby * abs(pos-x+1),dp[x][y-1] + baby * abs(pos-(N-y)))
print(int(max(dp[k][N-k] for k in range(N+1))))

### FIXED CODE ###

# coding: utf-8
# Your code here!
#import numpy as np
N = int(input())
A = list(map(int,input().split()))
table = []
 
for i, a in enumerate(A):
    table.append([a,i])
table.sort()
dp = [[0for i in range(N+1)]for j in range(N+1)]
for i in range(1,N+1):
    baby,pos = table.pop()
    dp[i][0]=dp[i-1][0]+baby*abs(pos-i+1)
    dp[0][i] = dp[0][i-1] + baby * abs(pos-(N-i))
    for x in range(1,i):
        y = i-x
        dp[x][y]= max(dp[x-1][y] + baby * abs(pos-x+1),dp[x][y-1] + baby * abs(pos-(N-y)))
print(int(max(dp[k][N-k] for k in range(N+1))))
### BUGGY CODE ###

S = input()
init_count = len(S)

while len(S) > 1:
    no_01 = True
    before_s = S[0]
    for i, s in enumerate(S):
        if before_s != s:
            no_01 = False
            newS = S[:i-1] + S[i+1:]
            S = newS
            break
    if no_01:
        break
print(init_count - len(S))

### FIXED CODE ###

S = input()
init_count = len(S)

tmp_i = 0
while len(S) > 1:
    no_01 = True
    before_s = None
    for i, s in enumerate(S[tmp_i:]):
        if i == 0:
            before_s = s
            continue
        if before_s != s:
            no_01 = False
            # print(S[:tmp_i + i-1], '(', S[tmp_i + i - 1], ' | ', S[tmp_i + i],  ')', S[tmp_i + i+1:])
            newS = S[:tmp_i + i-1] + S[tmp_i + i+1:]
            S = newS
            # print('newS: ', newS)
            tmp_i = tmp_i + i - 2
            if tmp_i < 0:
                tmp_i = 0
            # print(tmp_i)
            break
    if no_01:
        break
print(init_count - len(S))
### BUGGY CODE ###

def main():
    import math
    a, b, n = map(int, input().split())
    ans = 0
    if n > 10 ** 10:
        for x in range(n, 10 ** 8, -1):
            fx = math.floor(a/b * x) - math.floor(x / b) * a
            #print(fx)
            if ans < fx:
                ans = fx
            if ans > fx + 10 ** 3:
                #exit()
                pass

    elif n > 10 ** 8:
        for x in range(n, 10**6 , -1):
            fx = math.floor(a/b * x) - math.floor(x / b) * a
            #print(fx)
            if ans < fx:
                ans = fx
            if ans > fx + 10 ** 3:
                #exit()
                pass

    elif n > 10 ** 6:
        for x in range(n, 10**4 , -1):
            fx = math.floor(a/b * x) - math.floor(x / b) * a
            #print(fx)
            if ans < fx:
                ans = fx
            if ans > fx + 10 ** 3:
                #exit()
                pass

    elif n > 10 ** 4:
        for x in range(n, 10**2 , -1):
            fx = math.floor(a/b * x) - math.floor(x / b) * a
            #print(fx)
            if ans < fx:
                ans = fx
            if ans > fx + 10 ** 3:
                #exit()
                pass
    else: 
        for x in range(n, 0, -1):
            fx = math.floor(a * x / b) - math.floor(x / b) * a
            #print(fx)
            if ans < fx:
                ans = fx
            if ans > fx + 10 ** 3:
                #exit()
                pass

    print(ans)

if __name__ == "__main__":
    main()

### FIXED CODE ###


def main():
    import math
    a, b, n = map(int, input().split())
    if n >= b:
        ans = math.floor(a * (b-1)/b)
    else:
        ans = math.floor(a * n / b)
    
    print(ans)
    




if __name__ == "__main__":
    main()
### BUGGY CODE ###

import sys
P = int(input())
As = list(map(int, input().split()))
rs = [0]*P
mod = P
sys.setrecursionlimit(pow(10, 8))

def power(x, y):
    if   y == 0     : return 1
    elif y == 1     : return x % mod
    elif y % 2 == 0 : return power(x, y//2)**2 % mod
    else            : return power(x, (y-1)//2)**2 * x % mod
    
def mul(a, b):
    return ((a % mod) * (b % mod)) % mod

def div(a, b):
    return mul(a, power(b, mod-2))

def cmb(n, r):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod

NNN = 3000
g1 = [1, 1]
g2 = [1, 1]
inverse = [0, 1]
for i in range( 2, NNN + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )


for i in range(P):
    if As[i]:
        rs[0] += 1
        for k in range(P):
            rs[k] += (-1 + 2*(k%2)) * power(i, (P-1-k)) * cmb(P-1, k)
            rs[k] %= P
print(*rs)


### FIXED CODE ###

import sys
P = int(input())
As = list(map(int, input().split()))
rs = [0]*P
mod = P
sys.setrecursionlimit(pow(10, 8))

def power(x, y):
    if   y == 0     : return 1
    elif y == 1     : return x % mod
    elif y % 2 == 0 : return power(x, y//2)**2 % mod
    else            : return power(x, (y-1)//2)**2 * x % mod
    
def mul(a, b):
    return ((a % mod) * (b % mod)) % mod

def div(a, b):
    return mul(a, power(b, mod-2))

def cmb(n, r):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod

NNN = 3000
g1 = [1, 1]
g2 = [1, 1]
inverse = [0, 1]
for i in range( 2, NNN + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )
C = []
for i in range(P):
    C.append(cmb(P-1, i))


for i in range(P):
    if As[i]:
        rs[0] += 1
        tmp = 1
        for k in range(P):
            k = P-1-k
            rs[k] += (-1 + 2*(k%2)) * tmp * C[k]
            rs[k] %= mod
            tmp = tmp * i % mod
print(*rs)