codeforces:C. Colourblindness

Vasya has a grid with 22 rows and nn columns. He colours each cell red, green, or blue.

Vasya is colourblind and can't distinguish green from blue. Determine if Vasya will consider the two rows of the grid to be coloured the same.

Input

The input consists of multiple test cases. The first line contains an integer tt (1≤t≤1001≤t≤100) — the number of test cases. The description of the test cases follows.

The first line of each test case contains an integer nn (1≤n≤1001≤n≤100) — the number of columns of the grid.

The following two lines each contain a string consisting of nn characters, each of which is either R, G, or B, representing a red, green, or blue cell, respectively — the description of the grid.

Output

For each test case, output "YES" if Vasya considers the grid's two rows to be identical, and "NO" otherwise.

You can output the answer in any case (for example, the strings "yEs", "yes", "Yes" and "YES" will be recognized as a positive answer).

Example

input

Copy

 

6

2

RG

RB

4

GRBG

GBGB

5

GGGGG

BBBBB

7

BBBBBBB

RRRRRRR

8

RGBRRGBR

RGGRRBGR

1

G

G

output

Copy

YES
NO
YES
NO
YES
YES

Note

In the first test case, Vasya sees the second cell of each row as the same because the second cell of the first row is green and the second cell of the second row is blue, so he can't distinguish these two cells. The rest of the rows are equal in colour. Therefore, Vasya will say that the two rows are coloured the same, even though they aren't.

In the second test case, Vasya can see that the two rows are different.

In the third test case, every cell is green or blue, so Vasya will think they are the same.

#include <bits/stdc++.h>
using namespace std;
int t,cnt,n;
bool ok  = true;
int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cin >> t;

    while(t--)
    {
//        int arr[n] = {0};
        ok = true;
        cin >> n;
        string a, b;
        cin >> a >> b;
        for(int i = 0; i < n ; i++)
        {
            if(a[i] == 'R' && b[i] != a[i])
            {
                ok = false;
                break;
            }
            if(b[i] == 'R' && a[i] != b[i])
            {
                ok = false;
                break;
            }
        }

        if(!ok)
            cout << "NO" << endl;
        else
            cout << "YES" <<endl;

    }
    return 0;
}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值