Полуфинал Республиканской олимпиады Азербайджана 2018-2019

Go to the finals

Time limit 1 second
Memory limit 128 MiB

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.

Input data

First line contains the number of students n (1n1000). Each of the next n lines contains: number x[i] (0.0 < x[i]5.0) - average grade of the i-th student and one symbol y[i] (y[i] ϵ {A, B, C, D, E, F}) - computer science grade of this student. Students are numbered from 1 to n.

Output data

For each student in a separate line print 1 if the student goes to the final, or 0 otherwise.


Input example #1
3.7 C
4.0 B
Output example #1
Input example #2
3.5 B
3.6 C
2.5 A
Output example #2
Source 2018-2019 Republic Azerbaijan, Semifinals