Frangolino ali na mesa

시간 제한0.5초메모리 제한2048 MB

요약
각 명령이 같은 확률로 두 종류 중 하나로 실행될 때, 모든 테이블이 받는 주문 수의 기댓값을 10^9+7로 나눈 나머지로 구한다.
난이도

보통10점 중 7점

유형
확률, 수학, 동적 계획법, 누적 합
정답자
아직 제출이 없습니다

문제

Washington, a chef enthusiastic about artificial intelligence and passionate about cooking, decided to build a waiter-robot for his new restaurant, Frangolino, which specializes in breaded chicken. Washington will open the restaurant for a special night with friends and decided to test the waiter-robot on that occasion.

The restaurant will serve NN tables, numbered from 11 to NN, and will offer only one dish: chicken milanesa. Washington loves playing with words and decided to define two commands for the waiterrobot: the command “ali na mesa XX” (go to table XX) and the command “a milanesa XX” (milanesa XX).

The command “ali na mesa XX” means that the waiter-robot should move to table XX and wait for the next instruction. The command “a milanesa XX” means that the waiter-robot should register in the system an order for XX chicken milanesas for the table where it is currently located. At the beginning of the night, the waiter-robot is at table 11.

Unfortunately, the waiter-robot has a flaw and cannot handle anagrams properly. For each command received, the robot has a 5050\\% chance of executing it correctly and a 5050\\% chance of executing the other command. Your task is, given the history of commands received by the robot, to determine, for each table in the restaurant, the expected number of chicken milanesas that will be served.

입력

The first line of input contains two integers NN and QQ (1≤N,Q≤1051 ≤ N, Q ≤ 10^5), the number of tables and the number of waiter-robot commands, respectively.

The second line contains QQ integers X_1,…,X_QX\_1, \dots , X\_Q (1≤X_i≤N1 ≤ X\_i ≤ N) separated by spaces. Each X_iX\_i describes the argument of one of the commands that the waiter-robot received, in the order they occurred.

Note that the command itself is not provided, since the waiter-robot will execute either one with 5050\\% probability.

출력

The output should contain NN lines. The ii-th line should contain the expected number of chicken milanesas that will be served at table ii, as described below.

The expected value may not be an integer, but it will always be a rational number and, therefore, can be represented by an irreducible fraction pq\frac{p} {q} . Since pp and qq can be very large, you should print p×q−1 mod (109+7)p \times q^{-1} \bmod {(10^9 + 7)}, where q−1q^{-1} is the multiplicative inverse of qq modulo 109+710^9 + 7.

예제2

  1. 예제 1

    입력
    2 3
    1 2 1
    
    예상 출력
    750000007
    250000002
    
  2. 예제 2

    입력
    4 4
    1 2 3 4
    
    예상 출력
    750000008
    250000003
    1
    0