#include <bits/stdc++.h>
using namespace std;
long long int patern_steps(long long int n) {
  if (n == 1 || n == 0) return 1;
  return patern_steps(n - 1) + patern_steps(n - 2);
}
int main() {
  long long int N;
  long long int M;
  cin >> N;
  cin >> M;
  long long int a[M + 2];
  a[0] = -1;
  a[M + 1] = N + 1;
  for (long long int i = 1; i < M + 1; i++) cin >> a[i];
  long long int con = a[1];
  for (long long int i = 2; i < M + 1; i++) {
    if (con + 1 == a[i]) {
      cout << "0" << endl;
      exit(1);
    }
    con = a[i];
  }
  long long int patern = 1;
  long long int steps;
  for (long long int i = 1; i < M + 2; i++) {
    steps = a[i] - a[i - 1] - 2;
    cout << steps << " " << patern_steps(steps) << endl;
    patern *= patern_steps(steps);
  }
  cout << patern % 1000000007 << endl;
  return 0;
}
