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

from collections import deque

def run():
    n = int(input())
    dq = deque()
    for _ in range(n):
        order = input()
        if order[0] == 'i':
            dq.appendleft(order.split()[1])
        elif order[6] == ' ':
            key = order.split()[1]
            if not key in dq:
                continue
            for i in range(len(dq)):
                if dq[i] == key:
                    dq.remove(key)
                    break
        elif order[6] == 'F':
            dq.popleft()
        elif order[6] == 'L':
            dq.pop()

    print(' '.join(dq))

if __name__ == '__main__':
    run()




### FIXED CODE ###

from collections import deque

def run():
    n = int(input())
    dq = deque()
    for _ in range(n):
        order = input()
        if order[0] == 'i':
            dq.appendleft(order[7:])
        elif order[6] == ' ':
            key = order.split()[1]
            if not key in dq:
                continue
            for i in range(len(dq)):
                if dq[i] == key:
                    dq.remove(key)
                    break
        elif order[6] == 'F':
            dq.popleft()
        elif order[6] == 'L':
            dq.pop()

    print(' '.join(dq))

if __name__ == '__main__':
    run()
### BUGGY CODE ###

import sys
import numpy as np
from numba import njit
 
 
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
 
@njit('(i8[::1],)', cache=True)
def update(A):
  N = len(A)
  B = np.zeros_like(A)
  for i,x in enumerate(A):
    l = max(0, i-x)
    r = min(N-1, i+x)
    B[l] += 1
    if r + 1 < N:
      B[r+1] -= 1
  B = np.cumsum(B)
  return B
    
    
N,K = map(int, readline().split())
A = np.array(read().split(), np.int64)
 
k = min(K, 100)
for _ in range(K):
  A = update(A)
print(' '.join(A.astype(str)))

### FIXED CODE ###

import sys
import numpy as np
from numba import njit
 
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
 
@njit('(i8[::1],)', cache=True)
def update(A):
    N = len(A)
    B = np.zeros_like(A)
    for i, x in enumerate(A):
        l = max(0, i - x)
        r = min(N - 1, i + x)
        B[l] += 1
        if r + 1 < N:
            B[r + 1] -= 1
    B = np.cumsum(B)
    return B
 
N, K = map(int, readline().split())
A = np.array(read().split(), np.int64)
 
K = min(K, 100)
for _ in range(K):
    A = update(A)
print(' '.join(A.astype(str)))
### BUGGY CODE ###

def main():
    S = input()
    T = input()
    dp = [[0] * (len(S) + 1) for _ in range(len(T) + 1)]
    for j, t in enumerate(T, 1):
        for i, s in enumerate(S, 1):
            dp[j][i] = max(dp[j - 1][i], dp[j][i - 1], dp[j - 1][i - 1] + 1 if s == t else 0)
    i, j = len(S), len(T)
    R = ''
    while i > 0 and j > 0:
        n = dp[j][i]
        if dp[j - 1][i] == n:
            j -= 1
        elif dp[j][i - 1] == n:
            i -= 1
        elif dp[j - 1][i - 1] == n - 1:
            j -= 1
            i -= 1
            R += T[j]
        else:
            assert False
    return R[::-1]

print(main())


### FIXED CODE ###

def main():
    s = input()
    t = input()
    v = [0] * (len(t) + 1)
    dp = [v]
    for i, si in enumerate(s, 1):
        u, v = v, v.copy()
        dp.append(v)
        ll, ul = 0, 0
        for j, ti in enumerate(t, 1):
            uu = u[j]
            if si == ti:
                v[j] = ll = ul + 1
            else:
                if ll > uu:
                    v[j] = ll
                else:
                    ll = uu
            ul = uu
    k = dp[i][j]
    r = ''
    while k:
        if dp[i - 1][j] == k:
            i -= 1
        elif dp[i][j - 1] == k:
            j -= 1
        else:
            k -= 1
            i -= 1
            j -= 1
            r += s[i]
    print(r[::-1])

main()
### BUGGY CODE ###

#!/usr/bin/env python
# coding: utf-8

