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

from itertools import permutations
N, M, R = map(int, input().split())
r = list(map(lambda x: int(x) - 1, input().split()))
G = [[0] * N for i in range(N)]
for i in range(M):
    a, b, c = map(int, input().split())
    a, b = a - 1, b - 1
    G[a][b] = c
    G[b][a] = c

# ワーシャルフロイド
for k in range(N):
    for i in range(N):
        for j in range(N):
            G[i][j] = min(G[i][j], G[i][k] + G[k][j])

# 街の訪れ方を全探索
ans = float('inf')
for perm in permutations(r):
    tmp = 0
    for i in range(R - 1):
        tmp += G[perm[i]][perm[i + 1]]
    ans = min(ans, tmp)

print(ans)


### FIXED CODE ###

from itertools import permutations

N, M, R = map(int, input().split())
r = list(map(int, input().split()))
ARSP = [[float('inf')] * (N+1) for i in range(N+1)]
for i in range(M):
    a, b, c = map(int, input().split())
    ARSP[a][b] = c
    ARSP[b][a] = c


def warshall_floyd(adj_array):
    for k in range(len(adj_array)):
        for i in range(len(adj_array)):
            for j in range(len(adj_array)):
                if adj_array[i][k] + adj_array[k][j] < adj_array[i][j]:
                    adj_array[i][j] = min(adj_array[i][j], adj_array[i][k] + adj_array[k][j])
    return adj_array


ARSP = warshall_floyd(ARSP)

# 訪れ方の全列挙(max 8! = 40320)
journey = list(permutations(r))

ans = float('inf')
for j in journey:
    cost = 0
    for i in range(1, R):
        if ARSP[j[i]][j[i-1]] == float('inf'):
            break
        cost += ARSP[j[i]][j[i-1]]
        if cost >= ans:
            break
    else:
        ans = cost

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

n, k = map(int, input().split())
cnt = 1
while True:
  if n <= k**cnt + 1:
    cnt += 1
print(cnt)

### FIXED CODE ###

n, k = map(int, input().split())
cnt = 1
while True:
  if n <= k**cnt - 1:
    break
  cnt += 1
print(cnt)
### BUGGY CODE ###

def main():
  s=input()
  q=int(input())
  count=0
  for _ in [0]*q:
    a=list(input().split())
    if len(a)==1:
      count+=1
    else:
      if count%2==0:
        if a[1]=='1':
          l=[a[2],s]
          s=''.join(l)
        else:
          l=[s,a[2]]
          s=''.join(l)
      else:
        if a[1]=='1':
          l=[s,a[2]]
          s=''.join(l)
        else:
          l=[a[2],s]
          s=''.join(l)
  if count%2==1:
    s=s[::-1]
  print(s)
if __name__=='__main__':
  main()

### FIXED CODE ###

def main():
  from collections import deque
  s=deque(input())
  q=int(input())
  count=0
  for _ in [0]*q:
    a=list(input().split())
    if len(a)==1:
      count+=1
    else:
      if count%2==0:
        if a[1]=='1':
           s.appendleft(a[2])
        else:
          s.append(a[2])
      else:
        if a[1]=='1':
          s.append(a[2])
        else:
          l=(a[2],s)
          s.appendleft(a[2])
  if count%2==1:
    s=list(s)[::-1]
  print(''.join(s))
if __name__=='__main__':
  main()
### BUGGY CODE ###

N = int(input())
a = [int(e) for e in input().split()]

m = 1
for e in a:
    m *= e

if m > 10 ** 18:
    print(-1)
else:
    print(m)


### FIXED CODE ###

N = int(input())
a = [int(e) for e in input().split()]

if 0 in a:
    print(0)
    exit(0)

m = 1
for e in a:
    m *= e
    if m > 10 ** 18:
        print(-1)
        exit(0)

print(m)
### BUGGY CODE ###

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

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

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

ans = []

for inde, i in enumerate(h):
    for j in ways:
        if inde+1 in j:
            if j.index(inde+1) == 0:
                z = 1
            else:
                z = 0
            if i <= h[j[z]-1]:
                if inde not in ans:
                    ans.append(inde)

