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

import itertools

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


def main():
	k = []
	s = []
	answers = []

	for i in range(M + 1):
		inputs = list(map(int,input().split()))
		if i == M:
			answers = inputs.copy()
		else:
			k.append(inputs[0])
			s.append(inputs[1:])

	allCandidates = []
	for i in range(N + 1):
		candidates = [1] * i + [0] * (N - i)
		allCandidates.extend(list(itertools.permutations(candidates)))

	result = []
	for c in allCandidates:
		ok = True
		for i, ss in enumerate(s):
			sumBulk = 0
			for sNumber in ss:
				sumBulk += c[sNumber - 1]
			if sumBulk % 2 != answers[i]:
				ok = False
		if ok:
			result.append(c)

	print(len(list(set(result))))

if __name__ == '__main__':
	main()

### FIXED CODE ###

import itertools

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


def main():
	k = []
	s = []
	answers = []

	for i in range(M + 1):
		inputs = list(map(int,input().split()))
		if i == M:
			answers = inputs.copy()
		else:
			k.append(inputs[0])
			s.append(inputs[1:])

	allCandidates = (list(itertools.product(range(2), repeat=N)))

	result = []
	for c in allCandidates:
		ok = True
		for i, ss in enumerate(s):
			sumBulk = 0
			for sNumber in ss:
				sumBulk += c[sNumber - 1]
			if sumBulk % 2 != answers[i]:
				ok = False
		if ok:
			result.append(c)

	print(len(list(set(result))))

if __name__ == '__main__':
	main()
### BUGGY CODE ###

import re

s = input()
cnt = 0

def replace(match):
    global cnt
    if (match.group(1) == None):
        n = len(match.group(0))//2
        w = ["W" for i in range(n)]
        b = ["B" for i in range(n)]
        res = w + b
        cnt += n*(n+1)//2
    else:
        res = ["B" for i in range(len(match.group(1)) - 1)]
        res.insert(0, "W")
        cnt += len(match.group(1)) - 1

    return "".join(res)

while True:
    result = re.subn('(B{2,}W)|(BW)+', replace, s)

    if result[1] == 0:
        print(cnt)
        break
    else:
        s = result[0]

### FIXED CODE ###

s = input()

b = 0
c = 0
for i in range(len(s)):
    if s[i] == "B":
        b += 1
    else:
        c += b

print(c)
### BUGGY CODE ###

import sys

sys.setrecursionlimit(10**7)

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

in_n = lambda: int(readline())
in_nn = lambda: map(int, readline().split())
in_s = lambda: readline().rstrip().decode('utf-8')
in_nl = lambda: list(map(int, readline().split()))
in_nl2 = lambda H: [in_nl() for _ in range(H)]
in_map = lambda: [s == ord('.') for s in readline() if s != ord('\n')]
in_map2 = lambda H: [in_map() for _ in range(H)]
in_all = lambda: map(int, read().split())


def main():

    N = in_n()
    A = in_nl()

    n1, n2, n3 = 0, 0, 0
    for i in range(N):
        if A[i] == 1:
            n1 += 1
        elif A[i] == 2:
            n2 += 1
        elif A[i] == 3:
            n3 += 1

    dp = [[[-1.0 for _ in range(N + 1)] for _ in range(N + 1)] for _ in range(N + 1)]

    def solve(n1, n2, n3):

        if dp[n1][n2][n3] >= 0.0:
            return dp[n1][n2][n3]
        if n1 == n2 == n3 == 0:
            return 0.0

        cnt = n1 + n2 + n3
        ret = 0
        if n3 >= 1:
            ret += solve(n1, n2 + 1, n3 - 1) * n3
        if n2 >= 1:
            ret += solve(n1 + 1, n2 - 1, n3) * n2
        if n1 >= 1:
            ret += solve(n1 - 1, n2, n3) * n1

        ret = (ret + N) / cnt
        dp[n1][n2][n3] = ret
        return ret

    print(solve(n1, n2, n3))


