Assigning Partners | 프로그래밍의 벗 PivotOJ
PivotOJ

Assigning Partners

시간 제한: 1000ms메모리 제한: 256MB출처: CCC 2014 JuniorBOJ 10105

문제

The CEMC is organizing a workshop with an activity involving pairs of students. They decided to assign partners ahead of time. You need to determine if they did this consistently. That is, whenever A is a partner of B, then B is also a partner of A, and no one is a partner of themselves.

입력

The input consists of three lines. The first line consists of an integer N (1 < N ≤ 30), which is the number of students in the class. The second line contains the first names of the N students separated by single spaces. (Names contain only uppercase or lowercase letters, and no two students have the same first name). The third line contains the same N names in some order, separated by single spaces.

The positions of the names in the last two lines indicate the assignment of partners: the ith name on the second line is the assigned partner of the ith name on the third line.

출력

The output will be good if the two lists of names are arranged consistently, and bad if the arrangement of partners is not consistent.

예제

예제 1

입력
4
Ada Alan Grace John
John Grace Alan Ada
출력
good

예제 2

입력
7
Rich Graeme Michelle Sandy Vlado Ron Jacob
Ron Vlado Sandy Michelle Rich Graeme Jacob
출력
bad
코드를 제출하려면 로그인하세요.