print(n-len(ans))


### FIXED CODE ###

N, M = map(int, input().split())
H = list(map(int, input().split()))
LIST = [ 1 for _ in range(N)]
for _ in range(M):
    A, B = map(int, input().split())
    if H[A-1] >= H[B-1]: LIST[B-1] = 0
    if H[A-1] <= H[B-1]: LIST[A-1] = 0
print(sum(LIST))
### BUGGY CODE ###

n=int(input())
lst=[]
for i in range(n-1):
    lst.append(list(map(int,input().split())))
def neccesary_time(m):
    t=0
    for i in range(m,n-1):
        s=lst[i][1]
        if t<=s:
            t=s+lst[i][0]
        else:
            while s<t:
                s+=lst[i][2]
            t=s+lst[i][0]
    return t
for i in range(n-1):
    print(neccesary_time(i))
print(0)

### FIXED CODE ###

from math import ceil
n=int(input())
lst=[]
for i in range(n-1):
    lst.append(list(map(int,input().split())))
def neccesary_time(m):
    t=0
    for i in range(m,n-1):
        s=lst[i][1]
        if t<=s:
            t=s+lst[i][0]
        else:
            t=s+lst[i][2]*ceil((t-s)/lst[i][2])+lst[i][0]
    return t
for i in range(n-1):
    print(neccesary_time(i))
print(0)
### BUGGY CODE ###

import math
n = int(input())
ans = 0
for i in range(1,n+1):
    for j in range(1,n+1):
        for k in range(1,n+1):
            ans+=math.gcd(math.gcd(i,j),k)
print(ans)

### FIXED CODE ###

from math import gcd
n = int(input())
ans = 0
for i in range(1,n+1):
    for j in range(1,n+1):
        for k in range(1,n+1):
            ans+=gcd(gcd(i,j),k)
print(ans)
### BUGGY CODE ###

n = int(input())
A = list(map(int, input().split()))
B = []
for i in range(n):
    B.append(A[i])
    B = B[::-1]
print(*B)

### FIXED CODE ###

n = int(input())
A = list(map(int, input().split()))
if n%2==0:
    B = A[1::2][::-1] + A[::2]
    print(*B)
else:
    B = A[::2][::-1] + A[1::2]
    print(*B)
### BUGGY CODE ###

from operator import mul
from functools import reduce
mod=10**9+7
def cmb(n,r):
    r = min(n-r,r)
    if r == 0: return 1
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1,r + 1))
    return over // under%mod

n,a,b=map(int,input().split())
ans=((2**n-1)%(10**9+7)-cmb(n,a)-cmb(n,b))
print(int(ans))

### FIXED CODE ###

mod=10**9+7
n,a,b=map(int,input().split())
ans=pow(2,n,mod)-1 #n種類の花を使って花束を作る総数は2^n-1通り
comb1=1 #nCaの計算
for i in range(n-a+1,n+1): #n*(n-1)*…*(n-a+1)を計算
 comb1*=i
 comb1%=mod
for i in range(1,a+1): #1/a!=1/(1*2*…*a)=1^(p-2)*2^(p-2)*…*a^(p-2) (p=10**9+7)を計算
 comb1*=pow(i,mod-2,mod)
 comb1%=mod
comb2=1
for i in range(n-b+1,n+1): #n*(n-1)*…*(n-b+1)を計算
 comb2*=i
 comb2%=mod
for i in range(1,b+1): #1/b!=1/(1*2*…*b)=1^(p-2)*2^(p-2)*…*b^(p-2) (p=10**9+7)を計算
 comb2*=pow(i,mod-2,mod)
 comb2%=mod
ans-=(comb1+comb2) #nCa、nCbを総数から引く
ans%=mod
print(ans)
### BUGGY CODE ###

import sys
import math
import itertools

input = sys.stdin.readline


def main():
    l, r = [int(i) for i in input().split()]
    num = [i % 2019 for i in range(l, r + 1)]
    print(min([i * j % 2019 for i, j in itertools.combinations(num, 2)]))


