Count of paths

2

2 votes
Algorithms, Hard, Square Root Decomposition
Problem

Given a sequence . It's guaranteed that  for all i, means every element in the sequence divides .

A graph is built with this sequence. Specifically, an edge  exists when and only when  and . Obviously, this is a DAG.

Your task is to calculate the count of different paths from 1 to i for all i between 1 and n.

Input

The first line contains two integers, and .

The second line contains integers, representing the sequence .

It's guaranteed that .

Output

 lines. Each line contains an integer, the  integer is the count of different paths from 1 to i modulo .

Constraints

Sample Input
4 6
1 3 6 2
Sample Output
1
1
2
1
Time Limit: 1
Memory Limit: 256
Source Limit:
Explanation

The two paths from 1 to 3 are  and .

Contributers:
Editor Image

?