# In[17]:


#from sys import stdin
#input = stdin.readline

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


# In[18]:


class Node:
    def __init__(self, nb, data): #コンストラクタ
        self.nb = nb
        self.data = data #ノードがもつ数値
        self.parent = -1 # nodeがrootのとき-1、それ以外番号
        self.childs = [] # childになるnode classが入る
        
    def connect_childs(self, child_class_):
        self.childs.append(child_class_)


# In[19]:


nodes = [Node(_+1, 0) for _ in range(N)]


# In[12]:


for i in range(N-1):
    a, b = map(int, input().split())
    nodes[a-1].connect_childs(nodes[b-1])
    nodes[b-1].parent = a-1


# In[13]:


for i in range(Q):
    p, x = map(int, input().split())
    nodes[p-1].data += x


# In[14]:


def sum_data_to_childs(nodes):
    datas = [0]*N
    
    datas[0] = nodes[0].data
    
    for i in range(1, N):
        nodes[i].data += nodes[nodes[i].parent].data
        #print(nodes[i].data)
        datas[i] = nodes[i].data
        
    return datas


# In[15]:


datas = sum_data_to_childs(nodes)


# In[16]:


print(' '.join(map(str, datas)))


# In[ ]:






### FIXED CODE ###

#!/usr/bin/env python
# coding: utf-8

# In[17]:


from sys import stdin
input = stdin.readline

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


# In[18]:


class Node:
    def __init__(self, nb, data): #コンストラクタ
        self.nb = nb
        self.data = data #ノードがもつ数値
        self.parent = -1 # nodeがrootのとき-1、それ以外番号
        #self.childs = [] # childになるnode classが入る
        
    #def connect_childs(self, child_class_):
    #    self.childs.append(child_class_)


# In[19]:


nodes = [Node(_+1, 0) for _ in range(N)]


# In[12]:


for i in range(N-1):
    a, b = map(int, input().split())
    #nodes[a-1].connect_childs(nodes[b-1])
    nodes[b-1].parent = a-1


# In[13]:


for i in range(Q):
    p, x = map(int, input().split())
    nodes[p-1].data += x


# In[14]:


def sum_data_to_childs(nodes):
    datas = [0]*N
    
    datas[0] = nodes[0].data
    
    for i in range(1, N):
        nodes[i].data += nodes[nodes[i].parent].data
        #print(nodes[i].data)
        datas[i] = nodes[i].data
        
    return datas


# In[15]:


datas = sum_data_to_childs(nodes)


# In[16]:


print(' '.join(map(str, datas)))


# In[20]:


#datas = [0] * N


# In[21]:


#child = [[]] * N


# In[22]:


#print(child)


# In[ ]:
### BUGGY CODE ###