if __name__ == '__main__':
    main()


### FIXED CODE ###

n=int(input())
a=list(map(int,input().split()))
num1,num2,num3=0,0,0
for i in range(n):
    if a[i]==1:
        num1+=1
    elif a[i]==2:
        num2+=1
    else:
        num3+=1
dp=[[[-1.0 for k in range(n+1)] for i in range(n+1)] for j in range(n+1)]
def f(n1,n2,n3):
    if dp[n1][n2][n3]>=0.0:
        return dp[n1][n2][n3]
    if n1==n2==n3==0:
        return 0.0
    ret=n
    if n1>0:
        ret+=f(n1-1,n2,n3)*n1
    if n2>0:
        ret+=f(n1+1,n2-1,n3)*n2
    if n3>0:
        ret+=f(n1,n2+1,n3-1)*n3
    ret*=1.0/(n1+n2+n3)
    dp[n1][n2][n3]=ret
    return dp[n1][n2][n3]
print(f(num1,num2,num3))
### BUGGY CODE ###

# C - Linear Approximation
# https://beta.atcoder.jp/contests/abc102/tasks/arc100_a

# C_Linear_Approximation.py

# 7
# 1 1 1 1 2 3 4
#import sys

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

sum = 0
for i in range(N):
    a[i] = a[i] - (i+1)
    sum += a[i]
#print(a)
A = a[:]
A.sort()
max = A[-1]
min = A[0]

sadnesses = []

for b in range(min, max + 1):
    sadness = 0
    for i in range(N):
        if a[i] > b:
            sadness += a[i] - b
        else:
            sadness += b - a[i]
    sadnesses.append(sadness)

sadnesses.sort()
print(sadnesses[0])


### FIXED CODE ###

# C - Linear Approximation
# https://beta.atcoder.jp/contests/abc102/tasks/arc100_a

# C_Linear_Approximation.py

# 7
# 1 1 1 1 2 3 4
#import sys

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

for i in range(N):
    a[i] = a[i] - (i+1)

a.sort()
if N % 2 != 0:
    mid = (N-1)//2
else:
    mid = N // 2 -1
b = a[mid]

sadness_left = b * mid - sum(a[:mid])
sadness = sum(a) - b * N + sadness_left * 2

print(sadness)
### BUGGY CODE ###

n, m, Q = map(int, input().split())
LR = [[0 for _ in range(n)] for _ in range(n)]
for _ in range(m):
    l, r = map(int, input().split())
    LR[l-1][r-1] += 1

# 各Lについて累積和を取る
LR_rui = [[0] for _ in range(n)]
for i in range(n):
    for j in range(n):
        LR_rui[i].append(LR[i][j]+LR_rui[i][-1])

for _ in range(Q):
    p, q = map(int, input().split())
    ans = 0
    for i in range(p, q+1):
        ans += LR_rui[i-1][q] - LR_rui[i-1][p-1]
    print(ans)



### FIXED CODE ###

n, m, Q = map(int, input().split())
LR = [[0 for _ in range(n)] for _ in range(n)]
for _ in range(m):
    l, r = map(int, input().split())
    LR[l-1][r-1] += 1

# 二次元累積和の作成
LR_rui = [[0 for _ in range(n+1)] for _ in range(n+1)]
# 各Lについての累積
for i in range(n):
    for j in range(n):
        LR_rui[i+1][j+1] = LR_rui[i+1][j]+LR[i][j]
# 各Rについての累積:
for i in range(n):
    for j in range(n):
        LR_rui[i+1][j+1] = LR_rui[i+1][j+1] + LR_rui[i][j+1]

for _ in range(Q):
    p, q = map(int, input().split())
    ans = LR_rui[q][q] - LR_rui[p-1][q] - LR_rui[q][p-1] + LR_rui[p-1][p-1]
    print(ans)
