Harryxun/stf_run huggingface dataset:
#import numpy as np
import sys
from scipy.sparse.csgraph import floyd_warshall,csgraph_from_dense
from scipy.sparse import csr_matrix
input = sys.stdin.readline
def inputs():return [int(x) for x in input().split()]
N = int(input())
a,b =inputs()
M = int(input())
graph= [[10**9]*(N+1) for _ in range(N+1)]
E = {i:[] for i in range(N+1)}
for i in range(M):
  x,y = inputs()
  graph[x][y] = 1
  graph[y][x] = 1
  E[x].append(y)
  E[y].append(x)
G = csgraph_from_dense(graph, null_value=10**9)
dist_mat = floyd_warshall(graph,directed=False)
visited=[-1]*(N+1)
stk =[[a,-1,0]]
cnt=0
while stk:
  v,p,path =stk.pop()
  if v==b and path==dist_mat[a][b]:
    cnt+=1
    cnt%=(10**9+7)
  #visited[v]=1
  for i in E[v]:
    if i != p and path<dist_mat[a][b]:
      stk.append([i,v,path+1])
print(cnt%(10**9+7))


### FIXED CODE ###

import numpy as np
import sys
from scipy.sparse.csgraph import floyd_warshall,csgraph_from_dense
from scipy.sparse import csr_matrix
input = sys.stdin.readline
def inputs():return [int(x) for x in input().split()]
N,M,L = inputs()
ABC =[inputs() for _ in range(M)]
graph = [[10**13]*(N+1) for _ in range(N+1)]
for a,b,c in ABC:
    graph[a][b] = c
G = csgraph_from_dense(graph, null_value=10**13)
dist_mat = floyd_warshall(graph,directed=False)
graph2 = np.array([[10**13]*(N+1) for _ in range(N+1)])
np.fill_diagonal(graph2,0)
graph2[dist_mat<=L]=1
dist_mat2 = floyd_warshall(graph2,directed=False)
dist_mat2[dist_mat2==10**13]=0
Q = int(input())
for i in range(Q):
    s,t = inputs()
    print(int(dist_mat2[s,t])-1)
n,m = map(int, input().split())
li = [[] for _ in range(n)]
for i in range(m):
    a,b = map(int, input().split())
    a -= 1
    b -= 1
    li[a].append(b)
    li[b].append(a)

nodes = [i for i in range(n)]
group = [1]*n

def dfs(node, group):
    s = li[node]
    group[node]=0
    for v in s:
        if group[v]!=0:
            dfs(v, group)

cnt = 0       
for i in range(n):
    if group[i]!=0:
        dfs(i,group)
        cnt += 1

print(cnt-1)

### FIXED CODE ###

from collections import deque
n,m = map(int, input().split())
G = [[] for _ in range(n)]
for i in range(m):
    a,b = map(int, input().split())
    a-=1
    b-=1
    G[b].append(a)
    G[a].append(b)

dist = [-1]*n
que = deque()
cnt = 0

for i in range(n):
    if dist[i]!=-1:
        continue
    dist[i]=0
    que.append(i)
    while len(que):
        v = que.pop()
        s = G[v]
        for j in s:
            if dist[j]!=-1:
                continue
            dist[j]=0
            que.append(j)
    cnt += 1

print(cnt-1)
S,T = input.split()
print(T+S)

### FIXED CODE ###

S,T = input().split()
print("{}{}".format(T,S))
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
 
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
 
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

# 最大公約数 
def gcd(a, b):
  if a < b:
      a, b = b, a
  while a % b != 0:
      a, b = b, a % b
  return b

# 最小公倍数
def lcm(a, b):
  y = a*b / gcd(a, b)
  return int(y)

n, m = MAP()


L = []
for i in range(m):
  l = S_LIST()
  L.append(l)

# wa

wa = [0] * n
ac = [0] * n


