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

#!/usr/bin/env python
# -*- coding: utf-8 -*-


def main():
  height, width = map(int, input().split())
  max_value = height * width
  values = []
  queue = set()

  for y in range(height):
    values.append([0 if v == '#' else max_value for v in input().strip()])
    queue |= set((x, y) for x, v in enumerate(values[-1]) if v == 0)

  while len(queue) > 0:
    x, y = queue.pop()
    v = values[y][x] + 1

    if x > 0 and values[y][x - 1] > v:
      values[y][x - 1] = v
      queue.add((x - 1, y))

    if x < width - 1 and values[y][x + 1] > v:
      values[y][x + 1] = v
      queue.add((x + 1, y))

    if y > 0 and values[y - 1][x ] > v:
      values[y - 1][x] = v
      queue.add((x, y - 1))

    if y < height - 1 and values[y + 1][x] > v:
      values[y + 1][x] = v
      queue.add((x, y + 1))

  print(max(max(v) for v in values), flush=True)


if __name__ == '__main__':
  main()



### FIXED CODE ###

#!/usr/bin/env python
# -*- coding: utf-8 -*-
import numpy


def main():
  height, width = map(int, input().split())
  max_value = height + width
  values = []

  for y in range(height):
    values.append([0 if v == '#' else max_value for v in input().strip()])

  values = numpy.array(values)

  for x in range(width - 1):
    values[:, x + 1] = numpy.minimum(values[:, x] + 1, values[:, x + 1])

  for x in range(width - 1, 0, -1):
    values[:, x - 1] = numpy.minimum(values[:, x] + 1, values[:, x - 1])

  for y in range(height - 1):
    values[y + 1, :] = numpy.minimum(values[y, :] + 1, values[y + 1, :])

  for y in range(height - 1, 0, -1):
    values[y - 1, :] = numpy.minimum(values[y, :] + 1, values[y - 1, :])

  print(numpy.max(values), flush=True)


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

from math import factorial

n, m = map(int, input().split())
if n == m:
    print(2 * factorial(n)**2 % 1000000007)
elif abs(n - m) < 2:
    print(factorial(max(n, m)) * factorial(min(n, m) % 1000000007))
else:
    print(0)


### FIXED CODE ###

from math import factorial

n, m = map(int, input().split())
if n == m:
    print(2 * factorial(n)**2 % 1000000007)
elif abs(n - m) < 2:
    print(factorial(n) * factorial(m) % 1000000007)
else:
    print(0)
### BUGGY CODE ###

N,W = map(int,input().split())
# wv_list = [tuple(map(int,input().split())) for _ in range(N)]
w_list = []
v_list = []
for i in range(N):
    w,v = map(int,input().split())
    w_list.append(w)
    v_list.append(v)

memo = [[None  for _ in range(W+1)] for _ in range(N+1)]

def rec(check_item,residual_w):
    if memo[check_item][residual_w]:
        return memo[check_item][residual_w]    
    if check_item == N:
        res = 0
    elif residual_w < w_list[check_item]:
        res = rec(check_item+1, residual_w)
    else:
#         print(check_item,residual_w)
        res = max(rec(check_item+1,residual_w),
                  rec(check_item+1,residual_w-w_list[check_item])+v_list[check_item])
    memo[check_item][residual_w] = res
    
    return res

print(rec(0,W))

### FIXED CODE ###

N,W = map(int,input().split())
wv_list = [tuple(map(int,input().split())) for _ in range(N)]

memo = [0  for _ in range(W+1)]

for weight,value in wv_list:
    for w in range(W+1)[::-1]:
        if w  >= weight:
            memo[w] = max(memo[w], memo[w-weight]+value)
            
print(memo[W])
### BUGGY CODE ###

N, H = map(int, input().split())
D = [[0, 0] for i in range(2 * N)]
for i in range(N):
  a, b = map(int, input().split())
  D[2 * i] = [a, 2]
  D[2 * i + 1] = [b, 1]