if __name__ == "__main__":
    main()


### FIXED CODE ###

import sys
import math
import itertools

input = sys.stdin.readline


def main():
    l, r = [int(i) for i in input().split()]

    if r - l >= 2019:
        print(0)
        return
    else:
        num = [i for i in range(l, min(l + 2019, r + 1))]
        min_ = 2019
        for i, n in enumerate(num):
            for j in num[i + 1 :]:
                min_ = min([n * j % 2019, min_])
    print(min_)


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

import numpy as np

h, w = map(int, input().split())
m = np.array([list(input()) for _ in range(h)])

black_loc = []
for i in range(h):
    for j in range(w):
        if m[i][j] == "#":
            black_loc.append((i, j))

ans = 0
for i in range(h):
    for j in range(w):
        if m[i][j] == ".":
            tmp = 1000000000
            for (b_h, b_w) in black_loc:
                tmp = min(tmp, abs(i - b_h) + abs(j - b_w))
            ans = max(ans, tmp)

print(ans)


### FIXED CODE ###

from collections import deque

h, w = map(int, input().split())
m = [list(input()) for _ in range(h)]

flag = [[True] * w for _ in range(h)]

q = deque()

for i in range(h):
    for j in range(w):
        if m[i][j] == "#":
            q.appendleft((i, j, 0))
            flag[i][j] = False

ans = 0
while q:
    (i, j, n) = q.pop()
    ans = n
    for dx, dy in zip([1,0, -1, 0], [0, 1, 0, -1]):
        ni = i + dx
        nj = j + dy
        if (0 <= ni < h and 0 <= nj < w and flag[ni][nj]):
            flag[ni][nj] = False
            q.appendleft((ni, nj, n + 1))

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

from itertools import combinations

n = int(input())
value = list(map(int, input().split()))
cost = list(map(int, input().split()))

idx = range(n)
result = [0, sum(value)-sum(cost)]

for i in range(n):
  for com in combinations(idx, i):
    tmp = 0
    for c in com:
      tmp += value[c]-cost[c]
    result.append(tmp)
    
print(max(result))

### FIXED CODE ###

n = int(input())
value = list(map(int, input().split()))
cost = list(map(int, input().split()))
result = 0
for v, c in zip(value, cost):
  if v > c:
    result += v-c
print(result)
### BUGGY CODE ###

n = int(input())
s = str(input())
answer = n

for i in range(n):
	a = s[:i].count('W')
	b = s[i:].count('E')
	answer = min(answer, a+b)
	
print(answer)

### FIXED CODE ###

n = int(input())
s = str(input())
answer = n
dpa = [-1]*(n+1)
dpa[0] = 0
dpb = [-1]*(n+1)
dpb[0] = s.count('E')

for i in range(1,n+1):
	if s[i-1] == 'W':
		dpa[i] = dpa[i-1] + 1
		dpb[i] = dpb[i-1]	
	else:
		dpa[i] = dpa[i-1]
		dpb[i] = dpb[i-1] - 1

for i in range(n+1):
	answer = min(answer, dpa[i]+dpb[i])
	
print(answer)
### BUGGY CODE ###

N = int(input())
line = [int(i) for i in input().split()]


#sum
#count : 組み合わせの個数
#tmp : L番目の要素で始まる組み合わせの個数

count = 0

for L in range(N-1):
  sum = line[L]
  count_tmp = 1
  #ビットが被るまで右端を伸ばす。かぶったら終了
  for r in range(L+1,N):
    sum_tmp = sum+line[r]
    if sum_tmp == sum ^ line[r]:
      sum = sum_tmp
      count_tmp += 1
    else:
      break
  count += count_tmp

#L=N, r=Nの分を１つ追加する
print(count+1)

### FIXED CODE ###

N = int(input())
line = [int(i) for i in input().split()]


#sum
#count : 組み合わせの個数
#tmp : L番目の要素で始まる組み合わせの個数

count = 0
sum = line[0]
r = 1
count_tmp = 1

