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 ith being ai and bi, determine if the numbers rhyme based on your rules.

Constraints

1N104

1ai,bi109

Input Specification

The first line contains a single integer, N.

The next N lines contain two space-separated integers each, ai and bi.

Output Specification

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

Sample Input

Copy
5
7 11
11 14
19511 8247
311 6817
7 7

Sample Output

Copy
YES
NO
YES
NO
NO

Comments

There are no comments at the moment.