Harryxun/stf_run huggingface dataset:
n, m, k = map(int, input().split())
alst = list(map(int, input().split()))
blst = list(map(int, input().split()))
alst.append(2*10**9)
blst.append(2*10**9)
ptime = 0
acou = 0
bcou = 0
books = 0
while True:
    if alst[acou] < blst[bcou]:
        ptime += alst[acou]
        acou += 1
    elif alst[acou] > blst[bcou]:
        ptime += blst[bcou]
        bcou += 1
    else:
        if alst[acou+1] < blst[bcou+1]:
            ptime += alst[acou]
            acou += 1
        elif alst[acou+1] > blst[bcou+1]:
            ptime += blst[bcou]
            bcou += 1
    if ptime <= k:
        books += 1
    elif acou==len(alst)-1 and bcou==len(blst)-1:
        books += 1
        break
    else:
        break
print(books)

### FIXED CODE ###

n, m, k = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
a, b = [0], [0]

for i in range(n):
    a.append(A[i]+a[i])
for i in range(m):
    b.append(B[i]+b[i])

ans, j = 0, m
for i in range(n+1):
    if a[i] > k:
        break
    while b[j] > k - a[i]:
        j -= 1
    ans = max(ans, i+j)
print(ans)
n, k = map(int, input().split())
d = list(map(int, input().split()))
other = [i for i in range(10)] - d
m = 0
def dfs(m, now):
  m = int(m)
  if(m >= n):
    print(int(now))
  else:
    if(m == 0):
      m = ""
    m = str(m)
    for(o in other):
      dfs(m, m + o)
  

### FIXED CODE ###

n, k = map(int, input().split())
dd = list(map(int, input().split()))
frag = 1
for i in range(n, 10*n+1):
  frag = 1
  for d in dd:
    if(str(d) in str(i)):
      frag = 0
  if(frag):
    print(i)
    break
n = int(input())
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())

neck = min(a,b,c,d,e)

cnt = 5 + math.ceil(n / neck) - 1

print(cnt)

### FIXED CODE ###

import math

n = int(input())
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())

neck = min(a,b,c,d,e)

cnt = 5 + math.ceil(n / neck) - 1

print(cnt)
security_num = input()
pre_num = ""
    
for num in security_num:
	if pre_num == num: return "Bad"
	pre_num = num

return "Good"

### FIXED CODE ###

nums = input().strip()
pre_num = ""
result = ""
flag = True

for num in nums:
	if pre_num == num: flag = False
	pre_num = num

if flag: result = "Good"
else: result = "Bad"

print(result)
n,m=map(int,input().split())
p=[[] for i in range(m)]
y=[]
nl=[]
for i in range(m):
    t1,t2=map(int,input().split())
    p[t1-1].append(t2)
for i in range(m):
    for j in range(len(p[i])):
        u=str(i+1)
        d=str(j+1)
        while len(u)<6:
            u="0"+u
        while len(d)<6:
            d="0"+d
        t=u+d
        nl.append(t)
for i in range(m):
    print(nl[i])

### FIXED CODE ###

n,m=map(int,input().split())
p=[]
for i in range(m):
    t1,t2=map(int,input().split())
    p.append([i,t1,t2])
p.sort(key=lambda x:x[2])
c=[1 for i in range(n+1)]
num=[]
for i,pre,yea in p:
    tmp=str(pre).zfill(6)+str(c[pre]).zfill(6)
    num.append([i,tmp])
    c[pre]+=1
num.sort()
for i in num:
    print(i[1])
from collections import Counter
N = int(input())
A = [int(i) for i in input().split()]

f_list = [0 for i in range(N+1)]
f_list[0] = 1
for i in range(1, N+1):
    f_list[i] = f_list[i-1]*i

def c(n):
    return f_list[n]//f_list[n-2]//2

m = Counter(A)
s = 0
for x, y in m.items():
    else:
        s += c(y)