### BUGGY CODE ###

N = int(input())
array = list(map(int,input().split()))
product = 1
for i in array:
  product *= i
  
if product <= 10**18:
  print(product)
else:
  print(-1)

### FIXED CODE ###

N = int(input())
array = list(map(int,input().split()))
product =  1
if 0 in array:
  print(0)
  exit()
for i in array:
  product *= i
  if product > 10**18:
    print(-1)
    exit()
print(product)
### BUGGY CODE ###

k,s =map(int,input().split())
cnt=0
for x in range(0,k+1):
    for y in range(0,k+1):
        for z in range(0,k+1):
            if x+y+z == s:
                cnt+=1

print(cnt)

### FIXED CODE ###

k,s = map(int,input().split())
cnt = 0
for x in range(k+1):
    for y in range(k+1):
        z = s-x-y
        if z >= 0 and z <= k:
            cnt += 1

print(cnt)
### BUGGY CODE ###

inp = input().split()

# for i in range(1,1000000000000000000):
i = 1

while i <= 1000000000000000000:
	if i % int(inp[0])  == 0 and i % int(inp[1]) != 0:
		print(i)
		break
	i *= int(inp[0])


if i >= 1000000000000000000:
	print(-1)

### FIXED CODE ###

inp = input().split()

i = 1
x = 0

while i <= pow(10,18):
	if inp[0] == "1" and inp[1] == "1":
		print(-1)
		x = 1
		break
	if i % int(inp[0])  == 0 and i % int(inp[1]) != 0:
		print(i)
		x = 1
		break
	i *= int(inp[0])

if x == 0:
	print(-1)
### BUGGY CODE ###

def main():
    from collections import Counter
    import sys
    input = sys.stdin.buffer.readline

    _ = int(input())
    A = [int(i) for i in input().split()]

    ans = 0
    c = Counter(A)
    B = sorted(c.keys(), reverse=True)

    for b in B:
        if c[b] == 0:
            continue
        a = (2 ** b.bit_length()) - b
        if a == b:
            cur = c[b]//2
        else:
            if a in c.keys():
                cur = min(c[a], c[b])
            else:
                cur = 0
        ans += cur
        # c[b] -= cur
        c[a] -= cur

    print(ans)


if __name__ == '__main__':
    main()


### FIXED CODE ###

from collections import Counter

n = int(input())
A = [int(i) for i in input().split()]

A.sort(reverse=True)
C = Counter(A)
m = 1 << 30
ans = 0

for a in A:
    if C[a] <= 0:
        continue
    C[a] -= 1
    while m > a * 2:
        m >>= 1
    v = m - a
    if v in C and C[v] > 0:
        C[v] -= 1
        ans += 1

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

#!/usr/bin/env python3
import sys


def solve(H: int, W: int, A: "List[List[int]]", B: "List[List[int]]"):
    ab = [[0]*W for _ in range(H)]

    for h in range(H):
        for w in range(W):
            ab[h][w] = abs(A[h][w]-B[h][w])
    
    # i,jにいるときに作れる値
    setlist = [[set() for _ in range(W)] for _ in range(H)]
    for i in range(H):
        for j in range(W):
            if i == 0 and j == 0:
                setlist[i][j].add(ab[i][j])
                continue

            if  i == 0:
                for num in setlist[i][j-1]:
                    setlist[i][j].add(abs(num+ab[i][j]))
                    setlist[i][j].add(abs(num-ab[i][j]))
                continue

            if j == 0:
                for num in setlist[i-1][j]:
                    setlist[i][j].add(abs(num+ab[i][j]))
                    setlist[i][j].add(abs(num-ab[i][j]))
                continue                
            
            for num in setlist[i-1][j]:
                setlist[i][j].add(abs(num+ab[i][j]))
                setlist[i][j].add(abs(num-ab[i][j]))
            for num in setlist[i][j-1]:
                setlist[i][j].add(abs(num+ab[i][j]))
                setlist[i][j].add(abs(num-ab[i][j]))

    print(min(setlist[H-1][W-1]))
    return