D.sort(reverse=True)
cnt = 0
while H > 0:
  d = D[0]
  D = D[1:]
  if d[1] == 1:
    H -= d[0]
    cnt += 1
  else:
    k = -(-H // d[0])
    H -= d[0] * k
    cnt += k
print(cnt)

### FIXED CODE ###

N, H = map(int, input().split())
A = 0
B = [0] * (N + 1)
for i in range(N):
  a, b = map(int, input().split())
  A = max(a, A)
  B[i] = b
B.sort(reverse=True)
cnt = 0
i  = 0
while H > 0:
  if B[i] > A:
    H -= B[i]
    cnt += 1
    i += 1
  else:
    k = -(-H // A)
    H -= A * k
    cnt += k
print(cnt)
### BUGGY CODE ###

N, K = map(int, input().split())
lst = [int(x) for x in input().split()]
dp = [100 ** 10] * N
dp[0] = 0
dp[1] = abs(lst[0] - lst[1])
for i in range(2, N):
    j = K
    while j > 0:
        if i - j >= 0:
            tmp = dp[i - j] + abs(lst[i - j] - lst[i])
            dp[i] = min(dp[i], tmp)
        j -= 1
print(dp[-1])


### FIXED CODE ###

import numpy as np

N, K = map(int, input().split())
lst = np.array([int(x) for x in input().split()])
dp = np.zeros(N, dtype=int)

for i in range(1, N):
    start = max(i - K, 0)
    dp[i] = np.min(dp[start:i] + np.abs(lst[start:i] - lst[i]))
print(dp[-1])
### BUGGY CODE ###

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

s = [1] * len(a)
s[0] = a[0]
for i in range(n - 1):
    s[i + 1] = s[i] * a[i + 1]
    
num = [0] * (len(a) - k + 1)
num[0] = s[k - 1]
for i in range(len(a) - k):
    num[i + 1] = s[i + k] // s[i]
    
for i in range(len(a) - k):
    if num[i] < num[i + 1]:
        print('Yes')
    else:
        print('No')

### FIXED CODE ###

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

for i in range(len(a) - k):
    if a[i] < a[i + k]:
        print('Yes')
    else:
        print('No')
### BUGGY CODE ###

#http://compro.tsutajiro.com/archive/180220_probability_dp.pdf
import sys
n = int(input())
a = list(map(int, sys.stdin.readline().split( )))
cnt =[0,0,0]
for i in range(n):
    cnt[3-a[i]] += 1
dp = [[[0 for _ in range(n+1)] for __ in range(n+1)] for ___ in range(n+1)]

dp[n][n][n] = 0
divT = [1/i for i in range(1,n+1)]

for x in range(n,cnt[1]+cnt[2]-1,-1):## -2だったのを-1に
    for y in range(x,cnt[2]-1,-1):##cnt[2]
        for z in range(y,-1,-1):
            delta = n*divT[n-z-1]#2枚以下を引くまで
            if x != n:
                dp[x][y][z] += (dp[x+1][y][z] + delta) * (n-x)
            if y != x:
                dp[x][y][z] += (dp[x][y+1][z] + delta) * (x-y)#x+1,y+1ではない
            if z != y:
                dp[x][y][z] += (dp[x][y][z+1] + delta)* (y-z)#x+1,y+1,z+1ではない
            dp[x][y][z] *=divT[n-z-1]

print(dp[cnt[1]+cnt[2]][cnt[2]][0])


### FIXED CODE ###

#http://compro.tsutajiro.com/archive/180220_probability_dp.pdf
import sys
n = int(input())
a = list(map(int, sys.stdin.readline().split( )))
cnt =[0,0,0]
for i in range(n):
    cnt[3-a[i]] += 1
dp = [[[0 for _ in range(n+1)] for __ in range(n+1)] for ___ in range(n+1)]

dp[n][n][n] = 0
divT = [1/i for i in range(1,n+1)]

for x in range(n,cnt[1]+cnt[2]-1,-1):## -2だったのを-1に
    for y in range(x,cnt[2]-1,-1):##cnt[2]
        for z in range(y,-1,-1):
            delta = n*divT[n-z-1]#2枚以下を引くまで
            if x != n:
                dp[x][y][z] += (dp[x+1][y][z] + delta) * (n-x)
            if y != x:
                dp[x][y][z] += (dp[x][y+1][z] + delta) * (x-y)#x+1,y+1ではない
            if z != y:
                dp[x][y][z] += (dp[x][y][z+1] + delta)* (y-z)#x+1,y+1,z+1ではない
            dp[x][y][z] *=divT[n-z-1]

print(dp[cnt[1]+cnt[2]][cnt[2]][0])
### BUGGY CODE ###

n = int(input())
S = [input() for _ in range(n)]

count = 0
counted = []

for s in S:
  if s in counted:
    continue
  else:
    counted.append(s)
    count += 1
print(count)

### FIXED CODE ###

n = int(input())
S = [input() for _ in range(n)]

import hashlib
base1 = 1007
mod1 = 10**9+7
dic = {}

for s in S:
  hs = hashlib.md5(s.encode()).hexdigest()
  dic.setdefault(hs, s)

print(len(dic))
### BUGGY CODE ###

(m,f,r)=map(int, raw_input().split())
while 1:
    if m==f==r==-1:
        break
    elif m+f>=80:
        print 'A'
    elif m+f>=65:
        print 'B'
    elif m+f>=50:
        print 'C'
    elif m+f>=30 and r>=50:
        print 'C'
    elif m+f>=30:
        print 'C'
    elif m+f<30:
        print 'F'

### FIXED CODE ###

while 1:
    (m,f,r)=map(int, raw_input().split())
    if m==f==r==-1:
        break
    elif m == -1 or f == -1:
        print 'F'
    elif m+f>=80:
        print 'A'
    elif m+f>=65:
        print 'B'
    elif m+f>=50:
        print 'C'
    elif m+f>=30 and r>=50:
        print 'C'
    elif m+f>=30:
        print 'D'
    elif m+f<30:
        print 'F'
### BUGGY CODE ###

# n人がkポイント持っていてq回正解が出る
n, k, q = map(int, input().split())
a = [int(input()) for i in range(q)]

point =[k for j in range(n)]

# q回続ける
# listのn番目の数字は-1しない

for x in range(q):
    for y in range(n) :
        if y + 1 != a[x] :
            point[y] += -1

for z in range(n) :
    if point[z] > 0:
        print("Yes")
    else :
        print("No")

### FIXED CODE ###

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

point = [k - q] * (n + 1)

for _ in range(q):
    point[int(input()) -1] += 1

for z in range(n) :
    if point[z] > 0:
        print("Yes")
    else :
        print("No")
### BUGGY CODE ###

import sys
input = sys.stdin.readline

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

da = [[] for i in range(a)]
d = []
for i in range(b):
    k,kk = map(int,input().split())
    da[k-1].append(kk)
    d.append([k, kk])

for i in da:
    i.sort()

for i in d:
    p = da[i[0]-1].index(i[1])

    n = str(i[0])
    m = str(p+1)

    n = "0"*(6-len(n)) + n
    m = "0"*(6-len(m)) + m

    print(n+m)



### FIXED CODE ###

import sys
input = sys.stdin.readline

a,b = map(int,input().split())
aa = []
d = []
for i in range(b):
    k,kk = map(int,input().split())
    d.append([k, kk,i+1])

da = sorted(d)

kkk = da[0][0]
ll = 0
for i in range(b):
    kkkk = da[i][0]
    if kkk == kkkk:
        ll += 1
    else:
        kkk = kkkk
        ll = 1
    aa.append([da[i][2],da[i][0],ll])
aa.sort()

for i in aa:
    m = str(i[1])
    n = str(i[2])
    m = "0"*(6-len(m))+m
    n = "0"*(6-len(n))+n
    print(m+n)
### BUGGY CODE ###

import numpy as np


def main():
    S = input()
    S = S[::-1]
    _T = 'dreamer', 'dream', 'eraser', 'erase'
    T = []
    for t in _T:
        T.append(t[::-1])
    while 1:
        temp = []
        for t in T:
            if ''.join(S[:len(t)]) == t:
                S = S[len(t):]
        for t in T:
            temp.append(t in S)
        if any(temp) == False:
            break
    if len(S) > 0:
        print('NO')
    else:
        print('YES')


if __name__ == '__main__':
    main()


### FIXED CODE ###

def main():
    S = input()
    S = S[::-1]
    _T = 'dreamer', 'dream', 'eraser', 'erase'
    T = []
    for t in _T:
        T.append(t[::-1])
    i = 0
    while 1:
        temp = []
        bool = True
        for t in T:
            if S[i:len(t) + i] == t:
                i += len(t)
                bool = False
        if bool:
            break
    if len(S) != i:
        print('NO')
    else:
        print('YES')


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

from collections import Counter

maxn = 100000

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

par = [0] * n
rank = [0] * n

#初期化
for i in range(n):
    par[i] = i
    rank[i] = 0

#判定(一番上野根を求める)
def find(x):
    if par[x] == x:
        return x
    else:
        par[x] = find(par[x])
        return par[x]
    
#結合
def unite(x , y):
    rx = find(x)
    ry = find(y)
    
    if rx == ry:
        return
    
    if rank[rx] < rank[ry]:
        par[rx] = ry
    elif rank[rx] > rank[ry]:
        par[ry] = rx
    else:
        par[ry] = x
        rank[rx] += 1

a = [0] * m
b = [0] * m
for i in range(m):
    a[i],b[i] = map(int,input().split())
    a[i] -= 1
    b[i] -= 1
    
nn = [0]*(maxn+1)
for i in range(maxn+1):
    nn[i] = i * (i-1) // 2
    
dis = [0]*m
for i in range(m-1,-1,-1):
    ans = n*(n-1) // 2
    l = [find(j) for j in range(n)]
    ll = Counter(l)
    values, counts = zip(*ll.most_common())
    for j in counts:
        ans -= nn[j]
    dis[i] = ans
    unite(a[i],b[i])
    
for i in range(m):
    print(dis[i])

### FIXED CODE ###

maxn = 100000

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

par = [0] * n
rank = [0] * n
siz = [1] * n

#初期化
for i in range(n):
    par[i] = i
    rank[i] = 0

#判定(一番上野根を求める)
def find(x):
    if par[x] == x:
        return x
    else:
        par[x] = find(par[x])
        return par[x]
    
#結合
def unite(x , y):
    rx = find(x)
    ry = find(y)
    
    if rx == ry:
        return
    
    if rank[rx] < rank[ry]:
        par[rx] = ry
        siz[ry] += siz[rx]
        siz[rx] = 0
    elif rank[rx] > rank[ry]:
        par[ry] = rx
        siz[rx] += siz[ry]
        siz[ry] = 0
    else:
        par[ry] = x
        siz[rx] += siz[ry]
        siz[ry] = 0
        rank[rx] += 1

a = [0] * m
b = [0] * m
for i in range(m):
    a[i],b[i] = map(int,input().split())
    a[i] -= 1
    b[i] -= 1
    
nn = [0]*(maxn+1)
for i in range(maxn+1):
    nn[i] = i * (i-1) // 2
    
dis = [0]*m
ans = n*(n-1) // 2
dis[m-1] = ans
for i in range(m-1,0,-1):
    if find(a[i]) == find(b[i]):
        dis[i-1] = ans
    else:
        ans -= (siz[find(a[i])] * siz[find(b[i])])
        dis[i-1] = ans
        
    unite(a[i],b[i])
    
for i in range(m):
    print(dis[i])
### BUGGY CODE ###

R,C,k=map(int,input().split())
rcv = [[0 for _ in range(C+1)] for _ in range(R+1)]
for i in range(k):
  r,c,v = map(int,input().split())
  rcv[r][c] = v
# dp: 各場所までの合計の最大値
dp = [[[0 for _ in range(4)] for _ in range(C+1)] for _ in range(R+1)]
if rcv[1][1]>0:
  dp[1][1][1] = rcv[1][1]
#print(dp[1][1][1])
for r in range(1,R+1):
  cntmax=1
  for c in range(1,C+1):
    if rcv[r][c] > 0:
      cntmax += 1
    if r*c == 1:
      continue
    for i in range(min(cntmax,4)):
      candi=list()
      if r > 1 and i==0:  #うえからおりてくる、とらない(i=0)
        candi.extend(dp[r-1][c])
      if r > 1 and i==1 and rcv[r][c]>0:  #うえからおりてくる、とる(i=1)
        candi.extend([dp[r-1][c][j]+rcv[r][c] for j in range(4)])
      if c > 1: # ひだりから、とらない(i維持)
        candi.append(dp[r][c-1][i])
        if 0 < i and rcv[r][c]>0:  # ひだりから、とる(i-1から移行)
          candi.append(dp[r][c-1][i-1]+rcv[r][c])
      if len(candi) == 0:
        continue
      dp[r][c][i] = max(candi)
      #print(r,c,i,dp[r][c][i])
print(max(dp[R][C]))

### FIXED CODE ###

R,C,k=map(int,input().split())
rcv = [[0 for _ in range(C+1)] for _ in range(R+1)]
for i in range(k):
  r,c,v = map(int,input().split())
  rcv[r][c] = v
# dp: 各場所までの合計の最大値
dp0=[[0 for _ in range(C+1)] for _ in range(R+1)]
dp1=[[0 for _ in range(C+1)] for _ in range(R+1)]
dp2=[[0 for _ in range(C+1)] for _ in range(R+1)]
dp3=[[0 for _ in range(C+1)] for _ in range(R+1)]
dp1[1][1] = rcv[1][1]
for r in range(1,R+1):
  for c in range(1,C+1):
    dp1[r][c] = max(dp0[r][c]+rcv[r][c],dp0[r][c-1]+rcv[r][c],dp1[r][c-1])
    dp2[r][c] = max(dp1[r][c-1]+rcv[r][c],dp2[r][c-1])
    dp3[r][c] = max(dp2[r][c-1]+rcv[r][c],dp3[r][c-1])
    
    if r < R:
      dp0[r+1][c] = max(dp0[r][c],dp1[r][c],dp2[r][c],dp3[r][c])
print(max(dp0[R][C],dp1[R][C],dp2[R][C],dp3[R][C]))
### BUGGY CODE ###

from collections import Counter
import sys
input = sys.stdin.readline
n = int(input())
a = list(map(int, input().split()))
a_cnt = Counter(a)

a = sorted(list(set(a)))
n = len(a)

ans = 0
memo = set()
for i in range(n):
    flg = True
    if a_cnt[a[i]] == 1:
        for x in range(1, int(a[i] ** 0.5) + 1):
            if a[i] % x == 0:
                if x in memo:
                    flg = False
                    break

                if a[i] // x in memo:
                    flg = False
                    break
        
        if flg:
            ans += 1
    memo.add(a[i])
print(ans)


### FIXED CODE ###

import sys
input = sys.stdin.readline
n = int(input())
a = list(map(int, input().split()))
a.sort()

flg = [True for _ in range(10 ** 6 + 1)]
for i in range(n-1):
    if a[i] == a[i+1]:
        flg[a[i]] = False

ans = 0
for x in set(a):
    if flg[x]:
        ans += 1

    tmp = 1
    while tmp * x <= 10 ** 6:
        flg[tmp * x] = False
        tmp += 1

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

N, T = map(int, input().split())
X = [list(map(int, input().split())) for _ in range(N)]
X.sort()
dp = [-1 for _ in range(T+X[-1][0]+10)]
dp[0] = 0
for i in range(N):
  for j in range(T, 0, -1):
    if dp[j-1] != -1:
      dp[j-1+X[i][0]] = max(dp[j-1+X[i][0]], dp[j-1] + X[i][1])
print(max(dp))

### FIXED CODE ###

N, T = map(int, input().split())
X = [list(map(int, input().split())) for _ in range(N)]
X.sort()
dp = [-1 for _ in range(T+X[-1][0]+10)]
dp[0] = 0
for i in range(N):
  for j in range(T, 0, -1):
    if dp[j-1] != -1:
      dp[j-1+X[i][0]] = max(dp[j-1+X[i][0]], dp[j-1] + X[i][1])
print(max(dp))
### BUGGY CODE ###

l=[2658,3]
d=[2,4,5]
d_bar=[]
for m in range(10):
    if m not in d:
        d_bar.append(m) 
d_bar.sort()
n=[int(k) for k in str(l[0])]

for i in range(len(n)):
    dig1=''
    dig2=0
    for j in range(l[1]):
        p=dig1.join(str(d_bar[j]))
        if int(p)>l[0]:
          break
        dig1=p
        dig2=dig2+d_bar[j]*l[1]**(l[0]-i)
dig2=dig2+1
r=int(dig1)
q=int(dig1)
R=[]
while q!=0 or q!=1:
    q=q/l[1]
    r=q%l[1]
    R.insert(0,r)
s=''
for t in range(len(R)):
    s=s+str(R[t])
print(int(s))




### FIXED CODE ###

l=list(map(int,input().split()))
d=list(map(int,input().split()))
u={i for i in range(10)}
d_bar=u-set(d)
d_bar={str(i) for i in d_bar}
n=l[0]
n_set=set(str(n))
while True:
    if n_set<=d_bar:
        print(n)
        break
    n=n+1
    n_set=set(str(n))
### BUGGY CODE ###

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

m = 10**18
while True:
    n = min(n, abs(n-k)) 
    if n < m:
        m = n
    else:
        break

print(m)

### FIXED CODE ###

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

m = 10**18
n = n % k
while True:
    n = min(n, abs(n-k)) 
    if n < m:
        m = n
    else:
        break

print(m)
### BUGGY CODE ###

from math import sqrt
from itertools import combinations
import random
n = int(input())


def primes(x):
    if x < 2:
        return []
    primes = [i for i in range(x)]
    primes[1] = 0
    for prime in primes:
        if prime > sqrt(x):
            break
        if prime == 0:
            continue
        for non_prime in range(2 * prime, x, prime):
            primes[non_prime] = 0
    return [prime for prime in primes if prime != 0]


p = primes(55555)
ans = p[1:n]
k = 0
while True:
    comb = combinations(ans, 5)
    for c in comb:
        if sum(c) in p:
            ans[ans.index(min(c))] = p[n+k]
            k += 1
            break
    else:
        break
print('2 '+' '.join(map(str, ans)))

### FIXED CODE ###

print(' '.join(map(str, [11, 31, 41, 61, 71, 101, 131, 151, 181, 191, 211, 241, 251, 271, 281, 311, 331, 401, 421, 431, 461, 491, 521, 541, 571, 601, 631, 641, 661, 691, 701, 751, 761, 811, 821, 881, 911, 941, 971, 991, 1021, 1031, 1051, 1061, 1091, 1151, 1171, 1181, 1201, 1231, 1291, 1301, 1321, 1361, 1381][:int(input())])))
### BUGGY CODE ###

R,G,B,n=map(int,input().split())
count=0
for r in range(n+1):
    for g in range(n+1):
            if n>=r*R+g*G and (n-r*R-g*G)%B==0:
                count+=1
print(count)

### FIXED CODE ###

R,G,B,n=map(int,input().split())
count=0
for r in range(n+1):
    for g in range(n+1):
            if n>=r*R+g*G and (n-r*R-g*G)%B==0:
                count+=1
print(count)
### BUGGY CODE ###

import sys
input = sys.stdin.readline

n= int(input())
s = input()
R = []
G = []
B = []
import bisect
def func(l1,l2,l3,l3set):
  res =0
  for i in l1:
    for j in l2:
      if i>j:
        continue
      a = l3[bisect.bisect_left(l3,j):]
      res += len(a)
      if j*2-i in l3set:
        res -=1
  return res

for i in range(n):
  if s[i] == 'R':
    R.append(i+1)
  elif s[i] == 'G':
    G.append(i+1)
  else:
    B.append(i+1)
    
    
R_set = set(R)
G_set = set(G)
B_set = set(B)
ans = func(R,G,B,B_set)+func(R,B,G,G_set)+func(G,R,B,B_set)+func(G,B,R,R_set) + func(B,R,G,G_set)+func(B,G,R,R_set)
print(ans)
  





### FIXED CODE ###

import sys
input = sys.stdin.readline

n= int(input())
s = input()
R = []
G = []
B = []
import bisect
def func(l1,l2,l3,l3set):
  res =0
  for i in l1:
    for j in l2[bisect.bisect_left(l2,i):]:
      a = l3[bisect.bisect_left(l3,j):]
      res += len(a)
      if j*2-i in l3set:
        res -=1
  return res

for i in range(n):
  if s[i] == 'R':
    R.append(i+1)
  elif s[i] == 'G':
    G.append(i+1)
  else:
    B.append(i+1)
    
    
R_set = set(R)
G_set = set(G)
B_set = set(B)
ans = func(R,G,B,B_set)+func(R,B,G,G_set)+func(G,R,B,B_set)+func(G,B,R,R_set) + func(B,R,G,G_set)+func(B,G,R,R_set)
print(ans)
### BUGGY CODE ###

from itertools import groupby, chain
from operator import itemgetter


def sweep(l):
    result = []
    s = set(l)
    while s:
        a = max(s)
        b = 1 << (a.bit_length() - 1)
        s = {t ^ a if t >= b else t for t in s}
        s.discard(0)
        result.append([a, b])

    return result


t = int(input())
buf = []
for _ in range(t):
    n = int(input())
    aaa = list(map(int, input().split()))
    s = input()

    if s[-1] == '1':
        buf.append(1)
        continue

    grp = [list(map(itemgetter(1), itr)) for c, itr in groupby(zip(s, aaa), key=itemgetter(0))]
    if s[0] == '0':
        grp = grp[1:]
    grp1 = grp[0::2]
    grp0 = grp[1::2]
    erasable = [False] * sum(len(g) for g in grp1)
    for i in range(len(grp1)):
        l1 = list(chain(*grp1[:i + 1]))
        l0 = list(chain(*grp0[i:]))
        s0 = sweep(l0)

        for a, b in s0:
            for i in range(len(l1)):
                if l1[i] & b:
                    l1[i] ^= a

        for j, c in enumerate(l1):
            if c == 0:
                erasable[j] = True

    if all(erasable):
        buf.append(0)
    else:
        buf.append(1)


print('\n'.join(map(str, buf)))


### FIXED CODE ###

from itertools import groupby, chain
from operator import itemgetter


def sweep(l):
    result = []
    s = set(l)
    while s:
        a = max(s)
        b = 1 << (a.bit_length() - 1)
        s = {t ^ a if t >= b else t for t in s}
        s.discard(0)
        result.append([a, b])

    return result


t = int(input())
buf = []
for _ in range(t):
    n = int(input())
    aaa = list(map(int, input().split()))
    s = input()

    if s[-1] == '1':
        buf.append(1)
        continue

    grp = [list(map(itemgetter(1), itr)) for c, itr in groupby(zip(s, aaa), key=itemgetter(0))]
    if s[0] == '0':
        grp = grp[1:]
    grp1 = grp[0::2]
    grp0 = grp[1::2]
    erasable = [False] * sum(len(g) for g in grp1)
    for i in range(len(grp1)):
        l1 = list(chain(*grp1[:i + 1]))
        l0 = list(chain(*grp0[i:]))
        s0 = sweep(l0)

        for a, b in s0:
            for i in range(len(l1)):
                if l1[i] & b:
                    l1[i] ^= a

        for j, c in enumerate(l1):
            if c == 0:
                erasable[j] = True

    if all(erasable):
        buf.append(0)
    else:
        buf.append(1)


print('\n'.join(map(str, buf)))
### BUGGY CODE ###

S = list(input())
Q = int(input())
for i in range(Q):
    query = input().split()
    if int(query[0]) == 1:
        S.reverse()
    else:
        if int(query[1]) == 1:
            S.insert(0, query[2])
        else:
            S.append(query[2])
print("".join(S))


### FIXED CODE ###

from collections import deque
S = deque(list(input()))
Q = int(input())
t = 0
for i in range(Q):
    query = input().split()
    if int(query[0]) == 1:
        t += 1
    else:
        query[1] = int(query[1])
        if t % 2 == 1:
            if query[1] == 1:
                query[1] = 2
            else:
                query[1] = 1
        if query[1] == 1:
            S.appendleft(query[2])
        else:
            S.append(query[2])
if t % 2 == 1:
    S.reverse()
print("".join(S))
### BUGGY CODE ###

# coding: utf-8
# Your code here!
import sys

def input():
    return sys.stdin.readline().strip()

N, M = map(int, input().split())
a = [int(input()) for _ in range(M)]
li = [1] + [0 for _ in range(N)]

for i in range(1, N + 1):
    if i in a:
        continue
    else:
        li[i] = li[i - 1] + li[i - 2]
print(li[-1] % 1000000007)

### FIXED CODE ###

# coding: utf-8
# Your code here!
import sys

def input():
    return sys.stdin.readline().strip()

N, M = map(int, input().split())
a = set(int(input()) for _ in range(M))
li = [1] + [0 for _ in range(N)]

for i in range(1, N + 1):
    if i in a:
        continue
    else:
        li[i] = li[i - 1] + li[i - 2]
print(li[-1] % 1000000007)