BSSPC '22 P2 - Rhyming Numbers

View as PDF

Submit solution


Points: 3
Time limit: 2.0s
Memory limit: 256M

Author:
Problem type

It is a very well-known fact that Bayview Computer Club currently has exactly 11 executives, and eleven rhymes with seven.

Inspired by this, you have devised a set of rules for whether two numbers rhyme or not:

  • one of the numbers ends in 7
  • the other number ends in 11
  • neither number ends in 17

For two numbers to rhyme, all three conditions must be satisfied.

Given N pairs of numbers, the i^\text{th} being a_i and b_i, determine if the numbers rhyme based on your rules.

Constraints

1 \le N \le 10^4

1 \le a_i, b_i \le 10^9

Input Specification

The first line contains a single integer, N.

The next N lines contain two space-separated integers each, a_i and b_i.

Output Specification

For each of the N pairs, output on a separate line YES if the numbers rhyme, or NO otherwise.

Sample Input

5
7 11
11 14
19511 8247
311 6817
7 7

Sample Output

YES
NO
YES
NO
NO

Comments

There are no comments at the moment.