def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    H = int(next(tokens))  # type: int
    W = int(next(tokens))  # type: int
    A = [[int(next(tokens)) for _ in range(W)] for _ in range(H)]  # type: "List[List[int]]"
    B = [[int(next(tokens)) for _ in range(W)] for _ in range(H)]  # type: "List[List[int]]"
    solve(H, W, A, B)

if __name__ == '__main__':
    main()


### FIXED CODE ###

#!/usr/bin/env python3
import sys

def solve(H: int, W: int, A: "List[List[int]]", B: "List[List[int]]"):
    SA=[[0]*W for i in range(H)]
    MAX = (H+W)*80
    for i in range(H):
        for j in range(W):
            SA[i][j]=abs(A[i][j]-B[i][j])

    DP=[[0 for i in range(W)] for j in range(H)]
    DP[0][0]=1<<MAX+SA[0][0]

    for i in range(H):
        for j in range(W):
            tempbit=DP[i][j]
            if i<H-1:
                DP[i+1][j]|=tempbit<<SA[i+1][j]
                DP[i+1][j]|=tempbit>>SA[i+1][j]

            if j<W-1:
                DP[i][j+1]|=tempbit<<SA[i][j+1]
                DP[i][j+1]|=tempbit>>SA[i][j+1]

    ANS=1<<MAX*2
    for i in range(MAX*2+1):
        if 1<<i & DP[-1][-1]!=0:
            ANS=min(ANS,abs(i-MAX))

    print(ANS)
    return



def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    H = int(next(tokens))  # type: int
    W = int(next(tokens))  # type: int
    A = [[int(next(tokens)) for _ in range(W)] for _ in range(H)]  # type: "List[List[int]]"
    B = [[int(next(tokens)) for _ in range(W)] for _ in range(H)]  # type: "List[List[int]]"
    solve(H, W, A, B)

if __name__ == '__main__':
    main()
### BUGGY CODE ###

def popcount(n):
    return bin(n).count('1')

def calc(x):
    ans=0
    while x !=0:
        n=popcount(x)
        ans+=1
        x=x%n

    return ans


N=int(input())
X=int(input(),2)

ans=[]
for i in range(N-1,-1,-1):
    ans.append(calc(X ^ 1<<i))

for i in ans:
    print(i)
    
        
         



### FIXED CODE ###

def mpow(a,b,m):
    ans=1
    while b >0 :
        if b&1:
            ans = (ans*a)%m
        a=(a*a)%m
        b=b>>1

    return ans

def calcmod(X,m,N):
    mod=0
    X=X[::-1]
    # print(X)
    for i in range(N):
        if X[i] == '1':
        # if X & (1<<i) >0:
            mod += mpow(2,i,m)
            mod%=m
    return mod

def popcount(m):
    return bin(m).count("1")


def findsteps(mm):
    cnt=0
    while mm !=0:
        cnt+=1
        mm=mm%popcount(mm)
    return cnt
N=int(input())
x=input()
X=int(x,2)

##we need to find X%(m-1) and X%(m+1)
m=popcount(X)
m1=m+1
m2=m-1
firstmod=calcmod(x,m1,N)
if m2 !=0:
    secondmod=calcmod(x,m2,N)
fans=[0 for i in range(N)]
k=0
for i in range(N-1,-1,-1):
    if X & (1<<i) >0:
        ##the bit was set
        ##we need to find X%(m-1) - (2^i)%(m-1)
        if m2 == 0:
            ans=0
        else:
            mm=secondmod - mpow(2,i,m2)
            if mm < 0:
                mm+=m2
            mm=mm%m2
            ans=1+findsteps(mm)
    else:
        mm = firstmod + mpow(2,i,m1)
        mm=mm%m1
        ans=1+findsteps(mm)
    fans[k] = ans
    k+=1
        ##the bit was not set
