Virtual contest is a way to take part in past contest, as close as possible to participation on time. It is supported only ICPC mode for virtual contests.
If you've seen these problems, a virtual contest is not for you - solve these problems in the archive.
If you just want to solve some problem from a contest, a virtual contest is not for you - solve this problem in the archive.
Never use someone else's code, read the tutorials or communicate with other person during a virtual contest.

No tag edit access

G. Xor-matic Number of the Graph

time limit per test

2 secondsmemory limit per test

256 megabytesinput

standard inputoutput

standard outputYou are given an undirected graph, constisting of *n* vertices and *m* edges. Each edge of the graph has some non-negative integer written on it.

Let's call a triple (*u*, *v*, *s*) interesting, if 1 ≤ *u* < *v* ≤ *n* and there is a path (possibly non-simple, i.e. it can visit the same vertices and edges multiple times) between vertices *u* and *v* such that xor of all numbers written on the edges of this path is equal to *s*. When we compute the value s for some path, each edge is counted in xor as many times, as it appear on this path. It's not hard to prove that there are finite number of such triples.

Calculate the sum over modulo 10^{9} + 7 of the values of *s* over all interesting triples.

Input

The first line of the input contains two integers *n* and *m* (1 ≤ *n* ≤ 100 000, 0 ≤ *m* ≤ 200 000) — numbers of vertices and edges in the given graph.

The follow *m* lines contain three integers *u*_{i}, *v*_{i} and *t*_{i} (1 ≤ *u*_{i}, *v*_{i} ≤ *n*, 0 ≤ *t*_{i} ≤ 10^{18}, *u*_{i} ≠ *v*_{i}) — vertices connected by the edge and integer written on it. It is guaranteed that graph doesn't contain self-loops and multiple edges.

Output

Print the single integer, equal to the described sum over modulo 10^{9} + 7.

Examples

Input

4 4

1 2 1

1 3 2

2 3 3

3 4 1

Output

12

Input

4 4

1 2 1

2 3 2

3 4 4

4 1 8

Output

90

Input

8 6

1 2 2

2 3 1

2 4 4

4 5 5

4 6 3

7 8 5

Output

62

Note

In the first example the are 6 interesting triples:

- (1, 2, 1)
- (1, 3, 2)
- (1, 4, 3)
- (2, 3, 3)
- (2, 4, 2)
- (3, 4, 1)

In the second example the are 12 interesting triples:

- (1, 2, 1)
- (2, 3, 2)
- (1, 3, 3)
- (3, 4, 4)
- (2, 4, 6)
- (1, 4, 7)
- (1, 4, 8)
- (2, 4, 9)
- (3, 4, 11)
- (1, 3, 12)
- (2, 3, 13)
- (1, 2, 14)

Codeforces (c) Copyright 2010-2020 Mike Mirzayanov

The only programming contests Web 2.0 platform

Server time: Jun/01/2020 09:08:12 (i3).

Desktop version, switch to mobile version.

Supported by

User lists

Name |
---|