for L in range(N-1):
  #ビットが被るまで右端を伸ばす。かぶったら終了
  for r in range(r,N):
    sum_tmp = sum+line[r]
    if sum_tmp == sum ^ line[r]:
      sum = sum_tmp
      count_tmp += 1
      if r == N-1:
        r += 1
    else:
      break
  count += count_tmp
  count_tmp -= 1
  sum -= line[L]

#L=N, r=Nの分を１つ追加する
print(count+1)
### BUGGY CODE ###

N,M,*a=map(int,open(0).read().split())
dp=[0]*(N+1)
dp[0]=1
for i in a:
    dp[i]=0
if 1 in a:
    dp[1]=0
else:
    dp[1]=1
for i in range(2,N+1):
    if i not in a:
        dp[i]=dp[i-1]+dp[i-2]
print(dp[-1]%1000000007)    


### FIXED CODE ###

N,M=map(int,input().split())
dp=[1]*(N+1)
for i in range(M):
    dp[int(input())]=0
for i in range(2,N+1):
    if dp[i]!=0:
        dp[i]=(dp[i-1]+dp[i-2])
print(dp[-1]%1000000007)
### BUGGY CODE ###

def popcount(x):
    return bin(x).count("1")

N,X = open(0).read().split()
N = int(N)
X = int(X, 2)

p = popcount(X)
if X == 0 or p == 1:
    for i in range(0, N):
        k = 1 << (N - 1 - i)
        x = X ^ k
        ans = 0
        while x != 0:
            x %= popcount(x)
            ans += 1
        print(ans)

else:
    xi = X % (p + 1)
    xd = X % (p - 1)
    for i in range(0, N):
        k = 1 << (N - 1 - i)
        x = X ^ k
        if x == 0:
            print(0)
            continue

        if x > X:
            pi = p + 1
            x = (xi + k) % pi
        else:
            pd = p - 1
            x = (xd - k) % pd
        ans = 1
        while x != 0:
            x %= popcount(x)
            ans += 1
        print(ans)

### FIXED CODE ###

def popcount(x):
    return bin(x).count("1")

N, X = open(0).read().split()
N = int(N)
XS = list(X)
X = int(X, 2)

p = popcount(X)
xi = X % (p + 1)
if p == 1:
    xd = 0
else:
    xd = X % (p - 1)

for i in range(N):
    if XS[i] == "1":
        if p == 1:
            print(0)
            continue
        else:
            k = pow(2, N - 1 - i, p - 1)
            x = (xd - k) % (p - 1)
    else:
        k = pow(2, N - 1 - i, p + 1)
        x = (xi + k) % (p + 1)
    ans = 1
    while x != 0:
        x %= popcount(x)
        ans += 1
    print(ans)
### BUGGY CODE ###

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

d = sorted(A.count(a) for a in set(A))

if len(d) > K:
    print(sum(d[:len(d) - K]))
else:
    print(0)

### FIXED CODE ###

from collections import Counter

N, K = map(int, input().split())
A = list(map(int, input().split()))
d = Counter(A).most_common()

if len(d) > K:
    print(sum(v for k, v in d[-(len(d) - K):]))
else:
    print(0)
### BUGGY CODE ###

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

islow = True
counter = 0
min = 0

for i in range(len(plist)):
    islow = True
    if i == 0:
        counter += 1
        min = plist[i]
        current_min = i
    elif min > plist[i]:
        for j in range(current_min+1, plist.index(plist[i-1])):
            if plist[i] <= plist[j]:
                pass
            else:
                islow = False
                break
        if islow:
            counter += 1
            min = plist[i]
            current_min = i
            
print(counter)  

### FIXED CODE ###

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

islow = True
counter = 0
min = 0

for i in range(len(plist)):
    islow = True
    if i == 0:
        counter += 1
        min = plist[i]
        current_min = i
    elif min > plist[i]:
        counter += 1
        min = plist[i]
        current_min = i
        
print(counter)
### BUGGY CODE ###

# coding: utf-8
import sys
sysread = sys.stdin.readline
from heapq import heappop, heappush