for i in range(m):
  p = int(L[i][0])-1
  ans = L[i][1]
  if ans == "WA":
    # まだacない
    if ac[p] == 0:
      wa[p] = wa[p] + 1
  # acあった
  if ans == "AC":
    ac[p] = 1

for i in range(m):
  if ac[i] == 1:
    wa[i] = 0


print(sum(ac), sum(wa))


# for p in range(1, n+1):
#   if L[i][0] == str(p):
#     for i in range(m):
#       if L[i][1] == "WA":
#         wa += 1

#     for i in range(m):
#       if L[i][1] == "AC":
#         ac += 1
#   print(wa)
#   print(ac)

  

### FIXED CODE ###

import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
 
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
 
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

# 最大公約数 
def gcd(a, b):
  if a < b:
      a, b = b, a
  while a % b != 0:
      a, b = b, a % b
  return b

# 最小公倍数
def lcm(a, b):
  y = a*b / gcd(a, b)
  return int(y)

n, m = MAP()


L = []
for i in range(m):
  l = S_LIST()
  L.append(l)

# wa

wa = [0] * n
ac = [0] * n


for i in range(m):
  p = int(L[i][0])-1
  ans = L[i][1]
  if ans == "WA":
    # まだacない
    if ac[p] == 0:
      wa[p] = wa[p] + 1
  # acあった
  if ans == "AC":
    ac[p] = 1

for i in range(n):
  if ac[i] == 0:
    if wa[i] > 0:
      wa[i] = 0


print(sum(ac), sum(wa))


# for p in range(1, n+1):
#   if L[i][0] == str(p):
#     for i in range(m):
#       if L[i][1] == "WA":
#         wa += 1

#     for i in range(m):
#       if L[i][1] == "AC":
#         ac += 1
#   print(wa)
#   print(ac)
import math
[A,B,H,M] = list(map(int,input().split()))

tm = 60*H + M
#print('time', tm)
#進んだ距離
Dji = 0.5 * tm
Dhu = 6 * tm
#print('1', Dji,Dhu)
'''
#げんじつ感のある角度に
Dji2 = Dji % 180
Dhu2 = Dhu % 180
#print('2', Dji2,Dhu2)

#間の角度
kaku = abs(Dji2 - Dhu2)
#print('kakudo',kaku)
'''
Dji2 = Dji % 360
Dhu2 = Dhu % 360
#print('2', Dji2,Dhu2)

if abs(Dji2 - Dhu2) <=180:
    kaku = abs(Dji2 - Dhu2)
else:
    kaku = (360 - abs(Dji2 - Dhu2)) % 180


#余弦定理
if kaku ==0:
    out = Dhu - Dji

if kaku == 180:
    out == Dhu + Dji
else:
    out = math.sqrt(A**2 + B**2 - 2*A*B*math.cos(math.radians(kaku)))


print(out)

### FIXED CODE ###


import math
[A,B,H,M] = list(map(int,input().split()))

tm = 60*H + M
#print('time', tm)
#進んだ距離
Dji = 0.5 * tm
Dhu = 6 * tm
#print('1', Dji,Dhu)
'''
#げんじつ感のある角度に
Dji2 = Dji % 180
Dhu2 = Dhu % 180
#print('2', Dji2,Dhu2)

#間の角度
kaku = abs(Dji2 - Dhu2)
#print('kakudo',kaku)
'''
Dji2 = Dji % 360
Dhu2 = Dhu % 360
#print('2', Dji2,Dhu2)

if abs(Dji2 - Dhu2) <=180:
    kaku = abs(Dji2 - Dhu2)
else:
    kaku = 360 - abs(Dji2 - Dhu2)


#余弦定理
if kaku ==0:
    out = B - A

if kaku == 180:
    out = B + A
else:
    out = math.sqrt(A**2 + B**2 - 2*A*B*math.cos(math.radians(kaku)))


print(out)
from collections import defaultdict

