Harryxun/sft_time huggingface dataset:
### BUGGY CODE ###

n, k, q = map(int, input().split())
a = sorted([0] + list(int(input()) for _ in range(q)))
p = [k - q] * (n + 1)

for i in range(1, n + 1):
    p[i] += a.count(i)
    
for j in range(1, n + 1):
    if p[j] > 0:
        print('Yes')
    else:
        print('No')  

### FIXED CODE ###

n, k, q = map(int, input().split())
a = [0] + list(int(input()) for _ in range(q))
p = [k - q] * (n + 1)

for i in range(1, q + 1):
    p[a[i]] += 1
    
for j in range(1, n + 1):
    if p[j] > 0:
        print('Yes')
    else:
        print('No')
### BUGGY CODE ###

N = int(input())
a=list(map(int, input().split()))
Q = int(input())
num_a =[0]*100001
b=[]
c=[]
for i in range(Q):
  b1,c1=map(int, input().split())
  b.append(b1)
  c.append(c1)
for i in range(Q):
  if b[i] not in a:
    continue
  else:
    num_a[b[i]] = a.count(b[i])
num_b = []
for i in range(Q):
  if num_a[b[i]]==0:
    num_b.append(0)
  else:
    num_b.append(num_a[b[i]])
    num_a[c[i]] += num_a[b[i]]
    num_a[b[i]] = 0
sum = sum(a)
for i in range(Q):
  sum = sum - b[i]*num_b[i] +c[i]*num_b[i]
  print(sum)

### FIXED CODE ###

N = int(input())
a=list(map(int, input().split()))
Q = int(input())
num_a =[0]*100001
num_b = []
sum_a = sum(a)
b=[]
c=[]
for i in a:
  num_a[i]+= 1
for i in range(Q):
  b1,c1=map(int, input().split())
  b.append(b1)
  c.append(c1)
for i in range(Q):
  if num_a[b[i]]==0:
    num_b.append(0)
    sum_a = sum_a - b[i]*num_b[i] +c[i]*num_b[i]
  else:
    num_b.append(num_a[b[i]])
    num_a[c[i]] += num_a[b[i]]
    num_a[b[i]] = 0
    sum_a = sum_a - b[i]*num_b[i] +c[i]*num_b[i]
  print(sum_a)
### BUGGY CODE ###

n,q=map(int,input().split())
s=input()
def c1(num1,num2):
    return s[num1-1:num2].count("AC")
for i in range(q):
    l,r=map(int,input().split())
    print(c1(l,r))


### FIXED CODE ###

n,q=map(int,input().split())
s=input()
num=[0]
for i in range(n-1):
    if s[i+1]=="C" and s[i]=="A":
        num.append(num[-1]+1)
    else:
        num.append(num[-1])
for i in range(q):
    l,r=map(int,input().split())
    print(num[r-1]-num[l-1])
### BUGGY CODE ###

import sys
input = sys.stdin.readline
N, W = map(int, input().split())
vmax = 1000*100+1
wmax = 100*10**9
dp = [wmax] * vmax
dp[0] = 0

for i in range(N):
    wi, vi = map(int, input().split())
    ndp = dp[:]
    for j in range(vi, vmax):
        ndp[j] = min(dp[j], dp[j-vi] + wi)
    dp = ndp

v = 0
for i, w in enumerate(dp):    
    if w == wmax:
        continue
    if w <= W:
        v = i
print(v)



### FIXED CODE ###

import sys
input = sys.stdin.readline
N, W = map(int, input().split())
vmax = 1000*100+1
wmax = 100*10**9
dp = [wmax] * vmax
dp[0] = 0
 
for i in range(N):
    wi, vi = map(int, input().split())
    ndp = dp[:]
    for j in range(vi, vmax):
        ndp[j] = min(dp[j], dp[j-vi] + wi)
    dp = ndp

v = 0
for i, w in enumerate(dp):    
    if w == wmax:
        continue
    if w <= W:
        v = i
print(v)
### BUGGY CODE ###

#!/usr/bin/env python3
import sys
input = sys.stdin.readline

R, C, k = map(int, input().split())
field = [[0] * C for _ in range(R)]
for _ in range(k):
    r, c, v = map(int, input().split())
    r -= 1; c -= 1
    field[r][c] = v

