Ruffians

시간 제한1초메모리 제한2048 MB

요약
2행 5열 격자에 숫자가 주어질 때, 서로 다른 행과 서로 다른 열에 같은 숫자가 있는지 판정한다.
난이도

쉬움10점 중 2점

유형
완전 탐색, 배열, 구현
정답자
아직 제출이 없습니다

문제

Ashley and Brandon are playing the new hit card game, Ruffians!

In Ruffians, ten cards are dealt out in a grid of two rows and five columns. Each card has a number on it from 1 to 9. Ashley and Brandon are both looking for a pair of cards that have the same number.

After playing this game for a while, they realize that there is always a pair of cards that have the same number. To make the game harder, they require that they find a pair of cards with the same number, and that the two cards are in different rows and different columns.

Given an arrangement of cards, determine if such a pair exists or not.

입력

The first line of input contains a single integer tt (1≤t≤1031\leq t \leq 10^3). This is the number of test cases.

Each test case is represented on two lines.

The first line of each test case contains five integers, each between 11 and 99. The second line of the test case also contains five integers, each between 11 and 99. These two lines combined form the grid of two rows and five columns of cards.

출력

Output tt lines, one for each test case.

For each test case, if there exists a pair of cards with the same number in different rows and different columns, output YES. Otherwise, output NO.

예제1

  1. 예제 1

    입력
    3
    1 2 3 4 5
    1 2 3 4 5
    1 2 3 4 5
    2 6 7 8 9
    5 5 5 5 5
    5 5 5 5 5
    
    예상 출력
    NO
    YES
    YES