#P7470. [NOI Online 2021 提高组] 岛屿探险
[NOI Online 2021 提高组] 岛屿探险
Problem Description
Songmu is a girl who likes adventures. One day, she came to a sea area to explore.
In this sea area, there are islands in a row, numbered . Each island has two values: fatigue and fun .
For an island with fatigue and fun , if this island satisfies , then Songmu will feel happy when exploring this island. Here, denotes Songmu's fatigue before going onto the island (called the initial fatigue), and similarly, denotes Songmu's initial fun. denotes bitwise XOR (i.e., addition without carry in binary).
To enjoy herself more, Songmu will ask you queries. Each query gives an interval and two numbers . You need to tell Songmu: if her initial fatigue is and her initial fun is , then how many islands with indices in the interval can make Songmu feel happy while exploring.
Input Format
The first line contains two positive integers , denoting the number of islands and the number of queries.
The next lines each contain two integers , denoting the fatigue and fun of the -th island.
The next lines each contain four positive integers , denoting the left endpoint of the interval, the right endpoint of the interval, the initial fatigue, and the initial fun.
Output Format
Output lines in total, each containing one integer, the answer to the corresponding query.
4 2
1 1
4 2
5 1
2 7
1 4 6 5
2 4 3 3
2
1
20 10
215 144
2 110
174 132
214 142
116 108
155 192
236 208
216 214
99 220
236 118
190 81
230 131
10 238
189 198
183 13
45 193
14 234
208 192
126 19
49 38
7 14 251 184
2 18 89 76
11 15 49 196
8 11 83 139
10 15 119 239
9 16 148 120
11 17 225 34
15 16 3 46
14 15 86 227
7 18 252 103
7
2
2
2
1
3
1
1
0
7
Hint
Test points satisfy .
Test points satisfy .
Test points satisfy and .
Test points satisfy and .
Test points satisfy and .
Test points satisfy .
Test points satisfy .
All testdata satisfy , .
Translated by ChatGPT 5