Harryxun/stf_run huggingface dataset:
s, _, q = open(0)
g = ""
for q in q:
  p, f, c = q.split()
  if p == "1":
    g, s = s, g
  else:
    if f == "1":
      g += c
    else:
      s += c
print(g[::-1] + s)

### FIXED CODE ###

s = input()
if s == "AAA" or s == "BBB":
    print("No")
    exit()
print("Yes")
a = input().split()
n = int(a[0])
x = int(a[1])
l_str_list = input().split()
d = 0
answer = 0

for i in n:
  d += int(l_str_list[i])
  if d > x:
    answer = i + 1
    break;
print(answer)

### FIXED CODE ###

a = input().split()
n = int(a[0])
x = int(a[1])
l_str_list = input().split()
d = 0
answer = n + 1

for i in range(n):
  d += int(l_str_list[i])
  if d > x:
    answer = i + 1
    break
  if d == x:
    answer = i + 2
    break
print(answer)
n, m = map(int, input().split())
issafe = [True] * 10001
for _ in range(m):
    a = int(input())
    issafe[a] = False

dp = [0] * 10001
dp[0] = 1
if issafe[1]:
    dp[1] = 1

for i in range(2, n + 1):
    if  issafe[i - 1]:
        dp[i] = dp[i] + dp[i - 1]
    if issafe[i -  2]:
        dp[i] = dp[i - 2] + dp[i] 
    
    dp[i] %= 1000000007
    
print(dp[n])

### FIXED CODE ###

n, m = map(int, input().split())
issafe = [True] * (n +1)
for _ in range(m):
    a = int(input())
    issafe[a] = False

dp = [0] * (n + 1)
dp[0] = 1
if issafe[1]:
    dp[1] = 1

for i in range(2, n + 1):
    if  issafe[i - 1]:
        dp[i] = dp[i] + dp[i - 1]
    if issafe[i -  2]:
        dp[i] = dp[i - 2] + dp[i] 
    
    dp[i] %= 1000000007
    
print(dp[n])
import copy
H,W,K=map(int,input().split())
L=[list(map(int,input().split())) for i in range(H)]
ans=0
for i in range(2**H):
    for j in range(2**W):
        C=copy.deepcopy(L)
        for k range(H):
            if (i>>k&1):
                C[k]=["r"]*W
        for l range(W):
            if (j>>l&1):
                for m range(H):
                    C[l][m]="r"
        count=0
        for i in range(H):
            for j in range(W):
                if C[i][j]=="#":
                    count+=1
        if count==K:
            ans+=1
print(ans)


### FIXED CODE ###

import copy
H,W,K=map(int,input().split())
L=[[x for x in input()] for i in range(H)]
ans=0
for i in range(2**H):
    for j in range(2**W):
        C=copy.deepcopy(L)
        for k in range(H):
            if (i>>k&1):
                C[k]=["r"]*W
        for l in range(W):
            if (j>>l&1):
                for m in range(H):
                    C[m][l]="r"
        count=0
        for p in range(H):
            for q in range(W):
                if C[p][q]=="#":
                    count+=1
        if count==K:
            ans+=1
print(ans)
N, M = map(int, input().split())
ans = [None] * N
for _ in range(M):
    s, c = map(int, input().split())
    if ans[s - 1] in [None, c]:
        ans[s - 1] = c
    else:
        print(-1)
        quit()

ans = "".join(map(lambda i, n :str(n) if n else "0" if i else "1", enumerate(ans)))
if N > 1 and ans[0] == "0":
    print(-1)
    quit()

print(ans)


### FIXED CODE ###

N, M = map(int, input().split())
ans = [None] * N
for _ in range(M):
    s, c = map(int, input().split())
    if ans[s - 1] in [None, c]:
        ans[s - 1] = c
    else:
        print(-1)
        quit()

ans = "".join(map(lambda pair :str(pair[1]) if pair[1] != None else "0" if pair[0] or N == 1 else "1", enumerate(ans)))
if N > 1 and ans[0] == "0":
    print(-1)
    quit()