# dp[taken 0 - 2][R][C]
dp = [[-1] * (C + 1) * (R + 1) for _ in range(4)]
dp0 = dp[0]; dp1 = dp[1]; dp2 = dp[2]; dp3 = dp[3]
dp[0][0] = 0
for j in range(C):
    for i in range(R):
        for k in range(4):
            ij = i * C + j
            ij1 = ij + 1
            i1j = ij + C
            item = field[i][j]
            # Use
            if item and k < 3:
                dp[k+1][ij1] = max(dp[k+1][ij1], dp[k][ij] + item) 
                dp0[i1j] = max(dp0[i1j], dp[k][ij] + item) 
            # No use down
            if dp[k][ij] > dp0[i1j]:
                dp0[i1j] = dp[k][ij]
            # No use right
            if dp[k][ij] > dp[k][ij1]:
                dp[k][ij1] = dp[k][ij]

ans = 0
for i in range(4):
    for j in range(R + 1):
        ans = max(ans, dp[i][j * C + C - 1])
print(ans)

### FIXED CODE ###

#!/usr/bin/env python3
import sys
input = sys.stdin.readline

R, C, k = map(int, input().split())
field = [[0] * C for _ in range(R)]
for _ in range(k):
    r, c, v = map(int, input().split())
    r -= 1; c -= 1
    field[r][c] = v

# dp[taken 0 - 2][R][C]
dp = [[-1] * (C + 1) * (R + 1) for _ in range(4)]
dp0 = dp[0]; dp1 = dp[1]; dp2 = dp[2]; dp3 = dp[3]
dp[0][0] = 0
for j in range(C):
    for i in range(R):
        ij = i * C + j
        ij1 = ij + 1
        i1j = ij + C
        item = field[i][j]
        # Use
        if item:
            dp1[ij1] = max(dp1[ij1], dp0[ij] + item) 
            dp0[i1j] = max(dp0[i1j], dp0[ij] + item) 
        dp0[i1j] = max(dp0[i1j], dp0[ij]) 
        dp0[ij1] = max(dp0[ij1], dp0[ij]) 
        if item:
            dp2[ij1] = max(dp2[ij1], dp1[ij] + item) 
            dp0[i1j] = max(dp0[i1j], dp1[ij] + item) 
        dp0[i1j] = max(dp0[i1j], dp1[ij]) 
        dp1[ij1] = max(dp1[ij1], dp1[ij]) 
        if item:
            dp3[ij1] = max(dp3[ij1], dp2[ij] + item) 
            dp0[i1j] = max(dp0[i1j], dp2[ij] + item) 
        dp0[i1j] = max(dp0[i1j], dp2[ij]) 
        dp2[ij1] = max(dp2[ij1], dp2[ij]) 
        dp0[i1j] = max(dp0[i1j], dp3[ij]) 
        dp3[ij1] = max(dp3[ij1], dp3[ij]) 

ans = 0
for i in range(4):
    for j in range(R + 1):
        ans = max(ans, dp[i][j * C + C - 1])
print(ans)
### BUGGY CODE ###

N = int(input())
F = 10

for i in range(1,N+1):
    if N%i==0:
        F=min(F,max(len(str(i)),len(str(int(N/i)))))
print(F)


### FIXED CODE ###

N = int(input())
F = 11

for i in range(1,int((N+1)**0.5)+1):
    if N%i==0:
        F=min(F,max(len(str(i)),len(str(int(N/i)))))
print(F)
### BUGGY CODE ###

#!/mnt/c/Users/moiki/bash/env/bin/python
N,P = list(map(int, input().split()))
import math