for i in fans:
    print(i)
### BUGGY CODE ###

n = int(input())
a = list(map(int, input().split()))
ans = []
for i in range(1, n+1):
    print(a.index(i) + 1)



### FIXED CODE ###

n = int(input())
a = list(map(int, input().split()))
dic = {}
for i in range(n):
    dic[a[i]] = i+1
for i in range(n):
    print(dic[i+1])
### BUGGY CODE ###

import sys
sys.setrecursionlimit(10**6)
from collections import defaultdict
mod = 10**9+7
N = int(input())
g = [[] for _ in range(N)]
d = defaultdict(lambda:-1)
p2 = [1]*(N+1)
p2[1] = pow(2,mod-2,mod)
for i in range(N):
    p2[i+1] = (p2[i]*p2[1])%mod

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

def dfs(i,j):
    if d[(i,j)]!=-1:
        return d[(i,j)]
    res = 1
    for k in g[j]:
        if k==i:
            continue
        res += dfs(j,k)
    d[(i,j)] = res
    return res
dfs(a,b)
dfs(b,a)

ans = 1-p2[N]-N*p2[1]

for i in range(N):
    for j in g[i]:
        if j<i:
            continue
        n = max(d[(i,j)],d[(j,i)])
        ans += (1-p2[n])*(1-p2[N-n])
        ans %= mod

print(ans)


### FIXED CODE ###

from collections import defaultdict,deque
mod = 10**9+7
N = int(input())
g = [[] for _ in range(N)]
d = defaultdict(lambda:-1)
p2 = [1]*(N+1)
p2[1] = pow(2,mod-2,mod)
for i in range(N):
    p2[i+1] = (p2[i]*p2[1])%mod

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

q = deque([[a,b]])
while q:
    i,j = q.pop()
    s = 1
    f = True
    for k in g[j]:
        if k == i:
            continue
        if (j,k) not in d:
            if f:
                q.append([i,j])
            q.append([j,k])
            f = False
        else:
            s += d[(j,k)]
    if f:
        d[(i,j)] = s

q = deque([[b,a]])
while q:
    i,j = q.pop()
    s = 1
    f = True
    for k in g[j]:
        if k == i:
            continue
        if (j,k) not in d:
            if f:
                q.append([i,j])
            q.append([j,k])
            f = False
        else:
            s += d[(j,k)]
    if f:
        d[(i,j)] = s

ans = 1-p2[N]-N*p2[1]

for i in range(N):
    for j in g[i]:
        if j<i:
            continue
        n = max(d[(i,j)],d[(j,i)])
        ans += (1-p2[n])*(1-p2[N-n])
        ans %= mod

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

import sys
from heapq import heappop, heappush
from operator import itemgetter
from collections import deque, defaultdict, Counter
from bisect import bisect_left, bisect_right
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)
MOD = 10**9 + 7
INF = float('inf')

def sol():
    N = int(input())

    def f(i, j):
        return  max(i, j) * N + min(i, j)

    edges = defaultdict(deque)
    deg = defaultdict(int)

    for i in range(1, N + 1):
        A = list(map(int, input().split()))
        for j in range(N - 2):
            edges[f(i, A[j])].append(f(i, A[j + 1]))
            deg[f(i, A[j + 1])] += 1

    que = set()
    for i in range(1, N + 1):
        for j in range(i + 1, N + 1):
            if deg[f(i, j)] == 0:
                que.add(f(i, j))

    que = deque(que)

    L = deque()
    while que:
        now = que.popleft()
        L.append(now)

        while edges[now]:
            to = edges[now].popleft()
            deg[to] -= 1
            if deg[to] == 0:
                que.append(to)

    for _, e in edges.items():
        if e:
            print('-1')
            return

    ans = 0
    while L:
        V = set()
        while L:
            player, enemy = divmod(L[0], N)
            if player in V or enemy in V:
                break
            V.add(player)
            V.add(enemy)
            L.popleft()
        ans += 1

    print(ans)

