Harryxun/stf_run huggingface dataset:
N = int(input())
A = map(int, input().split())

count = -1
flag = True

while flag == True:
    count += 1
    for i in range(N):
        if A[i]%2 == 0:
            A[i] /= 2

        else:
            flag = False
            break



print(count)


### FIXED CODE ###

s = input()
t = 0
if s[0] == "1":
    t += 1

if s[1] == "1":
    t += 1

if s[2] == "1":
    t += 1

print(t)
a,b=list(map(int, input().aplit()))
if a<=b:
    print(a)
else:
    print(a-1)

### FIXED CODE ###

a,b=list(map(int, input().split()))
if a<=b:
    print(a)
else:
    print(a-1)
while True:
    (H, W) = [int(x) for x in input().split()]
    if H == W == 0:
        break

    for hc in range(H):
        for wc in range(W):
            if hc == 0 or hc == H - 1 or wc == 0 or wc == W - 1:
                print('#' , end = ' ')
            else:
                print('.',  end = ' ')
          print()
    print()

### FIXED CODE ###

while True:
    (H, W) = [int(x) for x in input().split()]
    if H == W == 0:
        break

    for hc in range(H):
        if hc == 0 or hc == H -1:
            print('#' * W)
        else:
            print('#' + '.' * (W -2) + '#')
    print()
from collections import *
import sys


def is_all_tarverse(start, mem, town_mem):

    if len(town_mem) == len(paths):
        return True

    for nxt in paths[start]:
        edge = frozenset((start, nxt))
        if edge in mem: continue
        if is_all_tarverse(nxt, mem | {edge}, town_mem | {nxt}):
            return True

    return False


paths = defaultdict(set)

a = input()
while a:
    st, dt = [int(x) for x in a.split()]
    paths[st].add(dt)
    paths[dt].add(st)
    a = input()

for start in paths:
    if is_all_tarverse(start, set(), {start}):
        print('YES')
        sys.exit()

print('NO')



### FIXED CODE ###


from collections import *
import sys


def is_all_tarverse(start, mem, town_mem):

    if len(town_mem) == len(paths):
        return True

    for nxt in paths[start]:
        edge = frozenset((start, nxt))
        if edge in mem: continue
        if is_all_tarverse(nxt, mem | {edge}, town_mem | {nxt}):
            return True

    return False


paths = defaultdict(set)

for _ in range(3):
    a = input()
    st, dt = [int(x) for x in a.split()]
    paths[st].add(dt)
    paths[dt].add(st)


for start in paths:
    if is_all_tarverse(start, set(), {start}):
        print('YES')
        sys.exit()

print('NO')
#import
#import math
#import numpy as np
N = int(input())
#= input()
#= map(int, input().split())
#= list(map(int, input().split()))
#= [input(), input()]
#= [list(map(int, input().split())) for _ in range(N)]
#= {i:[] for i in range(N)}
T = [int(input()) for _ in range(N)]


def gcd(x, y):
    if x < y:
        t = x
        x = y
        y = t

    if y == 0:
        return x

    else:
        return gcd(y, x % y)


if N == 1:
    print(T[0])

res = T[0] * T[1] // gcd(T[0], T[1])

if N > 2:
    for i in range(2, N):
        r = res * T[i] // gcd(res, T[i])
        res = max(r, res)

print(res)

### FIXED CODE ###

N = int(input())
T = [int(input()) for _ in range(N)]


def gcd(x, y):
    if x < y:
        t = x
        x = y
        y = t

    if y == 0:
        return x

    else:
        return gcd(y, x % y)


if N == 1:
    print(T[0])
    exit()

res = T[0] * T[1] // gcd(T[0], T[1])

if N > 2:
    for i in range(2, N):
        r = res * T[i] // gcd(res, T[i])
        res = max(r, res)

print(res)
import statistics
K,N = map(int,input().split())
A = [int(n) for n in input().split()]

a1 = max(A)-min(A)

