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

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

for i in range(m):

    j = int(eval(input()))

    dp[j] = -1

dp[0] = 1

dp[1] = 1 if dp[1] != -1 else 0

for i in range(2,n+1):

    if dp[i] == -1:

        dp[i] = 0

        continue

    dp[i] = dp[i-1] + dp[i-2]

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

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

for i in range(m):

    j = int(eval(input()))

    dp[j] = -1

dp[0] = 1

dp[1] = 1 if dp[1] != -1 else 0

for i in range(2,n+1):

    if dp[i] == -1:

        dp[i] = 0

        continue

    dp[i] = (dp[i-1] + dp[i-2])%1000000007

print((dp[n]))
n, m = list(map(int, input().split()))
dp = [0 for i in range(n + 1)]
for i in range(m):
    j = int(eval(input()))
    dp[j] = -1
dp[0] = 1
dp[1] = 1 if dp[1] != -1 else 0
for i in range(2, n + 1):
    if dp[i] == -1:
        dp[i] = 0
        continue
    dp[i] = dp[i - 1] + dp[i - 2]
print((dp[n] % 1000000007))

n, m = list(map(int, input().split()))
dp = [0 for i in range(n + 1)]
for i in range(m):
    j = int(eval(input()))
    dp[j] = -1
dp[0] = 1
dp[1] = 1 if dp[1] != -1 else 0
for i in range(2, n + 1):
    if dp[i] == -1:
        dp[i] = 0
        continue
    dp[i] = (dp[i - 1] + dp[i - 2]) % 1000000007
print((dp[n]))

-    dp[i] = dp[i - 1] + dp[i - 2] -print((dp[n] % 1000000007)) +    dp[i] = (dp[i - 1] + dp[i - 2]) % 1000000007 +print((dp[n]))