N, M = list(map(int, input().split()))

A = [True] * (N + 1)

for i in range(M):

    a = int(eval(input()))

    A[a] = False



dp = [0] * (N + 1)

dp[0] = 1

mod = 10 ** 9 + 7



for i in range(N):

    for j in range(i + 1, min(N, i + 2) + 1):

        if A[j]:

            dp[j] += dp[i]

            dp[j] %= mod

            # print(dp)



print((dp[N]))

N, M = list(map(int, input().split()))

A = [True] * (N + 1)

for _ in range(M):

    a = int(eval(input()))

    A[a] = False



dp = [0] * (N + 1)



dp[0] = 1

for i in range(N):

    for j in range(i + 1, min(N, i + 2) + 1):

        if A[j] is True:

            dp[j] += dp[i]

            dp[j] %= 10 ** 9 + 7



print((dp[N]))

N, M = list(map(int, input().split()))
A = [True] * (N + 1)
for i in range(M):
    a = int(eval(input()))
    A[a] = False
dp = [0] * (N + 1)
dp[0] = 1
mod = 10**9 + 7
for i in range(N):
    for j in range(i + 1, min(N, i + 2) + 1):
        if A[j]:
            dp[j] += dp[i]
            dp[j] %= mod
            # print(dp)
print((dp[N]))

N, M = list(map(int, input().split()))
A = [True] * (N + 1)
for _ in range(M):
    a = int(eval(input()))
    A[a] = False
dp = [0] * (N + 1)
dp[0] = 1
for i in range(N):
    for j in range(i + 1, min(N, i + 2) + 1):
        if A[j] is True:
            dp[j] += dp[i]
            dp[j] %= 10**9 + 7
print((dp[N]))

-for i in range(M): +for _ in range(M): -mod = 10**9 + 7 -        if A[j]: +        if A[j] is True: -            dp[j] %= mod -            # print(dp) +            dp[j] %= 10**9 + 7