Harryxun/stf_run huggingface dataset:
import math
import functools
n = int(input())
t = [int(input()) for _ in range(n)]

def lcm(x, y):
    return (x * y) // math.gcd(x, y)
    
ans = functools.reduce(lcm, t)
print(str(ans))

### FIXED CODE ###

import functools
import fractions
n = int(input())
t = [int(input()) for _ in range(n)]

def lcm(x, y):
    return (x * y) // fractions.gcd(x, y)
    
ans = functools.reduce(lcm, t)
print(ans)
if __name__ == '__main__':
	input_a = input()
	input_b = input()
	a = 2*input_a+2*input_b
	b = input_a*input_b
	print b," ", a

### FIXED CODE ###

n, m = map(int, raw_input().split())
print n*m, 2*n+2*m
N,K = map(int,input().split())
XY = list(list(map(int,input().split()))for i in range(N))
XY.sort()
ans = float('inf')
for i in range(N-K+1):
    miny = XY[i][1]
    maxy = miny
    y = []
    for j in range(i,i+K):
        y.append(XY[j][1])
    y.sort()
    ans = min((XY[j][0] - XY[i][0])*(y[-1]-y[0]),ans)
    for j in range(i+K,N):
        y.append(XY[j][1])  
        y.sort()
        for k in range(j-K+1):
            ans = min((XY[j][0] - XY[i][0])*(y[k+K-1]-y[k]),ans)
print(ans)

### FIXED CODE ###

N,K = map(int,input().split())
XY = []

for i in range(N):
    x,y = map(int,input().split())
    XY.append((x,y))


ans = float('inf')

for lx, _ in XY:
    for rx, _ in XY:
        if lx > rx:
            continue
        for _, dy in XY:
            for _, uy in XY:
                if dy > uy:
                    continue
                count = 0
                for x,y in XY:
                    if lx <= x <= rx and dy <= y <= uy:
                        count += 1
                if count >= K:
                    ans = min(ans,(rx-lx)*(uy-dy))
print(ans)
h,w=map(int,input().split())
lis=[]
for _ in range(h):
  lis.append(list(input()))
for hi in range(h):
  for wi in range(w):
    if lis[hi][wi]==".":
      c=0
      for x,y in [[1,1],[1,0],[1,-1],[0,1],[0,-1],[-1,1],[-1,0],[-1,-1]]:
        try:
          if lis[hi+x][y+y]=="#":
            c+=1
        finally:
          pass
      lis[hi][wi]==string(c)
for hi in range(h):
  s=""
  for wi in range(w):
    s+=lis[hi][wi]
  print(s)

### FIXED CODE ###

h,w=map(int,input().split())
lis=[input() for i in range(h)]
outs=[]
for x in range(h):
    s=""
    for y in range(w):
        if lis[x][y]==".":
            c=0
            for xi,yi in [(1,1),(1,0),(1,-1),(0,1),(0,-1),(-1,1),(-1,0),(-1,-1)]:
                if not (xi+x==-1 or yi+y==-1 or xi+x==h or yi+y==w):
                    c+=(1 if lis[xi+x][yi+y]=="#" else 0)
            s+=str(c)
        else:
            s+="#"
    outs.append(s)
for i in outs:
    print(i)
import math

A, B = map(int, input().split())

g = math.gcd(A, B)
d = []
p = []

