This page is still under construction.

Parts of this page are still being built. What you see may change.

Math Homework

Time limit1sMemory limit1024 MB

Summary
Construct a sequence of N integers in [1, 10^9] so that the GCD of each given subarray equals a given value at most 16, or report impossibility.
Level

Hard8 of 10

Topics
Number theory, Math, Segment tree, Greedy
Solved
No attempts yet

Problem

Your math teacher has given you an assignment involving coming up with a sequence of NN integers A1,…,ANA_1, \ldots, A_N, such that 1≤Ai≤1 000 000 0001 \le A_i \le 1\,000\,000\,000 for each ii.

The sequence AA must also satisfy MM requirements, with the iith one stating that the GCD (Greatest Common Divisor) of the contiguous subsequence AXi,…,AYiA_{X_i}, \ldots, A_{Y_i} (1≤Xi≤Yi≤N1 \le X_i \le Y_i \le N) must be equal to ZiZ_i. The GCD of a sequence of integers is the largest integer dd such that all the numbers in the sequence are divisible by dd.

Find any valid sequence AA consistent with all of these requirements, or determine that no such sequence exists.

Input

The first line contains two space-separated integers, NN and MM.

The next MM lines each contain three space-separated integers, XiX_i, YiY_i, and ZiZ_i (1≤i≤M1 \le i \le M).

Output

If no such sequence exists, output the string Impossible on one line. Otherwise, on one line, output NN space-separated integers, forming the sequence A1,…,ANA_1, \ldots, A_N. If there are multiple possible valid sequences, any valid sequence will be accepted.

Constraints

  • 1≤N≤150 0001 \le N \le 150\,000
  • 1≤M≤150 0001 \le M \le 150\,000
  • 1≤Zi≤161 \le Z_i \le 16 for each ii

Examples2

  1. Example 1

    Input
    2 2
    1 2 2
    2 2 6
    
    Expected output
    4 6
    
  2. Example 2

    Input
    2 2
    1 2 2
    2 2 5
    
    Expected output
    Impossible