MOD = 10**9+7



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

al = [True]*(n+1)

for _ in range(m):

    al[int(eval(input()))] = False



dp = [0]*(n+1) 

dp[0] = 1

for i in range(n):

    if i+2 <= n and al[i+2]:

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

    if i+1 <= n and al[i+1]:

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



print((dp[n]%MOD))
n,m = list(map(int, input().split()))

al = [True]*(n+1)

for _ in range(m):

    a = int(eval(input()))

    al[a] = False



MOD = 10**9+7

dp = [0]*(n+1)

dp[0] = 1

for i in range(n):

    if i+1 <= n and al[i+1]:

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

        dp[i+1]%=MOD

    if i+2 <= n and al[i+2]:

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

        dp[i+2]%=MOD



print((dp[n]))

MOD = 10**9 + 7
n, m = list(map(int, input().split()))
al = [True] * (n + 1)
for _ in range(m):
    al[int(eval(input()))] = False
dp = [0] * (n + 1)
dp[0] = 1
for i in range(n):
    if i + 2 <= n and al[i + 2]:
        dp[i + 2] += dp[i]
    if i + 1 <= n and al[i + 1]:
        dp[i + 1] += dp[i]
print((dp[n] % MOD))

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

-MOD = 10**9 + 7 -    al[int(eval(input()))] = False +    a = int(eval(input())) +    al[a] = False +MOD = 10**9 + 7 +    if i + 1 <= n and al[i + 1]: +        dp[i + 1] += dp[i] +        dp[i + 1] %= MOD -    if i + 1 <= n and al[i + 1]: -        dp[i + 1] += dp[i] -print((dp[n] % MOD)) +        dp[i + 2] %= MOD +print((dp[n]))