Let's call a binary string (a string where each character is either 0 or 1)

of length

an alternating string if and only if

for all

.
You can perform the following operation on a binary string

of length

:
- Choose a substring
and invert all characters of this substring, that is, replace
by
and vice versa.
Let's call beauty of a binary string

the minimum number of operations that need to be performed on

to make it an alternating string.
Now you are given a binary string

of length

.
You need to support

queries. Each query is represented by two indices

and

, denoting that you have to calculate the sum of beauty of all

non-empty subsequences of

modulo

.
The queries are given in a compressed format. Let

and

be the bounds for the

-th query. For

, let
%20%5Cbmod%20n%20)%20%2B%201)
and
%20%5Cbmod%20n%20)%20%2B%201)
. If

, they are swapped. Then assign

to

and

to

. The value of

will be given in the input.
Let

be the answer modulo

to the

-th query. You need to output
%20%3D%20(ans_1%20%2B%2023%20%5Ccdot%201)%20%5Coplus%20(ans_2%20%2B%2023%20%5Ccdot%202)%20%5Coplus%20%5Cldots%20%5Coplus%20(ans_q%20%2B%2023%20%5Ccdot%20q))
.
Here,

denotes the bitwise XOR operation.
String

is a subsequence of string

if and only if

can be obtained from

by deletion of several (possibly, zero) characters.