def run():
    # import sys
    # A = list(map(int, sys.stdin.readline().split()))
    # all = sys.stdin.readlines()
    # all = list(map(int, sys.stdin.read().split())
    #N, *A = map(int, open(0))
    #N = int(input())
    N, M, S = list(map(int, sysread().split()))
    to = [[] for _ in range(N+1)]
    max_m = 2500
    for _ in range(M):
        u,m,a,b = list(map(int, sysread().split()))
        to[u].append((m,b,a))
        to[m].append((u,b,a))


    CD = [[0,0]]
    for _ in range(N):
        c,d = list(map(int, sysread().split()))
        CD.append([c,d])

    queue = []
    # (time, node, rest-coin)
    if S > max_m:
        S = max_m
    heappush(queue, (0, 1, S))

    state = [[float('inf')] * (max_m+1) for _ in range(N+1)]

    while queue:
        time, node, coin = heappop(queue)
        if state[node][coin] < time: continue
        c, d = CD[node]
        if coin + c <= max_m and time + d < state[node][coin+c]:
            state[node][coin+c] = time + d
            heappush(queue, (time+d, node, coin+c))
        for n_node, n_time, n_coin in to[node]:
            if coin < n_coin:continue
            if state[n_node][coin-n_coin] < n_time + time:continue
            state[n_node][coin - n_coin] = n_time + time
            heappush(queue, (time + n_time, n_node, coin - n_coin))
    for s in state[2:]:
        print(min(s))

if __name__ == "__main__":
    run()

### FIXED CODE ###

import sys
readline = sys.stdin.readline
read = sys.stdin.read
 
n,m,s = [int(i) for i in readline().split()]
g = [[] for _ in range(n)]
for i in range(m):
    u,v,a,b = [int(i) for i in readline().split()]
    u -= 1
    v -= 1
    g[u].append((v,a,b))
    g[v].append((u,a,b))
 
 
cd = [int(i) for i in read().split()]
c = cd[::2]
d = cd[1::2]
 
 
from heapq import *
INF = 1<<61
M = 2500
if s >= M: s = M-1
dist = [[INF]*M for _ in range(n)] #startからの最短距離
dist[0][s] = 0
q = [(0,s,0)] #(そこまでの距離、銀の枚数、点)
 
while q:
    dv,num,v = heappop(q)
    if dist[v][num] < dv: continue
    if num+c[v] < M and dv+d[v] < dist[v][num+c[v]]:
        dist[v][num+c[v]] = dv + d[v]
        heappush(q, (dv + d[v], num+c[v] ,v))
    for to,a,b in g[v]:
        if num >= a and dv + b < dist[to][num-a]:
            dist[to][num-a] = dv + b
            heappush(q, (dv + b, num-a ,to))
    #print(q)
 
for i in range(1,n):
    print(min(dist[i]))
### BUGGY CODE ###

import collections
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

m = int(input())
a = list(map(int,input().split()))[:m]
c = collections.Counter(a)

memo = {}

for i in a:
    res = 0
    for k,v in c.items():
        if i == k: v -= 1
        
        if v >= 2:
            if not memo.get(v):
                memo[v] = combinations_count(v, 2)

            res += memo[v]
    print(res)

### FIXED CODE ###

import collections


m = int(input())
A = list(map(int,input().split()))[:m]
c = collections.Counter(A)
 
def hoge(n):
    return n * (n - 1) // 2

full = sum([ hoge(i) for i in c.values()])

for a in A:
    print(full - hoge(c[a]) + hoge(c[a]-1))
### BUGGY CODE ###

N, Q = map(int, input().split())
s = input()
k = 0

for i in range(Q):
	l, r = map(int, input().split())
	a = s[l - 1: r]
	print(a.count("AC"))



### FIXED CODE ###

N, Q = map(int, input().split())
s = input()
a = [0] * (N + 1)

for i in range(N):
	a[i + 1] = a[i] + (1 if s[i : i + 2] == "AC" else 0)
for i in range(Q):
	l, r = map(int, input().split())
	print(a[r - 1] - a[l - 1])
