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

import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees, log2, gcd
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from heapq import heappush, heappop
from functools import reduce, lru_cache
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def TUPLE(): return tuple(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7 
#mod = 998244353
#from decimal import *
#import numpy as np
#decimal.getcontext().prec = 10

S = input()[::-1]

arr = []
for i, x in enumerate(S):
	if x in digits:
		n = pow(10, i, 13)*int(x)%13
		arr.append(n)
	else:
		arr.append(pow(10, i, 13))

dp = [[0]*13 for _ in range(len(S)+1)]
#dp[i][j] : i桁目までで13で割って余る可能性の数
dp[0][0] = 1

for i, x in enumerate(arr, 1):
	if S[i-1] == "?":
		for k in range(10):
			for j in range(13):
				dp[i][j] += dp[i-1][(j-k*x)%13]
				dp[i][j] %= mod

	else:
		for j in range(13):
			dp[i][j] += dp[i-1][(j-int(x))%13]
			dp[i][j] %= mod


print(dp[-1][5])


### FIXED CODE ###

import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees, log2, gcd
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from heapq import heappush, heappop
from functools import reduce, lru_cache
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def TUPLE(): return tuple(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7 
#mod = 998244353
#from decimal import *
#import numpy as np
#decimal.getcontext().prec = 10

S = input()[::-1]

arr = []
for i, x in enumerate(S):
	if x in digits:
		n = pow(10, i, 13)*int(x)%13
		arr.append(n)
	else:
		arr.append(pow(10, i, 13))

dp = [[0]*13 for _ in range(len(S)+1)]
#dp[i][j] : i桁目までで13で割って余る可能性の数
dp[0][0] = 1

for i, x in enumerate(arr, 1):
	if S[i-1] == "?":
		for k in range(10):
			for j in range(13):
				dp[i][j] += dp[i-1][(j-k*x)%13]
				dp[i][j] %= mod

	else:
		for j in range(13):
			dp[i][j] += dp[i-1][(j-int(x))%13]
			dp[i][j] %= mod


print(dp[-1][5])
### BUGGY CODE ###

n = int(input())
a = []
for _ in range(n):
    A = int(input())
    a.append(A)

for i in range(n):
    d = a[i]
    del a[i]
    print(max(a))
    a.insert(i, d)

### FIXED CODE ###

n = int(input())
a = []
for _ in range(n):
    A = int(input())
    a.append(A)
    
s = sorted(a)
for i in range(n):
    if a[i] == s[-1]:
        print(s[-2])
    else:
        print(s[-1])
### BUGGY CODE ###

# -*- coding: utf-8 -*-
X,K,D=map(int,input().split())

for ii in range(K):
    if abs(X)<=D:
        if (K-ii)%2==1:
            if X>=0:
                X-=D
            else:
                X+=D
        break
    elif X>=0:
        X-=D
    else:
        X+=D
print(abs(X))
        


### FIXED CODE ###

# -*- coding: utf-8 -*-
X,K,D=map(int,input().split())

X=abs(X)
ii=int(X/D)
if K<=ii:
    X-=K*D
else:
    X-=ii*D
    if (K-ii)%2==1:
        X-=D

print(abs(X))
### BUGGY CODE ###

N = int(input())
array = []

for _ in range(N):
    A = int(input())
    if A in array:
        array.remove(A)
    else:
        array.append(A)

print(len(array))


### FIXED CODE ###

N = int(input())
maps = {}

for _ in range(N):
    A = int(input())
    if A in maps:
        maps.pop(A)
    else:
        maps[A] = 1

print(len(maps))
### BUGGY CODE ###

import sys

def input():
    return sys.stdin.readline().strip()

def main():
    K = int(input())
    S = input()

    mod = 10 ** 9 + 7
    n = len(S)
    ans = 0

    fact =[1]*(K+n)
    factinv = [1]*(K+n)


    for i in range(2,K+n):
        fact[i] = (fact[i-1] * i) % mod
        factinv[i] = pow(fact[i],mod-2,mod)

    def nCr(n,r):
        return (fact[n] * factinv[r] * factinv[n-r]) % mod

    for i in range(K+1):
        ans += ((25 ** i * nCr(i+n-1,n-1)) * (26 ** (K - i))) % mod
    print(ans)

if __name__ == "__main__":
    main()

### FIXED CODE ###

import sys

def input():
    return sys.stdin.readline().strip()

def main():
    K = int(input())
    S = input()

    mod = 10 ** 9 + 7
    n = len(S)
    ans = 0

    fact =[1]*(K+n)
    factinv = [1]*(K+n)
    inv = [0,1]


    for i in range(2,K+n):
        fact[i] = (fact[i-1] * i) % mod
        inv.append((-inv[mod % i] * (mod // i)) % mod)
        factinv[i] = (factinv[i-1] * inv[i]) % mod

    def nCr(n,r):
        r = min(r,n-r)
        return (fact[n] * factinv[r] * factinv[n-r]) % mod

    for i in range(K+1):
        tmp = pow(25,i,mod)
        tmp *= nCr(i+n-1,n-1)
        tmp *= pow(26,K-i,mod)
        ans += tmp
        ans %= mod
    print(ans)

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

import bisect

N = int(input())
L = sorted(map(int, input().split()))
# print(L)
# L = [1, 2, 3, 4]
# N = len(L)
S = 0
for i in range(N):
    a = L[i]
    for k in range(i - 1):
        c = L[k]
        j = bisect.bisect_left(L, a - c - 1)
        j = max(k + 1, j)
        while True:
            if a < L[j] + c:
                break
            j += 1
        if j >= i:
            continue
        # print(k, j, i)
        S += i - j

print(S)


### FIXED CODE ###

import bisect
import random

def test(L):
    lst = []
    N = len(L)
    for a in range(N):
        for b in range(a):
            for c in range(b):
                if L[a] < L[b] + L[c]:
                    lst.append((c, b, a))
    return lst

def test_len(L):
    return len(test(L))

def test2(L):
    return len(set((l[0], l[2]) for l in test(L)))

N = int(input())
L = sorted(map(int, input().split()))
# L = [1, 1, 1000]
# L = [218, 233, 389, 645, 704, 728, 786]
# N = 10
# L = sorted([random.randint(0, 1000) for _ in range(N)])
# L = [150, 190, 192, 281, 294, 374, 501, 686, 769, 954]
# print(L)
# N = len(L)
S = 0
for a in range(2, N):
    c = bisect.bisect_left(L, (L[a] + 2) // 2)
    while c >= 0:
        if L[a] < L[c] * 2:
            c -= 1
        else:
            break
    b = c + 1
    assert L[a] < L[b] * 2
    if b == 0:
        # print("b0", b, a, (a - 1) * (a) // 2)
        S += (a - 1) * (a) // 2
        continue
    if c >= a - 1:
        continue
    assert L[a] < L[b] + L[b]
    assert L[a] >= L[c] + L[c], (a, c)
    S += (a - b) * (a - b - 1) // 2
    while c >= 0:
        while L[a] >= L[b] + L[c]:
            b += 1
        assert L[a] < L[b] + L[c]
        assert L[a] >= L[b - 1] + L[c]
        # print(c, b, a)
        S += a - b
        c -= 1
print(S)
# print(test_len(L))
### BUGGY CODE ###


if __name__ == '__main__':
    a = int(input())
    b = [int(i) for i in input().split()]
    ans = 1
    b.sort(reverse=True)
    for i in b:
        if  0 in b:
            ans = 0
            break
        ans = ans*i
        if ans > 10 ** 18:
            ans = -1
            break
    print(ans)


### FIXED CODE ###

if __name__ == '__main__':
    a = int(input())
    b = [int(i) for i in input().split()]
    ans = 1
    b.sort(reverse=True)
    if 0 in b:
        ans = 0
    else:
        for i in range(len(b)):
            ans *= b[i]
            if ans > 10 ** 18:
                ans = -1
                break
    print(ans)
### BUGGY CODE ###

N,M = map(int,input().split())
ALL = set([])
Graph = [[] for _ in range(N)]
#gyaku = [set([]) for _ in range(N)]
for i in range(N-1+M):
  a,b = map(int,input().split())
  a-=1;b-=1
  Graph[a].append(b)
  #gyaku[b].add(a)
  ALL.add(b)
#print(Graph,gyaku)
for i in range(N):
  if i not in ALL:
    root = i
    break

ans = [0 for _ in range(N)]
Q = [root]
while Q:
  v = Q.pop()
  for w in Graph[v]:
    ans[w] = v+1
    Q.append(w)
for x in ans:
  print(x)
  


### FIXED CODE ###

import sys
sys.setrecursionlimit(10**7)
N,M = map(int,input().split())
ALL = [i for i in range(N)]
ALL = set(ALL)
Graph = [[] for _ in range(N)]
gyaku = [set([]) for _ in range(N)]
for i in range(N-1+M):
  a,b = map(int,input().split())
  a-=1;b-=1
  Graph[a].append(b)
  gyaku[b].add(a)
  ALL.discard(b)
#print(Graph,gyaku)
ALL = list(ALL);root = ALL[0]

used = set([])
TS = []
def dfs(v):
  if v in used:
    return
  used.add(v)
  for w in Graph[v]:
    if w in used:
      continue
    dfs(w)
    TS.append(w)
    
dfs(root)
TS.append(root)
TS.reverse()
#print(TS)
ans = [0 for _ in range(N)]
for i in range(N):
  now = TS[i]
  for nxt in Graph[now]:
    ans[nxt] = now+1
    
for x in ans:
  print(x)
### BUGGY CODE ###

N=int(input())
x=[]
m=N+1
x.append(set([1,N]))
for i in range(2,N//2+1):
    if N%i==0:
        a=i
        b=N//i
        m=min(m,a+b)
        if set([a,b]) in x:
            break
        else:
            x.append(set([a,b]))

print(m-2)

### FIXED CODE ###

import math
N=int(input())
m=N+1
for j in range(2,int(math.sqrt(N))+1):
    if N%j==0:
        a=j
        b=N//j
        if a>b:
            break
        else:
            m=min(m,(a+b))

print(m-2)
### BUGGY CODE ###

N, K = map(int, input().split())
H = list(map(int, input().split())) + [float('inf')] * K
dp = [float('inf')] * (N + K)
dp[0] = 0
for i in range(1, N):
    for j in range(1, K + 1):
        dp[i] = min(dp[i], dp[i - j] + abs(H[i - j] - H[i]))
print(dp[N - 1])

### FIXED CODE ###

N, K, *H = map(int, open(0).read().split())
H.extend([float('inf')] * K)
dp = [float('inf')] * (N + K)
dp[0] = 0
for i, hi in enumerate(H[1:], 1):
    dp[i] = min(dp[i - k] + abs(H[i - k] - hi) for k in range(1, K + 1))
print(dp[N - 1])
### BUGGY CODE ###

import sys
from operator import mul
from functools import reduce

def combinations_count(n, r):
    r = min(r, n - r)
    numer = reduce(mul, range(n, n - r, -1), 1)
    denom = reduce(mul, range(1, r + 1), 1)
    return numer // denom

n = int(input())
l = [int(x) for x in input().split()]

cl = [0 for i in range(n)]
ll = [x for x in set(l) if l.count(x) > 1]

if not ll:
    for i in range(n):
        print(0)
    sys.exit()

sum = 0
for i in ll:
    m = l.count(i)
    nc = combinations_count(m, 2)
    sum += nc
    # print(nc)
    cl[i-1] = nc - int(nc*(m-2)/m)

# print(sum)
# print(cl)
for i in l:
    print(sum - cl[i-1])


### FIXED CODE ###

import collections

def combinations_count(n, r):
    return n * (n-1) // r


n = int(input())
l = [int(x) for x in input().split()]

l1 = []
l2 = []
c = collections.Counter(l)

total = sum([combinations_count(i, 2) for i in c.values()])

for a in l:
    print(total-combinations_count(c[a], 2)+combinations_count(c[a]-1, 2))
### BUGGY CODE ###

N,T=map(int,input().split())
A=list(map(int,input().split()))


import collections
table=collections.defaultdict(set)
table2=collections.defaultdict(set)
tmp=0
for i in range(N-1):
  for j in range(i+1,N):
    table[A[j]-A[i]].add(i)
    table2[A[j]-A[i]].add(j)
    tmp=max(tmp,A[j]-A[i])
print(min(len(table[tmp]),len(table2[tmp])))


### FIXED CODE ###

N,T=map(int,input().split())
A=list(map(int,input().split()))


import heapq
import collections
hq=[]
heapq.heapify(hq)
heapq.heappush(hq,A[0])
tmp=0
table=collections.defaultdict(int)
for i in range(1,N):
  j=heapq.heappop(hq)
  table[A[i]-j]+=1
  tmp=max(tmp,A[i]-j)
  heapq.heappush(hq,j)
  heapq.heappush(hq,A[i])
print(table[tmp])
### BUGGY CODE ###

import sys
sys.setrecursionlimit(1<<20)
h,w=[int(x) for x in input().split()]
ch,cw=[int(x) for x in input().split()]
dh,dw=[int(x) for x in input().split()]
ch-=1
cw-=1
dh-=1
dw-=1

s=[]
for _ in range(h):
    s.append(list(input()))

nxt=[[ch,cw,0]]
#再起
def rcl(y,x,now):
    
    if y==dh and x==dw:
        print(now)
        exit()
    
    if s[y][x]=='#':
        return
    
    s[y][x]='#'
    # 四方を見る
    for i in range(4):
        yy,xx=-1,0
        if i==1:yy,xx=0,1
        if i==2:yy,xx=1,0
        if i==3:yy,xx=0,-1
        
        if y+yy<0 or h<=y+yy or x+xx<0 or w<=x+xx:
            continue
        if s[y+yy][x+xx]=='#':
            continue
        
        rcl(y+yy,x+xx,now)
    #5*5
    for i in range(-2,3):
        for j in range(-2,3):
            if i==0 and j==0:
                continue
            if y+i<0 or h<=y+i or x+j<0 or w<=x+j:
                continue
            if s[y+i][x+j]=='.':
                nxt.append([y+i,x+j,now+1])
                s[y+i][x+j]=now+1


while nxt:
    i=nxt.pop(0)
    if i[0]==dh and i[1]==dw:
        print(i[2])
        exit()
    rcl(i[0],i[1],i[2])
print(-1)

### FIXED CODE ###

import sys
sys.setrecursionlimit(1<<20)
h,w=[int(x) for x in input().split()]
ch,cw=[int(x) for x in input().split()]
dh,dw=[int(x) for x in input().split()]
ch-=1
cw-=1
dh-=1
dw-=1

s=[]
for _ in range(h):
    s.append(list(input()))

nxt=[[ch,cw,0]]
#再起
def rcl(y,x,now):
    
    if y==dh and x==dw:
        print(now)
        exit()
    
    if s[y][x]=='#':
        return
    
    s[y][x]='#'
    # 四方を見る
    for i in range(4):
        yy,xx=-1,0
        if i==1:yy,xx=0,1
        if i==2:yy,xx=1,0
        if i==3:yy,xx=0,-1
        
        if y+yy<0 or h<=y+yy or x+xx<0 or w<=x+xx:
            continue
        if s[y+yy][x+xx]=='#':
            continue
        
        rcl(y+yy,x+xx,now)
    #5*5
    for i in range(-2,3):
        for j in range(-2,3):
            if i==0 and j==0:
                continue
            if y+i<0 or h<=y+i or x+j<0 or w<=x+j:
                continue
            if s[y+i][x+j]=='.':
                nxt.append([y+i,x+j,now+1])
                s[y+i][x+j]=now+1


while nxt:
    i=nxt.pop(0)
    if i[0]==dh and i[1]==dw:
        print(i[2])
        exit()
    rcl(i[0],i[1],i[2])
print(-1)
### BUGGY CODE ###

import sys
input = sys.stdin.readline

def main():
    N = int(input())
    S = input()
    Q = int(input())
    x = tuple(map(int,input().split()))
    for k in x:
        d = 0
        m = 0
        dm = 0
        dmc = 0
        for i in range(N):
            st = S[i]
            if st == "D":
                d += 1
            elif st == "M":
                m += 1
                dm += d
            elif st == "C":
                dmc += dm
            if i >= k-1:
                if S[i-k+1] == "D":
                    dm -= m
                    d -= 1
                elif S[i-k+1] == "M":
                    m -= 1
        print(dmc)
    
if __name__ == "__main__":
    main()


### FIXED CODE ###

import sys
#input = sys.stdin.buffer.readline

def main():
    N = int(input())
    S = input()
    Q = input()
    x = tuple(map(int,input().split()))
    for k in x:
        d,m,dm,dmc = 0,0,0,0
        for i in range(N):
            st = S[i]
            if st == "D":
                d += 1
            elif st == "M":
                m += 1
                dm += d
            elif st == "C":
                dmc += dm
            if i >= k-1:
                if S[i-k+1] == "D":
                    dm -= m
                    d -= 1
                elif S[i-k+1] == "M":
                    m -= 1
        print(dmc)
    
if __name__ == "__main__":
    main()
### BUGGY CODE ###

n = int(input())
A = tuple(map(int, input().split()))
# fact_counts = [0] * (10**6+1)
fact_counts = dict()
def fact(n):
    if n%2 == 0:
        # fact_counts[2] += 1
        fact_counts.setdefault(2, 0)
        fact_counts[2] += 1
    while n%2 == 0:
        n //=2

    for f in range(3, int(n**0.5)+ 1, 2):
        if n%f == 0:
            # fact_counts[f] += 1
            fact_counts.setdefault(f, 0)
            fact_counts[f] += 1
        while n%f == 0:
            n //= f
    if n != 1:
        # fact_counts[n] += 1
        fact_counts.setdefault(n, 0)
        fact_counts[n] += 1

for a in A:
    fact(a)

pairwise = True
for c in fact_counts.values():
    if c > 1:
        pairwise = False

if pairwise:
    print('pairwise coprime')
else:
    if max(fact_counts.values()) == n:
        print('not coprime')
    else:
        print('setwise coprime')


### FIXED CODE ###

N = int(input())
A = tuple(map(int, input().split()))
maxa = max(A)
min_facts = [0] * (maxa+1)
def p(n):
    """ """
    is_prime = [True] * (n+1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, n+1):
        if not is_prime[i]:
            continue
        min_facts[i] = i
        
        for j in range(i*2, n+1, i):
            is_prime[j] = False
            if min_facts[j] == 0:
                min_facts[j] = i
p(maxa)
fact_counts = dict()
for a in A:
    while min_facts[a] > 0:
        f = min_facts[a]
        fact_counts.setdefault(f, 0)
        fact_counts[f] += 1
        while a%f == 0:
            a //= f

pairwise = True
for c in fact_counts.values():
    if c > 1:
        pairwise = False
        break

if pairwise:
    print('pairwise coprime')
else:
    if max(fact_counts.values()) == N:
        print('not coprime')
    else:
        print('setwise coprime')
### BUGGY CODE ###

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

d = [a[i] - a[i-1] for i in range(1, n)]
d.insert(0, a[0])
d.append(k - a[-1])

d = tuple(d)

most_min_path = 10000

for i in range(n):
    if i == 0:
        normal_ck = sum(d) - d[i] - d[-1]
        reverse_ck = sum(d) - d[i+1]
    elif i == n - 1:
        normal_ck = sum(d) - d[i]
        reverse_ck = sum(d) - d[i+1] - d[0]
    else:
        normal_ck = sum(d) - d[i]
        reverse_ck = sum(d) - d[i+1]
    if normal_ck > reverse_ck:
        min_ck = reverse_ck
    else:
        min_ck = normal_ck
    
    if most_min_path > min_ck:
        most_min_path = min_ck

print(most_min_path)

### FIXED CODE ###

k, n = map(int, input().split())
a = list(map(int, input().split()))
a.append(a[0] + k)

d = [a[i+1] - a[i] for i in range(n)]
l = 0
for i in range(n):
    l = max(l, a[i+1] - a[i])
print(k - l)
### BUGGY CODE ###

N = int(input())
S = input()

tmp = []
dada = ""
for i in range(N - 2):
    first = S[i]
    # print(i)
    for j in range(i + 1, N - 1):
        second = first + S[j]
        # print("\t" + str(j))
        for k in range(j + 1, N):
            third = second + S[k]
            # print("\t\t" + str(k))
            # print(third)
            if third not in tmp:
                tmp.append(third)
# print(tmp)
print(len(tmp))

### FIXED CODE ###

N = int(input())
S = input()

tmp = []
f = []
dada = ""
for i in range(N - 2):
    s = []
    first = S[i]
    if S[i] in f:
        continue
    f.append(first)
    for j in range(i + 1, N - 1):
        t = []
        second = first + S[j]
        if S[j] in s:
            continue
        s.append(S[j])
        for k in range(j + 1, N):
            third = second + S[k]
            if S[k] in t:
                continue
            t.append(S[k])
            if third not in tmp:
                tmp.append(third)
# print(tmp)
print(len(tmp))
### BUGGY CODE ###

import sys
readline = sys.stdin.readline

S = readline().rstrip()
gx,gy = map(int,readline().split())

C = []

import itertools
for key,g in itertools.groupby(S):
  C.append([key,len(list(g))])
  
x,y = 0,0
ind = 0
if C[0][0] == "F":
  x += C[0][1]
  ind = 1

# Xの方向を向いている
dirX = True
now = set([(x,y)])
for i in range(ind,len(C)):
  if C[i][0] == "F":
    step = C[i][1]
    nex = set()
    if dirX:
      for n in now:
        if n[0] + step <= 8000:
          nex.add((n[0] + step,n[1]))
        if n[0] - step >= -8000:
          nex.add((n[0] - step,n[1]))
    else:
      for n in now:
        if n[1] + step <= 8000:
          nex.add((n[0],n[1] + step))
        if n[1] - step >= -8000:
          nex.add((n[0],n[1] - step))
    now = nex
  else:
    if C[i][1] % 2 == 1:
      dirX ^= True
    
if (gx,gy) in now:
  print("Yes")
else:
  print("No")


### FIXED CODE ###

S = input()
X,Y = map(int,input().split())

# [文字,その文字が連続する数]
from collections import deque
sumS = deque()
import itertools
for key,g in itertools.groupby(S):
  sumS.append([key,len(list(g))])
  
startx = 0 # Fで始まる場合はX軸の正の方向にあらかじめ進めて置く
# 最初のTが出るまではX軸正の方向に進む
if sumS[0][0] == "F":
  startx = sumS[0][1]
  sumS.popleft()

xdir = True # X軸方向を向いている
dpXcur = set()
dpXcur.add(startx)
dpYcur = set()
dpYcur.add(0) # Y軸は必ず0から始まる
dpXnex = set()
dpYnex = set()
for i in range(len(sumS)):
  if sumS[i][0] == "F":
    steps = sumS[i][1] # 進む数
    if xdir: # X軸方向を向いている場合
      for x in dpXcur:
        dpXnex.add(x + steps)
        dpXnex.add(x - steps)
      dpXcur = dpXnex
      dpXnex = set()
    else:
      for y in dpYcur:
        dpYnex.add(y + steps)
        dpYnex.add(y - steps)
      dpYcur = dpYnex
      dpYnex = set()
  elif sumS[i][0] == "T":
    turns = sumS[i][1] # 方向転換する数
    if turns % 2 == 1:
      # 奇数回の場合はX/Y軸の切り替え (偶数回の場合は何も起こらない)
      xdir ^= True
      
if X in dpXcur and Y in dpYcur:
  print("Yes")
else:
  print("No")
### BUGGY CODE ###

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

ans=1
for i in range(N):
    ans = ans * A[i]
if ans > 10**18:
    ans = -1
print(ans)


### FIXED CODE ###

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

ans=1
if 0 in A:
    ans=0
else:
    for i in range(N):
        ans = ans * A[i]
        if ans > 10**18:
            ans = -1
            break
print(ans)
### BUGGY CODE ###

# D - Digits Parade

# dp[i][j] Sの大きい位からi桁の数で、あり得るもののうち、13で割った余りがjになるものの個数。0桁スタート
# 大きい位から順に始めないと13で割ったときの余りを求める計算量が大きくなる

S = input()

MOD = 10**9 + 7
dp = [[0]*13 for _ in range(len(S))]

if S[0] == "?":
    for j in range(10):
        dp[0][j] = 1
else:
    dp[0][int(S[0])] = 1

for i in range(1, len(S)):
    if S[i] == "?":
        for q_number in range(10): # ?の中身としてあり得る数字
            for front_number in range(13):
                dp[i][(10 * front_number + q_number) % 13] += dp[i-1][front_number]
                dp[i][(10 * front_number + q_number) % 13] %= MOD
    else:
        for front_number in range(13):
            dp[i][(10 * front_number + int(S[i])) % 13] += dp[i-1][front_number]
            dp[i][(10 * front_number + int(S[i])) % 13] %= MOD

print(dp[len(S)-1][5] % MOD)

### FIXED CODE ###

# D - Digits Parade

# dp[i][j] Sの大きい位からi桁の数で、あり得るもののうち、13で割った余りがjになるものの個数。0桁スタート
# 大きい位から順に始めないと13で割ったときの余りを求める計算量が大きくなる

S = input()

MOD = 10**9 + 7
dp = [[0]*13 for _ in range(len(S))]

if S[0] == "?":
    for j in range(10):
        dp[0][j] = 1
else:
    dp[0][int(S[0])] = 1

for i in range(1, len(S)):
    if S[i] == "?":
        for q_number in range(10): # ?の中身としてあり得る数字
            for front_number in range(13):
                dp[i][(10 * front_number + q_number) % 13] += dp[i-1][front_number]
                dp[i][(10 * front_number + q_number) % 13] %= MOD
    else:
        for front_number in range(13):
            dp[i][(10 * front_number + int(S[i])) % 13] += dp[i-1][front_number]
            dp[i][(10 * front_number + int(S[i])) % 13] %= MOD

print(dp[len(S)-1][5] % MOD)