QOJ.ac

QOJ

Limite de temps : 3 s Limite de mémoire : 512 MB Points totaux : 100

#10350. Stars

Statistiques

Little Y is a girl with a vivid imagination.

One night, while gazing at the starry sky, Little Y began to identify constellations using the astronomical knowledge she had learned. This time, however, she hoped to add her own creative touch to the existing patterns to create designs of her own.

There are $n$ stars in the sky. By consulting various ancient and modern texts, Little Y obtained $m$ pieces of information. The $i$-th piece of information states that there should be a connection between star $a_i$ and star $b_i$. For each piece of information, Little Y assigned a weight $c_i$ to the connection based on its age, origin, and other factors.

Little Y wants to select some of these $m$ pieces of information to connect the stars and form her own pattern.

Little Y hopes that the resulting pattern contains no multiple edges, meaning there is at most one edge between any two stars. Furthermore, the pattern must be connected.

Additionally, since this year is 2017, Little Y wants the sum of the weights of the selected edges, modulo $p = 17$, to be a specific value. Therefore, for each $k$ where $0 \le k < p$, Little Y wants to know the number of ways to form a connected pattern with no multiple edges such that the sum of the edge weights modulo $p$ is $k$.

Since the answer may be very large, you only need to provide the answer modulo $998244353$.

Input

The input is read from standard input.

The first line contains two integers $n$ and $m$, as described above.

The next $m$ lines each contain three integers $a_i, b_i, c_i$, representing an edge connecting $a_i$ and $b_i$ with weight $c_i$.

Output

The output is sent to standard output.

The output consists of $p$ lines, each containing one integer. The $i$-th line represents the number of ways such that the sum of the edge weights modulo $p$ is $i - 1$, modulo $998244353$.

Examples

Input 1

4 8
1 2 0
1 2 1
2 3 0
2 3 1
3 4 0
3 4 1
1 4 0
1 4 2

Output 1

5
12
13
11
6
1
0
0
0
0
0
0
0
0
0
0
0

Subtasks

The data scale and characteristics for each test case are shown in the table below.

Test Case$n$$m$Other Constraints
1$\leq17$$\leq20$None
2$\leq25$
3$\leq30$
4$\leq10^5$Weights are all $0$
5
6$\leq14$$\leq50$Weights are all $1$
7
8$\leq15$
9
10
11$\leq13$$\leq10^5$None
12$\leq14$
13
14$\leq15$
15
16$\leq16$
17
18
19
20$\leq17$
21
22
23
24
25

For 100% of the data, it is guaranteed that $1 \le n \le 17, 1 \le m \le 10^5, 0 \le c_i < p = 17$.

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.