def get_prime(n):
    """ Returns  a list of primes < n """
    sieve = [True] * n
    for i in range(3,int(n**0.5)+1,2):
        if sieve[i]:
            sieve[i*i::2*i]=[False]*((n-i*i-1)//(2*i)+1)
    return [2] + [i for i in range(3,n,2) if sieve[i]]

primax = int(1e8) #+ 8 * int(1e6)
primes = get_prime(primax)
# print(primes)


def df(P, p):
    if P >= p:
        cnt = 0
        while P >= p and P % p == 0:
            P = int(P//p)
            cnt += 1
        return cnt
    else:
        raise "P , p error."

gc = []
for p in primes:
    if P % p == 0:
        cnt = df(P, p)
        P = int( P // int(p**cnt))
        gc.append([p, cnt])
        # P = int(P//p)
ans = 1
for g,cnt in gc:
    if cnt >= N:
        ans *= g**(cnt//N)

print(ans)
# print(primes)k
# print(gc)

### FIXED CODE ###

#!/mnt/c/Users/moiki/bash/env/bin/python
N,P = list(map(int, input().split()))
import math

if N == 1:
    print(P)
    exit(0)

def get_prime(n):
    """ Returns  a list of primes < n """
    sieve = [True] * n
    for i in range(3,int(n**0.5)+1,2):
        if sieve[i]:
            sieve[i*i::2*i]=[False]*((n-i*i-1)//(2*i)+1)
    return [2] + [i for i in range(3,n,2) if sieve[i]]

primax = int(1e7) + 9 * int(1e6)
primes = get_prime(primax)
# print(primes)



def df(P, p):
    if P >= p:
        cnt = 0
        while P >= p and P % p == 0:
            P = int(P//p)
            cnt += 1
        return cnt
    else:
        raise "P , p error."

gc = []
for p in primes:
    if P % p == 0:
        cnt = df(P, p)
        P = int( P // int(p**cnt))
        gc.append([p, cnt])
ans = 1
for g,cnt in gc:
    if cnt >= N:
        ans *= g**(cnt//N)

debug = 1
for g,cnt in gc:
    debug *= g**cnt

# N > 100:  why WA
# debug < P: under 3 RE
# debug*2 > P:  None
if P > 1e9 and debug != P and  debug < P and N == 1:
    raise "errror"
print(ans)
### BUGGY CODE ###

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

MOD = 998244353

dp = [[0]*(s+1) for i in range(n+1)]
dp[0][0] = 1

for i in range(n):
    for ss in range(s+1):
        if(ss >= a[i]):
            dp[i+1][ss] = (dp[i][ss]*2 % MOD + dp[i][ss-a[i]] % MOD)%MOD
        else:
            dp[i+1][ss] = dp[i][ss]*2 % MOD

print(dp[n][s])

### FIXED CODE ###

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

MOD = 998244353

dp = [[0]*(s+1) for i in range(n+1)] #動的計画法を用いる
dp[0][0] = 1

for i in range(n):
    for ss in range(s+1):
        if(ss >= a[i]):
            dp[i+1][ss] = (dp[i][ss]*2 + dp[i][ss-a[i]])%MOD #非常に大きな数になると考えられるため先にMOD計算を行う
        else:
            dp[i+1][ss] = dp[i][ss]*2 % MOD

print(dp[n][s])
### BUGGY CODE ###

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

class UnionFind:
    def __init__(self, val):
        self.parent = self
        self.val = val
        self.rank = 0

    def get_root(self):
        n = self
        while n.parent is not n:
            n = n.parent
        return n

    def find_set(self):
        return self.get_root().val


friends = []
for i in range(n + 1):
    friends.append(UnionFind(i))

graph = [[] for _ in range(n + 1)]
for _ in range(m):
    a, b = map(int, input().split())
    graph[a].append(b)
    graph[b].append(a)
    x, y = friends[a], friends[b]
    x_root, y_root = x.get_root(), y.get_root()
    if x_root.rank == y_root.rank:
        y_root.parent = x_root
        x_root.rank += 1
    elif x_root.rank > y_root.rank:
        y_root.parent = x_root
    else:
        x_root.parent = y_root

block = [[] for _ in range(n + 1)]
for _ in range(k):
    c, d = map(int, input().split())
    block[c].append(d)
    block[d].append(c)


labels = [None] * (n + 1)
for i in range(1, n + 1):
    if labels[i] is None:
        x = friends[i]
        counter = 0
        connected = []
        for j in range(i, n + 1):
            y = friends[j]
            if x.find_set() == y.find_set():
                counter += 1
                connected.append(j)
        for c in connected:
            labels[c] = [i, counter]
ans = []
for i in range(1, n + 1):
    num = labels[i][1] - 1
    for j in graph[i]:
        if labels[i][0] == labels[j][0]:
            num -= 1
    for k in block[i]:
        if labels[i][0] == labels[k][0]:
            num -= 1
    ans.append(num)
print(*ans)

### FIXED CODE ###

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

graph = [[] for _ in range(n + 1)]
for _ in range(m):
    a, b = map(int, input().split())
    graph[a].append(b)
    graph[b].append(a)

block = [[] for _ in range(n + 1)]

for _ in range(k):
    c, d = map(int, input().split())
    block[c].append(d)
    block[d].append(c)

def dfs(graph, start):
    visited = set([start])
    stack = []
    can_reach = set([start])
    for f in graph[start]:
        stack.append(f)
        can_reach.add(f)
    while stack:
        friend = stack.pop()
        visited.add(friend)
        candidates = graph[friend]
        for c in candidates:
            if c not in visited:
                can_reach.add(c)
                stack.append(c)
    return can_reach

labels = [None] * (n + 1)
for i in range(1, n + 1):
    if labels[i] is None:
        c = dfs(graph, i)
        for j in c:
            labels[j] = [i, len(c)]

ans = []
for i in range(1, n + 1):
    num = labels[i][1] - 1
    for j in graph[i]:
        if labels[i][0] == labels[j][0]:
            num -= 1
    for k in block[i]:
        if labels[i][0] == labels[k][0]:
            num -= 1
    ans.append(num)
print(*ans)
### BUGGY CODE ###

a, b, k = map(int, input().split())
x = [i for i in range(a, b+1)]
y = set(x[:k])
z = set(x[-k:])
ans = y | z
ans1 = sorted(list(ans))
for i in ans1:
  print(i)

### FIXED CODE ###

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

if (b-a +1) <= 2 * k:
  for i in range(a,b+1):
    print(i)
else:
  for i in range(a, a+k):
    print(i)
  for i in range(b-k+1, b+1):
    print(i)
### BUGGY CODE ###

n = int(input())
X = input()
pc = X.count('1')
nx = int(X, 2)

def f(n):
    c = 0
    while n > 0:
        n %= bin(n).count('1')
        c += 1
    return c

tmp = pow(2, n)
nxp = nx%(pc+1)
nxm = nx%(pc-1) if pc > 1 else 0
for i in range(n-1, -1, -1):
    if (nx>>i)&1:
        # 2**iを引く
        if pc-1 == 0:
            print(0)
            continue
        p = pow(2, i, pc-1)
        r = (nx-p)%(pc-1)
    else:
        # 2**iを足す
        r = (nx+pow(2, i, pc+1))%(pc+1)

    if r > 0:
        print(f(r) + 1)
    else:
        print(1)
    

### FIXED CODE ###

n = int(input())
X = input()
pc = X.count('1')
nx = int(X, 2)

def f(n):
    c = 0
    while n > 0:
        n %= bin(n).count('1')
        c += 1
    return c

nxp = nx%(pc+1)
nxm = nx%(pc-1) if pc > 1 else 0
for i in range(n-1, -1, -1):
    if (nx>>i)&1:
        # 2**iを引く
        if pc-1 == 0:
            print(0)
            continue
        p = pow(2, i, pc-1)
        r = (nxm-p)%(pc-1)
    else:
        # 2**iを足す
        r = (nxp+pow(2, i, pc+1))%(pc+1)

    print(f(r) + 1)
### BUGGY CODE ###

n = int(input())
a = list(map(int, input().split()))
b=0
for i in range(n):
  print(a.count(i+1))

### FIXED CODE ###

n = int(input())
a = list(map(int, input().split()))
b=0
c = [0]*n+[0]
for i in range(n-1):
  c[a[i]] +=1
for j in range(1,n+1):
  print(c[j])
### BUGGY CODE ###

import math
from functools import reduce
 
def gcd(*numbers):
    return reduce(math.gcd, numbers)
 
def gcd_list(numbers):
    return reduce(math.gcd, numbers)

t = 0
k= int(input(''))+1
for l in range(1,k):
    for m in range(1,k):
        for n in range(1,k):
            if l==m and m==n:
                t+=l
            elif l==m:
                t+=math.gcd(l,n)
            elif l==n:
                t+=math.gcd(l,m)
            elif m==n:
                t+=math.gcd(l,m)
            else:
                t+= gcd_list([l,m,n])
#            print("{}/{}/{} -> {}".format(l,m,n,gcd(l,m,n)))

print(t)


### FIXED CODE ###

import math
from functools import reduce
 
def gcd(*numbers):
    return reduce(math.gcd, numbers)
 
def gcd_list(numbers):
    return reduce(math.gcd, numbers)

t = 0
k= int(input(''))+1

#cnt={}

for l in range(1,k):
    for m in range(l,k):
        for n in range(m,k):
#            print("{}/{}/{}".format(l,m,n))
#            key = '-'.join(map(str,sorted([l,m,n])))
#            if not key in cnt.keys():
#                cnt[key] = 0
#            cnt[key]+=1
            if l==m and l==n:
                t+= gcd_list([l,m,n])
#                print("{}/{}/{} -> {} a".format(l,m,n,gcd(l,m,n)))
            elif l==m or l==n or m ==n:
                t+= gcd_list([l,m,n])*3
#                print("{}/{}/{} -> {} b".format(l,m,n,gcd(l,m,n)))
            elif l!=m and m!=n:
                t+= gcd_list([l,m,n])*6
#                print("{}/{}/{} -> {} c".format(l,m,n,gcd(l,m,n)))

#for a,b in cnt.items():
#    print("{} -> {}".format(a,b))
print(t)
### BUGGY CODE ###

import sys
from collections import deque
readline = sys.stdin.buffer.readline
def even(n): return 1 if n%2==0 else 0
 
H,W = map(int,readline().split())
sh,sw = map(int,readline().split())
gh,gw = map(int,readline().split())
sh,sw = sh-1,sw-1
gh,gw = gh-1,gw-1
maze = []
for _ in range(H):
    maze += [list(readline().rstrip().decode())]
visited = [[10**9]*W for _ in range(H)] #必要な最小ワープ回数
deq = deque([(0,sh,sw)])
visited[sh][sw] = 0
ans = 10**9
while deq:
    rp,h,w = deq.pop()
    if h == gh and w == gw:
        ans = min(ans,rp)
        continue
    for i in range(5):
        for j in range(5):
            if 0 <= h+i-2 < H and 0 <= w+j-2 < W:
                if maze[h+i-2][w+j-2] == ".":
                    if abs(i-2)+abs(j-2) <= 1:
                            if visited[h+i-2][w+j-2] > rp:
                                deq.append((rp,h+i-2,w+j-2))
                                visited[h+i-2][w+j-2] = rp
                    else:
                        if visited[h+i-2][w+j-2] > rp+1:
                            deq.append((rp+1,h+i-2,w+j-2))
                            visited[h+i-2][w+j-2] = rp+1
print(ans if ans != 10**9 else -1)

### FIXED CODE ###

import sys
import heapq
push = heapq.heappush
pop = heapq.heappop
readline = sys.stdin.buffer.readline
def even(n): return 1 if n%2==0 else 0
 
H,W = map(int,readline().split())
sh,sw = map(int,readline().split())
gh,gw = map(int,readline().split())
sh,sw = sh-1,sw-1
gh,gw = gh-1,gw-1
maze = []
for _ in range(H):
    maze.append(readline().rstrip().decode())
visited = [[10**6]*W for _ in range(H)] #必要な最小ワープ回数
hp = []
push(hp,(0,sh,sw))
visited[sh][sw] = 0
while hp:
    rp,h,w = pop(hp)
    if visited[h][w] < rp:
        continue
    if h == gh and w == gw:
        print(rp)
        exit()
    for i in range(5):
        for j in range(5):
            if i == 2 and j == 2:
                continue
            if 0 <= h+i-2 < H and 0 <= w+j-2 < W:
                if maze[h+i-2][w+j-2] == ".":
                    if abs(i-2)+abs(j-2) <= 1:
                            if visited[h+i-2][w+j-2] > rp:
                                push(hp,(rp,h+i-2,w+j-2))
                                visited[h+i-2][w+j-2] = rp
                    else:
                        if visited[h+i-2][w+j-2] > rp+1:
                            push(hp,(rp+1,h+i-2,w+j-2))
                            visited[h+i-2][w+j-2] = rp+1
print(-1)
### BUGGY CODE ###

def f(n):
    return n * (n+1) // 2

N = int(input())
ans = 0
for i in range(N):
    i += 1
    ans += i * f(N//i)
print(ans)


### FIXED CODE ###

N = int(input())
table = [0] * (N + 1)
for i in range(1, N + 1):
    for j in range(i, N + 1, i):
        table[j] += 1
ans = 0
for i in range(N):
    i += 1
    ans += i * table[i]
print(ans)
### BUGGY CODE ###

N, Q = map(int, input().split())
query = []
for i in range(Q):
    v, w = map(int, input().split())
    if v < w:
        v, w = w, v
    query.append((v - 1, w - 1))


def f(v, w):
    L = set()
    L.add(0)
    while w != 0:
        L.add(w)
        w = (w - 1) // N
    while v != 0:
        if v in L:
            return v + 1
        v = (v - 1) // N
    return 1


for v, w in query:
    print(f(v, w))



### FIXED CODE ###

import sys
N, Q = map(int, input().split())
query = []
for i in range(Q):
    v, w = map(int, input().split())
    if v < w:
        v, w = w, v
    query.append((v - 1, w - 1))


def f(v, w):
    L = set()
    L.add(0)
    while w != 0:
        L.add(w)
        w = (w - 1) // N
    while v != 0:
        if v in L:
            return v + 1
        v = (v - 1) // N
    return 1

if N==1:
    for v, w in query:
        print(w+1)
    sys.exit()
for v, w in query:
    print(f(v, w))
### BUGGY CODE ###

N=int(input())
A=[int(x) for x in input().split()]
bit= [bin(x ^ y) for x in A for y in A]
B=set(bit)
AA=[]
for a in A:
  AA.append(bin(a))
if all(a in B for a in AA):
  print("Yes")
else:
  print("No")

### FIXED CODE ###

import collections
N=int(input())
A=[int(x) for x in input().split()]
AA=sorted(A)
c=collections.Counter(A)
third=N//3
answer="No"

#文字が全部0
if all(a==0 for a in A):
  answer="Yes"

#0aa0aaという並びに出来る
#0がN/3個,aが2N/3個で数字は二種類
elif len(c)==2 and N%3==0:
  if all(a==0 for a in AA[:third]):
    answer="Yes"
     
#abc,abc...,abcという並びに出来る
#aがN/3個,bがN/3個,cがN/3個で数字は三種類
elif len(c)==3 and N%3==0:
  if A.count(AA[0])==third and \
  A.count(AA[third])==third and \
  A.count(AA[2*third])==third:
    if bin(AA[0]^AA[third])==bin(AA[2*third]) and \
    bin(AA[third]^AA[2*third])==bin(AA[0]) and \
    bin(AA[2*third]^AA[0])==bin(AA[third]):
      answer="Yes"
    
print(answer)
### BUGGY CODE ###

N=int(input())
A=list(map(int,input().split()))
ans=N
for i in range(N-1):
  sum=A[i]
  xsum=A[i]
  for j in range(i+1,N):
    if sum+A[j]!=xsum^A[j]:
      break
    sum+=A[j]
    xsum=xsum^A[j]
    ans+=1
print(ans)

### FIXED CODE ###

N=int(input())
A=list(map(int,input().split()))
xsum,sum=A[0],A[0]
ans,x,y=0,0,0
flag=True
while flag:
  if xsum==sum:
    ans+=(x-y+1)
    x+=1
    if x==N:
      break
    sum+=A[x]
    xsum^=A[x]
  else:
    sum-=A[y]
    xsum^=A[y]
    y+=1
print(ans)
### BUGGY CODE ###

import heapq

n, m = map(int, input().split())
info = [list(map(int, input().split())) for i in range(m)]

tree = [[] for i in range(n)]
for i in range(m):
    a, b = info[i]
    a -= 1
    b -= 1
    tree[a].append(b)

set_ = set([])
for i in range(n):
    for j in tree[i]:
        set_.add(j)

start = set([])
for i in range(n):
    if i not in set_:
        start.add(i)

q = []
for i in start:
    heapq.heappush(q, (0, i))
dp = [0]*n
while q:
    cnt, pos = heapq.heappop(q)
    for next_pos in tree[pos]:
        if cnt + 1 > dp[next_pos]:
            dp[next_pos] = cnt + 1
            heapq.heappush(q, (cnt + 1, next_pos))
print(max(dp))

### FIXED CODE ###

import sys


input = sys.stdin.readline
sys.setrecursionlimit(200000)

n, m = map(int, input().split())
info = [list(map(int, input().split())) for i in range(m)]
tree = [[] for i in range(n)]
start_point = [True] * n
for i in range(m):
    tree[info[i][0] - 1].append(info[i][1] - 1)
    start_point[info[i][1] - 1] = False
     
dp = [-1]*n

def dfs(pos):
    if dp[pos] !=-1:
        return dp[pos]
    if not tree[pos]:
        dp[pos] = 0
        return 0
    ans = 0
    for i in tree[pos]:
        ans = max(ans, dfs(i) + 1)
    dp[pos] = ans
    return ans

for i in range(n):
    dfs(i)
print(max(dp))
### BUGGY CODE ###

n=int(input())
for i in range(1,n+1):
    e=0
    for j in range(1,101):
        for k in range(1,101):
            for l in range(1,101):
                if((j*j)+(k*k)+(l*l)+(j*k)+(k*l)+(l*j)==i):
                    e=e+1
    print(e)

### FIXED CODE ###

from math import sqrt, floor

N = int(input())
d = [0] * (N+1)

k = floor(sqrt(N))
for x in range(1, k):
    for y in range(1, k):
        for z in range(1, k):
            c = x*x + y*y + z*z + x*y + y*z + z*x
            if 1 <= c <= N:
                d[c] += 1


for i in range(1, N+1):
    print(d[i])
### BUGGY CODE ###

import sys
N,Y=map(int,input().split())

total = 0

for a in range(N+1):
    for b in range(N+1):
        if a + b > N:
            continue
        for c in range(N+1):
            if a + b + c > N:
                break
            total = 10000 * a + 5000 * b + 1000 * c
            if total == Y and a + b + c == N:
                print(a,b,c)
                sys.exit()
print(-1,-1,-1)

### FIXED CODE ###

import sys
N,Y=map(int,input().split())

total = 0

for a in range(N+1):
    for b in range(N+1):
        c = N - (a + b)
        if c < 0:continue
        total = 10000 * a + 5000 * b + 1000 * c
        if total == Y and a + b + c == N:
            print(a,b,c)
            sys.exit()
print(-1,-1,-1)
### BUGGY CODE ###

from decimal import Decimal, getcontext

getcontext().prec = 10

N = int(input())
p = [0] + list(map(Decimal, input().split()))

#print(p)

dp = [[0 for a in range(3100)] for b in range(3100)]
#dp[i][j] = i枚目までのコインを投げて，表の個数がj枚である確率

dp[1][0] = 1-p[1]
dp[1][1] = p[1]

for i in range(2, N + 1):
    for j in range(i+1):
        dp[i][j] = (dp[i-1][j-1] * p[i] + dp[i-1][j] * (1-p[i]))
        #dp[i][j] = i-1枚目までで表がj-1かつi回目で表　＋　i-1回目までで表がj枚かつi回目で裏（MECE）
        #print(i, j, dp[i][j])

ans = Decimal(0)

for k in range(-(-N//2), N+1):
    ans += dp[N][k]

print(ans)

### FIXED CODE ###

import numpy as np

N = int(input())
p = [0] + list(map(float, input().split()))

dp = np.zeros((3100, 3100))
#dp[i, j] = i枚目までのコインを投げて，表の個数がj枚である確率
#pythonのlistだと遅いので，numpyにおけるベクトル漸化式としてdpを埋めていく

dp[1, 0] = 1-p[1]
dp[1, 1] = p[1]

for i in range(2, N + 1):
    dp[i] = np.roll(dp[i-1], 1) * p[i] + dp[i-1] * (1-p[i])
    #dp[i][j] = i-1枚目までで表がj-1かつi回目で表　＋　i-1回目までで表がj枚かつi回目で裏（MECE）
    #つまり，dp[i][j] = dp[i-1][j-1] * p[i] + dp[i-1][j] * (1 - p[i])
    #numpyを使ってベクトル漸化式と見ることで，for_loopを一層分解消。
    #print(i, j, dp[i][j])

ans = 0

for k in range(-(-N//2), N+1):
    ans += dp[N, k]

print(ans)
### BUGGY CODE ###

N,M=map(int,input().split())

div=10**9+7
n=1
m=1
diff=abs(N-M)
for i in range(N):
    n*=(i+1)%div
for i in range(M):
    m*=(i+1)%div

if diff>1:
    ans=0
elif diff==0:
    ans=(2*n*m)%div
elif diff==1:
    ans=(n*m)%div
print(ans)

### FIXED CODE ###

N, M = map(int, input().split())
MOD = 10 ** 9 + 7
nn = 1
mm = 1
for i in range(1, N + 1):
  nn = (nn * i) % MOD
for j in range(1, M + 1):
  mm = (mm * j) % MOD
if abs(N - M) >= 2:
  ans = 0
elif abs(N - M) == 1:
  ans = (nn * mm) % MOD
else:
  ans = (2 * nn * mm) % MOD
print(ans)