### BUGGY CODE ###

n = int(input())
ls = list(map(int, input().split()))
MOD = 10 ** 9 + 7

ans = 0
for i in range(len(ls)):
    for j in range(i+1, len(ls)):
        ans += ls[i]*ls[j]
print(ans%MOD)

### FIXED CODE ###

n = int(input())
ls = list(map(int, input().split()))
MOD = 10 ** 9 + 7

ans = 0
SUM = sum(ls)
for i in range(len(ls)):
    SUM -= ls[i]
    ans += ls[i] * SUM
print(ans%MOD)
### BUGGY CODE ###

x,y,z,k = map(int,input().split())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
C = list(map(int,input().split()))

ls = [0]*(len(A)*len(B))
for i in range(len(A)):
    for j in range(len(B)):
        ls[(i*len(B))+j] = A[i] + B[j]
ls.sort(reverse = True)
ls = ls[:k]
check_ls = []
for i in range(len(C)):
    for j in range(len(ls)):
        check_ls.append(C[i] + ls[j])
check_ls.sort(reverse = True)
for i in range(k):
    print(check_ls[i])

### FIXED CODE ###

x,y,z,k = map(int,input().split())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
C = list(map(int,input().split()))

ls = [0]*(len(A)*len(B))
for i in range(len(A)):
    for j in range(len(B)):
        ls[(i*len(B))+j] = A[i] + B[j]
ls.sort(reverse = True)
ls = ls[:k]
check_ls = []
for i in range(len(C)):
    for j in range(len(ls)):
        check_ls.append(C[i] + ls[j])
check_ls.sort(reverse = True)
for i in range(k):
    print(check_ls[i])
### BUGGY CODE ###

DIV=10**9+7
N=int(input())

ans=1
while N>0:
  ans*=N
  N-=1
  
print(ans%DIV)


### FIXED CODE ###

N=int(input())
ans=1
DIV=10**9+7
while N>1:
  ans=(ans*(N%DIV))%DIV
  N-=1
print(ans)
### BUGGY CODE ###

N, K = map(int, input().split())
A = sorted(list(map(int, input().split())))
F = sorted(list(map(int, input().split())), reverse=True)