max_v = 0
for i in range(len(A)-1):
    A_i = None
    if (A[i+1]-A[i])>max_v:
        max_v = A[i+1]-A[i]
        A_i = i+1

a2 = A[A_i-1]+abs(K-A[A_i])
print(a2) if a1>a2 else print(a1)

### FIXED CODE ###

import statistics
K,N = map(int,input().split())
A = [int(n) for n in input().split()]

a1 = max(A)-min(A)

max_v = 0
A_i = None
for i in range(len(A)-1):
    if (A[i+1]-A[i])>max_v:
        max_v = A[i+1]-A[i]
        A_i = i+1

a2 = A[A_i-1]+abs(K-A[A_i])
print(a2) if a1>a2 else print(a1)
n, m = map(int,input().split())
drink = []
for i in range(n):
  drink.append(list(map(int,input().split())))
sorteddrink = sorted(drink, key = lambda x:x[0])

count = 0
cost = 0
index = 0

while True:
  if count + sorteddrink[index][1] > m:
    break
  cost += sorteddrink[index][0] * sorteddrink[index][1]
  count += sorteddrink[index][1]
  index += 1
  
cost += sorteddrink[index][0] * (m - count)
print(cost)

### FIXED CODE ###

n, m = map(int,input().split())
drink = []
for i in range(n):
  drink.append(list(map(int,input().split())))
sorteddrink = sorted(drink, key = lambda x:x[0])

count = 0
cost = 0
index = 0

while True:
  if index > n - 1:
    break
  if count + sorteddrink[index][1] > m:
    break
  cost += sorteddrink[index][0] * sorteddrink[index][1]
  count += sorteddrink[index][1]
  index += 1

if index <= n - 1:
  cost += sorteddrink[index][0] * (m - count)
print(cost)
s = input()
K = int(input())
result = []
alphabet = list("abcdefghijklmnopqrstuvwxyz")

for u in alphabet:
    for i in range(len(s)):
        if s[i] == u:
            for j in range(K):
                result.append(s[i:i + j + 1])
    if len(result) > K:
        break
result = list(set(result))
result.sort()
print(result[K - 1])


### FIXED CODE ###

s = input()
K = int(input())
subs = []
for i in range(0, len(s)):
    for j in range(i + 1, K + i + 1 if i + K <= len(s) else len(s) + 1):
        subs.append(s[i:j])


subs = list(set(subs))

subs.sort()
print(subs[K - 1])
import sys
input = sys.stdin.readline
n,m = map(int,input().split())
chk = []
for i in range(n):
  a,b =  map(int,input().split())
  if a <= m:
    chk.append((-b,a))

from heapq import heapify, heappop, heappush
from operator import itemgetter
chk = sorted(chk,key=itemgetter(1))

s = []
heapify(s)
ans = 0
if chk == []:
  print(0)
  exit()
  
cnt = chk[0][1]
for i in chk:
  a,b = i
  if b == cnt:
    heappush(s,i)
  if b > cnt:
    r,t = heappop(s)
    ans -= r
    heappush(s,i)
    cnt = b
  
for i in range(m-cnt+1):
  r,t = heappop(s)
  ans -= r    
print(ans)

### FIXED CODE ###

import sys
input = sys.stdin.readline
n,m = map(int,input().split())
chk = []
for i in range(n):
  a,b =  map(int,input().split())
  if a <= m:
    chk.append((a,b))

from heapq import heappop, heappush
from operator import itemgetter
chk = sorted(chk,key=itemgetter(0),reverse=True)

q = []
ans = 0
for i in range(1, m + 1):
    while chk and chk[-1][0] <= i:
        a,b = chk.pop()
        heappush(q,-b)
    if q:
        ans -= heappop(q)
print(ans)
number = int(input())
lower = list(map(int, input().split()))

time = 0
max = 0

def down(i):
    global max
    global time

    if max > (number-i+1):
        break

    for j in range(i, number-1):
        if lower[j] >= lower[j+1]:
            time += 1
        else:
            return


for i in range(len(lower)):
    down(i)
    if max < time:
        max = time
    time = 0

print(max)


