Harryxun/stf_run huggingface dataset:
from collections import defaultdict
vertices, edges = map(int, input().split(" "))
connect = defaultdict(set)
for i in range(vertices):
    a, b = map(int, input().split(" "))
    connect[a] |= {b}
    connect[b] |= {a}

comb_answers = defaultdict(int)

def bfs(start, connect, visited):
    queue = [start]
    while queue:
        here = queue.pop()
        visited |= {here}
        for conn in connect[here]:
            if conn not in visited:
                visited |= {conn}
                queue.append(conn)
    return visited
    
for e in connect[1]:
    need_visit = bfs(e, connect, {1})
    temp_answer = 0
    queue = [[{1}, e]]
    while queue:
        visited, now = queue.pop()
        visited |= {now}
        # print(visited, now, need_visit)
        for conn in connect[now]:
            if conn not in visited:
                queue.append([visited | {conn}, conn])
        if visited == need_visit:
            for c in comb_answers.keys():
                if c in visited:
                    comb_answers[c] += 1
                    break
            else:
                comb_answers[e] += 1
            # print(visited, now, need_visit)
answer = 1
for v in comb_answers.values():
    answer *= v

print(answer)

### FIXED CODE ###

from collections import defaultdict
vertices, edges = map(int, input().split(" "))
connect = defaultdict(set)
for i in range(edges):
    a, b = map(int, input().split(" "))
    connect[a] |= {b}
    connect[b] |= {a}

answer = 0
queue = [[set(), 1]]
while queue:
    visited, now = queue.pop()
    visited |= {now}
    # print(visited, now, need_visit)
    if len(visited) == vertices:
        answer += 1
    else:
        for conn in connect[now]:
            if conn not in visited:
                queue.append([visited | {conn}, conn])
        # print(visited, now, need_visit)

print(answer)
def f(y,x,c0):
  global A
  c=A[y][x]
  if c=='X' or c!=c0:
    return 0
  else:
    A[y][x]='X'
    for i,j in [[0,-1],[0,1],[-1,0],[1,0]]:
      f(y+i,x+j,c0)
    return 1

while 1:
  H,W=map(int,raw_input().split())
  if H==W==0: break
  A=[['X' for _ in range(W+2)] for _ in range(H+2)]
  for i in range(H):
    A[i+1][1:W+1]=list(raw_input())
  c=0
  for i in range(1,H+1):
    for j in range(1,W+1):
      c+=f(i,j,A[i][j])
  print c

### FIXED CODE ###

def f(y,x,a):
  M.append([y,x])
  while M:
    y,x=M.pop()
    if A[y][x]==a:
      A[y][x]=' '
      for i,j in [[0,-1],[-1,0],[0,1],[1,0]]: M.append([y+i,x+j])
  return 1

M=[]
while 1:
  H,W=map(int,raw_input().split())
  if H==W==0: break
  A=[list(' '*(W+2)) for _ in range(H+2)]
  for i in range(H): A[i+1][1:W+1]=list(raw_input())
  c=0
  for i in range(1,H+1):
    for j in range(1,W+1):
      a=A[i][j]
      if a!=' ': c+=f(i,j,a)
  print c
A, B = map(int, input().split())
    S = input()
    C = "1234567890"
    for i in range(len(S)):
        if i == A:
            if S[i] == "-":
                continue
            else:
                print("No")
                exit()
        else:
            if S[i] in C:
                continue
            else:
                print("No")
                exit()
    print("Yes")
    exit()
resolve()

### FIXED CODE ###

def resolve():
    A, B = map(int, input().split())
    S = input()
    C = "1234567890"
    for i in range(A):
        if S[i] in C:
            continue
        else:
            print("No")
            exit()
    if S[A] != "-":
        print("No")
        exit()
    for i in range(A+1, len(S)):
        if S[i] in C:
            continue
        else:
            print("No")
            exit()
    print("Yes")
resolve()
a,b,c = map(int, input().split())
if a == b and a!= c:
    print('Yes')
elif a == c and b != c:
    print('Yes')
elif b = c and a != c:
    print('Yes')
else:
    print('No')

