Boring Not boring problem
87% Success520 Attempts50 Points2s Time Limit512MB Memory1024 KB Max Code

You are given two integers $$n$$($$1 \le n \le 10^5$$) and $$m$$ ($$1 \le m \le 10^5$$). Initially, you have an array $$a$$ of $$n$$ zeros, and $$m$$ applied queries on it. Query is given as $$l$$ $$r$$ $$x$$, where you apply $$a_i$$ = $$a_i$$ xor $$x$$ (xor  denotes the operation bitwise XOR) for every $$i$$ between $$l$$ and $$r$$. But this problem seems boring, so Almas modify some queries interval. By modifying, he applied that operation on a subset of positions on a segment(maybe empty subset). Now he asks you how many different arrays he could have after applying queries. Since the answer can be large, output by modulo 1000000007 ($$10^9 + 7$$).

Input

- In first line, you are given two integers $$n$$ and $$m$$. 

- In next $$m$$ lines, you are given $$l$$ $$r$$ $$x$$. 

 

Output
-Print in a single line answer by modulo 1000000007.
 

Constraints

- $$1 \leq n \leq 10^5$$

- $$0 \leq m \leq 10^5$$

- $$1 \leq  l \leq  r \leq n$$

- $$0 \leq x \le 2^{30} - 1$$
 

Examples
Input
4 1
1 4 1
Output
16
Explanation

if we apply query on position $$i$$, $$a_i$$ is $$1$$ else $$0$$. so there $$8$$ different arrays

Please login to use the editor

You need to be logged in to access the code editor

Loading...

Please wait while we load the editor

Loading Editor...
Results