### FIXED CODE ###

number = int(input())
lower = list(map(int, input().split()))

time = 0
max = 0

def down(i):
    global time
    for j in range(i, number-1):
        if lower[j] >= lower[j+1]:
            time += 1
        else:
            return j+1

    return 0

now = 0
for i in range(len(lower)):

    if now > i:
        continue

    if max > (number-i+1):
        break

    now = down(i)

    if max < time:
        max = time
    time = 0



print(max)
# ABC072d
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**6)

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

ans = 0
for i in range(n):
    if p[i] == i+1:
        t = p[i]
        p[i] = p[i+1]
        p[i+1] = t
        ans += 1
print(ans)


### FIXED CODE ###

# ABC072d
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**6)

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

ans = 0
for i in range(n):
    if p[i] == i+1:
        if i == n-1:
            ans += 1
            continue
        t = p[i]
        p[i] = p[i+1]
        p[i+1] = t
        ans += 1
print(ans)
n = int(input())
lis = [list(map(int, input().split())) for i in range(n)]

ans = 0
for i in range(n):
    for j in range(i+1, n):
        ans += ((lis[i][0] - lis[j][0]) ** 2 + (lis[i][1] - lis[j][1]) ** 2) ** 0.5

ans *= 2/N
print(ans)

### FIXED CODE ###

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

ans = 0
for i in range(n):
    for j in range(i+1, n):
        ans += ((lis[i][0] - lis[j][0]) ** 2 + (lis[i][1] - lis[j][1]) ** 2) ** 0.5

ans *= 2/n

print(ans)
N = input()
List = map(int, input().split())
newList = sorted(List)[::-1]
print(sum(List[::2]) - sum(List[1::2]))

### FIXED CODE ###

N = input()
List = map(int, input().split())
nList = sorted(List)[::-1]
print(sum(nList[::2]) - sum(nList[1::2]))
inp = input().strip()
print len( [ for i in range( len(inp)-1 ) if inp[i] != inp[i+1] ] )

### FIXED CODE ###

inp = raw_input().strip()
print len( [ i for i in range( len(inp)-1 ) if inp[i] != inp[i+1] ] )
but=list(map(int,input()))
but = sorted(but)
res = but[-1]
but = sorted(but)
res += but[-1]
print(res)


### FIXED CODE ###


but=list(map(int,input().split()))
but = sorted(but)
res = but[-1]
but[-1] -= 1
but = sorted(but)
res += but[-1]
print(res)
from bisect import *
from collections import *
from itertools import *
import functools
import sys
import math
from decimal import *
from copy import *
from heapq import *
from fractions import *
getcontext().prec = 30
MAX = sys.maxsize
MAXN = 1000001
MOD = 10**9+7
spf = [i for i in range(MAXN)]
spf[0]=spf[1] = -1
def sieve():
    for i in range(2,MAXN,2):
        spf[i] = 2
    for i in range(3,int(MAXN**0.5)+1):
        if spf[i]==i:
            for j in range(i*i,MAXN,i):
                if spf[j]==j:
                    spf[j]=i
