Problem:
Score : 1400 points

Problem Statement

Snuke got an integer sequence from his mother, as a birthday present. The sequence has N elements, and the i-th of them is i.
Snuke performs the following Q operations on this sequence. The i-th operation, described by a parameter q_i, is as follows:

Take the first q_i elements from the sequence obtained by concatenating infinitely many copy of the current sequence, then replace the current sequence with those q_i elements.

After these Q operations, find how many times each of the integers 1 through N appears in the final sequence.

Constraints

1 ≦ N ≦ 10^5

0 ≦ Q ≦ 10^5

1 ≦ q_i ≦ 10^{18}

All input values are integers.

Input

The input is given from Standard Input in the following format:

N Q
q_1
:
q_Q

Output

Print N lines. The i-th line (1 ≦ i ≦ N) should contain the number of times integer i appears in the final sequence after the Q operations.

Sample Input 1

5 3
6
4
11

Sample Output 1

3
3
3
2
0

After the first operation, the sequence becomes: 1,2,3,4,5,1.

After the second operation, the sequence becomes: 1,2,3,4.

After the third operation, the sequence becomes: 1,2,3,4,1,2,3,4,1,2,3.

In this sequence, integers 1,2,3,4,5 appear 3,3,3,2,0 times, respectively.

Sample Input 2

10 10
9
13
18
8
10
10
9
19
22
27

Sample Output 2

7
4
4
3
3
2
2
2
0
0

Solution in C (GCC 5.4.1) (judge verdict: Wrong Answer)

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

//#define min(x,y) ((x)>(y))?(y):(x)

int main() {
	int i, j, k, l, N, Q;
	scanf("%d%d", &N, &Q);
	long long min, ord, s[Q], x;
	long long c[10010][N+1];
	for (i=0;i<Q;i++) scanf("%lld", &s[i]);
	min = 1000000000000000000LL;
	for (i=0;i<Q;i++) if (min>s[i]) { min = s[i]; ord = i; }
	for (i=0;i<Q;i++) if (s[i]>=s[i+1] || (min<s[i] && ord > i)) s[i] = -1;
//	for (i=0;i<Q;i++) printf("%lld ", s[i]); printf("\n");
	j = 0;
	for (i=0;i+j<Q;i++) {
		while (s[i+j] == -1) j++;
		if (j>0) s[i] = s[i+j];
		else continue;
	}
	memset(s+Q-j, 0, sizeof(long long)*j);
	Q -= j;
//	for (i=0;i<Q;i++) printf("%lld\n", s[i]);
	min = (N>s[0])?s[0]:N;
	for (i=1;i<=min;i++) {
		c[i-1][0] = i;
		for (j=1;j<=i;j++) c[i-1][j] = 1;
		for (j=i+1;j<=N;j++) c[i-1][j] = 0;
	}
//	for (i=0;i<min;i++) { for (j=0;j<=N;j++) printf("%lld\t", c[i][j]); printf("\n"); }
	j = min;
	for (i=0;i<Q;i++) {
		x = s[i];
		if (x < min) continue;
		c[j][0] = x;
		for (k=1;k<N+1;k++) c[j][k] = 0;
		while (x>0) {
			for (k=j-1;k>=0;k--) if (x>=c[k][0]) break;
			x -= c[k][0];
			for (l=1;l<=N;l++) c[j][l] += c[k][l];
		}
//		for (l=0;l<=N;l++) printf("%lld\t", c[j][l]); printf("\n");
		j++;
	}

	for (l=1;l<=N;l++) printf("%lld\n", c[j-1][l]);

	return 0;
}