CF1922A.Tricky Template

普及/提高-

通过率:0%

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

You are given an integer nn and three strings a,b,ca, b, c , each consisting of nn lowercase Latin letters.

Let a template be a string tt consisting of nn lowercase and/or uppercase Latin letters. The string ss matches the template tt if the following conditions hold for all ii from 11 to nn :

  • if the ii -th letter of the template is lowercase, then sis_i must be the same as tit_i ;
  • if the ii -th letter of the template is uppercase, then sis_i must be different from the lowercase version of tit_i . For example, if there is a letter 'A' in the template, you cannot use the letter 'a' in the corresponding position of the string.

Accordingly, the string doesn't match the template if the condition doesn't hold for at least one ii .

Determine whether there exists a template tt such that the strings aa and bb match it, while the string cc does not.

输入格式

The first line contains an integer tt ( 1t10001 \le t \le 1000 ) — the number of test cases.

The first line of each test case contains an integer nn ( 1n201 \le n \le 20 ) — the length of the given strings.

The next three lines contain the strings a,ba, b and cc . Each string consists of exactly nn lowercase Latin letters.

输出格式

For each testcase, print "YES" if there exists a template tt such that the strings aa and bb match it, while the string cc does not. Otherwise, print "NO".

输入输出样例

  • 输入#1

    4
    1
    a
    b
    c
    2
    aa
    bb
    aa
    10
    mathforces
    luckforces
    adhoccoder
    3
    acc
    abd
    abc

    输出#1

    YES
    NO
    YES
    NO

说明/提示

In the first test case, you can use the template "C". The first letter of strings aa and bb differ from 'c', so they match the template. The first letter of string cc equals 'c', so it doesn't match.

In the third test case, you can use the template "CODEforces".

首页