# にぶたん := N人のメンバーそれぞれが完食にかかる時間のうち最大値をxに以下にできるか？
ok, ng = 10 ** 18, -1
while ok - ng > 1:
    x = (ok + ng) // 2

    need_training = 0
    for a, f in zip(A, F):
        need_training += max(0, a - x // f)

        if need_training > K:
            ng = x
            break
    else:
        ok = x

print(ok)


### FIXED CODE ###

from math import ceil
N, K = map(int, input().split())
A = sorted(list(map(int, input().split())))
F = sorted(list(map(int, input().split())), reverse=True)

K = min(K, sum(A))
X = [[a, f] for a, f in zip(A, F)]

ok, ng = 10 ** 12 + 1, -1
while abs(ok - ng) > 1:
    m = (ok + ng) // 2
    k_cost = 0
    for a, f in X:
        if a * f <= m:
            continue
        else:
            k_cost += max(0, ceil(-(m / f - a)))

    if k_cost <= K:
        ok = m
    else:
        ng = m

print(ok)
### BUGGY CODE ###

n = int(input())
ans = []
for _ in range(n):
    a = int(input())
    if a in ans:
        ans.pop(ans.index(a))
    else:
        ans.append(a)
print(len(ans))


### FIXED CODE ###

import collections
n = int(input())
a = [int(input()) for _ in range(n)]
c = collections.Counter(a)

print(len(list(filter(lambda x: x[1]%2 == 1, c.items()))))
### BUGGY CODE ###

n = int(input())
s = list(input())

ans = float('inf')
for i in range(n):
    c = s[:i].count('W') + s[i + 1:].count('E')
    ans = min(ans, c)
print(ans)

### FIXED CODE ###

n = int(input())
s = list(input())

cw = [0] * (n + 1)
for i in range(1, n + 1):
    if s[i - 1] == 'W':
        cw[i] = cw[i - 1] + 1
    else:
        cw[i] = cw[i - 1]

s2 = s[::-1]
ce = [0] * (n + 1)
for i in range(1, n + 1):
    if s2[i - 1] == 'E':
        ce[i] = ce[i - 1] + 1
    else:
        ce[i] = ce[i - 1]
ce = ce[::-1]

ans = float('inf')
for i in range(n):
    ans = min(ans, cw[i] + ce[i + 1])
print(ans)
### BUGGY CODE ###

n = int(input())
a = [int() for _ in input().split()]
cnt =0
while all(i%2==0 for i in a):
  a = [int(i//2) for i in a]
  cnt +=1
print(cnt)

### FIXED CODE ###

n = int(input())
A = list(map(int,input().split()))
c = 0
while all(a%2 == 0 for a in A) :
    for i in range(len(A)): A[i] = A[i]/2
    c += 1
print(c)
### BUGGY CODE ###

import itertools
from sys import stdin
N=list(map(int,stdin.readline().strip().split()))[0]
st=list(stdin.readline().strip())
count=0
cnt = 0
for i in range(10):
    for j in range(10):
        for k in range(10):
            cnt=0
            number=[str(i),str(j),str(k)]
            for num in range(N):
                if number[cnt]==st[num]:
                    cnt+=1
                    if cnt==3:
                        count += 1
                        break
            cnt = 0


print(count)

### FIXED CODE ###

def main():
  N = int(input())
  S = list(map(int,input()))
  ans = 0
  for i in range(10):
    for j in range(10):
      for k in range(10):
        flg = False
        flg2 = False
        for x in range(N):
          if flg2:
            break
          if not flg:
            if S[x] == i:
              flg = True
          else:
            if S[x] == j:
              flg2 = True
              if k in S[x+1:]:
                ans +=1
  print(ans)
main()
### BUGGY CODE ###

N=int(input())
S=input()
count=0
R=[]
G=[]
B=[]
for i in range(N):
  if S[i]=="R":
    R.append(i)
  if S[i]=="G":
    G.append(i)
  if S[i]=="B":
    B.append(i)
for r in R:
  for g in G:
    for b in B:
      if r<g and g<b:
        if b-g!=g-r:
          count+=1
      elif r<b and b<g:
        if g-b!=b-r:
          count+=1
      elif g<r and r<b:
        if b-r!=r-g:
          count+=1
      elif g<b and b<r:
        if r-b!=b-g:
          count+=1
      elif b<r and r<g:
        if g-r!=r-b:
          count+=1
      elif b<g and g<r:
        if r-g!=g-b:
          count+=1
print(count)

### FIXED CODE ###

N=int(input())
S=input()
count=0
R=0
G=0
B=0
for i in range(N):
  if S[i]=="R":
    R+=1
  if S[i]=="G":
    G+=1
  if S[i]=="B":
    B+=1
count=0
for i in range(N-2):
  for j in range(i,N-1):
    k=j+j-i
    try:
      if S[i]!=S[j] and S[j]!=S[k] and S[k]!=S[i]:
        count+=1
    except:
      pass
    
print(R*G*B-count)
### BUGGY CODE ###

s = input()
k = int(input())
n = len(s)

sub = set()

for i in range(n+1):
    for j in range(n-i+1):
        sub.add(s[i:i+j])

sub = sorted(sub)

print(sub[k])

### FIXED CODE ###

s = input()
k = int(input())
n = len(s)

sub = set()

for i in range(n):
  for j in range(5):
    sub.add(s[i:i+j+1])
print(sorted(sub)[k-1])
### BUGGY CODE ###

n = int(input())
data = list(map(int, input().split()))
 
a = 1
i = 0
for i in range(n):
  a = a*data[i]

if a > 10**18:
  a = -1
    # break
 
print(a)

### FIXED CODE ###

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

flag = 0
if data.count(0) > 0:
	print(0)
else:
  a = data[0]
  for i in range(1,n):
    a = a*data[i]
    if a > 10**18:
      flag = 1
      break
      
  if flag == 1:
    print('-1')
  else:
    print(a)