Boring Not boring problem

1

2 votes
Advanced Data Structures, Segment Trees, Linear Algebra, Data Structures
Problem

You are given two integers n(1n105) and m (1m105). 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 ai = ai 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 (109+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

- 1n105

- 0m105

- 1lrn

- 0x2301
 

Sample Input
4 1
1 4 1
Sample Output
16
Time Limit: 2
Memory Limit: 512
Source Limit:
Explanation

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

Editor Image

?