def make_divisors(n):
    lower_divisors, upper_divisors = [], []
    i = 1
    while i*i <= n:
        if n % i == 0:
            lower_divisors.append(i)
            if i != n // i:
                upper_divisors.append(n//i)
        i += 1
    return lower_divisors + upper_divisors[::-1]


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

exist = set()
dup = set()
for item in a:
    if item in exist:
        dup.add(item)
    else:
        exist.add(item)

ret = 0

for i in range(n):
    is_ok = True
    val = a[i]
    if val in dup:
        continue
    divs = make_divisors(val)
    for item in divs:
        if item == val:
            continue
        elif item in cand:
            is_ok = False
            break
    if is_ok:
        ret += 1

print(ret)


### FIXED CODE ###

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

cand = set(a)

exist = set()
dup = set()
for item in a:
    if item in exist:
        dup.add(item)
    else:
        exist.add(item)

dame_set = set()

a.sort()
ret = 0

for val in a:
    if val in dup:
        if val in dame_set:
            continue
        else:
            i = 1
            cnt = 10 ** 6 // val
            while i <= cnt:
                tmp = i * val
                if tmp in cand:
                    dame_set.add(tmp)
                i += 1
    else:
        if val in dame_set:
            continue
        else:
            ret += 1
            i = 1
            cnt = 10 ** 6 // val
            while i <= cnt:
                tmp = i * val
                if tmp in cand:
                    dame_set.add(tmp)
                i += 1

print(ret)
### BUGGY CODE ###

def main():
    import sys
    sys.setrecursionlimit(10 ** 6)
    from bisect import bisect_left,bisect
    n = int(input())
    x = list(map(int,input().split()))
    t = n.bit_length()

    kprv = [[10**10 for i in range(t+1)] for j in range(n)]
    for i in range(t):
        for j in range(n):
            if j + pow(2,i) > n-1:
                break
            kprv[j][i] = x[j+2**i] - x[j]

    L = int(input())
    q = int(input())

    for _ in range(q):
        a , b = map(lambda x:int(x)-1,input().split())
        cou = 0
        if a > b:
            a , b = b , a
        now = a
        while now < b:
            cou += 1
            p = L
            while True:
                nex = bisect(kprv[now],p)
                if nex == 0:
                    break
                else:
                    p -= kprv[now][nex-1]
                    now += pow(2,nex-1)
        print(cou)

main()

### FIXED CODE ###

import sys
sys.setrecursionlimit(10 ** 6)  # 変更
from bisect import bisect_left,bisect

n = int(input())
x = list(map(int,input().split()))
L = int(input())
t = n.bit_length()
prv = [n-1] * n
for i in range(n):
    prv[i] = bisect(x,x[i]+L) - 1
kprv = [prv]
S = prv
for i in range(t-1):
    kar = [n-1] * n
    for j in range(n):
        kar[j] = S[S[j]]
    kprv.append(kar)
    S = kar

q = int(input())
for _ in range(q):
    a , b = map(lambda x:int(x)-1,input().split())
    if a > b:
        a , b = b , a
    lef = 0
    rig = n-1
    while rig - lef > 1:
        mid = (rig+lef)//2
        p = mid.bit_length()
        now = a
        for i in range(p):
            if (mid>>i) & 1 == 1:
                now = kprv[i][now]
        if now >= b:
            rig = mid
        elif now < b:
            lef = mid
    print(rig)
### BUGGY CODE ###

#!/usr/bin/env python3
import sys
input = sys.stdin.readline

R, C, k = map(int, input().split())
field = [[0] * C for _ in range(R)]
for _ in range(k):
    r, c, v = map(int, input().split())
    r -= 1; c -= 1
    field[r][c] = v

# dp[taken 0 - 2][R][C]
dp = [[-1] * (C + 1) * (R + 1) for _ in range(4)]
dp[0][0] = 0
for j in range(C):
    for i in range(R):
        for k in range(4):
            ij = i * C + j
            ij1 = i * C + j + 1
            i1j = (i + 1) * C + j
            # Use
            if field[i][j] and k < 3:
                dp[k+1][ij1] = max(dp[k+1][ij1], dp[k][ij] + field[i][j]) 
                dp[0][i1j] = max(dp[0][i1j], dp[k][ij] + field[i][j]) 
            # No use down
            dp[0][i1j] = max(dp[0][i1j], dp[k][ij]) 
            # No use right
            dp[k][ij1] = max(dp[k][ij1], dp[k][ij]) 

ans = 0
for i in range(4):
    for j in range(R + 1):
        ans = max(ans, dp[i][j * C + C - 1])
print(ans)

### FIXED CODE ###

#!/usr/bin/env python3
import sys
input = sys.stdin.readline

R, C, k = map(int, input().split())
field = [[0] * C for _ in range(R)]
for _ in range(k):
    r, c, v = map(int, input().split())
    r -= 1; c -= 1
    field[r][c] = v

# dp[taken 0 - 2][R][C]
dp = [[-1] * (C + 1) * (R + 1) for _ in range(4)]
dp0 = dp[0]; dp1 = dp[1]; dp2 = dp[2]; dp3 = dp[3]
dp[0][0] = 0
for j in range(C):
    for i in range(R):
        ij = i * C + j
        ij1 = ij + 1
        i1j = ij + C
        item = field[i][j]
        # Use
        if item:
            dp1[ij1] = max(dp1[ij1], dp0[ij] + item) 
            dp0[i1j] = max(dp0[i1j], dp0[ij] + item) 
        dp0[i1j] = max(dp0[i1j], dp0[ij]) 
        dp0[ij1] = max(dp0[ij1], dp0[ij]) 
        if item:
            dp2[ij1] = max(dp2[ij1], dp1[ij] + item) 
            dp0[i1j] = max(dp0[i1j], dp1[ij] + item) 
        dp0[i1j] = max(dp0[i1j], dp1[ij]) 
        dp1[ij1] = max(dp1[ij1], dp1[ij]) 
        if item:
            dp3[ij1] = max(dp3[ij1], dp2[ij] + item) 
            dp0[i1j] = max(dp0[i1j], dp2[ij] + item) 
        dp0[i1j] = max(dp0[i1j], dp2[ij]) 
        dp2[ij1] = max(dp2[ij1], dp2[ij]) 
        dp0[i1j] = max(dp0[i1j], dp3[ij]) 
        dp3[ij1] = max(dp3[ij1], dp3[ij]) 

ans = 0
for i in range(4):
    for j in range(R + 1):
        ans = max(ans, dp[i][j * C + C - 1])
print(ans)
### BUGGY CODE ###

import sys
from scipy.sparse.csgraph import dijkstra
from scipy.sparse import csr_matrix
sys.setrecursionlimit(10**7)
n, m = [int(i) for i in sys.stdin.readline().split()]
INF = 10**9
graph = [[1e-10 if j - i == 1 else 0 for i in range(n)] for j in range(n)]
for i in range(m):
    l, r, c = [int(i) for i in sys.stdin.readline().split()]
    l -= 1
    r -= 1
    graph[l][r] = c
    graph[r][l] = c
graph = csr_matrix(graph)
res = dijkstra(graph, indices=[0])
print(int(res[0][-1]) if res[0][-1] < INF else -1)

### FIXED CODE ###

import sys
import heapq
sys.setrecursionlimit(10**7)
n, m = [int(i) for i in sys.stdin.readline().split()]
INF = 10**9
graph = {j:[(j-1, 1e-10)] if j > 0 else [] for j in range(n)}
for i in range(m):
    l, r, c = [int(i) for i in sys.stdin.readline().split()]
    l -= 1
    r -= 1
    graph[l].append((r, c))
    graph[r].append((l, c))
que = [(0,0)]
already = set()
res = [-1 for i in range(n)]
while len(que) > 0:
    cost, cand = heapq.heappop(que)
    if cand in already:
        continue
    res[cand] = cost
    already.add(cand)
    for _next, _next_cost in graph[cand]:
        if _next in already:
            continue
        heapq.heappush(que, (cost + _next_cost, _next))
print(int(res[-1]))
### BUGGY CODE ###

import sys
X, Y, Z, K = map(int, input().split())
A = list(map(int, sys.stdin.readline().split()))
B = list(map(int, sys.stdin.readline().split()))
C = list(map(int, sys.stdin.readline().split()))
AB = []
for i in range(X):
    for j in range(Y):
        AB.append(A[i] + B[j])
AB.sort(reverse = True)
ans = []
AB2 = AB[:min(X * Y + 1, K + 1)]
for ab in AB2:
    for c in C:
        ans.append(ab + c)
ans.sort(reverse = True)
for i in range(K):
    print(ans[i])

### FIXED CODE ###

import sys
X, Y, Z, K = map(int, input().split())
A = list(map(int, sys.stdin.readline().split()))
B = list(map(int, sys.stdin.readline().split()))
C = list(map(int, sys.stdin.readline().split()))
A.sort(reverse = True)
B.sort(reverse = True)
C.sort(reverse = True)
AB = []
ans = []
for a in A:
    for b in B:
        AB.append(a + b)
AB.sort(reverse=True)
AB = AB[:min(3001, X*Y*Z+1)]
for c in C:
    for ab in AB:
        ans.append(c + ab)
ans.sort(reverse=True)
for i in range(K):
    print(ans[i])
### BUGGY CODE ###

import sys
sys.setrecursionlimit(10**4)
n=int(input())
a=list(map(int,input().split()))
num1,num2,num3=0,0,0
for i in range(n):
    if a[i]==1:
        num1+=1
    elif a[i]==2:
        num2+=1
    else:
        num3+=1
dp=[[[-1 for k in range(n+1)] for i in range(n+1)] for j in range(n+1)]
def f(n1,n2,n3):
    if dp[n1][n2][n3]>=0:
        return dp[n1][n2][n3]
    if n1==n2==n3==0:
        return 0.0
    ret=0.0
    if n1>0:
        ret+=f(n1-1,n2,n3)*n1
    if n2>0:
        ret+=f(n1+1,n2-1,n3)*n2
    if n3>0:
        ret+=f(n1,n2+1,n3-1)*n3
    ret+=n
    ret*=1.0/(n1+n2+n3)
    dp[n1][n2][n3]=ret
    return dp[n1][n2][n3]
print(f(num1,num2,num3))

### FIXED CODE ###

n=int(input())
a=list(map(int,input().split()))
num1,num2,num3=0,0,0
for i in range(n):
    if a[i]==1:
        num1+=1
    elif a[i]==2:
        num2+=1
    else:
        num3+=1
dp=[[[-1.0 for k in range(n+1)] for i in range(n+1)] for j in range(n+1)]
def f(n1,n2,n3):
    if dp[n1][n2][n3]>=0.0:
        return dp[n1][n2][n3]
    if n1==n2==n3==0:
        return 0.0
    ret=n
    if n1>0:
        ret+=f(n1-1,n2,n3)*n1
    if n2>0:
        ret+=f(n1+1,n2-1,n3)*n2
    if n3>0:
        ret+=f(n1,n2+1,n3-1)*n3
    ret*=1.0/(n1+n2+n3)
    dp[n1][n2][n3]=ret
    return dp[n1][n2][n3]
print(f(num1,num2,num3))
### BUGGY CODE ###

import sys
import bisect

sys.setrecursionlimit(10**7)
INF = 10 ** 18
MOD = 10 ** 9 + 7
def LI(): return list(map(int, sys.stdin.readline().split()))
def II(): return int(sys.stdin.readline())
def LS(): return list(map(list, sys.stdin.readline().split()))
def S(): return list(sys.stdin.readline())[:-1]

def main():
    n = II()
    ls = LI()
    ls = sorted(ls)
    ans = 0
    for i in range(n):
        for j in range(i):
            ans += j - (bisect.bisect_right(ls[:j], ls[i] - ls[j]))

            # ans += a
            # print(ls[i], ls[j], bisect.bisect_left(ls[:j], ls[i] - ls[j]))
            # if ls[i] < ls[j] + ls[h]:
            #     # print(ls[i], ls[j], ls[h])

    print(ans)

if __name__ == '__main__':
    main()

### FIXED CODE ###

import sys
import bisect

sys.setrecursionlimit(10**7)
INF = 10 ** 18
MOD = 10 ** 9 + 7
def LI(): return list(map(int, sys.stdin.readline().split()))
def II(): return int(sys.stdin.readline())
def LS(): return list(map(list, sys.stdin.readline().split()))
def S(): return list(sys.stdin.readline())[:-1]

def main():
    n = II()
    ls = LI()
    ls = sorted(ls)
    ans = 0
    for i in range(n):
        for j in range(i):
            ans += j - (bisect.bisect_right(ls[:j], ls[i] - ls[j]))

            # ans += a
            # print(ls[i], ls[j], bisect.bisect_left(ls[:j], ls[i] - ls[j]))
            # if ls[i] < ls[j] + ls[h]:
            #     # print(ls[i], ls[j], ls[h])

    print(ans)

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

import sys
def Is(): return [int(x) for x in sys.stdin.readline().split()]

N,M,Q = Is()
lis = [[0]*(N+1) for _ in range(N+1)]
for i in range(M):
    l,r = Is()
    lis[l][r] += 1

cs = [[0]*(N+1) for _ in range(N+1)]
for i in range(1,N+1):
    for j in range(1,N+1):
        cs[i][j] = cs[i][j-1] + lis[i][j]

for _ in range(Q): 
    p,q = Is()
    t = 0
    for i in range(p,q+1):
        t += cs[i][q] - cs[i][i-1]
    print(t)

### FIXED CODE ###

import sys
def Is(): return [int(x) for x in sys.stdin.readline().split()]

N,M,Q = Is()
lis = [[0]*(N+1) for _ in range(N+1)]
for i in range(M):
    l,r = Is()
    lis[l][r] += 1

cs = [[0]*(N+1) for _ in range(N+1)]
for i in range(1,N+1):
    for j in range(1,N+1):
        cs[i][j] = cs[i][j-1] + sum(lis[i][:j+1])

for _ in range(Q): 
    p,q = Is()
    t = 0
    for i in range(p,q+1):
        t += cs[i][q] - cs[i][q-1]
    print(t)
### BUGGY CODE ###

# -*- coding: utf-8 -*-

N, M = map(int, input().split())
Wlist = []
for i in range(N):
    A, B = map(int, input().split())
    Wlist.append([A,B])
Wlist.sort(key=lambda x:x[0])

Ans = 0
for day in range(1,M+1):
    Best = 0
    BestIdx = -1
    for i, W in enumerate(Wlist):
        if W[0] > day:
            break
        if Best < W[1]:
            Best = W[1]
            BestIdx = i
    if BestIdx >= 0:
        Ans += Best
        Wlist[BestIdx][1] = 0
            
print(Ans)


### FIXED CODE ###

# -*- coding: utf-8 -*-
import heapq

N, M = map(int, input().split())
Wlist = []
for i in range(N):
    A, B = map(int, input().split())
    Wlist.append([A,B])
Wlist.sort(key=lambda x:x[0])

h = []
Ans = 0
Index = 0
for day in range(1,M+1):
    while Index < N:
        if Wlist[Index][0] <= day:
            heapq.heappush(h, -Wlist[Index][1])
            Index += 1
        else:
            break
    if len(h):
        Ans += -heapq.heappop(h)

print(Ans)
### BUGGY CODE ###

def main():
    item_no, discount_no = [int(x) for x in input().split()]
    prices = [int(x) for x in input().split()]

    for _ in range(discount_no):
        prices.sort(reverse=True)
        prices[0] //= 2

    print(sum(prices))


if __name__ == '__main__':
    main()


### FIXED CODE ###

# 解説を読んだ。優先度付きキューね，はい。
import heapq


def main():
    item_no, discount_no = [int(x) for x in input().split()]
    prices = [int(x) * -1 for x in input().split()]
    heapq.heapify(prices)

    for _ in range(discount_no):
        current_max = heapq.heappop(prices)
        current_max = current_max * -1 // 2 * -1
        heapq.heappush(prices, current_max)

    print(- sum(prices))


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

import numpy as np

#N = 39
#S = "RBRBGRBGGBBRRGBBRRRBGGBRBGBRBGBRBBBGBBB"
N=int(input())
S=input()
r = len(S.replace("G", "").replace("B", ""))
g = len(S.replace("R", "").replace("B", ""))
#b = len(S.replace("R", "").replace("G", ""))
b = N - r - g
 
ans = r * g * b
 
for i in range(N):
    for k in [N - k_ - 1 for k_ in range(N)]:
        if i >= k:
            break
            
        tar_j = i + k
        if (tar_j > 2 * i) & (tar_j < 2 * k):
            if np.mod(tar_j, 2) == 0:
                j = int(tar_j / 2)
                s = S[i] + S[j] + S[k]
                if ("R" in s) & ("G" in s) & ("B" in s):
                    ans -= 1
        else:
            break
print(ans)


### FIXED CODE ###


#S = "RBRBGRBGGBBRRGBBRRRBGGBRBGBRBGBRBBBGBBB"# * 1000
#N = len(S)

N=int(input())
S=input()
r = len(S.replace("G", "").replace("B", ""))
g = len(S.replace("R", "").replace("B", ""))
b = N - r - g
 
ans = r * g * b
 
is_break = False
for i in range(N):
    for j in range(i, int((N+i)/2 + 1)):
        k = 2 * j - i
        if k < N:
            s = S[i] + S[j] + S[k]
            if ("R" in s) & ("G" in s) & ("B" in s):
                    ans -= 1

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

def main():
    n = int(input())
    a = list( map( int, input().split()))
    sum = 1
    for i in a:
        sum *= i
    if sum - 1000000000000000000 > 0:
        print(-1)
    else:
       print(sum)
    
if __name__ == '__main__':
    main()

### FIXED CODE ###

import copy

def main():
    n = int(input())
    a = list( map( int, input().split()))
    sum = 1
    if 0 in a:
        print(0)
    else:
        for i in a:
            sum = sum * i
            if sum > 1000000000000000000:
                print(-1)
                exit()
        print(sum)
    
if __name__ == '__main__':
    main()
### BUGGY CODE ###

a,b,c,d=map(int,input().split());m=998244353;D=[[0]*(d+1)for _ in range(c+1)];D[a][b]=1
for i in range(c):
 for j in range(d):D[i+1][j+1]+=(D[i+1][j]*(i+1)+D[i][j+1]*(j+1)-D[i][j]*i*j)%m
print(D[c][d])

### FIXED CODE ###

ma = 3010
dp = [[0] * ma for _ in range(ma)]
mod = 998244353


a, b, c, d = map(int, input().split())
dp[a][b] = 1
for i in range(b+1, ma):
    dp[a][i] = dp[a][i - 1] * a % mod
for i in range(a+1, ma):
    dp[i][b] = dp[i - 1][b] * b % mod


for i in range(a+1, ma):
    for j in range(b+1, ma):
        dp[i][j] = (-dp[i - 1][j - 1] * (i-1)*(j-1) +
                    dp[i - 1][j] * j + dp[i][j - 1] * i) % mod
print(dp[c][d])
### BUGGY CODE ###

N,Q=map(int,input().split())
S=[i for i in input()]
L=[list(map(int, input().split())) for _ in range(Q)]
for i in L:
  m=0
  for j in range(i[0]-1,i[1]-1):
    if S[j]=='A' and S[j+1]=='C':
      m+=1
  print(m)

### FIXED CODE ###

N,Q=map(int,input().split())
S=[i for i in input()]
t=[0]*(N+1)
for i in range(N-1):
  t[i+1]=t[i]+(1 if S[i]=='A' and S[i+1]=='C' else 0)
for i in range(Q):
  l,r=map(int, input().split())
  print(t[r-1]-t[l-1])
### BUGGY CODE ###

n,k=map(int,input().split())
heights=[int(i) for i in input().split()]

dp=[0]*n
dp[1]=abs(heights[1]-heights[0])

for i in range(2,n):
  dp[i]=min([dp[i-j]+abs(heights[i]-heights[i-j]) for j in range(1,min(k+1,i+1))])
print(dp[n-1])

### FIXED CODE ###

n,k=map(int,input().split())
heights=[int(i) for i in input().split()]

dp=[0]*n
dp[1]=abs(heights[1]-heights[0])

for i in range(2,n):
  step=[]
  for j in range(1,min(k+1,i+1)):
      step.append(dp[i-j]+abs(heights[i]-heights[i-j]))
    
  dp[i]=min(step)
print(dp[n-1])
### BUGGY CODE ###


import sys
input = sys.stdin.readline
N = int(input())
A = list(map(int, input().split()))

S = []
for i in range(N):
    S.append(A.index(max(A))+1)
    A[A.index(max(A))] -= 100000

for i in reversed(S):
    print(str(i) + " ")


### FIXED CODE ###

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

M = []

for i in range(len(L)):
    l = (L[i], i+1)
    M.append(l)

M = sorted(M)

for x in M:
    print(x[1])