### FIXED CODE ###

a,b,c = map(int, input().split())
if a == b and a!= c:
    print('Yes')
elif a == c and b != c:
    print('Yes')
elif b == c and a != c:
    print('Yes')
else:
    print('No')
a, b = map(int,input.split())

print('Even' if a*b % 2 == 0 else 'Odd')


### FIXED CODE ###

a, b = map(int,input().split())
print('Even' if a*b % 2 == 0 else 'Odd')
def actual(x1, y1, x2, y2):
    a = x2 - x1
    b = y2 - y1

    x3, y3 = x2 - b, y2 + a
    x4, y4 = x3 - a, y3 - b

    return f'{x3} {y3} {x4} {y4}'

x1, y1, x2, y2 = map(int, input().split())
print(actual(x1, y1, x2, y2))


### FIXED CODE ###

def actual(x1, y1, x2, y2):
    a = x2 - x1
    b = y2 - y1

    x3, y3 = x2 - b, y2 + a
    x4, y4 = x3 - a, y3 - b

    # return f'{x3} {y3} {x4} {y4}'
    return '{} {} {} {}'.format(x3, y3, x4, y4)

x1, y1, x2, y2 = map(int, input().split())
print(actual(x1, y1, x2, y2))
H, W = map(int, input().split())
print("#"*(W+2))
for _ in range(H):
    print(f"#{input()}#")
print("#"*(W+2))

### FIXED CODE ###

H, W = map(int, input().split())
a = [input()for _ in range(H)]
print("#"*(W+2))
for r in a:
    print("#"+r+"#")
print("#"*(W+2))
import sys
from collections import Counter
 
inf = 1<<60
 
def solve():
    N, M = map(int, input().split())
    edges = [None]*M
 
    for i in range(M):
        ui, vi, ci = map(int, sys.stdin.readline().split())
        edges[i] = (ui-1, vi-1, -ci)
 
    ans = Bellmanford(N, M, edges)
 
    if ans is not None:
        print(-ans)
    else:
        print('inf')
 
def Bellmanford(N, M, edges):
    dist = [inf]*N
    dist[0] = 0
    flag = True
 
    while True:
        flag = False
 
        for (u, v, c) in edges:
            if d[u] != inf and dist[v] > dist[u] + c:
                dist[v] = dist[u] + c
                flag = True
 
        # print(dist)
 
        if not flag or dist[0] < 0:
            break
 
    if dist[0] >= 0:
        return dist[N - 1]
    else:
        return None
 
if __name__ == '__main__':
    solve()

### FIXED CODE ###

import sys
from collections import Counter

sys.setrecursionlimit(10**7)
 
inf = 1<<100
 
def solve():
    N, M = map(int, input().split())
    edges = [None]*M
    Adj = [[] for i in range(N)]
 
    for i in range(M):
        ui, vi, ci = map(int, sys.stdin.readline().split())
        ui, vi = ui - 1, vi - 1
        edges[i] = (ui, vi, -ci)
        Adj[ui].append(vi)

    visitable = [False]*N

    dfs(N, M, Adj, visitable, 0)

    reachable = [False]*N
    reachable[0] = True
    reachable[N - 1] = True

    for u in range(1, N - 1):
        visited = [False]*N

        dfs(N, M, Adj, visited, u)

        if visited[N - 1]:
            reachable[u] = True
 
    ans = Bellmanford(N, M, edges, visitable, reachable)
 
    if ans is not None:
        print(-ans)
    else:
        print('inf')

def dfs(N, M, Adj, visitable, u):
    visitable[u] = True

    for v in Adj[u]:
        if not visitable[v]:
            dfs(N, M, Adj, visitable, v)

def Bellmanford(N, M, edges, visitable, reachable):
    dist = [inf]*N
    dist[0] = 0
    flag = True

    cnt = 0
 
    for i in range(N):
        flag = False

        for (u, v, c) in edges:
            if dist[u] != inf and dist[v] > dist[u] + c:
                dist[v] = dist[u] + c

                if visitable[v] and reachable[v]:
                    flag = True

        # print(dist)

        if not flag:
            break

        if flag and i == N - 1:
            return None

    return dist[N - 1]
 