N, Q = map(int, input().split())
e = [[] for _ in range(N + 1)]
for i in range(N - 1):
    a, b = map(int, input().split())
    e[a].append(b)

q = defaultdict(int)
for i in range(Q):
    p, x = map(int, input().split())
    q[p] += x

seen = [False] * (N + 1)
ans = [0] * (N + 1)


def dfs(e, v, x):
    seen[v] = True
    ans[v] += x
    for next_v in e[v]:
        if seen[next_v]:
            continue
        else:
            dfs(e, next_v, x + q[next_v])


dfs(e, 1, q[1])

print(*ans[1:])


### FIXED CODE ###

from collections import defaultdict
import sys
input = sys.stdin.readline

sys.setrecursionlimit(10**6)

N, Q = map(int, input().split())
e = [[] for _ in range(N + 1)]
for i in range(N - 1):
    a, b = map(int, input().split())
    e[a].append(b)

q = defaultdict(int)
for i in range(Q):
    p, x = map(int, input().split())
    q[p] += x

seen = [False] * (N + 1)
ans = [0] * (N + 1)


def dfs(e, v, x):
    seen[v] = True
    ans[v] += x
    for next_v in e[v]:
        if seen[next_v]:
            continue
        else:
            dfs(e, next_v, x + q[next_v])