print(ans)
n = int(input())

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

b=0
for i in range(n):
   b = b + 1/a[i]
b=1/b
print(b)



### FIXED CODE ###

n = int(input())

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

b=0
for i in range(n):
   b = b + 1/a[i]
b=1/b
print(b)
x, y=map(int, input().split())
alp='ABCDEF'
if x==y:
  print('=')
elif alp.index(x)<alp.index(y):
  print('<')
else:
  print('>')

### FIXED CODE ###

x, y=input().split()
alp='ABCDEF'
if x==y:
  print('=')
elif alp.index(x)<alp.index(y):
  print('<')
else:
  print('>')
n, k = list(map(int, input().split()))
a = list(map(int, input().split()))
ans = list(str(format(k, 'b')))
L = len(ans)
zero = 0
one = 0
for i in range(n):
    a[i] = str(format(a[i], 'b'))
    if len(a[i]) < L:
        a[i] = '0' * (L - len(a[i])) + a[i]
for i in range(L + 1):
    one = 0
    zero = 0
    for j in range(n):
        if a[j][i] == '0':
            zero += 1
        else:
            one += 1
    if zero > one:
        ans[i] = '1'
    else:
        ans[i] = '0'
ans = "".join(ans)
sum = 0
for i in range(n):
    a[i] = int(a[i], 2)
    sum += a[i] ^ int(ans, 2)
print(sum)


### FIXED CODE ###

n, k = list(map(int, input().split()))
a = list(map(int, input().split()))
bit_len = len(format(k, 'b'))
for i in range(n):
    bit_len = max(bit_len, len(format(a[i],'b')))
bit_count = [0 for i in range(bit_len)]
for i in range(n):
    bit = format(a[i], 'b').zfill(bit_len)
    for j in range(bit_len):
        if bit[j] == '1':
            bit_count[j] += 1
ans = 0
now_num = 0
for i in range(bit_len):
    if bit_count[i] < n - bit_count[i]:
        if now_num + 2 ** (bit_len - i - 1) <= k:
            now_num += 2 ** (bit_len - i - 1)
            ans += (n - bit_count[i]) * (2 ** (bit_len - i - 1))
            continue
    ans += bit_count[i] * (2 ** (bit_len - i - 1))
print(ans)
N = int(input())
B = list(map(int, input().split()))
res = B[0]
for i in range(1, N):
    res += min(B[i - 1], B[i])

print(res)

### FIXED CODE ###

N = int(input())
B = list(map(int, input().split()))
res = B[0]
for i in range(1, N-1):
    res += min(B[i - 1], B[i])
res += B[-1]
print(res)
n,a,b = map(int, input().split())
def f(x):
  ret = 0
  while(x > 0):
    ret += x % 10
    x //= 10
nums = filter(lambda x: f(x) >= a && f(x) <= b, range(1, n + 1))
print(sum(nums))

### FIXED CODE ###

n,a,b = map(int, input().split())
def f(x):
  ret = 0
  while(x > 0):
    ret += x % 10
    x //= 10
  return ret
nums = filter(lambda x: f(x) >= a and f(x) <= b, range(1, n + 1))
print(sum(nums))
import fraction

a,b=map(int,input().split())
print(int((a * b /fraction.gcd(a, b))))

### FIXED CODE ###

import fractions
 
a,b=map(int,input().split())
print(int((a * b /fractions.gcd(a, b))))
S = input().length()
if S == S[::-1]:
  print("Yes")
else:
  print("No")


### FIXED CODE ###