if __name__ == '__main__':
    solve()
import math

N = int(input())
end = int(math.sqrt(N))+1
ans = len(str(N))

for a in range(1,end):
  if N%a == 0:
    b = N//a
    ans = min(ans, len(str(max(a,b)))
print(ans)


### FIXED CODE ###

N = int(input())

import math

end = int(math.sqrt(N))+1
ans = len(str(N))

for a in range(1,end):
  if N % a ==0:
    b = N//a
    ans = min(ans, len(str(max(a,b))))
print(ans)
a = int(input())
b = int(input())
if a > 8 or b > 8:
    print(":(")
else:
    print("Yay!")

### FIXED CODE ###

a,b = map(int,input().split())
if a > 8 or b > 8:
    print(":(")
else:
    print("Yay!")
from collections import defaultdict
import math
data = {}


def solve(n, a):
    if n == 2 and a[0] == a[1]:
        return a[0]
    n_dict = defaultdict(int)
    for i in range(len(a)):
        for j in range(len(list(a)) - i + 1):
            n_dict[math.gcd(a[i], a[j + i - 1])] += 1
    return sorted(n_dict.items(), key=lambda x: x[0])[1][0]


def input_from_console():
    n = int(input())
    a = list(map(int, input().split()))
    return n, a


def main():
    n, a_list = input_from_console()
    print(solve(n, a_list))


if __name__ == "__main__":
    main()


### FIXED CODE ###


def gcd(a, b):
    if b == 0:
        return a
    elif a == 0:
        return b
    else:
        return gcd(b, a % b)


def solve(n, a):
    l, r = [], []
    l = [0 for i in range(n + 1)]
    r = [0 for i in range(n + 1)]
    r[n] = 0

    for i in range(0, n):
        if i == 0:
            l[0] = 0
        else:
            l[i] = gcd(l[i - 1], a[i - 1])

    for i in range(n, 0, -1):

        if i == n:
            r[i] = 0
        else:
            r[i] = gcd(r[i+1], a[i])
    m = 0
    for i in range(n):
        # print('m', m)
        m = max(m, gcd(l[i], r[i + 1]))
    return m


def input_from_console():
    n = int(input())
    a = list(map(int, input().split()))
    return n, a


def main():
    n, a_list = input_from_console()
    print(solve(n, a_list))


if __name__ == "__main__":
    main()
x = int(input())
glad = x//*1000 + x%500//5*5
print(glad)


### FIXED CODE ###

x = int(input())
glad = x//500*1000 + x%500//5*5
print(glad)
N, K = list(map(int, input().split(' ')))
S = list(input())

def change():
    check = S[0]
    k = 1
    while S[k] == check:
        k += 1
    i = 0
    while S[k + i] != check:
        S[k + i] = check
        i += 1

group = 1
old = S[0]
happy_num = 0
for i in range(1, N):
    if old == S[i]:
        group += 1
        if i == N - 1:
            happy_num += group - 1
    else:
        happy_num += group - 1
        old = S[i]
        group = 1
print(happy_num)

border = 0
for k in range(K):
    old = S[0]
    for i in range(1, N):
        if old != S[i]:
            border += 1
            if border == 2:
                break
            old = S[i]
    if border == 0:
        break
    elif border == 1:
        happy_num += 1
        S[1:] = S[0]
    else:
        happy_num += 2
        change()

print(happy_num)

### FIXED CODE ###

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

def change():
    check = S[0]
    k = 1
    while S[k] == check:
        k += 1
    i = 0
    while S[k + i] != check:
        S[k + i] = check
        i += 1

group = 1
old = S[0]
happy_num = 0
for i in range(1, N):
    if old == S[i]:
        group += 1
        if i == N - 1:
            happy_num += group - 1
    else:
        happy_num += group - 1
        old = S[i]
        group = 1
#print(happy_num)


old = S[0]
border = 0
for i in range(1, N):
    if old != S[i]:
        border += 1
        old = S[i]
#print(border)

changed = 2 * K
if changed < border:
    print(happy_num + 2 * K)
else:
    print(N - 1)
# -*- coding: utf-8 -*-
A, B, M = map(int,  input().split())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
sum = [0] * (A * B)

for i in range(M):
        x, y, c = map(int,  input().split())
        sum[(y-1)*A + (x-1)] = -c

for ia in range(A):
        for ib in range(B):
                sum[ib*A + ia] += a[ia] + b[ib]

sum.sort()

i=0
while sum[i] < 0:
        i+=0
print(sum[i])

### FIXED CODE ###

# -*- coding: utf-8 -*-
A, B, M = map(int,  input().split())
a = list(map(int,input().split()))
b = list(map(int,input().split()))

sum = []
for i in range(M):
        x, y, c = map(int,  input().split())
        sum.append(a[x-1]  + b[y-1] - c)

a.sort()
b.sort()

sum.append(a[0] + b [0])

sum.sort()

i=0
while sum[i] < 0:
        i+=0
print(sum[i])
x = int(input())
L = [n**k for n in range(1, x) for k in range(1, x//2) if n**k<=x]
print (max(L))

### FIXED CODE ###

x = int(input())
if x == 1:
  print(x)
else:
  L = [n**k for n in range(1, x//2) for k in range(2, 10) if n**k<=x]
  print (max(L))
import sys
I = sys.stdin.readline
pr = sys.stdout.write

def main():
	n=int(I())
	ar=list(map(int,I().split()))

	def solve(x):
		if x>=n-2:return abs(ar[n-1]-ar[x])
		return min(abs(ar[x]-ar[x+1])+solve(x+1) , abs(ar[x]-ar[x+2])+solve(x+2))

	pr(solve(0))

if __name__ == '__main__':main()

### FIXED CODE ###

import sys
I = lambda:map(int,sys.stdin.readline().split())
pr = lambda x:sys.stdout.write(f'{x}\n')
sys.setrecursionlimit(2000000001)

mn = lambda w,x,y,z: min(abs(w)+x,abs(y)+z)
n = ar = dp = 0

def solve(x):
	global n,ar,dp
	if x>=n-2: return dp[x]
	if dp[x] != -1: return dp[x]
	dp[x] = mn(ar[x]-ar[x+1], solve(x+1), ar[x]-ar[x+2], solve(x+2))
	# pr(f'{x} => {dp[x]}')
	return dp[x]

def main():
	global n,ar,dp
	n, ar = *I(), [*I()]
	dp = [-1]*(n-2) + [abs(ar[-2]-ar[-1]),0]
	# pr((n,ar,dp))
	pr(solve(0))

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

import bisect

idx_r = bisect.bisect_left(x, 0)

if x[idx_r] == 0:
    idx_l = idx_r
else:
    idx_l = idx_r - 1

ans = 1000000007
    
# right
if 0 <= idx_r + K - 1 < N:
    ans_tmp = x[idx_r + K - 1]
    ans = min(ans, ans_tmp)

# left
if 0 <= idx_l - K + 1 < N:
    ans_tmp = -x[idx_l - K + 1]
    ans = min(ans, ans_tmp)

# right -> left
for i in range(N):
    if idx_r + i >= N or idx_r - K + 1 + i < 0: continue
    ans_tmp = 2 * x[idx_r + i] - x[idx_r - K + 1 + i]
    ans = min(ans, ans_tmp)

# left -> right
for i in range(N):
    if idx_l + K - 1 - i >= N or idx_l - i < 0: continue
    ans_tmp = x[idx_l + K - 1 - i] - 2 * x[idx_l - i]
    ans = min(ans, ans_tmp)

print(ans)

### FIXED CODE ###

# encoding: utf-8
import math
N, K = map(int, input().split())
x = list(map(int, input().split()))

# find position of Mr.Sunuke
for i_snk, xi in enumerate(x):
    if xi >= 0: break

# (left, right) * K patterns, left + right = K
min_dist = (x[-1] - x[0]) * K
for left in range(K + 1):
    right = K - left
    # skip
    # print("#", i_snk, left, right)
    if i_snk - left < 0: continue
    elif right + i_snk > N: continue
    # calc dist
    left_x = x[i_snk - left]
    right_x = x[i_snk + right - 1]
    tocorner = int(min(math.fabs(left_x), math.fabs(right_x)))
    side2side = right_x - left_x
    # print("##", i_snk, left_x, right_x, tocorner + side2side)
    if tocorner + side2side < min_dist: min_dist = tocorner + side2side

print(min_dist)
S = input()
print(S[0] + string(len(S)-2) + S[len(S)-1])

### FIXED CODE ###

S = input()
print(S[0] + str(len(S)-2) + S[len(S)-1])
n=int(input())
a=list(map(int,input().split()))
q=int(input())
sum=sum(a)
a2,a3=[],[]
import bisect as bs

for i in set(a):
    a2.append(i)
    a3.append(a.count(i))

#print(sum)
#print(a2,a3)

def idx(l,x):
    return bs.bisect_left(l,x)

for i in range(q):
    b,c=map(int,input().split())
    if b in a2 and c in a2:
        b_idx=idx(a2,b)
        c_idx=idx(a2,c)
        sum+=(c-b)*a3[b_idx]
        a3[c_idx]+=a3[b_idx]
        a3[b_idx]=0
    elif b in a2:
        a2.append(c)
        b_idx=idx(a2,b)
        sum+=(c-b)*a3[b_idx]
        a3.append(a3[b_idx])
        a3[b_idx]=0
#    print(a2,a3)
    print(sum)

### FIXED CODE ###

n=int(input())
a=list(map(int,input().split()))
q=int(input())
sum=sum(a)

count=[0]*(10**5+1)

for i in a:
    count[i]+=1

for i in range(q):
    b,c=map(int,input().split())
    if count[b]!=0:
        sum+=(c-b)*count[b]
        count[c]+=count[b]
        count[b]=0
    print(sum)
def main():
  _map = map
  _range = range
  _len = len
  _max = max
  _input = input
  _int = int
  n, m = _map(_int, _input().split())
  d1 = {}
  for _ in _range(n):
    a, b = _map(_int, _input().split())
    if a in d1:
      d1[a].append(b)
    else:
      d1[a] = [b]
  result = 0
  d2 = {}
  maxb = -1
  maxbn = -1
  for i in _range(1, m + 1):
    if i in d1:
      for j in d1[i]:
        if j not in d2:
          d2[j] = 0
        d2[j] += 1
        if j > maxb:
          maxbn = maxb
          maxb = j
        elif j > maxbn
          maxbn = j
    else:
      if _len(d2) == 0:
        continue
    result += maxb
    if d2[maxb] == 1:
      del d2[maxb]
      if _len(d2) == 0:
        maxb = -1
        maxbn = -1
      else:
        if maxbn != -1:
          maxb = maxbn
          maxbn = -1
        else:
          maxb = _max(d2.keys())
    else:
      d2[maxb] -= 1
  print(result)
main()

### FIXED CODE ###

n, m = map(int, input().split())
d1 = {}
for _ in range(n):
  a, b = map(int, input().split())
  if a in d1:
    d1[a].append(b)
  else:
    d1[a] = [b]
result = 0
d2 = {}
maxb = -1
for i in range(1, m + 1):
  if i in d1:
    for j in d1[i]:
      if j not in d2:
        d2[j] = 0
      d2[j] += 1
      if j > maxb:
        maxb = j
  else:
    if len(d2) == 0:
      continue
  result += maxb
  if d2[maxb] == 1:
    del d2[maxb]
    if len(d2) == 0:
      maxb = 0
    else:
      maxb = max(d2.keys())
  else:
    d2[maxb] -= 1
print(result)
n,m = (int(i) for i in input().split())
x = [int(i) for i in input().split()]

if m == 1:
	print(0)
else:
	x.sort()

	tupple_diff_x = (x[i+1] - x[i] for i in range(m-1))

	list_diff_x = list(tupple_diff_x)

	for i in range(n-1):
		list_diff_x.remove(max(list_diff_x))

	print(sum(list_diff_x))

### FIXED CODE ###

n,m = (int(i) for i in input().split())
x = [int(i) for i in input().split()]

if n >= m:
	print(0)
else:
	sorted_x = sorted(x)
 
	diff_x = []
	diff = 0
	result = 0
 
	for i in range(m-1):
		diff = sorted_x[i+1] - sorted_x[i]
		result += diff
		diff_x.append(diff)

	sorted_diff = sorted(diff_x, reverse=True)[:n-1]
 
	for i in range(n-1):
		result -= sorted_diff[i]
	 
	print(result)
t = int(input())
for i in range(t):
    able = "Yes"
    a,b,c,d = map(int, input().split())
    if a - b < 0:
        able = "No"
    else:
        x = c+(a-c)%b
        if x <= c:
            x+=d
        for i in range(10000):
            x-=b
            if x >= 0:
                if x <= c:
                    x+=d
            else:
                able = "No"
                break
    print(able)

### FIXED CODE ###

n = int(input())
a= list(input().split())
res = 0
for i in range(n-1):
    if a[i] == a[i+1]:
        a[i+1]=10001
        res +=1
print(res)
s1,s2,s3=list(map(str,input().split()))
print(s1[:5] +''+ s2[:7] +''+ s3[:5])

### FIXED CODE ###

s1,s2,s3=list(map(str,input().split(',')))
print(s1 , s2 , s3)
from heapq import heappush, heappop
INF = 10 ** 20

def main():
  while True:
    n, m, l, k, a, h = map(int, input().split())
    if n == 0:
      break
    if l != 0:
      sisetu = list(map(int, input().split())) + [a, h]
    else:
      input()
      sisetu = [a, h]
  
    costs = [[INF] * n for _ in range(n)]
    for _  in range(k):
      x, y, t = map(int, input().split())
      costs[x][y] = t
      costs[y][x] = t
    for k in range(n):
      costsk = costs[k]
      for i in range(n):
        costsi = costs[i]
        costsik = costsi[k]
        for j in range(i + 1, n):
          costsij = costsi[j]
          costsikj = costsik + costsk[j]
          if costsij > costsikj:
              costsi[j] = costsikj
              costs[j][i] = costsikj
  
    edges = [[] for _ in range(n)]
    for i in range(n):
      for j in range(i + 1, n):
        if i in sisetu and j in sisetu and costs[i][j] <= m:
          edges[i].append((costs[i][j], j))
          edges[j].append((costs[i][j], i))
  
    que = []
    heappush(que, (0, a))
    cost = [INF] * n
    cost[a] = 0
    while que:
      total, node = heappop(que)
      for dist, to in edges[node]:
        if total + dist < cost[to]:
          cost[to] = total + dist
          heappush(que, (total + dist, to))
    if cost[h] == INF:
      print("Help!")
    else:
      print(cost[h] + max(0, (cost[h] - m)))

main()


### FIXED CODE ###

from heapq import heappop, heappush
INF = 10 ** 20

def main():
  while True:
    n, m, l, k, a, h = map(int, input().split())
    if n == 0:
      break
  
    if l == 0:
      input()
      sisetu = [a, h]
    else:
      sisetu = list(map(int, input().split()))
      sisetu += [a, h]
  
    edges = [[] for _ in range((m + 1) * n)]
    for _ in range(k):
      x, y, t = map(int, input().split())
      for i in range(t, m + 1):
        edges[i * n + x].append((t, (i - t) * n + y))
        edges[i * n + y].append((t, (i - t) * n + x))
    
    for node in sisetu:
      for i in range(m):
        edges[i * n + node].append((1, (i + 1) * n + node))
  
    que = []
    heappush(que, (0, m * n + a))
    costs = [INF] * ((m + 1) * n)
    costs[m * n + a] = 0
    
    while que:
      total, node = heappop(que)
      for dist, to in edges[node]:
        if costs[to] > total + dist:
          costs[to] = total + dist
          heappush(que, (total + dist, to))
    ans = min([costs[i * n + h] for i in range(m + 1)])
    if ans == INF:
      print("Help!")
    else:
      print(ans)

main()
n,t=list(input())
ts = list(input())
print(sum([min(t, next - prev) for prev, next in zip(ts, ts[1:])], t))

### FIXED CODE ###

n,t = list(map(int,input().split()))
ts = list(map(int,input().split()))
print(sum([min(t, next - prev) for prev, next in zip(ts, ts[1:])], t))
a

### FIXED CODE ###

N, L = map(int, input().split())
S = []
for _ in range(N):
    S.append(input())

S1 = sorted(S)

S2 ="".join(S1)

print(S2)
d,t,s=intput().split()
d1=s*t
if d<=d1:
  print("Yes")
else:
  print("No)

### FIXED CODE ###

d,t,s=input().split()
d=int(d)
t=int(t)
s=int(s)
d1=s*t
if d<=d1:
  print("Yes")
else:
  print("No")
while True:
  H, W = map(int, raw_input().split())
  for i in range(H):
    width = ""
    for j in range(W):
      width += "#"
    print width
  print ""

### FIXED CODE ###

while True:
  H, W = map(int, raw_input().split())
  if H == 0 and W == 0:
    break
  for i in range(H):
    width = ""
    for j in range(W):
      width += "#"
    print width
  print ""
import math
import numpy as np

N = input()
l = N.split()

print(np.lcm(int(l[0]), int(l[1])))

### FIXED CODE ###

N = input()
L = N.split()
a = int(L[0])
b = int(L[1])

if a < b:
    c = a
    a = b
    b = c

r = a % b
    
while r != 0:
    a = b
    b = r
    r = a % b

# この時のbが最大公約数

print(int(int(L[0])*int(L[1])/b))
n,m = map(int,input().split())
des = [0]*(n+1)
a = 1

for i in range(0,m):
  b = (list(map(int,input().split()))
  if b[0] == 1:
    des[b[1]] += 1
    if des[b[1]] == 2:
      print('possible')
      a = 0
      break
    
    if b[1]  == n:
      des[b[0]] += 1
      if des[b[0]] == 2:
        print ('possible')
        a = 0
        break
if a:
  print('impossible')

### FIXED CODE ###

import sys 

N,M  = map(int,input().split())
     
a = [[0 for i in range(2)] for j in range(M)]
b = [] 
c = []

for i in range(M):
  a[i][0] , a[i][1] = map(int,input().split())
  first, second = a[i][0],a[i][1]
  if first == 1:
    b.append(second)
  if second == N:
    c.append(first)

b_set = set(b)
c_set = set(c)

if list(b_set & c_set) is None or len(list(b_set & c_set)):
  res = ('POSSIBLE')
else:
  res = ('IMPOSSIBLE')

print(res)
N,K,Q = (int(i) for i in input().split())

points = [K-Q for i in range(N)]
for i in range(Q):
  A = int(input()) - 1
  points(A) += 1

for i in range(Q):
  if points[i] <= 0:
    print("No")
  else:
    print("Yes")


### FIXED CODE ###

N,K,Q = (int(i) for i in input().split())

points = [K-Q for i in range(N)]
for i in range(Q):
  A = int(input()) - 1
  points[A] += 1

for i in range(N):
  if points[i] <= 0:
    print("No")
  else:
    print("Yes")
import sys
sys.setrecursionlimit((10 ** 5) * 2)
 
def kai(a):
  if a == 1:
    return 1
  else:
    return a*kai(a-1)
  
N = int(input())
S = input()
count = 0
ans = 1
 
for i, s in enumerate(S):
  if ((s == "W") & (i%2 == 0)) or ((s == "B") & (i%2 == 1)):
    ans *= (i - (count*2))
    count += 1

other = N - count
if other != 0:
  ans *= (kai(other*2)//(2**other))
 
print(kai(ans)%(10**9 + 7))

### FIXED CODE ###

N = int(input())
S = input()
count = 0
ans = 1
m = 10**9 + 7
 
for i in range(N):
  if S[2*i] == "W":
    ans = ans * ((2*i) - (count*2))%m
    count += 1
  if S[2*i + 1] == "B":
    ans = ans * ((2*i + 1) - (count*2))%m
    count += 1
 
if count != N:
  print(0)
else:
  for o in range(1, N+1):
    ans *= o
    ans %= m
  print(ans % m)