sol()

### FIXED CODE ###

import sys
from heapq import heappop, heappush
from operator import itemgetter
from collections import deque, defaultdict, Counter
from bisect import bisect_left, bisect_right
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)
MOD = 10**9 + 7
INF = float('inf')


def sol():
    N = int(input())
    A = [deque()] + [deque(map(int, input().split())) for _ in range(N)]

    days = [0] * (N + 1)
    now = [0] * (N + 1)

    que = deque([i + 1 for i in range(N)])

    while que:
        i = que.popleft()
        if not A[i]:
            continue

        a = A[i].popleft()
        if now[a] == i:
            days[a] = days[i] = max(days[a], days[i]) + 1
            que.append(i)
            que.append(a)
            now[a] = now[i] = 0
        else:
            now[i] = a

    for i in range(1, N + 1):
        if A[i]:
            print(-1)
            return
    print(max(days))


sol()
### BUGGY CODE ###

import sys
rr = lambda: sys.stdin.readline().strip()
rri = lambda: int(rr())
rrs = lambda: [int(_) for _ in rr().split()]

N, M = rrs()
A = rrs()

for i in range(M):
    B, C = rrs()
    A.extend([C] * B)

A.sort(reverse=True)

print(sum(A[:N]))

### FIXED CODE ###

import sys
rr = lambda: sys.stdin.readline().strip()
rri = lambda: int(rr())
rrs = lambda: [int(_) for _ in rr().split()]

from operator import itemgetter

N, M = rrs()
A = rrs()

data = [rrs() for _ in range(M)]

data.sort(key=itemgetter(1), reverse=True)

p = 0
for d in data:
    if p <= N:
        A.extend([d[1]] * d[0])
    p += d[0]

A.sort(reverse=True)

print(sum(A[:N]))
### BUGGY CODE ###

N = int(input())
A = []
A = input().split()
A = [int(i) for i in A]
A.sort()
A.reverse()
while True:
    A[0] = A[0] - A[1]
    A.sort()
    A.reverse()
    if A[1] == 0:
        break
print(A[0])


### FIXED CODE ###

import fractions
from functools import reduce
n = int(input())
a_li = list(map(int, input().split()))


def gcd_list(numbers):
    return reduce(fractions.gcd, numbers)


print(gcd_list(a_li))
### BUGGY CODE ###

import sys
from collections import deque

input = sys.stdin.readline
H, W = map(int, input().split())

grid = []
for _ in range(H):
    grid.append(list(input().strip()))

q = deque()
# x, y, count, pre color
q.append((0, 0, 1 if grid[0][0] == "#" else 0, grid[0][0]))

visited = [[-1 for _ in range(W)] for _ in range(H)]
ans = float("inf")
while q:
    x, y, count, pre = q.popleft()
    # print(x, y, count, pre)
    if visited[y][x] != -1 and visited[y][x] < count:
        continue
    visited[y][x] = count

    for dx, dy in ((1, 0), (0, 1)):
        nx = x + dx
        ny = y + dy
        nc = count
        if nx < 0 or W <= nx or ny < 0 or H <= ny:
            continue
        if grid[ny][nx] != pre and grid[ny][nx] == "#":
            nc += 1
        if nx == W-1 and ny == H-1:
            ans = min(ans, nc)
            print(ans)
            sys.exit()
        else:
            if count == nc:
                q.appendleft((nx, ny, nc, grid[ny][nx]))
            else:
                q.append((nx, ny, nc, grid[ny][nx]))

# print(visited)
print(ans)

### FIXED CODE ###

import sys
from collections import deque

input = sys.stdin.readline
H, W = map(int, input().split())