for a in A:
    print(s - (m[a] - 1))

### FIXED CODE ###

from collections import Counter
N = int(input())
A = [int(i) for i in input().split()]

def c(n):
    return n *(n-1) // 2

m = Counter(A)
s = 0
for x, y in m.items():
    if y != 1:
        s += c(y)
for a in A:
    print(s - (m[a] - 1))
arr = input().spilt()
arr = int(arr)
print(15-sum(arr))

### FIXED CODE ###

arr = list(map(int, input().split()))
print(15-sum(arr))
import math
n , a , b  = map(int, input().split())
if a >= n : exit(print(n))
ans = n//(a+b)
#print("ans",ans)
print(ans*a+(n-ans*a-ans*b))

### FIXED CODE ###

s = list(input())
if len(set(s)) == 1:
    print("No")
else:
    print("Yes")
def sample(n):
    return n * n * n

n = input()
print sample(n)

### FIXED CODE ###

def sample(n):
    return n * n * n

n = input()
x = sample(n)
print x
h, w = map(int, input().split())
field = [input() for _ in range(h)]
MOD = 10 ** 9 + 7

dp = [[0] * w for _ in range(h)]
dp[0][0] = 1

for i in range(1, w):
    if field[0][i] == ".":
        dp[0][i] = dp[0][i-1] 

for i in range(1, h):
    if field[i][0] == ".":
        dp[i][0] = dp[i-1][0]

for row in range(1, h):
    for col in range(1, w):
        if field[i][j] == ".":
            dp[i][j] = dp[i-1][j] + dp[i][j-1]
print(dp[-1][-1])



### FIXED CODE ###

h, w = map(int, input().split())
field = [input() for _ in range(h)]
MOD = 10 ** 9 + 7

dp = [[0] * w for _ in range(h)]
dp[0][0] = 1

for i in range(1, w):
    if field[0][i] == ".":
        dp[0][i] = dp[0][i-1] 

for i in range(1, h):
    if field[i][0] == ".":
        dp[i][0] = dp[i-1][0]

for row in range(1, h):
    for col in range(1, w):
        if field[row][col] == ".":
            dp[row][col] = (dp[row-1][col] + dp[row][col-1]) % MOD
print(dp[-1][-1])
N = int(input())
L = [0]*(N+2)
L[0] = 2
L[1] = 1
if N<=2:
    print(L[i-1])
else:
    for i in range(2,N+1):
        L[i] = L[i-1]+L[i-2]
    print(L[N])


### FIXED CODE ###

N = int(input())
L = [0]*(N+2)
L[0] = 2
L[1] = 1
if N<=1:
    print(L[N])
else:
    for i in range(2,N+1):
        L[i] = L[i-1]+L[i-2]
    print(L[N])
import sys

n, m = map(int, input().split())
l = [list(map(int, input().split())) for i in range(m)]
ans = [0] * m
check = [10] * m
for i in l:
    if check[i[0] - 1] == 10:
        ans[i[0] - 1] = i[1]
        check[i[0] - 1] = i[1]
    elif check[i[0] - 1] != i[1]:
        print(-1)
        sys.exit()

    if i[0] == 1 and i[1] == 0 and n != 1:
        print(-1)
        sys.exit()

for i in ans:
    print(i, end="")


### FIXED CODE ###

import sys

n, m = map(int, input().split())
l = [list(map(int, input().split())) for i in range(m)]
ans = [0] * n
check = [10] * n
for i in l:
    if check[i[0] - 1] == 10:
        ans[i[0] - 1] = i[1]
        check[i[0] - 1] = i[1]
    elif check[i[0] - 1] != i[1]:
        print(-1)
        sys.exit()
    if i[0] == 1 and i[1] == 0 and n != 1:
        print(-1)
        sys.exit()

if n > 1 and check[0] == 10:
    ans[0] = 1

for i in ans:
    print(i, end="")
A, B = map(int, input().split())
if A >= 13:
    print(B)
