There are nails on the circumference of a circular board. They are numbered in clockwise order.
A permutation of is given. A thread starts at nail and visits in this order. The part of the thread between two consecutive nails is a taut straight segment.
Each query gives two integers . Imagine cutting the thread and keeping only the part from through . The remaining thread consists of the segments .
Two distinct segments cross if their interiors have a common point. Determine whether the number of crossing pairs of segments in the remaining thread is odd.
The input is given in the following format:
For each test case, print the answers to its queries in order, one per line.
Print 1 if the number of crossing pairs is odd, and print 0 otherwise.
In the first query, segment - crosses segment -. There is exactly one crossing pair, so the answer is 1.
Each case is given in the following format:
| 2 | 9 | is increasing or decreasing. |
| 3 | 74 | No additional constraints. |