Examination 2
시간 제한2초메모리 제한1024 MB
연산자 우선순위와 좌결합 규칙을 가진 문자열 S가 정의하는 IOI 함수에 대해, Q개의 정수 X_i 각각에 대한 참·거짓 값을 판정한다.
문제
JOI-kun goes to IOI High School, where the final exam is held soon. In the exam, students will be tested on whether they can correctly calculate the value of an IOI function. An IOI function is a string obtained by one of the following six rules defined by IOI High School, which maps integers between and (inclusive) to boolean values, either True or False.
- Let be an integer between and (inclusive), then
[a]is an IOI function (ais the string representation of in decimal notation). This IOI function maps integers greater than or equal to toTrue, and integers less than toFalse. - Let
fbe an IOI function, then(f)is also an IOI function. This IOI function maps the same integers toTrueandFalseasfdoes. - Let
fbe an IOI function, then!fis also an IOI function. This IOI function maps integers thatfmaps toTruetoFalse, and vice versa. - Let
fandgbe IOI functions, thenf&gis also an IOI function. This IOI function maps integers toTrueif bothfandgmap them toTrue, and toFalseotherwise. - Let
fandgbe IOI functions, thenfˆgis also an IOI function. This IOI function maps integers toTrueif exactly one offorgmaps them toTrue, and toFalseotherwise. - Let
fandgbe IOI functions, thenf|gis also an IOI function. This IOI function maps integers toTrueif at least one offorgmaps them toTrue, and toFalseotherwise.
If an IOI function is obtained using multiple rules, the rule with the higher number determines the boolean value that the IOI function maps integers to. For example, for [1]&[2]|[3], rule 6 is applied to f = [1]&[2] and g = [3] (rather than applying rule 4 to f = [1] and g = [2]|[3]). Additionally, for rules 4, 5, and 6, the rule is applied so that f becomes as long as possible. For example, for [4]ˆ[5]ˆ[6], rule 5 is applied to f = [4]ˆ[5] and g = [6] (rather than applying rule 5 to f = [4] and g = [5]ˆ[6]).
To prepare for the exam, JOI-kun has prepared an IOI function of length and intends to practice determining the boolean values that this IOI funcition maps integers to. He askes for your help, as you are proficient with handling IOI functions, to create a sample solution.
Write a program which, given , , and , determines the boolean values that the IOI function maps integers to.
입력
The input is given from Standard Input in the following format:
출력
Print lines to Standard Output. -th line () should contain a single boolean value which the IOI function maps the integer to.
제한
- .
- .
- is an IOI function of length .
- ().
- , , and () are integers.