Twin Guardians
시간 제한1초메모리 제한2048 MB
테스트 케이스마다 두 수가 주어질 때, 둘 다 소수이고 차이가 2인 쌍둥이 소수인지 판정합니다.
문제
In a distant Mathematical Kingdom, there stands an ancient gate known as the “Twin Gate.” Legend has it that the gate will only open when two “Twin Guardians” stand before it at the same time.
The king has summoned a wise adventurer to help determine whether the two given numbers are “Twin Primes.” If they genuinely are Twin Guardians (i.e., Twin Primes), the gate will shine brightly and open; otherwise, it will remain firmly shut.
Definition of Twin Primes: If two numbers and are both prime, they are called “twin primes.”
입력
Each test contains multiple test cases. The first line contains the number of test cases . The description of the test cases follows.
The only line of each test case contains two integers and , representing a task assigned by the king that asks you to check these two numbers.
출력
For each test case, if and are twin primes, output Y (indicating “Yes, the Twin Gate opens!”); otherwise, output N.