s = input()
n = len(s)
left = s[:(n-1)//2]
print('Yes' if left == left[::-1] == s[(n+3)//2 - 1:]  else 'No')
a, b = map(int, input().split())
if a>b:
    print('a>b')
else if a<b:
    print('a<b')
else:
    print('a=b')

### FIXED CODE ###

a,b = map(int, input().split(' '))
if a>b:
    print('a > b')
elif a<b:
    print('a < b')
else:
    print('a == b')
s=list(input())
if len(s)%2==0:
  c=len(s)/2
  d=i*(-1)-1
  sum=0
  for i in range(c):
    if s[i]!=s[d]:
      sum+=1
  print(sum)
else:
  sum2=0
  e=(len(s)-1)/2
  f=i*(-1)-1
  for i in range(e):
    if s[i]!=s[f]:
      sum2+=1
  print(sum2)

### FIXED CODE ###

def resolve():
    S = input()
    s = len(S)
    count = 0
    if s%2 == 0:
        for i in range(s//2):
            if S[i] != S[(i+1)*-1]:
                count += 1
    else:
        for i in range((s-1)//2):
            if S[i] != S[(i+1)*-1]:
                count += 1
    print(count)
resolve()
if int(input()) < 1000 :
  print("ABC")
elif 1000 <= int(input()) <1999 :
  print("ABD")

### FIXED CODE ###

N = int(input())

if N < 1000:
  print("ABC")
elif N >= 1000 and N < 1999:
  print("ABD")
from scipy.misc import comb

N = input()
K = int(input())

L = len(N)

if N.count("0") > L - K:
    integer = int(N)
    N = str(integer - integer % 10 - 1)

M = ["0"] * L
count = 0

for i in range(L):
    count += bool(int(N[i]))
    M[i] = N[i]
    if count == K:
        M = "".join(M)
        break

index = 0
ans = 0
while index < L:
    if int(M[index]):
        n = L - index - 1
        k = K - index
        digit = (int(M[index]) - 1)
        ans += comb(n, k, exact=True) * 9 ** k + \
               digit * comb(n, k - 1, exact=True) * 9 ** (k - 1)
    index += 1

print(ans + 1)

### FIXED CODE ###

from scipy.misc import comb

N = input()
K = int(input())

L = len(N)

if N.count("0") > L - K:
    integer = int(N)
    N = str(integer - integer % 10 - 1)

L = len(N)

if L < K or N[0] == "-":
    print(0)
    quit()

M = ["0"] * L
count = 0
for i in range(L):
    count += bool(int(N[i]))
    M[i] = N[i]
    if count == K:
        M = "".join(M)
        break

index = 0
ans = 0
count = 0
while index < L:
    if int(M[index]):
        count += 1
        n = L - index - 1
        k = K - count + 1
        digit = int(M[index]) - (count != K)
        ans += comb(n, k, exact=True) * 9 ** k + \
               digit * comb(n, k - 1, exact=True) * 9 ** (k - 1)
    index += 1

print(int(ans))
s, t = input().split()
a, b = map(int, input().split())
u = str(input())
 
if u = s:
  print(a-1, b)
else:
  print(a, b-1)

### FIXED CODE ###

s, t = input().split()
a, b = map(int, input().split())
u = str(input())
 
if u==s:
  print(a-1, b)
else:
  print(a, b-1)
import math

a=int(input("")).split("")
return (a[1]**2-a[0])


### FIXED CODE ###

a=[]
for i in range(0,2):
  a.append(int(input()))
print(a[0]**2-a[1])
import math
import copy
from copy import deepcopy
import sys
import fractions
import numpy as np
from functools import reduce
import statistics
import heapq

input = sys.stdin.readline
# sys.setrecursionlimit(10**6)

# ===FUNCTION===

def getInputInt():
    inputNum = int(input())
    return inputNum


def getInputListInt():
    outputData = []
    inputData = input().split()
    outputData = [int(n) for n in inputData]

    return outputData


def getSomeInputInt(n):
    outputDataList = []
    for i in range(n):
        inputData = int(input())
        outputDataList.append(inputData)

    return outputDataList


def getSomeInputListInt(n):
    inputDataList = []
    outputDataList = []
    for i in range(n):
        inputData = input().split()
        inputDataList = [int(n) for n in inputData]
        outputDataList.append(inputDataList)

    return outputDataList


# ===CODE===

n = getInputInt()
data = getInputListInt()
l = len(data)

ans = []

for i in range(l-2, -1, -1):
    cnt = 0
    for j in ans:
        if j % (i+1) == 0:
            cnt += 1
    if data[i] != cnt % 2:
        ans.append(i+1)

if len(ans) == 0:
    print(0)
else:
    print(len(ans))
    print(*ans, sep=" ")




### FIXED CODE ###

import sys

# import re
import math
import collections
# import decimal
# import bisect
# import itertools
import fractions
# import functools
import copy
import heapq
import decimal
# import statistics
import queue

sys.setrecursionlimit(10000001)
INF = 10 ** 16
MOD = 10 ** 9 + 7

ni = lambda: int(sys.stdin.readline())
ns = lambda: map(int, sys.stdin.readline().split())
na = lambda: list(map(int, sys.stdin.readline().split()))


# ===CODE===


def main():
    n = ni()
    a = na()

    b = [0 for i in range(n)]
    ans = []

    for i in range(n // 2, n):
        if a[i] == 1:
            b[i] = a[i]
            ans.append(i + 1)

    for i in range(n // 2 - 1, -1, -1):
        cnt = 0
        for j in range(i * 2 + 1, n, i + 1):
            cnt ^= b[j]
        if cnt != a[i]:
            b[i] = 1
            ans.append(i + 1)

    tmp = len(ans)
    print(tmp)
    if tmp > 0:
        print(*ans, sep=" ")


if __name__ == '__main__':
    main()
A,B, K=map(int,input().split())
List_A = list(map(int, input().split()))
List_B = list(map(int, input().split()))
res = 0
a=0
b=0
inter = []
inter2 = 0
n = A+B
for i in range(n):
  if a ==A and b !=B:
    inter.append(List_B[b])
    b +=1
  elif a !=A and b ==B:
    inter.append(List_A[a])
    a +=1
  else:
    if List_A[a]>List_B[b]:
      inter.append(List_B[b])
      b +=1
    elif List_A[a] < List_B[b]:
      inter.append(List_A[a])
      a +=1
    else:
      k = min(A-a, B-b)
      for j in range(1,k):
        if List_B[b+j] > List_A[a+j]:
          inter.append(List_A[a])
          a +=1
          break
        elif List_A[a+j] > List_B[b+j]:
          inter.append(List_B[b])
          b +=1
          break
        else:
          if j == k-1:
            if B-b > A-a:
              inter.append(List_A[a])
              a +=1
              break
            elif A-a > B-b:
              inter.append(List_B[b])
              b += 1
              break
          else:
            pass
for i in range(n):
  inter2 += inter[i]
  if K < inter2:
    break
  else:
    res +=1
print(res)

### FIXED CODE ###

A,B,K=map(int,input().split())
List_A = list(map(int, input().split()))
List_B = list(map(int, input().split()))
SumListA=[]
SumListA.append(0)
SumListB=[]
SumListB.append(0)
res =0
a=0
for i in range(A):
  SumListA.append(SumListA[i]+List_A[i])
for i in range(B):
  SumListB.append(SumListB[i]+List_B[i])

j=B
for i in range(A+1):
  if SumListA[i] > K:
    break
  while K-SumListA[i] < SumListB[j]:
    j += -1
  res = max(i+j,res)
print(res)
# coding: utf-8
# Here your code !

n = int(input())
a = input().split()
a_int = sorted(list(map(int,a )))
print(a_int)
max_a = max(a_int)

col = [0,0,0,0,0,0,0,0]
all_col = 0 

for i in range(len(a_int)):
    if a_int[i] < 400:
        col[0] += 1
    elif a_int[i] < 800:
        col[1] += 1
    elif a_int[i] < 1200:
        col[2] += 1
    elif a_int[i] < 1600:
        col[3] += 1
    elif a_int[i] < 2000:
        col[4] += 1
    elif a_int[i] < 2400:
        col[5] += 1
    elif a_int[i] < 2800:
        col[6] += 1
    elif a_int[i] < 3200:
        col[7] += 1
    else:
        all_col += 1

min_c = len(list(filter((lambda x: x > 0), col)))
max_c = min_c + all_col
if max_c > 8:
    max_c -= max_c -8
print(str(min_c)+'  ' +str(max_c))



### FIXED CODE ###

r = input().split()
ans = int(r[0]) * 100 + int(r[1]) *10 + int(r[2])
if ans%4 == 0:
    print("YES")
else:
    print("NO")
N,K=[int(s) for s in input().split()]
ls=[-1 for _ in range(N+1)]
for _ in range(K):
  a,b=[int(s) for s in input().split()]
  if ls[a]==-1:
    ls[a]=b
  else:
    ls[0]=0
    
print(ls)

if ls[0]==0:
  print(-1)
else:
  if N==1:
    ans=max([ls[1],0])    
  if N==2:
    for i in range(10,100):
      a=i//10
      b=i%10
      if (a==ls[1] or ls[1]==-1) and (b==ls[2] or ls[2]==-1):
        ans=i
        break
  if N==3:
    for i in range(100,1000):
      a=i//100
      b=(i//10)%10
      c=i%10
      if (a==ls[1] or ls[1]==-1) and (b==ls[2] or ls[2]==-1) and (c==ls[3] or ls[3]==-1):
        ans=i
        break
print(ans)

### FIXED CODE ###

N,K=[int(s) for s in input().split()]
ls=[-1 for _ in range(N+1)]
for _ in range(K):
  a,b=[int(s) for s in input().split()]
  if ls[a]==-1:
    ls[a]=b
  elif ls[a]==b:
    continue
  else:
    ls[0]=0
ans=0


if ls[0]==0:
  print(-1)
else:
  if N==1:
    ans=max([ls[1],0])    
  if N==2:
    for i in range(10,100):
      if ls[1]==0:
        ans=-1
      else:
        a=i//10
        b=i%10
        if (a==ls[1] or ls[1]==-1) and (b==ls[2] or ls[2]==-1):
          ans=i
          break
  if N==3:
    for i in range(100,1000):
      if ls[1]==0:
        ans=-1
      else:
        a=i//100
        b=(i//10)%10
        c=i%10
        if (a==ls[1] or ls[1]==-1) and (b==ls[2] or ls[2]==-1) and (c==ls[3] or ls[3]==-1):
          ans=i
          break
  print(ans)
from collections import defaultdict,deque
import sys,heapq,bisect,math,itertools,string,queue,copy,time
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpl_str(): return list(sys.stdin.readline().split())

N,a,b = inpl()
def calc(N,x):
    ret = 1
    for i in range(N-x+1,N+1):
        ret *= i
        ret %= mod

    for i in range(1, x+1):
        ret *= pow(i,mod-2,mod)
        ret %= mod

    return ret%mod

ans = pow(2,N,mod)-1 - calc(a) - calc(b)
print(ans%mod)


### FIXED CODE ###

from collections import defaultdict,deque
import sys,heapq,bisect,math,itertools,string,queue,copy,time
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpl_str(): return list(sys.stdin.readline().split())

N,a,b = inpl()
def calc(x):
    ret = 1
    for i in range(N-x+1,N+1):
        ret *= i
        ret %= mod

    for i in range(1, x+1):
        ret *= pow(i,mod-2,mod)
        ret %= mod

    return ret%mod

ans = pow(2,N,mod)-1 - calc(a) - calc(b)
print(ans%mod)
x, y = input(), input()
price = 0
try:
    if 1 <= int(x) <= 205 and 1 <= int(y) <= 205:
        if int(x) == 1 or int(y) == 1:
            price += 400000
        if int(x) == 1:
            price += 300000
        elif int(x) == 2:
            price += 200000
        elif int(x) == 3:
            price += 100000
        if int(y) == 1:
            price += 300000
        elif int(y) == 2:
            price += 200000
        elif int(y) == 3:
            price += 100000

    print(price)
except:
    print(price)

### FIXED CODE ###

x, y = input().split()
price = 0
try:
    if 1 <= int(x) <= 205 and 1 <= int(y) <= 205:
        if int(x) == 1 and int(y) == 1:
            price += 400000
        if int(x) == 1:
            price += 300000
        elif int(x) == 2:
            price += 200000
        elif int(x) == 3:
            price += 100000
        if int(y) == 1:
            price += 300000
        elif int(y) == 2:
            price += 200000
        elif int(y) == 3:
            price += 100000

    print(price)
except:
    print(price)
import numpy as np
import sys
from collections import defaultdict
readline = sys.stdin.buffer.readline
# sys.setrecursionlimit(10**8)


def geta(fn=lambda s: s.decode()):
    return map(fn, readline().split())


def gete(fn=lambda s: s.decode()):
    return fn(readline().rstrip())


def main():
    n = gete(int)

    ans = 0
    for i in range(1, n+1):
        m = n//i
        ans += i * m * (m+1) // 2

    print(ans)


if __name__ == "__main__":
    main()


### FIXED CODE ###

import sys
from collections import defaultdict
readline = sys.stdin.buffer.readline
# sys.setrecursionlimit(10**8)


def geta(fn=lambda s: s.decode()):
    return map(fn, readline().split())


def gete(fn=lambda s: s.decode()):
    return fn(readline().rstrip())


def main():
    n = gete(int)

    ans = 0
    for i in range(1, n+1):
        m = n//i
        ans += i * m * (m+1) // 2

    print(ans)


if __name__ == "__main__":
    main()
n,q=map(int,input().split())
ans=[0]*(n+1)
score=[0]*(n+1)
g=[[] for _ in range(n+1)]
for i in range(n-1):
    a,b=map(int,input().split())
    g[a].append(b)
for j in range(q):
    p,x=map(int,input().split())
    score[p]+=x
visited=set()
visited.add(1)
def dfs(v):
    global ans
    ans[v]+=score[v]
    for i in range(len(g[v])):
        if not g[v][i] in visited:
            ans[g[v][i]]+=ans[v]
            dfs(g[v][i])
dfs(1)
ans_chr=""
for i in range(1,n+1):
    ans_chr=ans_chr+str(ans[i])+" "
print(ans_chr)


### FIXED CODE ###

import sys
sys.setrecursionlimit(400000)
n,q=map(int,input().split())
ans=[0]*(n+1) #答え
score=[0]*(n+1) #xの総和
g=[[] for _ in range(n+1)] #グラフ
for i in range(n-1):
    a,b=map(int,input().split())
    g[a].append(b)
    g[b].append(a)
for j in range(q):
    p,x=map(int,input().split())
    score[p]+=x

visited=[0]*(n+1)
def dfs(v):
    visited[v]+=1
    global ans
    ans[v]+=score[v]
    for i in range(len(g[v])):
        if visited[g[v][i]]==0:
            ans[g[v][i]]+=ans[v]
            dfs(g[v][i])
dfs(1)
print(" ".join(map(str, ans[1:])))
n, m = map(int, input().split())
a = [input() for _ in range(n)]
b = [input() for _ in range(m)]
for i in range(n):
    for j in range(n):
        flag = True
        for k in range(m):
            for l in range(m):
                if a[i+k][j+l] != b[k][l]:
                    flag = False
                    break
            if not flag:
                break
        if flag:
            print('Yes')
            exit()
print('No')

### FIXED CODE ###

n, m = map(int, input().split())
a = [input() for _ in range(n)]
b = [input() for _ in range(m)]
for i in range(n-m+1):
    for j in range(n-m+1):
        flag = True
        for k in range(m):
            for l in range(m):
                if a[i+k][j+l] != b[k][l]:
                    flag = False
                    break
            if not flag:
                break
        if flag:
            print('Yes')
            exit()
print('No')
import sys
n,m=map(int,input().split())
number=[[int(i) for i in l.split()] for l in sys.stdin]
visit=[0]*(n+1)
node=[[] for i in range(n+1)]
for i in number:
  node[i[0]].append(i[1])
  node[i[1]].appedn(i[0])
ans=0
def dfs(x):
  global ans
  if visit.count(1)==n:
    ans+=1
    return 0
  for i in node[x]:
    if visit[i]==0:
      visit[i]=1
      dfs(i)
      visit[i]=0
  return 0
dfs(1)
print(ans)

### FIXED CODE ###

import sys
n,m=map(int,input().split())
number=[[int(i) for i in l.split()] for l in sys.stdin]
visit=[0]*(n+1)
visit[1]=1
node=[[] for i in range(n+1)]
for i in number:
  node[i[0]].append(i[1])
  node[i[1]].append(i[0])
ans=0
def dfs(x):
  global ans
  if visit.count(1)==n:
    ans+=1
    return 0
  for i in node[x]:
    if visit[i]==0:
      visit[i]=1
      dfs(i)
      visit[i]=0
  return 0
dfs(1)
print(ans)
a=int(input())
b=int(input())
x=(a*b)%2
if x==0:
    print("Even")
else:
    print("Odd")

### FIXED CODE ###

a,b=map(int,input().split())
x=(a*b)%2
if x==0:
	print("Even")
else:
  	print("Odd")
5
30 44
26
18
81
18
6

### FIXED CODE ###

import sys
input = sys.stdin.readline

n = int(input())
d, x = [int(w) for w in input().split()]

ans = x
for i in range(n):
    a = int(input())
    ans += 1 + (d - 1) // a
print(ans)
H, W = map(int, input().split())

s = ['.'*(W+2)] + ['.'+input()+'.' for _ in range(H)] + ['.'*(W+2)]
for hi in range(1, W+1):
  for wi in range(1, H+1):
    if s[hi][wi] == '.':
      continue
    if s[hi-1][wi]=='.' and s[hi+1][wi]=='.':
      if s[hi][wi-1]=='.' and s[hi][wi+1]=='.':
        print('No')
        exit()
        
print('Yes')

### FIXED CODE ###

H, W = map(int, input().split())

s = ['.'*(W+2)] + ['.'+input()+'.' for _ in range(H)] + ['.'*(W+2)]
for hi in range(1, H+1):
  for wi in range(1, W+1):
    if s[hi][wi] == '.':
      continue
    if s[hi-1][wi]=='.' and s[hi+1][wi]=='.':
      if s[hi][wi-1]=='.' and s[hi][wi+1]=='.':
        print('No')
        exit()
        
print('Yes')
A, B = map(int, input().split())
def fun(A, B, n=1):
  if n%B == 0: return n
  return fun(A, B, n+1)
print(fun(A, B))

### FIXED CODE ###

from fractions import gcd
A, B = map(int, input().split())
print((A*B)//gcd(A, B))
N = int(input())
nodes = {}
for _ in range(N-1):
    l, r, d = map(int, input().split())
    if nodes.get(str(l)) is None:
        nodes[str(l)] = {'to': [], 'color': -1}
    if nodes.get(str(r)) is None:
        nodes[str(r)] = {'to': [], 'color': -1}

    nodes[str(l)]['to'].append((str(r), d))
    nodes[str(r)]['to'].append((str(l), d))


def dfs(node, color):
    nodes[node]['color'] = color
    for n, d in nodes[node]['to']:
        if nodes[n]['color'] != -1:
            continue

        if d % 2 == 0:
            dfs(n, color)
        else:
            dfs(n, (color+1) % 2)


dfs('1', 0)
for i in range(1, N+1):
    print(nodes[str(i)]['color'])


### FIXED CODE ###

N = int(input())
nodes = {}
for _ in range(N-1):
    l, r, d = map(int, input().split())
    if nodes.get(str(l)) is None:
        nodes[str(l)] = {'to': [], 'color': -1}
    if nodes.get(str(r)) is None:
        nodes[str(r)] = {'to': [], 'color': -1}

    nodes[str(l)]['to'].append((str(r), d))
    nodes[str(r)]['to'].append((str(l), d))

q = [('1', 0)]
while q:
    node, color = q.pop()

    nodes[node]['color'] = color
    for n, d in nodes[node]['to']:
        if nodes[n]['color'] != -1:
            continue

        if d % 2 == 0:
            q.append((n, color))
        else:
            q.append((n, (color+1) % 2))


for i in range(1, N+1):
    print(nodes[str(i)]['color'])