LOVE GURU

0

0 votes
Problem

Ronty has taken the initiative to find out who are likely to become couples in the near future. Accordingly, he has arranged N students in a line. Each ith student has a romance factor Ai .

Your task is to find out whether the consecutive two people's romance factor have a common divisor other than 1 and if they are from the opposite sex or not. Print YES if the criteria matches and NO if it doesn't.

INPUT:

1. First-line contains t test cases.

2. The first line of the test case contains N , the number of students.

3. The second line contains each N space-separated integers A1, A2,....., AN.

4. The third line contains N space-separated characters , 'M' for Male and 'F' for Female.

OUTPUT:

1. For each test case print space-separated N-1 strings saying YES or NO.

CONSTRAINTS:

1 ≤ t ≤ 20

3 ≤ N ≤ 106

2 ≤ Ai ≤ 1018

 

 

Time Limit: 0.11
Memory Limit: 256
Source Limit:
Editor Image

?