eolymp
bolt
Try our new interface for solving problems
Problems

Go to the finals

Go to the finals

Welcome to the semifinal round of the Olympiad! In order to successfully pass this round, the organisers consider that the average student's grade should be no less than $3.5$, and the grade for computer science should be $A$ or $B$. The organisers also believe that not all students will be able to go to the finals, but they may be wrong, as this task is still not solved. Solve this problem by writing a program that will be able to identify students who have passed and have not passed to the final round. \InputFile First line contains the number of students $n~(1 \le n \le 1000)$. Each of the next $n$ lines contains: number $x_i~(0.0 < x_i \le 5.0)$ --- average grade of the $i$-th student and one symbol $y_i~(y_i \in \{A, B, C, D, E, F\})$ --- computer science grade of this student. Students are numbered from $1$ to $n$. \OutputFile For each student in a separate line print $1$ if the student goes to the final, or $0$ otherwise.
Time limit 1 second
Memory limit 128 MiB
Input example #1
2
3.7 C
4.0 B
Output example #1
0
1
Input example #2
3
3.5 B
3.6 C
2.5 A
Output example #2
1
0
0
Source 2018-2019 Republic Azerbaijan, Semifinals