dfs(e, 1, q[1])
print(*ans[1:])
# coding: utf-8
# Your code here!
num = int(raw_input())#数字を取得
num_of_digit = len(str(num)) #数字の桁数を取得
total = 0 #1が現れる回数
for i in range(num_of_digit):
    count = 0
    count  += (num // (10**(i+1)) +1) * 10**i
    if num % (10**(i+1)) < (10**i)*2:
        count -= min ((10**i)*2-(num % (10**(i+1))+1),10**i)
    total += count
print total

### FIXED CODE ###

# coding: utf-8
# Your code here!
eng_li = []
removed_list = []
all_letter = 26
for i in range (97,97+all_letter):
    eng_li.append(chr(i))
 
string = list(raw_input().strip())
length = len(string)
if length < all_letter:
    for i in string:
        eng_li.remove(i)
    string.append(eng_li[0])
    answer = "".join(string)
else:
    for i in range(all_letter-1):
        if ord(string[-1]) < ord(string[-2]) :
            removed_list.append(string[-1])
            string.pop()
        else:
            removed_list.append(string[-1])
            string.pop()
            removed_list=filter(lambda x:x>string[-1],sorted(removed_list))
            string.pop()
            string.append(removed_list[0])
            answer ="".join(string)
            break
    else:
        answer = -1
print answer
S = input()
K = int(input())
 
if K == 1:
  print(int(S[0]))
elif len(S) == 1:
  print(int(S))
elif S[:K] == "1"*K:
  print(1)
else:
  for i in range(K+1):
    if S[i] != "1":
      print(int(S[i]))
      break

### FIXED CODE ###

S = input()
K = int(input())
 
one = True
for i in range(K):
  if S[i] != "1":
    print(int(S[i]))
    one = False
    break
if one:
  print(1)
#coding:utf-8

import sys

L = list(int(input()) for i in range(6))

for i in range(5):
        for j in range(5):
            if abs(L[i]-L[j]) > L[6]:
                print(":(")
                sys.exit()

print("Yay!")

### FIXED CODE ###

#coding:utf-8

import sys

L = list(int(input()) for i in range(6))

for i in range(5):
        for j in range(5):
            if abs(L[i]-L[j]) > L[5]:
                print(":(")
                sys.exit()

print("Yay!")
def count(h_list):
    if len(h_list) == 0:
        return 0
    if len(h_list) == 1:
        return h_list[0]
    if (h_list != 0).all():
        return 1 + count(h_list - 1)
    elif (h_list == 1).all():
        return 1
    return sum([count(x) for x in divide_by_zero(h_list)])


def divide_by_zero(arr):
    non_zero = []
    for ar in arr:
        if ar == 0:
            if non_zero:
                yield np.array(non_zero)
                non_zero = []
        else:
            non_zero.append(ar)
    yield np.array(non_zero)

n = int(input())
h_list = np.array([int(x) for x in input().split(" ")])
print(count(h_list))


### FIXED CODE ###

def count(h_list):
    if len(h_list) == 0:
        return 0
    if len(h_list) == 1:
        return h_list[0]
    if 0 not in h_list:
        return 1 + count([x-1 for x in h_list])
    elif all(x == 1 for x in h_list):
        return 1
    return sum([count(x) for x in divide_by_zero(h_list)])


def divide_by_zero(arr):
    non_zero = []
    for ar in arr:
        if ar == 0:
            if non_zero:
                yield non_zero
                non_zero = []
        else:
            non_zero.append(ar)
    yield non_zero


n = int(input())
h_list = [int(x) for x in input().split(" ")]
print(count(h_list))
N, M, X = list(map(int, input().split(" ")))

import numpy as np

vals = []
for i in range(N):
    v = list(map(int, input().split(" ")))
    vals.append(v)

vals = np.array(vals)

import itertools

prod = []
for i in range(1, N+1):
    v = list(itertools.combinations(range(N), i))
    prod.extend(v)
    
money = 1e8

for p in prod:
    ans = np.zeros(4)
    for p_ in p:
        ans += vals[p_]
    if (ans[1] >= X) and (ans[2] >= X) and (ans[3] >= X):
        if money > ans[0]:
            money = ans[0]
 
if money >= 1e8:
    print(-1)
else:
    print(int(money))

### FIXED CODE ###

N, M, X = list(map(int, input().split(" ")))

import numpy as np

vals = []
for i in range(N):
    v = list(map(int, input().split(" ")))
    vals.append(v)

vals = np.array(vals)

import itertools

prod = []
for i in range(1, N+1):
    v = list(itertools.combinations(range(N), i))
    prod.extend(v)
    
money = 1e10

for p in prod:
    ans = np.zeros(M+1)
    
    for p_ in p:
        ans += vals[p_]
    
    flag = True
    for j in range(M):
        if ans[1+j] < X:
            flag = False
    if flag:
        if money > ans[0]:
            money = ans[0]
 
if money >= 1e10:
    print(-1)
else:
    print(int(money))
n,k=map(int,input().split())
s=input()+"d"
d=[]
r=s[0]
c=0
for i in range(n+1):
    if r==s[i]:
        c+=1
    else:
        d.append(c)
        r=s[i]
        c=1
if s[0]=="0":
        d=[0]+d
if s[-2]=="0":
    d+=[0]
if len(d)<=2*k+1:
    print(n)
else:
    l=sum(d[:2*k+1])
    p=sum(d[:2*k+1])
    for i in range(len(d)-2*k-3):
        p=p-d[2*i]-d[2*i+1]+d[2*i+2*k+1]+d[2*i+2*k+2]
        l=max(l,p)
    print(l)

### FIXED CODE ###

n,k=map(int,input().split())
s=input()+"d"
d=[]
r=s[0]
c=0
for i in range(n+1):
    if r==s[i]:
        c+=1
    else:
        d.append(c)
        r=s[i]
        c=1
if s[0]=="0":
        d=[0]+d
if s[-2]=="0":
    d+=[0]
if len(d)<=2*k+1:
    print(n)
else:
    l=sum(d[:2*k+1])
    p=sum(d[:2*k+1])
    for i in range((len(d)-2*k-1)//2):
        p=p-d[2*i]-d[2*i+1]+d[2*i+2*k+1]+d[2*i+2*k+2]
        l=max(l,p)
    print(l)
n=input()
p=list(map(int,input().split()))
a = 0
for i in range(n-2):
    a += 1*(0<((p[i] < p[i+1])*(p[i+1] < p[i+2])))
print(a)

### FIXED CODE ###

n=int(input())
p=list(map(int,input().split()))
a = 0
for i in range(n-2):
  a += 1-((p[i] < p[i+1])^(p[i+1] < p[i+2]))
print(a)
a=input()
n=[chr(i) for i in range(97, 97+26)]
# [chr(i) for i in range(ord('a'), ord('z')+1)]
print(n[1+n.count(a)]


### FIXED CODE ###

a=input()
n=[chr(i) for i in range(97, 97+26)]
# [chr(i) for i in range(ord('a'), ord('z')+1)]
print(n[1+n.index(a)])
import numpy as np
N,K=map(int,input().split())
p=np.array(list(map(int,input().split())))

ans=0
for i in range(N-K+1):
    ans=max(ans, sum(p[i:i+K]))

print((ans+K)/2)

### FIXED CODE ###

import numpy as np

N,K=map(int,input().split())
p=np.array(list(map(int,input().split())))

pcm=np.concatenate([np.array([0]),(p+1).cumsum()],0)

print((pcm[K:]-pcm[0:-K]).max() /2)
s=input()
if s[1]==s[2] and s[2]==s[3]:
  print("No")
else:
  print("Yes")

### FIXED CODE ###

s=input()
if s[0]==s[1] and s[1]==s[2]:
  print("No")
else:
  print("Yes")
import sys
input = sys.stdin.readline

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

b=[]
M = 0
count = [0 for _ in range(N)]
for i in reversed(range(1,N+1)):
    if count[i-1]%2 == a[i-1]: continue
    else:
        for j in range(1,int(i**0.5)+1):
            if i%j==0:
                count[j]+=1
                if j!=i//j:
                    count[i//j]+=1
        M+=1
        b.append(i)
print(M)
if M!=0:
    print(*b)


### FIXED CODE ###

import sys
input = sys.stdin.readline

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

b=[]
M = 0
count = [0 for _ in range(N+1)]
for i in reversed(range(1,N+1)):
    if count[i]%2 == a[i-1]: continue
    else:
        for j in range(1,int(i**0.5)+1):
            if i%j==0:
                count[j]+=1
                if j!=i//j:
                    count[i//j]+=1
        M+=1
        b.append(i)
print(M)
if M!=0:
    print(*b)
from __future__ import division
import math

def cross(p1,p2):
    a,b,c,d=p1[0],p1[1],p2[0],p2[1]
    t=pow(a,2)+pow(c,2)+pow(d,2)-pow(b,2)-2*a*c
    alpha=4*(pow(b-d,2)+pow(c-a,2))
    beta=4*(t*(b-d)-2*b*pow(c-a,2))
    gamma=pow(t,2)+4*pow(b,2)*pow(c-a,2)-4*pow(c-a,2)
    judge=pow(beta,2)-4*alpha*gamma
    EPS=1e-5
    return 1,1
    if judge>EPS:
        y1=(-beta+math.sqrt(judge))/(2*alpha)
        y2=(-beta-math.sqrt(judge))/(2*alpha)
        x1=(2*(b-d)*y1+pow(c,2)+pow(d,2)-pow(a,2)-pow(b,2))/(2*(c-a))
        x2=(2*(b-d)*y2+pow(c,2)+pow(d,2)-pow(a,2)-pow(b,2))/(2*(c-a))
        return ((x1,y1),(x2,y2))
    elif -EPS<=judge<=EPS:
        y=-beta/(2*alpha)
        x=(2*(b-d)*y+pow(c,2)+pow(d,2)-pow(a,2)-pow(b,2))/(2*(c-a))
        return ((x,y),)
    else:
        return None

def maxNum(P,L):
    ans=1
    for x,y in P:
        cnt=0
        for px,py in L:
            d=math.sqrt(pow(px-x,2)+pow(py-y,2))
            if d<=1:
                cnt+=1
        ans=max(ans,cnt)
    return ans

while True:
    n=input()
    if n==0:break
    L=[map(float,raw_input().split(",")) for i in range(n)]
    P=[]
    for i in range(n-1):
        for j in range(i+1,n):
            points=cross(L[i],L[j])
            if points:
                P.extend(points)
    print maxNum(P,L)

### FIXED CODE ###

from __future__ import division
import math

def cross(p1,p2):
    a,b,c,d=p1[0],p1[1],p2[0],p2[1]
    t=pow(a,2)+pow(c,2)+pow(d,2)-pow(b,2)-2*a*c
    alpha=4*(pow(b-d,2)+pow(c-a,2))
    beta=4*(t*(b-d)-2*b*pow(c-a,2))
    gamma=pow(t,2)+4*pow(b,2)*pow(c-a,2)-4*pow(c-a,2)
    judge=pow(beta,2)-4*alpha*gamma
    EPS=1e-5
    if c==a:
        y=(pow(a,2)+pow(b,2)-pow(c,2)-pow(d,2))/(2*(b-d))
        bd=pow(b-d,2)
        a1=4*bd
        b1=-8*a*bd
        c1=4*a*a*bd+pow(a*a-b*b-c*c-d*d+2*b*d,2)-4*bd
        inroot=pow(b1,2)-4*a1*c1
        if inroot<0:
            return None
        x1=(-b1+math.sqrt(inroot))/(2*a1)
        x2=(-b1-math.sqrt(inroot))/(2*a1)
        return ((x1,y),(x2,y))

    if judge>EPS:
        y1=(-beta+math.sqrt(judge))/(2*alpha)
        y2=(-beta-math.sqrt(judge))/(2*alpha)
        x1=(2*(b-d)*y1+pow(c,2)+pow(d,2)-pow(a,2)-pow(b,2))/(2*(c-a))
        x2=(2*(b-d)*y2+pow(c,2)+pow(d,2)-pow(a,2)-pow(b,2))/(2*(c-a))
        return ((x1,y1),(x2,y2))
    elif -EPS<=judge<=EPS:
        y=-beta/(2*alpha)
        x=(2*(b-d)*y+pow(c,2)+pow(d,2)-pow(a,2)-pow(b,2))/(2*(c-a))
        return ((x,y),)
    else:
        return None

def maxNum(P,L):
    ans=1
    for x,y in P:
        cnt=0
        for px,py in L:
            d=math.sqrt(pow(px-x,2)+pow(py-y,2))
            if d<=1:
                cnt+=1
        ans=max(ans,cnt)
    return ans

while True:
    n=input()
    if n==0:break
    L=[map(float,raw_input().split(",")) for i in range(n)]
    P=[]
    for i in range(n-1):
        for j in range(i+1,n):
            points=cross(L[i],L[j])
            if points:
                P.extend(points)
    print maxNum(P,L)
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):
  if y==0:
    return x
  return gcd(y,x%y)
# 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=int(lcm(ans,I()))

  return ans

# 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())
a,b,c=map(int, input().split())
if c-a-b<0:
  print("No")
else:
  if 4ab<(c-a-b)**2:
    print("Yes")
  else:
    print("No")
    
    

### FIXED CODE ###

a,b,c=map(int, input().split())
if c-a-b<0:
  print("No")
else:
  if 4*a*b<(c-a-b)**2:
    print("Yes")
  else:
    print("No")
rom collections import Counter


def main():
    n = int(input())
    a = list(map(int, input().split()))
    c = Counter
    q = int(input())
    s = sum(a)
    for _ in range(q):
        b, c = map(int, input().split())
        s -= C[b]*b
        s += C[b]*c
        C[c] += c[b]
        c[b] = 0
        print(s)

if __name__ == "__main__":
    main()


### FIXED CODE ###

from collections import Counter


def main():
    n = int(input())
    a = list(map(int, input().split()))
    cnt = Counter(a)
    q = int(input())
    s = sum(a)
    for _ in range(q):
        b, c = map(int, input().split())
        s -= cnt[b]*b

        s += cnt[b]*c
        cnt[c] += cnt[b]
        cnt[b] = 0
        print(s)

if __name__ == "__main__":
    main()
print(max(0,int(input())-int(input())))

### FIXED CODE ###

x, t =map(int,input().split())
print(max(0,x-t))
import sys
import math
def I():return int(sys.stdin.readline().replace("\n",""))
def I2():return map(int,sys.stdin.readline().replace("\n","").split())
def S():return str(sys.stdin.readline().replace("\n",""))
def L():return list(sys.stdin.readline().replace("\n",""))
def Intl():return [int(k) for k in sys.stdin.readline().replace("\n","").split()]
def Lx(k):return list(map(lambda x:int(x)*-k,sys.stdin.readline().replace("\n","").split()))

if __name__ == "__main__":
    n,m =I2()
    h = Intl()
    l = [[] for i in range(n)]
    cnt = 0
    for i in range(m):
        a,b = I2()
        l[a-1].append(b)
        l[b-1].append(a)
    for i in range(n):
        if len(l[i]) == 0:cnt +=1
        for j in l[i]:
            if h[i] > h[j-1]:
                f = True
            else:
                f = False
        if f:cnt += 1
    print(cnt)

### FIXED CODE ###

import sys
import math
def I():return int(sys.stdin.readline().replace("\n",""))
def I2():return map(int,sys.stdin.readline().replace("\n","").split())
def S():return str(sys.stdin.readline().replace("\n",""))
def L():return list(sys.stdin.readline().replace("\n",""))
def Intl():return [int(k) for k in sys.stdin.readline().replace("\n","").split()]
def Lx(k):return list(map(lambda x:int(x)*-k,sys.stdin.readline().replace("\n","").split()))

if __name__ == "__main__":
    n,m =I2()
    h = Intl()
    l = [[] for i in range(n)]
    cnt = 0
    for i in range(m):
        a,b = I2()
        l[a-1].append(b)
        l[b-1].append(a)
    #print(l)
    for i in range(n):
        if len(l[i]) == 0:
            cnt +=1
            continue
        #print(cnt)
        for j in l[i]:
            if h[i] > h[j-1]:
                f = True
            else:
                f = False
                break
        if f:cnt += 1
    print(cnt)
max = 0
min = 100000000
ave = 0
x = int(input())
for i in range(0, x):
    a = int(input())
    if(max < a):
        max = a
    if(min > a):
        min = a
    avg += a
print("%d %d %d"%(min, max, ave//x))


### FIXED CODE ###

x = input()
a = list(map(int, input().split()))
print("%d %d %d"%(min(a), max(a), sum(a)))
n, k = map(int, input().split())
sec = [list(map(int, input().split())) for _ in range(k)]
sec.sort()

mod = 998244353

dp = [0] * n
dp[0] = 1
sum_dp = [0, 1]
for i in range(1, n):
    for l, r in sec:
        if i - l < 0:
            break
        elif i - r > 0:
            dp[i] = ((dp[i] + sum_dp[i-l+1]) % mod - sum_dp[i-r]) % mod
        else:
            dp[i] = (dp[i] + sum_dp[i-l+1]) % mod
    
    sum_dp.append((sum_dp[-1] + dp[i]) % modp)

print(dp[n-1])

### FIXED CODE ###

n, k = map(int, input().split())
sec = [list(map(int, input().split())) for _ in range(k)]
sec.sort()

mod = 998244353

dp = [0] * n
dp[0] = 1
sum_dp = [0, 1]
for i in range(1, n):
    for l, r in sec:
        if i - l < 0:
            break
        elif i - r > 0:
            dp[i] = ((dp[i] + sum_dp[i-l+1]) % mod - sum_dp[i-r]) % mod
        else:
            dp[i] = (dp[i] + sum_dp[i-l+1]) % mod
    
    sum_dp.append((sum_dp[-1] + dp[i]) % mod)

print(dp[n-1])