using System;

namespace atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] inputs = Console.ReadLine().Split(' ');
            int n = int.Parse(inputs[0]);
            int m = int.Parse(inputs[1]);
            long p = 1;
            int lastNum = -1;
            int[] ng = new int[m];
            int[] patterns = new int[n + 1];
            for (int i = 0; i < n + 1; i++)
            {
                patterns[i] = 2;
            }
            for (int i = 0; i < m; i++)
            {
                ng[i] = int.Parse(Console.ReadLine());
                if(ng[i] == lastNum + 1)
                {
                    Console.Write("0");
                    return;
                }
                lastNum = ng[i];
                patterns[ng[i]] = 1;
                if (ng[i] >= 0)
                    patterns[ng[i]] = 1;
                if (ng[i] - 1 >= 0)
                    patterns[ng[i] - 1] = 1;
                if (ng[i] - 2 >= 0)
                    patterns[ng[i] - 2] = 1;
            }
            int patternLength = patterns.Length;
            if (patternLength - 1 >= 0)
                patterns[patternLength - 1] = 1;
            if (patternLength  - 2 >= 0)
                patterns[patternLength - 2] = 1;
            for (int i = 0; i < n + 1; i++)
            {
                p *= patterns[i];
                Console.WriteLine(p);
            }
            Console.WriteLine();
            Console.WriteLine(p % 1000000007);
        }
    }
}