elif 6 <= A < 13:
    print(b/2)
else:
    print('0')

### FIXED CODE ###

Age, Full_cost= map(int, input().split())

if Age >= 13:
    print(Full_cost)
elif 6 <= Age <=12:
    print(int(Full_cost/2))
else:
    print(0)
def round_up_mean(a,b):
  ans = -(-(a+b)//2)
  print(ans)


a,b = int(input().split(" "))
round_up_mean(a, b)

### FIXED CODE ###

#import math
def round_up_mean(a,b):
#  ans = math.ceil((a+b)/2)
#  print(ans)
  ans = -(-(a+b)//2)
  print(ans)

a, b = map(int, input().split(" "))
round_up_mean(a, b)
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(1000000)

def main():
    s = readline().rstrip().decode()
    K = int(readline())
    #sに含まれる文字を一文字ずつ抽出する.
    #ここで抽出した文字を組み合わせて辞書順に文字列を構成していく
    #K<=5だから高々26^5個の文字列を構成することになる
    l = sorted(list(set(s)))
    #cnd:=構成した文字列を辞書順に格納するリスト
    cnd = []
    #f(sub):=subから構成可能なK文字以下のSの部分文字列を構成する関数
    def f(sub):
        cnd.append(sub)
        if len(sub) < K: 
            #lから選んでsubに一文字追加する
            for i in l:
                nx = sub+i
                if nx in s:
                    f(nx)
    for i in l:
        f(i) 
    print(cnd[K-1j])
if __name__ == '__main__':
    main()


### FIXED CODE ###

import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(1000000)

def main():
    s = readline().rstrip().decode()
    K = int(readline())
    #sに含まれる文字を一文字ずつ抽出する.
    #ここで抽出した文字を組み合わせて辞書順に文字列を構成していく
    #K<=5だから高々26^5個の文字列を構成することになる
    l = sorted(list(set(s)))
    #cnd:=構成した文字列を辞書順に格納するリスト
    cnd = []
    #f(sub):=subから構成可能なK文字以下のSの部分文字列を構成する関数
    def f(sub):
        cnd.append(sub)
        if len(sub) < K: 
            #lから選んでsubに一文字追加する
            for i in l:
                nx = sub+i
                if nx in s:
                    f(nx)
    for i in l:
        f(i) 
    print(cnd[K-1])
if __name__ == '__main__':
    main()
N, X = map(int, input().split())
xs = map(int, input().split())
xs.append(X)
xs.sort()
xs = [_ - xs[0] for _ in xs]
diffs = [xs[i]-xs[i-1] for i in range(1, len(xs))]
def gcd(a, b):
  if(a>b): return gcd(b, a)
  if a % b == 0:
    return b
  else:
    r = a % b
    return gcd(b, r)

prev = diffs[0]
for cur in diffs[1:]:
  prev = gcd(prev, cur)
print(prev)

### FIXED CODE ###

N, X = map(int, input().split())
xs = list(map(int, input().split()))
xs.append(X)
xs.sort()
xs = [_ - xs[0] for _ in xs]
diffs = [xs[i]-xs[i-1] for i in range(1, len(xs))]
def gcd(a, b):
    if(a<b): return gcd(b, a)
    if a % b == 0:
      return b
    else:
      r = a % b
      return gcd(b, r)

prev = diffs[0]
for cur in diffs[1:]:
    prev = gcd(prev, cur)
print(prev)
import numpy as np
H,W=map(int,input().split())
a=[list(map(str,list(input()))) for i in range(H)]
f=np.empty((H+2,W+2))
f=f.tolist()
#print(f)
#print(a)

for i in range(H+2):
    for j in range(W+2):
        if (i==0)or(i==H+1)or(j==0)or(j==W+1):
            f[i][j]='#'
            #print("#")
        elif (i>0)and(j>0):
            f[i][j]=a[i-1][j-1]
            #print(a[i-1][j-1])
for i in f:print(*i, sep='')

### FIXED CODE ###

import numpy as np
H,W=map(int,input().split())
a=[list(map(str,list(input()))) for i in range(H)]
f=np.empty((H+2,W+2))
f=f.tolist()
#print(f)
#print(a)

for i in range(H+2):
    for j in range(W+2):
        if (i==0)or(i==H+1)or(j==0)or(j==W+1):
            f[i][j]='#'
            #print("#")
        elif (i>0)and(j>0):
            f[i][j]=a[i-1][j-1]
            #print(a[i-1][j-1])
for i in f:print(*i, sep='')
n,q = map(int,input().split())
s = input()
for i in range(n):
    l,r = map(int,input().split())
    print(s[l-1:r].count("AC"))

### FIXED CODE ###

n,q = map(int,input().split())
s = input()
count = [0]*n
for i in range(1,n):
    count[i] += count[i-1]
    if s[i-1:i+1] == "AC":count[i] += 1
for i in range(q):
    l,r = map(int,input().split())
    print(count[r-1]-count[l-1])
a = int(input())
b = int(input())

if a + b == 15:
    print('+')
elif a * b == 15:
    print('*')
else:
    print('x')


### FIXED CODE ###

N = input().split(" ")
a = int(N[0])
b = int(N[1])
if a + b== 15:
    print('+')
elif a * b== 15:
    print('*')
else:
    print('x')
from datetime import datetime
input_date = datetime.datetime(input(), "%Y%m%d")

heisei = datetime.datetime(2019,4,30)
if input_date < heisei:
    print('Heisei')
else:
    print('TBD')

### FIXED CODE ###

import datetime
s=input()

input_date = datetime.datetime.strptime(s, "%Y/%m/%d")
heisei = datetime.datetime(2019,4,30)

if input_date <= heisei:
    print('Heisei')
else:
    print('TBD')
n, k = map(int, input().split())

li = [0]
li.extend(list(map(int, input().split())))
tuita = [0]*(n+1)
cnt = 0
town = 1

def search(town, times):
  if town > n:
    return 1
  if times == 0:
    return town
  return search(li[town], times - 1)

while True:
  town = li[town]
  cnt += 1
  if tuita[town] == 0:
    tuita[town] = cnt
  else:
    if k < tuita[town]:
      print(search(1, k))
    elif k == tuita[town]:
      print(town)
    else:
      print(search(town, (k - tuita[town]) % (cnt - tuita[town])))
    break
 

  
    

### FIXED CODE ###

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

li = [0]
li.extend(list(map(int, input().split())))
tuita = [0]*(n+1)
cnt = 0
town = 1

lastTown = 1
while True:
  town = li[town]
  cnt += 1
  if tuita[town] == 0:
    tuita[town] = cnt
  else:
    if k < tuita[town]:
      lastTown = 1
      times = k
    elif k == tuita[town]:
      lastTown = town
      times = 0
    else:
      lastTown = town
      times = (k - tuita[town]) % (cnt - tuita[town])
    break

town = lastTown
while times > 0:
  if times <= 0:
    break
  times -= 1
  town = li[town]
print(town)
n = int(input())
d,x = map(int,input().split())
a = []
count = x
for i in range(n):
  a[i] = int(input())
  count += d//a[i] + 1
print(count)
  
  

### FIXED CODE ###

n = int(input())
d,x = map(int,input().split())
count = x
a = [int(input()) for i in range(n)]
for i in range(n):
  j = 0
  while j * a[i] + 1 <= d:
    count += 1
    j += 1
print(count)
literal = ('a', 'b', 'c', 'd', 'e', 'f', 
           'g', 'h', 'i', 'j', 'k', 'l', 
           'm', 'n', 'o', 'p', 'q', 'r', 
           's', 't', 'u', 'v', 'w', 'x', 
           'y', 'z')
x = int(input())
str2 = ''
str3 = ''
q = x
if x < 27:
    str3 = literal[x-1]
while q > 26:
    q, mod = divmod(x, 26)
    str1 = ''
    if q > 26:
        x = q
        str1 = literal[mod - 1]
        str3 = str1 + str2
        str2 = str3
        str3 = ''
    else:
        str1 += literal[q - 1]
        str1 += literal[mod - 1]
        str3 = str1 + str2
print(str3)

### FIXED CODE ###

a = input()
if a.islower():
    print('a')
else:
    print('A')
class Dice():

    def __init__(self, label):
        self.label = label

    def north(self):
        self.change([2, 6, 3, 4, 1, 5])

    def west(self):
        self.change([3, 2, 6, 1, 5, 4])

    def east(self):
        self.change([4, 2, 1, 6, 5, 3])

    def south(self):
        self.change([5, 1, 3, 4, 6, 2])

    def change(self, convert):
        num = []
        for i in range(6):
            num.append(self.label[convert[i] - 1])
        self.label = num

    def is_same_dice(self, another_dice):
        for i in range(6):
            if i % 2 == 0:
                self.north()
            else:
                self.west()
            for j in range(4):
                self.rotate()
                if self.label == another_dice:
                    return True
        return False


def main():
    f = [int(x) for x in input().split()]
    s = [int(x) for x in input().split()]

    if Dice(f).is_same_dice(s):
        print('Yes')
    else:
        print('No')


if __name__ == '__main__':
    main()

### FIXED CODE ###

class Dice():

    def __init__(self, label):
        self.label = label

    def north(self):
        self.change([2, 6, 3, 4, 1, 5])

    def west(self):
        self.change([3, 2, 6, 1, 5, 4])

    def east(self):
        self.change([4, 2, 1, 6, 5, 3])

    def south(self):
        self.change([5, 1, 3, 4, 6, 2])

    def rotate(self):
        self.change([1, 4, 2, 5, 3, 6])

    def change(self, convert):
        num = []
        for i in range(6):
            num.append(self.label[convert[i] - 1])
        self.label = num

    def is_same_dice(self, another_dice):
        for i in range(6):
            if i % 2 == 0:
                self.north()
            else:
                self.west()
            for j in range(4):
                self.rotate()
                if self.label == another_dice:
                    return True
        return False


def main():
    f = [int(x) for x in input().split()]
    s = [int(x) for x in input().split()]

    if Dice(f).is_same_dice(s):
        print('Yes')
    else:
        print('No')


if __name__ == '__main__':
    main()
from typing import Dict

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


def pow(a, b, mod=10 ** 9 + 7):
    if b == 0:
        return 1
    elif b == 1:
        return a
    elif b % 2 == 0:
        return (pow(a, b // 2) ** 2) % mod
    else:
        return (a * pow(a, b // 2) ** 2) % mod


def inv(x, mod=10 ** 9 + 7):
    return pow(x, mod - 2, mod=mod)


def factorize(x):
    ans = {}
    v = 2
    while v * v <= x:
        if x % v == 0:
            ans[v] = 0
            while x % v == 0:
                x //= v
                ans[v] += 1
        v += 1
    if x != 1:
        ans[x] = 1
    return ans


def merge(d: Dict[int, int], c: Dict[int, int]):
    for k, v in c.items():
        if k not in d:
            d[k] = v
        d[k] = max(d[k], v)


tmp = {}
for v in A:
    merge(tmp, factorize(v))
t = 1
mod = 10 ** 9 + 7
for k, v in tmp.items():
    t *= k ** v
    t %= mod
ans = 0
for a in A:
    ans += t * inv(a)
print(ans % mod)


### FIXED CODE ###


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


def pow(a, b, mod=10 ** 9 + 7):
    if b == 0:
        return 1
    elif b == 1:
        return a
    elif b % 2 == 0:
        return (pow(a, b // 2) ** 2) % mod
    else:
        return (a * pow(a, b // 2) ** 2) % mod


def inv(x, mod=10 ** 9 + 7):
    return pow(x, mod - 2, mod=mod)


def factorize(x):
    ans = {}
    v = 2
    while v * v <= x:
        if x % v == 0:
            ans[v] = 0
            while x % v == 0:
                x //= v
                ans[v] += 1
        v += 1
    if x != 1:
        ans[x] = 1
    return ans


def merge(d, c):
    for k, v in c.items():
        if k not in d:
            d[k] = v
        d[k] = max(d[k], v)


tmp = {}
for v in A:
    merge(tmp, factorize(v))
t = 1
mod = 10 ** 9 + 7
for k, v in tmp.items():
    t *= k ** v
    t %= mod
ans = 0
for a in A:
    ans += t * inv(a)
print(ans % mod)
a = int(input())
b = int(input())
c = int(input())
x = int(input())
ans = 0

for i in range(0,a):
    if x < 500 * i:
        break
    if x == 500 * i:
        ans += 1
        break
    for j in range(0,b):
        if x < 500 * i + 100 * j:
            break
        if x == 500 * i + 100 * j:
            ans += 1
            break
        for k in range(0,c)
            if x < 500 * i + 100 * j + 50 * k:
                break
            if x == 500 * i + 100 * j + 50 * k:
                ans += 1
                break

print(ans)


### FIXED CODE ###

a = int(input())
b = int(input())
c = int(input())
x = int(input())
ans = 0

for i in range(0,a+1):
    if x < 500 * i:
        break
    if x == 500 * i:
        ans += 1
        break
    for j in range(0,b+1):
        if x < 500 * i + 100 * j:
            break
        if x == 500 * i + 100 * j:
            ans += 1
            break
        for k in range(0,c+1):
            if x < 500 * i + 100 * j + 50 * k:
                break
            if x == 500 * i + 100 * j + 50 * k:
                ans += 1
                break

print(ans)
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,queue,copy

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7
dd=[(-1,0),(0,1),(1,0),(0,-1)]
ddn=[(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return input()

# GCD -- START --
def gcd(x,y):
  while y:
    x,y=y,x%y
  return x
# GCD --- END ---

# LCM -- START --
def lcm(x,y):
  return x*y/gcd(x,y)
# LCM --- END ---

def main():
  n=I()
  l=[I() for _ in range(n)]
  l.sort()
  a=l[0]

  for x in l[1:]:
    b=[a,x]
    b.sort()

    if b[1]%b[0]==0:
      a=b[1]
    else:
      a=int(lcm(b[0],b[1]))

  return a

# main()
print(main())


### FIXED CODE ###

import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,queue,copy

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7
dd=[(-1,0),(0,1),(1,0),(0,-1)]
ddn=[(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return input()

# GCD -- START --
def gcd(x,y):
  while y:
    x,y=y,x%y
  return x
# GCD --- END ---

# LCM -- START --
def lcm(x,y):
  return x*y//gcd(x,y)
# LCM --- END ---

def main():
  n=I()
  ans=I()

  for _ in range(n-1):
    ans=lcm(ans,I())

  return ans

# main()
print(main())
n = int(input())
print("1" if x == 0 else "0")

### FIXED CODE ###

n = int(input())
print("1" if n == 0 else "0")
from collections import Counter
print(Counter(input()).most_common()[1][1]*2)

### FIXED CODE ###

from collections import deque
import copy
S = deque(input())
S2 = deque([])
counter = 0
while True:
    flag = True
    while True:
        if len(S) == 0:
            break
        s = S.popleft()
        if len(S2) == 0:
            S2.append(s)
            flag = False
            continue
        
        elif s!=S2[-1]:
            S2.pop()
            flag = False
            counter +=2
        else:
            S2.append(s)
    
    if flag:
        break
    else:
        S = copy.deepcopy(S2)
print(counter)
S = list(input())
Q = int(input())
l_list = []
r_list = []
for i in range(Q):
    A = list(map(str, input().split()))
    if len(A)==1:
        flag = not flag
    else:
        if flag:
            if A[1]=="1":
                l_list.insert(0, A[2])
            else:
                r_list.append(A[2])
        else:
            if A[1]=="1":
                r_list.insert(0, A[2])
            else:
                l_list.append(A[2])
if flag:
    print("".join(l_list)+"".join(S)+"".join(r_list))
else:
    print("".join(r_list[::-1])+"".join(S[::-1])+"".join(l_list[::-1]))

### FIXED CODE ###

from collections import deque
S = deque(input())
Q = int(input())
flag = True
for i in range(Q):
    A = list(map(str, input().split()))
    if len(A)==1:
        flag = not flag
    else:
        if flag:
            if A[1]=="1":
                S.appendleft(A[2])
            else:
                S.append(A[2])
        else:
            if A[1]=="1":
                S.append(A[2])
            else:
                S.appendleft(A[2])
S = "".join(S)
if flag:
    print(S)
else:
    print(S[::-1])
N,M = map(int,input().split())

sc = {}

def main():
    for i in range(M):
        s,c = input().split()
        s = int(s)
        if s not in sc:
            sc[s] = c
        else:
            if sc[s] != c:
                return -1
                break


    ans = ["0"] * N

    for k,n in sc.items():
        ans[k-1] = n

    result = ''.join(ans)
    if result[0] != '0' or result == '0':
        return result
    else:
        result[0] = '1'    
        return int(result)

FUCK = main()
print(FUCK)        

### FIXED CODE ###

def main():
    sc = {}
    N,M = map(int,input().split())
    for _ in range(M):
        s,c = input().split()
        s = int(s)
        if s not in sc:
            sc[s] = c
        else:
            if sc[s] != c:
                return -1

    if 1 in sc and sc[1] == '0' and N != 1:
        return -1

    ans = ["0"] * N

    for k,n in sc.items():
        ans[k-1] = n

    result = ''.join(ans)
    if result[0] != '0' or result == '0':
        return result
    else:
        result = '1' + result[1:]    
        return int(result)


print(main())
N = int(input())
K = int(input())
A = list(map(int, input().split()))
A.sort()
print(sum(A[0:K]))

### FIXED CODE ###

N, K = map(int, input().split()) 
A = list(map(int, input().split()))
A.sort()
print(sum(A[0:K]))
import math
def factorization(n):
    i = 2
    factors = []
    while i <= math.floor(math.sqrt(n)):
        print(i,n)
        if n%i == 0:
            factors.append(i)
            n //= i
        else:
            i += 1
    if n > 1:
        factors.append(n)
    return factors
N = int(input())
S = math.factorial(N)
print(S)
print(factorization(S))

### FIXED CODE ###

import math
def factorization(n):
    i = 2
    factors = []
    while i <= math.floor(n**0.5):
        if n%i == 0:
            factors.append(i)
            n //= i
        else:
            i += 1
    if n>1:
        factors.append(n)
    return factors
#約数列挙
N = int(input())
ls = []
if N == 1:
    print(1)
else:
    for i in range(1,N+1):
        ls.extend(factorization(i))
    ls.sort()
    ans = 1
    now = 1
    now_2 = 0
    for i in range(len(ls)):
        if i == 0:
            now_2 = ls[i]
        else:
            if ls[i] == now_2:
                now += 1
            else:
                ans *= (now+1)
                now = 1
                now_2 = ls[i]
    ans *= (now+1)
    print(ans%(10**9+7))
memo = input().spllit()
a,b,c = [int(x) for x in memo]
if(a < b && b < c):
    print("Yes")
else:
    print("No")

### FIXED CODE ###

memo = input().split()
a,b,c = [int(x) for x in memo]
if a < b and b < c :
    print("Yes")
else:
    print("No")