grid = []
for _ in range(H):
    grid.append(list(input().strip()))

q = deque()
# x, y, count, pre color
q.append((0, 0, 1 if grid[0][0] == "#" else 0, grid[0][0]))

visited = [[-1 for _ in range(W)] for _ in range(H)]
ans = float("inf")
while q:
    x, y, count, pre = q.popleft()
    # print(x, y, count, pre)
    v_score = visited[y][x]
    if v_score != -1 and v_score <= count:
        continue
    visited[y][x] = count

    for dx, dy in ((1, 0), (0, 1)):
        nx = x + dx
        ny = y + dy
        nc = count
        if nx < 0 or W <= nx or ny < 0 or H <= ny:
            continue
        n_color = grid[ny][nx]
        if n_color != pre and n_color == "#":
            nc += 1
        if nx == W-1 and ny == H-1:
            ans = min(ans, nc)
            print(ans)
            sys.exit()
        else:
            if visited[ny][nx] != -1 and visited[ny][nx] <= nc:
                continue
            if count == nc:
                q.appendleft((nx, ny, nc, n_color))
            else:
                q.append((nx, ny, nc, n_color))

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

n,k=map(int,input().split())
s=[]
for i in range(k):
    l,r=map(int,input().split())
    for j in range(l,r+1):
        s.append(j)

dp=[0]*n
dp[0]=1

for i in range(0,n):
    for j in range(0,i):
        if i-j in s:
            dp[i]+=dp[j]

print(dp[n-1]%998244353)


### FIXED CODE ###

n,k=map(int,input().split())
k_list=[]

for i in range(k):
    l,r=map(int,input().split())
    k_list.append([l,r])

dp=[0]*(n+1)
dp[1]=1
dpsum=[0]*(n+1)
dpsum[1]=1

for i in range(1,n):
    dpsum[i]=dp[i]+dpsum[i-1]
    for j in range(k):
        l,r=k_list[j]
        li=i+l
        ri=i+r+1
        if li<=n:
            dp[li]+=dpsum[i]
            dp[li]=dp[li]%998244353
        if ri<=n:
            dp[ri]-=dpsum[i]
            dp[ri]=dp[ri]%998244353

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

N = int(input())
A = list(map(int, input().split()))
for a in A:
    if A.count(a) != 1:
        print("NO")
        exit()

print("YES")

### FIXED CODE ###

N = int(input())
A = list(map(int, input().split()))
if len(set(A)) == N:
    print("YES")
else:
    print("NO")
### BUGGY CODE ###

# coding: utf-8
# Your code here!

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

#最小公倍数でよいか？
#全てのjについてAiBiはAjで割り切れる
#計算時間は？
from fractions import gcd
mod =10**9+7
def lcd(x,y):
    g = gcd(x,y)
    return x*y//g

ag = 1
for i in range(n):
    ag = lcd(ag,a[i])

ans = 0

for i in range(n):
    ans += ag//a[i]

ans %=mod

print(ans)


### FIXED CODE ###


from fractions import gcd
import random
n = int(input())
a = list(map(int, input().split( )))
random.shuffle(a)
#最小公倍数でよいか？
#全てのjについてAiBiはAjで割り切れる
#計算時間は？

mod =10**9+7
def lcd(x,y):
    g = gcd(x,y)
    return x*y//g

ag1 = 1
for i in range(n//2):
    ag1 = lcd(ag1,a[i])
ag2 = 1
for i in range(n//2,n):
    ag2 = lcd(ag2,a[i])

ag3 = lcd(ag1,ag2)

ans = 0

for i in range(n//2):
    ans += ag1//a[i]
ans*=ag3//ag1
ans %=mod
ans2 = 0
for i in range(n//2,n):
    ans2 += ag2//a[i]
ans2*= ag3//ag2
ans2%=mod 
ans += ans2
ans %=mod
print(ans)