P4688 [Ynoi Easy Round 2016] Falling into the Rabbit Hole

Background

5.632 I (or you who are reading this text) do not belong to this world. This is the boundary of the world. 6.41 The meaning of the world must lie outside the world. Everything in the world exists as it exists, and happens as it happens. There is no value in the world. — *Tractatus Logico-Philosophicus* Our lover is just a soap bubble blown up by fantasy, borrowing a name at random. Take the letter. You can make the fake act come true. I was originally just complaining for no reason, spilling out love without any goal—now these drifting birds finally have a place to rest, and you can see it from the letter. Take it—since it is not from the heart, the words sound especially pleasant. Take it, let’s do it like this... ![](https://cdn.luogu.com.cn/upload/pic/21091.png) As expected... what a good woman needs is: cigarettes, the rooftop... and light, fluttering clothes... One day, Mizukami Yuki saw a cloth doll falling from the sky onto the water. That cloth doll, thrown in order to be “accepted by the sky”, must have flown around in the sky countless times, already covered in wounds. “Accepted by the sky”—that was an act to search for the “road to return to the sky” that had been spreading in this city since who knows when. ![](https://cdn.luogu.com.cn/upload/pic/21102.png) A puppet that was thrown out to be accepted by the sky, dancing in the air and finally falling. That was the act of a girl who tried to offer to the sky a girl who herself is the world. ![](https://cdn.luogu.com.cn/upload/pic/21093.png) Spanning the Milky Way, the two stars called Vega and Altair, or Zhinü-xing and Niulang-xing, together with Deneb at the top of the Northern Cross, form the Summer Triangle. It is called, for example, a sacred figure like the Trinity. Only when the sacred figure shines in the sky does the world meet the sky. ![](https://cdn.luogu.com.cn/upload/pic/21094.png) I want to try it—a prank for the first time, and also the last time. ![](https://cdn.luogu.com.cn/upload/pic/21095.png) That is... what? Nothing happened, you know. It’s just that Mamiya-kun jumped down on his own initiative~ What is going on? Nothing happened, you know. It’s just that Mamiya-kun jumped down on his own initiative~ But I saw it. Was it that thing that killed everyone? Nothing happened, you know. It’s just that Mamiya-kun jumped down on his own initiative~ No, that thing did nothing. It’s just... Nothing happened, you know. It’s just that Mamiya-kun jumped down on his own initiative~ Just... what is going on... Nothing happened, you know. It’s just that Mamiya-kun jumped down on his own initiative~ I definitely heard the sound of a skull shattering. But that was not from the outside world. It came from inside myself. ![](https://cdn.luogu.com.cn/upload/pic/21096.png) Mizukami... I sometimes think about things like this... Where exactly is the limit of the world... Beyond the end of the world... even further beyond... If there were such a place... If I could stand at that place... could I still look at the scenery at the end, just like usual? I think about that.... I naturally thought about it... and then decided that it seems a bit strange. Because that is the end of the world. It is the limit of the world. If I can see that... then would the limit of the world... be equal to my limit? Because the world seen from there... what I see... is my world, isn’t it? The limit of the world... will become my limit~ The world is what I see, touch, and feel. If so, what exactly is the world? What is the difference between the world and me... I think about that. Is there? The difference between the world and me. It is the same. But perhaps other people also feel the same... Even you might also think that the world is yourself. And I think that is probably correct... Although I am not very sure... maybe you are also standing at the end of the world, looking at it like me. So you are also the same as the world. But... that is indeed strange... If the world is me... why can’t I see the world that you see? Even though you exist in my world... I still can’t see the world that you see. I have never seen the world that you see. That is almost like two parallel universes that never intersect... Even if there are phenomena suggesting that thing exists... it is absolutely untouchable... I... can’t see the world where you are... But... Is that really true? Have I really never seen your world... If everyone equally has their own world, then why does the world become one? Why do so many worlds exist here? The reason why the world becomes one ...I sometimes think about such things. So... that is why I can come to like you.

Description

You are playing a galgame, and suddenly realize you have been slacking off too much today, so you want to write a data structure problem to practice: There is a sequence $a$ of length $n$. There are $m$ queries. Each query gives three intervals. For numbers that appear in all three intervals, delete them one by one. Ask for the sum of the counts of remaining numbers in the three intervals at the end. Queries are independent. Note that “delete” means deleting one by one, not deleting all elements equal to that value at once. For example, if the three intervals are $[1,2,2,3,3,3,3]$, $[1,2,2,3,3,3,3]$, and $[1,1,2,3,3]$, then we throw away $1$ occurrence of $1$, $1$ occurrence of $2$, and $2$ occurrences of $3$ together.

Input Format

The first line contains two integers $n,m$. The second line contains $n$ integers denoting $a_i$. Then follow $m$ lines. Each line contains $6$ integers $l_1,r_1,l_2,r_2,l_3,r_3$ describing the three intervals.

Output Format

For each query, output one integer denoting the answer.

Explanation/Hint

Idea: nzhtl1477, Solution: nzhtl1477, Code: nzhtl1477, Data: nzhtl1477 $1\leq n , m \leq 10^5$, $1 \leq a_i\leq 10^9$, $1\leq l_1,r_1,l_2,r_2,l_3,r_3\leq n$, $l_1\leq r_1$, $l_2\leq r_2$, $l_3\leq r_3$。 Translated by ChatGPT 5