F.A.Q
Hand In Hand
Online Acmers
Problem Archive
Realtime Judge Status
Authors Ranklist
 
     C/C++/Java Exams     
ACM Steps
Go to Job
Contest LiveCast
ICPC@China
Best Coder beta
VIP | STD Contests
    DIY | Web-DIY beta
Author ID 
Password 
 Register new ID

Expectation

Time Limit: 10000/5000 MS (Java/Others)    Memory Limit: 524288/524288 K (Java/Others)
Total Submission(s): 1104    Accepted Submission(s): 440


Problem Description
You are given an undirected graph consisting of $n$ vertices with $m$ weighted edges. We define the weight of a spanning tree as the bitwise AND of all edges' weight in spanning tree.

Now select a spanning tree randomly, you should calculate the expected value of the weight of this spanning tree. You are required to print the result mod $998244353$. $i.e.$, print $x \times y^{-1}$ mod $998244353$ where $x \times y ^ {-1}$ is the irreducible fraction representation of the result, where $y ^ {-1}$ denotes the multiplicative inverse of $y$ modulo $998244353$.


 

Input
The first line is an integer $t(1 \leq t \leq 10)$, the number of test cases.

For each test case, there are two space-separated integers $n(2 \leq n \leq 100)$ and $m(1 \leq m ¡Ü 10^{4})$ in the first line, the number of nodes and the number of edges.

Then follows $m$ lines, each contains three integers $u, v, w(1 \leq u, v, \leq n, 1 \leq w \leq 10^{9}, u \neq v)$, space separated, denoting an weight edge between $u$ and $v$ has weight $w$.

 

Output
For each test case, output a single line with a single integer, denoting the answer.
 

Sample Input
1 3 3 1 2 1 1 3 1 2 3 1
 

Sample Output
1
 

Source
 

Statistic | Submit | Discuss | Note
Hangzhou Dianzi University Online Judge 3.0
Copyright © 2005-2024 HDU ACM Team. All Rights Reserved.
Designer & Developer : Wang Rongtao LinLe GaoJie GanLu
Total 0.000000(s) query 1, Server time : 2024-05-19 12:11:18, Gzip enabled