MOD = 10**9 + 7

N, M = [int(x) for x in input().split()]

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



dp = [0]*(N + 1)

dp[0] = 1

for step in range(N):

    if step in a:

        continue

    for width in [1, 2]:

        to = step + width

        if to <= N and not to in a:

            dp[to] = (dp[to] + dp[step]) % MOD



print((dp[N]))
MOD = 10**9 + 7

N, M = [int(x) for x in input().split()]

a = set()

for i in range(M):

    a.add(int(eval(input())))



dp = [0]*(N + 1)

dp[0] = 1

for step in range(N):

    if not step in a:

        for width in [1, 2]:

            to = step + width

            if to <= N and not to in a:

                dp[to] = (dp[to] + dp[step]) % MOD



print((dp[N]))
MOD = 10**9 + 7
N, M = [int(x) for x in input().split()]
a = set([int(eval(input())) for i in range(M)])
dp = [0] * (N + 1)
dp[0] = 1
for step in range(N):
    if step in a:
        continue
    for width in [1, 2]:
        to = step + width
        if to <= N and not to in a:
            dp[to] = (dp[to] + dp[step]) % MOD
print((dp[N]))

MOD = 10**9 + 7
N, M = [int(x) for x in input().split()]
a = set()
for i in range(M):
    a.add(int(eval(input())))
dp = [0] * (N + 1)
dp[0] = 1
for step in range(N):
    if not step in a:
        for width in [1, 2]:
            to = step + width
            if to <= N and not to in a:
                dp[to] = (dp[to] + dp[step]) % MOD
print((dp[N]))

-a = set([int(eval(input())) for i in range(M)]) +a = set() +for i in range(M): +    a.add(int(eval(input()))) -    if step in a: -        continue -    for width in [1, 2]: -        to = step + width -        if to <= N and not to in a: -            dp[to] = (dp[to] + dp[step]) % MOD +    if not step in a: +        for width in [1, 2]: +            to = step + width +            if to <= N and not to in a: +                dp[to] = (dp[to] + dp[step]) % MOD