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

oks = [True]*(n+1)

for i in range(m):

    a = int(eval(input()))

    oks[a] = False

dp = [0]*(n+1)

dp[0] = 1

for i in range(n+1):

    for j in range(i+1,min(n+1,i+3)):

        if oks[j]:

            dp[j] += dp[i]

            dp[j] %= 1000000007

print((dp[n]))

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

a = set([int(eval(input())) for i in range(m)])

mod = 10**9+7



dp = [0]*(n+1)

dp[0] = 1

for i in range(n):

    if i+1<n+1 and not i+1 in a:

        dp[i+1] += dp[i]

        dp[i+1] %= mod

    if i+2<n+1 and not i+2 in a:

        dp[i+2] += dp[i]

        dp[i+2] %= mod



print((dp[n]))
n, m = list(map(int, input().split()))
oks = [True] * (n + 1)
for i in range(m):
    a = int(eval(input()))
    oks[a] = False
dp = [0] * (n + 1)
dp[0] = 1
for i in range(n + 1):
    for j in range(i + 1, min(n + 1, i + 3)):
        if oks[j]:
            dp[j] += dp[i]
            dp[j] %= 1000000007
print((dp[n]))

n, m = list(map(int, input().split()))
a = set([int(eval(input())) for i in range(m)])
mod = 10**9 + 7
dp = [0] * (n + 1)
dp[0] = 1
for i in range(n):
    if i + 1 < n + 1 and not i + 1 in a:
        dp[i + 1] += dp[i]
        dp[i + 1] %= mod
    if i + 2 < n + 1 and not i + 2 in a:
        dp[i + 2] += dp[i]
        dp[i + 2] %= mod
print((dp[n]))

-oks = [True] * (n + 1) -for i in range(m): -    a = int(eval(input())) -    oks[a] = False +a = set([int(eval(input())) for i in range(m)]) +mod = 10**9 + 7 -for i in range(n + 1): -    for j in range(i + 1, min(n + 1, i + 3)): -        if oks[j]: -            dp[j] += dp[i] -            dp[j] %= 1000000007 +for i in range(n): +    if i + 1 < n + 1 and not i + 1 in a: +        dp[i + 1] += dp[i] +        dp[i + 1] %= mod +    if i + 2 < n + 1 and not i + 2 in a: +        dp[i + 2] += dp[i] +        dp[i + 2] %= mod