def fib(n,m):
    if n == 0:
        return [0, 1]
    else:
        a, b = fib(n // 2)
        c = ((a%m) * ((b%m) * 2 - (a%m)))%m
        d = ((a%m) * (a%m))%m + ((b)%m * (b)%m)%m
        if n % 2 == 0:
            return [c, d]
        else:
            return [d, c + d]

def charIN(x= ' '):
    return(sys.stdin.readline().strip().split(x))

def arrIN(x = ' '):
    return list(map(int,sys.stdin.readline().strip().split(x)))

def ncr(n,r):
    num=den=1
    for i in range(r):
        num = (num*(n-i))%MOD
        den = (den*(i+1))%MOD

    return (num*(pow(den,MOD-2,MOD)))%MOD

def flush():
    return sys.stdout.flush()

'''*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*'''
n,m = arrIN()

d = defaultdict(list)

for i in range(m):
    a,b = input().split()
    d[int(a)].append(b)
ca = pe = 0
for i in range(1,n+1):
    if "AC" in d[i]:
        ca+=1
        pe+=d[i].index("AC")
print(ca,de)

### FIXED CODE ###

from bisect import *
from collections import *
from itertools import *
import functools
import sys
import math
from decimal import *
from copy import *
from heapq import *
from fractions import *
getcontext().prec = 30
MAX = sys.maxsize
MAXN = 1000001
MOD = 10**9+7
spf = [i for i in range(MAXN)]
spf[0]=spf[1] = -1
def sieve():
    for i in range(2,MAXN,2):
        spf[i] = 2
    for i in range(3,int(MAXN**0.5)+1):
        if spf[i]==i:
            for j in range(i*i,MAXN,i):
                if spf[j]==j:
                    spf[j]=i
def fib(n,m):
    if n == 0:
        return [0, 1]
    else:
        a, b = fib(n // 2)
        c = ((a%m) * ((b%m) * 2 - (a%m)))%m
        d = ((a%m) * (a%m))%m + ((b)%m * (b)%m)%m
        if n % 2 == 0:
            return [c, d]
        else:
            return [d, c + d]

def charIN(x= ' '):
    return(sys.stdin.readline().strip().split(x))

def arrIN(x = ' '):
    return list(map(int,sys.stdin.readline().strip().split(x)))

def ncr(n,r):
    num=den=1
    for i in range(r):
        num = (num*(n-i))%MOD
        den = (den*(i+1))%MOD

    return (num*(pow(den,MOD-2,MOD)))%MOD

def flush():
    return sys.stdout.flush()

'''*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*'''
n,m = arrIN()

d = defaultdict(list)

for i in range(m):
    a,b = input().split()
    d[int(a)].append(b)
ca = pe = 0
for i in range(1,n+1):
    if "AC" in d[i]:
        ca+=1
        pe+=d[i].index("AC")
print(ca,pe)
n = int(input())
a = map(int, input().split())

ans = 0
for i in range(len(a)):
  if i != a[i]-1:
    ans += 1
    
if ans <= 2:
  print("YES")
else:
  print("NO")

### FIXED CODE ###

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

ans = 0
for i in range(len(a)):
  if i != a[i]-1:
    ans += 1
    
if ans <= 2:
  print("YES")
else:
  print("NO")
import math


def read_ints():
    return [int(c) for c in input().split()]


def solve(a, b, c, d):
    if a < b:
        return False
    if d < b:
        return False
    if c >= b:
        return True
    e = a % b
    delta = d % b
    if delta == 0:
        return e <= c
    g = math.gcd(b, delta)
    maxv = b - g
    return maxv <= c


def main():
    n = int(input())
    for _ in range(n):
        print("Yes" if solve(*read_ints()) else "No")


if __name__ == '__main__':
    main()

### FIXED CODE ###

import fractions as math


def read_ints():
    return [int(c) for c in input().split()]


def solve(a, b, c, d):
    if a < b:
        return False
    if d < b:
        return False
    if c >= b:
        return True
    e = a % b
    delta = d % b
    if delta == 0:
        return e <= c
    g = math.gcd(b, delta)
    maxv = b - g
    return maxv <= c


def main():
    n = int(input())
    for _ in range(n):
        print("Yes" if solve(*read_ints()) else "No")


if __name__ == '__main__':
    main()
v_num = int(input())
adjacent = [[0 for n in range(v_num)] for m in range(v_num)]
for _ in range(v_num):
    inp = (int(n) for n in input().split(" "))
    for i in inp[2:]:
        adjacent[inp[0] - 1][i - 1] = 1
for i in range(v_num):
    print(*adjacent[i])

### FIXED CODE ###

v_num = int(input())
adjacent = [[0 for n in range(v_num)] for m in range(v_num)]
for _ in range(v_num):
    inp = [int(n) for n in input().split(" ")]
    for i in inp[2:]:
        adjacent[inp[0] - 1][i - 1] = 1
for i in range(v_num):
    print(*adjacent[i])
import numpy as np
n=input()
n=int(n)
a=input().split()
b=np.zeros(n)
div=0
num_8=0
for i in range(n):
 a[i]=int(a[i])
 if a[i]<=399 and a[i]>=1:
  b[i]=0
 elif a[i]>=400 and a[i]<=799:
  b[i]=1
 elif a[i]>=800 and a[i]<=1199:
  b[i]=2
 elif a[i]>=1200 and a[i]<=1599:
  b[i]=3
 elif a[i]>=1600 and a[i]<=1999:
  b[i]=4
 elif a[i]>=2000 and a[i]<=2399:
  b[i]=5
 elif a[i]>=2400 and a[i]<=2799:
  b[i]=6
 elif a[i]>=2800 and a[i]<=3199:
  b[i]=7
 else:
  b[i]=8
  num_8=num_8+1
for i in range(8):
 if i in b:
  div=div+1
min=div
max=div+num_8
if min==0:
 min=1
print(min,max)

### FIXED CODE ###

a=input().split()
b=int(a[0])*100+int(a[1])*10+int(a[2])
if b%4==0:
 print("YES")
else:
 print("NO")
n,w=map(int,input().split())
a=[[0,0] for _ in range(n)]
vw=[[0,0] for _ in range(n)]
for j in range(n):
    a[j][0],a[j][1]=map(int,input().split())
    vw[j][0],vw[j][1]=a[j][1]/a[j][0],j
vw.sort(reverse=True)
print(vw,a)
j=0
v=0
while(w>0):
    print(w,a[vw[j][1]][0],a)
    d=min(w,a[vw[j][1]][0])
    print(d)
    v=v+d*vw[j][0]
    w=w-d
    a[j][1]-=d
    print(v, w, a[j][1],vw[j][0]*d)
    j+=1
  #  print(v,w,a[j][1])
print(int(v))

### FIXED CODE ###

n,w=map(int,input().split())
val=[]
we=[]
for i in range(n):
  a,b=map(int,input().split())
  we.append(a)
  val.append(b)
dp=[[0 for _ in range(w+1)]for _ in range(n+1)]
for i in range(n+1):
  for j in range(w+1):
    if i==0 or j==0:
      continue
    if we[i-1]>j:
      dp[i][j]=dp[i-1][j]
    else:
      dp[i][j]=max(dp[i-1][j],val[i-1]+dp[i-1][j-we[i-1]])
print(dp[n][w])
a = int(input())
s = input()
i = 0
while(i<len(s)-1):
  if s[i] == s[i+1]:
    s.pop(i)
  else:
    i+=1
print(len(s))

### FIXED CODE ###

a = int(input())
s = list(input())
i = 0
while(i<len(s)-1):
  if s[i] == s[i+1]:
    s.pop(i)
  else:
    i+=1
print(len(s))
import itertools as it
import collections as col
import heapq as hq
import sys
import copy as cp
sys.setrecursionlimit(10**9)
input = sys.stdin.readline


def dump(*objects):
    print(*objects, file=sys.stderr)


N = int(input())
A = [0] + list(map(int, input().split())) + [0]
dump(N, A)
B = cp.deepcopy(A)
C = cp.deepcopy(A)
for i in range(1, len(A)):
    dump(i)
    B[i] = B[i-1] + abs(A[i]-A[i-1])
for i in range(len(A)-2, -1, step=-1):
    dump(i)
    C[i] = C[i+1] + abs(A[i]-A[i+1])
dump(A, B, C)
for i in range(1, N+1):
    dump(i, B[i-1] + B[N+1] - B[i+1] + abs(A[i-1]-A[i+1]))
    print(B[i-1] + C[i+1] + abs(A[i-1]-A[i+1]))

exit(0)


### FIXED CODE ###

import itertools as it
import collections as col
import heapq as hq
import sys
import copy as cp
sys.setrecursionlimit(10**9)
input = sys.stdin.readline


def dump(*objects):
    print(*objects, file=sys.stderr)


N = int(input())
A = [0] + list(map(int, input().split())) + [0]
# dump(N, A)
B = cp.deepcopy(A)
C = cp.deepcopy(A)
for i in range(1, len(A)):
    # dump(i)
    B[i] = B[i-1] + abs(A[i]-A[i-1])
for i in range(len(A)-2, -1, step=-1):
    # dump(i)
    C[i] = C[i+1] + abs(A[i]-A[i+1])
# dump(A, B, C)
for i in range(1, N+1):
    # dump(i, B[i-1] + B[N+1] - B[i+1] + abs(A[i-1]-A[i+1]))
    print(B[i-1] + C[i+1] + abs(A[i-1]-A[i+1]))

exit(0)
h, w = map(int, input().split())
rb = ['#'] * (w + 2)
a = [rb + [['#'] + list(input()) + ['#'] for _ in range(h)] + rb]
p = [(i, j) for i in range(1, h + 1) for j in range(1, w + 1) if a[i][j] == '#']
d = (-1, 0), (1, 0), (0, -1), (0, 1)
r = -1
while p:
    r += 1
    s = []
    for i, j in p:
        for di, dj in d:
            di += i
            dj += j
            if a[di][dj] == '.':
                a[di][dj] = '#'
                s.append((di, dj))
    p = s
print(r)


### FIXED CODE ###

h, w = map(int, input().split())
a = [['#'] * (w + 2)] + [['#'] + list(input()) + ['#']
                          for _ in range(h)] + [['#'] * (w + 2)]
p = [(i, j) for i in range(1, h + 1) for j in range(1, w + 1) if a[i][j] == '#']
d = (-1, 0), (1, 0), (0, -1), (0, 1)
r = -1
while p:
    r += 1
    s = []
    for i, j in p:
        for di, dj in d:
            di += i
            dj += j
            if a[di][dj] == '.':
                a[di][dj] = '#'
                s.append((di, dj))
    p = s
print(r)
n, k = map(int,input().split())
a = sorted(list(map(int,input().split())))
def cmb(n, r, mod):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod
mod = 10**9+7
N = 10**4
g1 = [1, 1]
g2 = [1, 1]
inverse = [0, 1]
for i in range( 2, N + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )
ans = 0
for i in range(N-K+1):
  ans += (a[n-1-i]-a[i])*cmb(n-1-i,k-1,mod)
  ans %=  mod
print(ans)

### FIXED CODE ###

n, k = map(int,input().split())
a = sorted(list(map(int,input().split())))
def cmb(n, r, mod):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod
mod = 10**9+7
N = 10**5
g1 = [1, 1]
g2 = [1, 1]
inverse = [0, 1]
for i in range( 2, N + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )
ans = 0
for i in range(n-k+1):
  ans += (a[n-1-i]-a[i])*cmb(n-1-i,k-1,mod)
  ans %=  mod
print(ans)
n, d = list(map(int, split().input()))

### FIXED CODE ###

n, d = list(map(int, input().split()))
count = 0
for i in range(n):
  x, y = list(map(int, input().split()))
  p = x **2 + y **2
  if p <= d**2:
    count += 1
    
print(count)
while True:
	D=input()
	if str.isupper(D):
		print("A")
	else:
		print("a")

### FIXED CODE ###

D=input()
if str.isupper(D):
	print("A")
else:
	print("a")
N = int(input())
A_s = []
for i in range(N):
  A_s.append(int(input()))
  
A_s = np.array(A_s)
  
m_index = A_s.argmax()
sort_A_s = sorted(A_s)
m_value = A_s[m_index]
m_second = sort_A_s[N-2]

for i in range(N):
  if i != m_index:
    print(m_value)
  else:
    print(m_second)

### FIXED CODE ###

import numpy as np

N = int(input())
A_s = []
for i in range(N):
  A_s.append(int(input()))
  
A_s = np.array(A_s)
  
m_index = A_s.argmax()
sort_A_s = sorted(A_s)
m_value = A_s[m_index]
m_second = sort_A_s[N-2]

for i in range(N):
  if i != m_index:
    print(m_value)
  else:
    print(m_second)
def Fib(n, memo={}):
    if n < 2:
        return 1
    elif n in memo:
        return memo[n]
    else:
        memo[n] = Fib(n - 1, memo) + Fib(n - 2, memo)
        return memo[n]


def resolve():
    N, M = [int(i) for i in input().split()]
    aa = []
    for _ in range(M):
        aa.append(int(input()))
    fib_l = list(Fib(i) for i in range(N))

    ans = 1
    now = 0
    for a in aa:
        if now == a:
            ans = 0
            break
        tmp = a - now - 1
        ans = ans * fib_l[tmp]
        now = a + 1
    else:
        ans = ans * fib_l[N - now]
    print(ans % (10**9 + 7))


resolve()


### FIXED CODE ###

def Fib(n, memo={}):
    if n < 2:
        return 1
    elif n in memo:
        return memo[n]
    else:
        memo[n] = Fib(n - 1, memo) + Fib(n - 2, memo)
        return memo[n]


def resolve():
    N, M = [int(i) for i in input().split()]
    aa = []
    for _ in range(M):
        aa.append(int(input()))
    fib_l = list(Fib(i) for i in range(N + 1))

    ans = 1
    now = 0
    for a in aa:
        if now == a:
            ans = 0
            break
        tmp = a - now - 1
        ans = ans * fib_l[tmp]
        now = a + 1
    else:
        ans = ans * fib_l[N - now]
    print(ans % (10**9 + 7))


resolve()
import collections
import math
n=int(input())
s=[''.join(list(input()).sort()) for _ in range(n)]
l=list(collections.Counter(s).values())
def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

c=0
for i in range(len(l)):
    k=int(l[i])
    if k!=1:c+=combinations_count(k,2)
print(c)

### FIXED CODE ###

import collections
import math
n=int(input())
s=[]
for i in range(n):
    sl=list(input())
    sl.sort()
    s.append("".join(sl))

l=list(collections.Counter(s).values())
def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

c=0
for i in range(len(l)):
    k=int(l[i])
    if k!=1:c+=combinations_count(k,2)
print(c)
a = input().split()
if 'Y' in a:
    print(four)
else:
    print(three)

### FIXED CODE ###

N = int(input())
a = input().split()
if 'Y' in a:
    print('Four')
else:
    print('Three')
import sys
input = sys.stdin.readline
a,b=map(int,input().split())
if a=="H":
    print(b)
else:
    if b=="H":
        print("D")
    else:
        print("H")


### FIXED CODE ###

import sys
input = sys.stdin.readline
a,b=input().split()
if a=="H":
    print(b)
else:
    if b=="H":
        print("D")
    else:
        print("H")
n, w = map(int, input().split())
wv = [list(map(int, input().split())) for _ in range(n)]

V_MAX = 10 ** 5 + 1
INF = 10 **18

dp = [[INF] * (V_MAX) for _ in range(n + 1)]
for i in range(n):
  for j in range(V_MAX):
    if wv[i][1] > j:
      dp[i + 1][j + wv[i][1]] = min(dp[i + 1][j + wv[i][0]], dp[i][j] + wv[i][0])
    dp[i + 1][j] = min(dp[i][j], dp[i + 1][j])
print(min([i for i, v in enumerate(dp[-1]) if v <= w]))
      

### FIXED CODE ###

N, W = [int(i) for i in input().split()]
WV = [[int(i) for i in input().split()] for j in range(N)]

import numpy as np
max_value = np.sum(np.array(WV), axis=0)[1]

# dp[v]: 価値vを達成するのに必要な重さの最小値
dp = np.full(max_value + 1, W + 1, dtype='int64')

dp[0] = 0
for w, v in WV:
    # 価値i(0 <= i <= max_value - v)のときの重さの最小値に対し
    # 次の荷物を入れて、価値i+vのときの重さの最小値を更新
    np.minimum(dp[:-v] + w, dp[v:], out=dp[v:])
print(np.max(np.where(dp <= W)))