N,M = [int(i) for i in input().split()]
A = []
for _ in range(M):
    A.append(int(input()))
def fibo(n):
    if n <= 2:
        return n
    return fibo(n-1) + fibo(n-2)
cnt = 1
for a in range(len(A)+1):
    if a == 0:
        if A[a] == 1:
            width = 1
        else:
            width = A[a]-2
    elif a > 0 and a < M:
        width = A[a] - A[a-1] - 2
    elif a == (M):
        width = N-A[a-1]-1
    if width < 0:
        tmp = 0
        cnt = 0
        break
    else:
        tmp = fibo(width) % 1000000007
    print(width,tmp)
    cnt *= tmp