for i in range(1,int(math.sqrt(g))+1):
    if g % i == 0:
        d.append(i)
        if i != g//i:
           d.append(g//i)

for i in d:
    s = 0
    for j in range(1,int(math.sqrt(i))+1):
        if i % j == 0:
            s += 1

    if s == 1:
        p.append(i)

print(len(p))


### FIXED CODE ###

import fractions

A, B = map(int, input().split())

g = fractions.gcd(A, B)
d = []
p = []

for i in range(1,int(pow(g, 0.5))+1):
    if g % i == 0:
        d.append(i)
        if i != g//i:
           d.append(g//i)

for i in d:
    s = 0
    for j in range(1,int(pow(i, 0.5))+1):
        if i % j == 0:
            s += 1

    if s == 1:
        p.append(i)

print(len(p))
# -*- coding: utf-8 -*-
# python template for atcoder1
import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline

MOD = 10**9+7
N, M = map(int, input().split())
S = list(input().split())
T = list(input().split())

# Sのi文字目までと、Tのj文字目までで、dp[i][j]こ
dp = [[0]*(N+1) for _ in range(M+1)]

for i in range(1, N+1):
    for j in range(1, M+1):
        if S[i-1] == T[j-1]:
            dp[i][j] = 1+dp[i-1][j]+dp[i][j-1]
            dp[i][j] %= MOD
        else:
            dp[i][j] = dp[i-1][j]+dp[i][j-1]-dp[i-1][j-1]
            dp[i][j] %= MOD
print((dp[-1][-1]+1) % MOD)


### FIXED CODE ###

# -*- coding: utf-8 -*-
# python template for atcoder1
import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline

MOD = 10**9+7
N, M = map(int, input().split())
S = list(input().split())
T = list(input().split())

# Sのi文字目までと、Tのj文字目までで、dp[i][j]こ
dp = [[0]*(M+1) for _ in range(N+1)]

for r in range(1, N+1):
    for k in range(1, M+1):
        if S[r-1] == T[k-1]:
            dp[r][k] = 1+dp[r-1][k]+dp[r][k-1]
            dp[r][k] %= MOD
        else:
            dp[r][k] = dp[r-1][k]+dp[r][k-1]-dp[r-1][k-1]
            dp[r][k] %= MOD
print((dp[-1][-1]+1) % MOD)
n = int(input())
leaves = list(map(int, input().split()))

ans = 0
nodes_min = [0] * (n + 1)
nodes_max = [0] * (n + 1)
nodes_min[n] = leaves[n]
nodes_max[n] = leaves[n]

for depth in range(n, 0, -1):
    root_min = nodes_min[depth] // 2 + nodes_min[depth] % 2
    nodes_min[depth - 1] = leaves[depth - 1] + root_min
    root_max = nodes_max[depth]
    nodes_max[depth - 1] = leaves[depth - 1] + root_max
nodes = [0] * (n + 1)
nodes[0] = 1
for depth in range(n):
    roots = nodes[depth]-leaves[depth]
    if nodes[depth] < nodes_min[depth]:
        print(-1)
        break
    nodes[depth + 1] = min(roots * 2, nodes_max[depth + 1])
else:
    if nodes[n] < nodes_min[depth]:
        print(-1)
    else:
        print(sum(nodes))

### FIXED CODE ###

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

ans = 0
nodes_min = [0] * (n + 1)
nodes_max = [0] * (n + 1)
nodes_min[n] = leaves[n]
nodes_max[n] = leaves[n]

for depth in range(n, 0, -1):
    root_min = nodes_min[depth] // 2 + nodes_min[depth] % 2
    nodes_min[depth - 1] = leaves[depth - 1] + root_min
    root_max = nodes_max[depth]
    nodes_max[depth - 1] = leaves[depth - 1] + root_max
nodes = [0] * (n + 1)
nodes[0] = 1
for depth in range(n):
    roots = nodes[depth]-leaves[depth]
    if nodes[depth] < nodes_min[depth]:
        print(-1)
        break
    nodes[depth + 1] = min(roots * 2, nodes_max[depth + 1])
else:
    if nodes[n] < nodes_min[n]:
        print(-1)
    else:
        print(sum(nodes))
R = int(input())
r = 'AGC'
if R<2800:
    r[1]='R'
if R<1200:
    r[1]='B'
print(r)

### FIXED CODE ###

R = int(input())
r = 'AGC'
if R<2800: r='ARC'
if R<1200: r='ABC'
print(r)
S = input()
flag = True
Cflag = False
for i, c in enumerate(S):
    if i == 0:
        if c == "A":
            continue
        else:
            flag = False
            break

    if c == "C" and i >= 2:
        if Cflag:
            flag = False
        cflag = True
    elif not (97 <= ord(c) <= 122):
        flag = False

if flag and cflag:
    print("AC")
else:
    print("WA")


### FIXED CODE ###

S = input()
flag = True
cflag = False
for i, c in enumerate(S):
    if i == 0:
        if c == "A":
            continue
        else:
            flag = False
            break

    if c == "C" and 2 <= i < len(S)-1:
        if cflag:
            flag = False
        cflag = True

    elif not (97 <= ord(c) <= 122):
        flag = False


if flag and cflag:
    print("AC")
else:
    print("WA")
n = int(input())
h = map(int, input().split())

ans = 1
m = n-1
high = ih[0]

for i in range(m):
    if h[i+1] >= high:
        ans += 1
        high = h[i+1]
    else:
        continue
        

print(ans)



### FIXED CODE ###

n = int(input())
h = input().split()
 
ans = 1
m = n-1
high = int(h[0])
 
for i in range(m):
    if int(h[i+1]) >= high:
        ans += 1
        high = int(h[i+1])
    else:
        continue
        
 
print(ans)
a = list(map(int,input().split()))

list.sort(a, reverse=True)

ans = "No"


if a[m-1] >= sum(a)/(4*m) :
  ans = "Yes"
print (ans)

### FIXED CODE ###

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

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

list.sort(a, reverse=True)

ans = "No"


if a[m-1] >= sum(a)/(4*m) :
  ans = "Yes"
print (ans)
s, t= [""] * 2
a, b = [0] * 2
u = [""]

def format_input(filename = None):
	global s,t
	global a,b
	global u
	if filename == None:
		s, t = list(map(str, input().split()))
		a, b = list(map(int, input().split()))
		u = list(map(str, input().split())).pop()

def get_answer():
	answer = [a, b]
	if u == s:
		answer[0] -= 1
	else:
		answer[1] -= 1

	return answer

if __name__ == '__main__':
	format_input()

	ans = get_answer()
	print(ans[0], ans[1])


### FIXED CODE ###



s, t= [""] * 2
a, b = [0] * 2
u = [""]

def format_input(filename = None):
	global s,t
	global a,b
	global u
	if filename == None:
		s, t = list(map(str, input().split()))
		a, b = list(map(int, input().split()))
		u = list(map(str, input().split())).pop()

def get_answer():
	answer = [a, b]
	if u == s:
		answer[0] -= 1
	else:
		answer[1] -= 1

	return answer

if __name__ == '__main__':
	format_input()

	ans = get_answer()
	print(ans[0], ans[1])
x,y,a,b,c=map(int,input().split())
p=list(map(int,input().split()))
q=list(map(int,input().split()))
r=list(map(int,input().split()))
p=p.sort()
q=q.sort()
r=r.sort()
p=p[:x+1]
q=q[:y+1]
pqr=[]
pqr=p+q+r
pqr=pqr.sort()
print(sum(pqr[:x+y]))

### FIXED CODE ###

x,y,a,b,c=map(int,input().split())
p=list(map(int,input().split()))
q=list(map(int,input().split()))
r=list(map(int,input().split()))
p.sort(reverse=True)
q.sort(reverse=True)
r.sort(reverse=True)
p=p[:x]
q=q[:y]
p[len(p):len(p)]=q
p[len(p):len(p)]=r
p.sort(reverse=True)
print(sum(p[:x+y]))
A, B, C = map(int, input().split())
if A < C < B or B < C < A:
    print("Yes")
else:
    print("No")

### FIXED CODE ###

A, B, C = map(int, input().split())
if A < C < B or B < C < A:
    print("Yes")
else:
    print("No")
n=int(input())
a,b,c=[],[],[]
for _ in range(n):
  A,B,C=map(int,input().split())
  a.append(A)
  b.append(B)
  c.append(C)
#print(a,b,c)
dp=[[[0] for _ in range(3)] for _ in range(n)]
dp[0][0]=a[0]
dp[0][1]=b[0]
dp[0][2]=c[0]
#print(dp)
for i in range(1,n):
  dp[i][0]=max(dp[i-1][1]+a[i],dp[i-1][2]+a[i])
  #print("dp[i][0]",dp[i][0],"dp[i-1][1]",dp[i-1][1],"dp[i-1][2]",dp[i-1][2],"a[i]",a[i])
  dp[i][1]=max(dp[i-1][0]+b[i],dp[i-1][2]+b[i])
  #print("dp[i][1]",dp[i][1],"dp[i-1][0]",dp[i-1][0],"dp[i-1][2]",dp[i-1][2],"b[i]",b[i])
  dp[i][2]=max(dp[i-1][0]+c[i],dp[i-1][1]+c[i])
  #print("dp[i][2]",dp[i][2],"dp[i-1][0]",dp[i-1][0],"dp[i-1][1]",dp[i-1][1],"c[i]",c[i])
  #print(i,dp)
print(max(dp[-1][0],dp[-1][1],dp[-1][2])



### FIXED CODE ###

n=int(input())
a,b,c=[],[],[]
for _ in range(n):
  A,B,C=map(int,input().split())
  a.append(A)
  b.append(B)
  c.append(C)
#print(a,b,c)
dp=[[[0] for _ in range(3)] for _ in range(n)]
dp[0][0]=a[0]
dp[0][1]=b[0]
dp[0][2]=c[0]
#print(dp)
for i in range(1,n):
  dp[i][0]=max(dp[i-1][1]+a[i],dp[i-1][2]+a[i])
  #print("dp[i][0]",dp[i][0],"dp[i-1][1]",dp[i-1][1],"dp[i-1][2]",dp[i-1][2],"a[i]",a[i])
  dp[i][1]=max(dp[i-1][0]+b[i],dp[i-1][2]+b[i])
  #print("dp[i][1]",dp[i][1],"dp[i-1][0]",dp[i-1][0],"dp[i-1][2]",dp[i-1][2],"b[i]",b[i])
  dp[i][2]=max(dp[i-1][0]+c[i],dp[i-1][1]+c[i])
  #print("dp[i][2]",dp[i][2],"dp[i-1][0]",dp[i-1][0],"dp[i-1][1]",dp[i-1][1],"c[i]",c[i])
  #print(i,dp)
#print(dp)
print(max(dp[-1][0],dp[-1][1],dp[-1][2]))
import sys
import itertools
# import math
# from pprint import pprint
import numpy as np


N,M,X = map(int, sys.stdin.readline().strip().split())
C = []
for _ in range(0, N):
    C.append(list(map(int, sys.stdin.readline().strip().split())))

# N = 3
# M = 3
# X = 10
#
# C = [
#     [60,2,2,4],
#     [70,8,7,9],
#     [50,2,3,9],
# ]

C.sort(key=lambda x:x[0])

for i in range(1, N+1):
    for j in itertools.combinations(C, i):
        l = [k[1:] for k in j]
        # pprint(l)
        if len(l) > 1:
            ll = np.sum(l, axis=0)
            # print(ll)
            flag = all((m >= X) for m in ll)
        else:
            flag = all((m >= X) for m in l[0])
        if flag:
            print(np.sum(j, axis=0)[0])
            sys.exit()
print(-1)


### FIXED CODE ###

import sys
import itertools
# import math
# from pprint import pprint
import numpy as np


N,M,X = map(int, sys.stdin.readline().strip().split())
C = []
for _ in range(0, N):
    C.append(list(map(int, sys.stdin.readline().strip().split())))

# N = 3
# M = 3
# X = 10
#
# C = [
#     [60,2,2,4],
#     [70,8,7,9],
#     [50,2,3,9],
# ]

C.sort(key=lambda x:x[0])

ans = None
for i in range(1, N+1):
    for j in itertools.combinations(C, i):
        l = [k[1:] for k in j]
        # pprint(l)
        if len(l) > 1:
            ll = np.sum(l, axis=0)
            # print(ll)
            flag = all((m >= X) for m in ll)
        else:
            flag = all((m >= X) for m in l[0])
        if flag:
            n = np.sum(j, axis=0)[0]
            if ans == None or  ans > n:
                ans = n

if ans:
    print(ans)
else:
    print(-1)
N = input()
d = []
for i in range(N):
    a.append(input())
print(len(list(set(li)))

### FIXED CODE ###

#coding : utf-8
 
n = int(input())
d = []
for i in range(n):
    d.append(int(input()))
print(len(list(set(d))))
from scipy.sparse.csgraph import floyd_warshall as wf
n=int(input())
s=[list(map(float,input().split()))for i in range(n)]
a=wf(s,directed=False).tolist()
if s!=a:
    print(-1)
else:
    c=0
    for i in range(n-1):
        for j in range(i+1,n):
            for d in range(n):
                if d!=i and d!=j:
                    if s[i][j]>=s[i][d]+s[d][j]:
                        break
            else:
                c+=int(s[i][j])
else:
    print(c)

### FIXED CODE ###

import numpy as np
from scipy.sparse.csgraph import floyd_warshall as wf
n=int(input())
s=np.array([list(map(int,input().split()))for i in range(n)])
if np.any(s!=wf(s,directed=False)):
    print(-1)
else:
    c=0
    for i in range(n):
        s[i][i]=10**10
    for i in range(n):
        for j in range(i+1,n):
            d=np.min(s[i]+s[j])
            if s[i,j]!=d:
                c+=s[i,j]
    else:
        print(c)
W, H, x, y, r = map(int, raw_input().split))
??????
if 0 <= x-r and x+r <= W and 0 <= y-r and y+r <= H:
????print 'Yes'
else:
??print 'No'

### FIXED CODE ###

W, H, x, y, r = map(int, raw_input().split())
 
if r <= x and x + r <= W and r <= y and y + r <= H:
 print 'Yes'
else:
 print 'No'
def ceil(x,y):
    if x%y == 0:
        return x//y
    if x%y == 1:
        return x//y + 1

n = int(input())
x,y = 1,1

for _ in range(n):
    t,a  = map(int,input().split())
    temp = max(ceil(x,t),ceil(y,a))
    x = t*temp
    y = a*temp

print(x+y)

### FIXED CODE ###

def ceil(x,y):
    if x%y == 0:
        return x//y
    else:
        return x//y + 1

n = int(input())
x,y = 1,1

for _ in range(n):
    t,a  = map(int,input().split())
    temp = max(ceil(x,t),ceil(y,a))
    x = t*temp
    y = a*temp

print(x+y)
# -*- coding: utf-8 -*-

import numpy as np
from collections import Counter


N = input()
# N = int(input())
# t = np.array(list(map(int, input().split())))
t = np.array(map(int, raw_input().split()))

odd = t[0::2]
even = t[1::2]

rest = 0

for _k in [odd, even]:
    counter = Counter(tmp_list)

    # counter.most_common()[0][0]
    # uni = list(set(_k))
    # cnt = np.zeros((len(uni), ))
    # for _i in uni:
    #     cnt[uni.index(_i)] += 1
    # unique = np.unique(odd, return_counts=True)
    # rest += len(_k) - count[np.argmax(count)]
    rest += len(_k) - counter.most_common()[0][1]
print rest


### FIXED CODE ###

# -*- coding: utf-8 -*-
import numpy as np
from collections import Counter
N = input()
t = np.array(map(int, raw_input().split()))

odd = t[0::2]
even = t[1::2]
rest = 0

co = Counter(odd)
ce = Counter(even)

omc = co.most_common()
emc = ce.most_common()

if omc[0][0] == emc[0][0]:
    if len(omc) < 2 and len(emc) < 2:       # same
        rest = len(even)
    elif len(omc) < 2:
        rest = len(even)
    elif len(emc) < 2:
        rest = len(odd)
    else:
        or1 = len(odd) - co.most_common()[0][1]
        or2 = len(odd) - co.most_common()[1][1]
        er1 = len(even) - ce.most_common()[0][1]
        er2 = len(even) - ce.most_common()[1][1]

        if or1 + er2 > or2 + er1:
            rest = or2 + er1
        else:
            rest = or1 + er2
else:
    rest = len(odd) - co.most_common()[0][1] + len(even) - ce.most_common()[0][1]


print rest
x,a,b=map(int,input().split())
if abs(x-a) < abs(x-b):
    print("A")
else:
    pring("B")

### FIXED CODE ###

x,a,b=list(map(int,input().split()))
if abs(x-a) < abs(x-b):
    print("A")
else:
    print("B")
#二部グラフになっている時の色の塗り分けを聞いている
import sys
if n==1:
  print(0)
  sys.exit()
  
n=int(input())
es=[[] for i in range(n)]
for i in range(n-1):
  u,v,w=list(map(int,input().split()))
  es[u-1].append([v,w])
  es[v-1].append([u,w])

colors=[0 for i in range(n)]
#深さ優先探索　頂点vをcolorで塗ることを考える
def dfs(v,color):
  colors[v-1]=color
  for i in es[v-1]:
    if i[1]%2==0 and colors[i[0]-1]==0:
      dfs(i[0],color)
    elif i[1]%2==1 and colors[i[0]-1]==0:
      dfs(i[0],(-1)*color)
  return colors

    
a=dfs(1,-1)
for i in a:
  if i==-1:
    print(0)
  else:
    print(1)
  


### FIXED CODE ###

# 再帰の深さが1000を超えそうなときはこれをやっておく
import sys
sys.setrecursionlimit(10**7)
#二部グラフになっている時の色の塗り分けを聞いている
n=int(input())
es=[[] for i in range(n)]
for i in range(n-1):
  u,v,w=list(map(int,input().split()))
  es[u-1].append([v,w])
  es[v-1].append([u,w])

colors=[0 for i in range(n)]
#深さ優先探索　頂点vをcolorで塗ることを考える
def dfs(v,color):
  colors[v-1]=color
  for i in es[v-1]:
    if i[1]%2==0 and colors[i[0]-1]==0:
      dfs(i[0],color)
    elif i[1]%2==1 and colors[i[0]-1]==0:
      dfs(i[0],(-1)*color)
  return colors

    
a=dfs(1,-1)
for i in a:
  if i==-1:
    print(0)
  else:
    print(1)
import math as m
from functools import reduce
n,l= int(input()),[]
def f(a, b):
    return int(a * b // m.gcd(a, b))
for i in range(n):
    l.append(int(input()))
print(reduce( lambda x,y: y//m.gcd(x,y)*x, l))





### FIXED CODE ###

import math as m
from functools import reduce
n,T= int(input()),[]
def gcd(a, b):
    while b:
        a, b = b, a % b
    return a
for i in range(n):
    T.append(int(input()))
tmp = max(T)
for i in range(n):
    if tmp % T[i] != 0:
        tmp = T[i]//gcd(tmp, T[i])*tmp

print(tmp)
import math
def lcm(x, y):
    return (x * y) // math.gcd(x, y)

print(lcm(int(input()), 2))


### FIXED CODE ###

def gcd(a, b):
    while b:
        a, b = b, a % b
    return a
  
def lcm(x, y):
    return (x * y) // gcd(x, y)

print(lcm(int(input()), 2))
from collections import defaultdict

import sys
sys.setrecursionlimit(10**6)
ii = lambda: int(input())
mis = lambda: map(int,input().split())
lmis = lambda: list(mis())
INF = float('inf')

def main():
    n,k=mis()
    if n>=k:
        n%=k
        print(k%n)
        exit()
    else: print(n if n<=k//2 else k-n)



if __name__ == "__main__":
    main()

### FIXED CODE ###

from collections import defaultdict

import sys
sys.setrecursionlimit(10**6)
ii = lambda: int(input())
mis = lambda: map(int,input().split())
lmis = lambda: list(mis())
INF = float('inf')

def main():
    n,k=mis()
    if n>=k:
        n%=k
        print(k%n if n!=0 else 0)
        exit()    
    print(n if n<=k//2 else k-n)



if __name__ == "__main__":
    main()
a = int(input())
b = int(input())
c = int(input())

ba = b - a
cb = c - b

if ba == cb:
    print("Yes")
else:
    print("No")

### FIXED CODE ###

a, b, c = map(int, input().split())

if b - a == c - b:
    print("YES")
else:
    print("NO")
print('{0[0]} {0[1]} {0[2]:.6f}'.format(
      (lambda a, b: (a // b, a % d, a / b))(
       *map(int, input().split())))

### FIXED CODE ###

from __future__ import division, print_function
from sys import stdin
a, b = (int(s) for s in stdin.readline().split())
print(a // b, a % b, '{:.6f}'.format(a / b))
a, b, k = map(int, input().split())
ans = []

for i in range(1, max(a,b)):
    if a % i == 0 and b % i == 0:
        ans.append(i)

print(ans[-k])

### FIXED CODE ###

a, b, k = map(int, input().split())
ans = []

for i in range(1, max(a,b)+1):
	if a % i == 0 and b % i == 0:
		ans.append(i)

print(ans[-k])
s = deque()
n = int(input())
initial = "left"
for i in range(n):
    order = list(input().split())
    if len(order) == 3:
        if initial == "left":
            if int(order[1]) == 1:
                s.appendleft(order[2])
            else:
                s.append(order[2])
        else:
            if int(order[1]) == 1:
                s.append(order[2])
            else:
                s.appendleft(order[2])
    else:
        initial = "right"
    
if initial == "left":
    print(s)
else:
    print(s[::-1])

### FIXED CODE ###

from collections import deque
s = deque(input())
n = int(input())
initial = True
for i in range(n):
    order = list(input().split())
    if len(order) == 3:
        if initial:
            if int(order[1]) == 1:
                s.appendleft(order[2])
            else:
                s.append(order[2])
        else:
            if int(order[1]) == 1:
                s.append(order[2])
            else:
                s.appendleft(order[2])
    else:
        initial = not initial
    
if initial:
    print(''.join(s))
else:
    print(''.join(s)[::-1])
s = raw_input()
n = int(raw_input())

for i in range(n):
    message = raw_input().split(" ")
    a, b = int(message[1]), int(message[2])

    if message[0] == "print":
        print(s[a:b+1])
    elif message[0] == "reverse":
        s[a:b+1] = s[a:b+1][::-1]
    elif message[0] == "replace":
        s = s[:a] + message[3] + s[b:]

### FIXED CODE ###

s = raw_input()
n = int(raw_input())

for i in range(n):
    message = raw_input().split(" ")
    a, b = int(message[1]), int(message[2])

    if message[0] == "print":
        print(s[a:b+1])
    elif message[0] == "reverse":
        s = s[:a] + s[a:b+1][::-1] + s[b+1:]
    elif message[0] == "replace":
        s = s[:a] + message[3] + s[b+1:]
N, Y = map(int, input().split())
counter = True
for i in range(N+1):
    for j in range(N - i+1):
        if j >= 0 and (N-i-j) >= 0 and counter:
            if 10**4*i + 5*10**3*j + 10**3*(N-i-j) == Y:
                #print(str(i)+" "+str(j)+" "+str(N-i-j))
                print(i, j, N-i-j)
                counter = False
        else:
            break
if counter:
    print("-1 -1 -1")

### FIXED CODE ###

a = input()
print("2018/01/" + a[-2:])
r =int(input())
print(r*pi)

### FIXED CODE ###

import numpy as np

r = int(input())
print(2*r*np.pi)
S = list(map(str, input()))

if(S[0]==S[1] or S[1]==S[2] or S[2]==S[3]):
  print("Bad")
else:
  print(Good)

### FIXED CODE ###

S = list(map(str, input()))
 
if(S[0]==S[1] or S[1]==S[2] or S[2]==S[3]):
  print("Bad")
else:
  print("Good")
def pyramid(N: int, info: list) -> tuple:
    """
    """
    _info = sorted(info, key=lambda x: x[2], reverse=True)
    x, y, h = _info[0]
    candidtes = [
        (cx, cy, h + abs(cx - x) + abs(cy - y))
        for cx in range(100+1)
        for cy in range(100+1)]

    for x, y, h in _info[1:]:
        temp = []
        for cx, cy, H in candidtes:
            th = max(H - abs(cx - x)-abs(cy - y), 0)
            if th == h:
                temp.append((cx, cy, H))

        candidtes = temp

    return candidtes[0]

if __name__ == "__main__":
    N = int(input())
    info = [
        tuple(int(s) for s in input().split())
        for _ in range(N)]
    cx, cy, h = pyramid(N, info)
    print(cx, cy, h)


### FIXED CODE ###

def programming_education(N: int) -> str:
    if N == 1:
        return 'Hello World'

    A = int(input())
    B = int(input())
    return str(A + B)


if __name__ == "__main__":
    N = int(input())
    ans = programming_education(N)
    print(ans)
a, b = map(int, input().split())
if a * b % == 0:
  print('Even')
else:
  print('Odd')
  
  

### FIXED CODE ###

a,b=map(int,input().split())
if a*b % 2 == 0:
  print('Even')
else:
  print('Odd')
l=xrange(1,input()+1)
for a,b in[map(int,raw_input().split(","))for i in xrange(input())]:l[a-1],l[b-1]=l[b-1],l[a-1]
for i in l:print i

### FIXED CODE ###

w = int(input())
n = int(input())

amida = [i for i in range(1, w + 1)]
for _ in range(n):
    a, b = [int(i) - 1 for i in input().split(",")]
    amida[a], amida[b] = amida[b], amida[a]

for x in amida:
    print(x)