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

kaidan = [True] * (N+2)

for i in range(M):

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



dp = [0]*(N+2)

dp[0] = 1

for i in range(N):

    if kaidan[i+2]:

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

        dp[i+2] %= 1000000007

    if kaidan[i+1]:

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

        dp[i+1] %= 1000000007



print((dp[N]))

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

kaidan = [True] * (N+3)

for i in range(M):

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



dp = [0]*(N+3)

dp[0] = 1

for i in range(N):

    if kaidan[i+2]:

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

        dp[i+2] %= 1000000007

    if kaidan[i+1]:

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

        dp[i+1] %= 1000000007



print((dp[N]))

N, M = list(map(int, input().split()))
kaidan = [True] * (N + 2)
for i in range(M):
    kaidan[int(eval(input()))] = False
dp = [0] * (N + 2)
dp[0] = 1
for i in range(N):
    if kaidan[i + 2]:
        dp[i + 2] += dp[i]
        dp[i + 2] %= 1000000007
    if kaidan[i + 1]:
        dp[i + 1] += dp[i]
        dp[i + 1] %= 1000000007
print((dp[N]))

N, M = list(map(int, input().split()))
kaidan = [True] * (N + 3)
for i in range(M):
    kaidan[int(eval(input()))] = False
dp = [0] * (N + 3)
dp[0] = 1
for i in range(N):
    if kaidan[i + 2]:
        dp[i + 2] += dp[i]
        dp[i + 2] %= 1000000007
    if kaidan[i + 1]:
        dp[i + 1] += dp[i]
        dp[i + 1] %= 1000000007
print((dp[N]))

-kaidan = [True] * (N + 2) +kaidan = [True] * (N + 3) -dp = [0] * (N + 2) +dp = [0] * (N + 3)