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 Fortran (gfortran v4.8.4) (judge verdict: Wrong Answer)

module mod_stack
  implicit none
  type t_node
    private
    integer(8) :: item
    type(t_node), pointer :: prev => null()
    type(t_node), pointer :: next => null()
  end type t_node
  type t_stack
    private
    integer :: num = 0
    type(t_node), pointer :: head => null()
    type(t_node), pointer :: tail => null()
  contains
    procedure :: push => push
    procedure :: pop => pop
    procedure :: peek => peek
    procedure :: clear => clear
    procedure :: size => size_of
  end type t_stack
contains
  function new_node(item) result(node)
    integer(8), intent(in) :: item
    type(t_node), pointer :: node
    allocate(node)
    node%item = item
  end
  subroutine push(this,item)
    class(t_stack), intent(inout) :: this
    integer(8), intent(in) :: item
    type(t_node), pointer :: node
    node => new_node(item)
    if (associated(this%head)) then
      node%prev => this%tail
      this%tail%next => node
    else
      this%head => node
    end if
    this%tail => node
    this%num = this%num+1
  end
  function pop(this) result(item)
    class(t_stack), intent(inout) :: this
    integer(8) :: item
    type(t_node), pointer :: node
    item = this%tail%item
    node => this%tail%prev
    deallocate(this%tail)
    this%tail => node
    if (associated(node)) then
      node%next => null()
    else
      this%head => null()
    end if
    this%num = this%num-1
  end
  function peek(this) result(item)
    class(t_stack), intent(in) :: this
    integer(8) :: item
    item = this%tail%item
  end
  subroutine clear(this)
    class(t_stack), intent(inout) :: this
    type(t_node), pointer :: node, prev
    if (.not.associated(this%tail)) return
    node => this%tail
    do while (associated(node%prev))
      prev => node%prev
      deallocate(node)
      node => prev
    end do
    this%head => null()
    this%tail => null()
    this%num = 0
  end
  integer function size_of(this)
    class(t_stack), intent(in) :: this
    size_of = this%num
  end
end module mod_stack
program sequential_operations_on_sequence
  use mod_stack
  implicit none
  type(t_stack) :: stack
  integer :: n, q, i, j, x
  integer(8) :: tmp1, tmp2, p(100000) = 0_8, k, l, r, m
  integer(8) :: t(100000) = 0_8, ans(0:100001) = 0_8
  read(*,*) n, q
  call stack%push(int(n,8))
  do i = 1, q
    read(*,*) tmp1
    do while (stack%size() > 0 .and. stack%peek() >= tmp1)
      tmp2 = stack%pop()
    end do
    call stack%push(tmp1)
  end do
  q = stack%size()
  do i = q, 1, -1
    p(i) = stack%pop()
  end do
  t(q) = 1_8
  do i = q, 2, -1
    j = i-1
    t(j) = t(j)+t(i)*(p(i)/p(j))
    k = mod(p(i),p(j))
    do while (k >= p(1))
      r = j
      l = 1
      do while (r-l > 1)
        m = (l+r)/2
        if (p(m) > k) then
          r = m
        else
          l = m
        end if
      end do
      j = l
      t(j) = t(j)+t(i)*(k/p(j))
      k = mod(k,p(j))
    end do
    x = int(k,4)
    ans(x) = ans(x)+t(i)
  end do
  x = int(p(1),4)
  ans(x) = ans(x)+t(1)
  do i = n, 1, -1
    ans(i) = ans(i)+ans(i+1)
  end do
  do i = 1, n
    write(*,'(i0)') ans(i)
  end do
end program sequential_operations_on_sequence