A. Short Sort

time limit per test

1 second

memory limit per test

256 megabytes

input

standard input

output

standard output

There are three cards with letters aa, bb, cc placed in a row in some order. You can do the following operation at most once:

  • Pick two cards, and swap them.

Is it possible that the row becomes abcabc after the operation? Output "YES" if it is possible, and "NO" otherwise.

Input

The first line contains a single integer t� (1≤t≤61≤�≤6) --- the number of test cases.

The only line of each test case contains a single string consisting of each of the three characters aa, bb, and cc exactly once, representing the cards.

Output

For each test case, output "YES" if you can make the row abcabc with at most one operation, or "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

abc

acb

bac

bca

cab

cba

output

Copy

复制代码
YES
YES
YES
NO
NO
YES

Note

In the first test case, we don't need to do any operations, since the row is already abcabc.

In the second test case, we can swap cc and bb: acb→abcacb→abc.

In the third test case, we can swap bb and aa: bac→abcbac→abc.

In the fourth test case, it is impossible to make abcabc using at most one operation.

解题说明:水题,三个字母只要确保有一个在正确的位置上就行。

cpp 复制代码
#include <stdio.h>
int main()
{
	int n;
	char a[4];
	scanf("%d", &n);
	for (int i = 1; i <= n; i++)
	{
		scanf("%s", a);
		if (a[0] == 'a' || a[1] == 'b' || a[2] == 'c')
		{
			printf("YES\n");
		}
		else
		{
			printf("No\n");
		}
	}
	return 0;
}
相关推荐
落落落sss4 分钟前
MQ集群
java·服务器·开发语言·后端·elasticsearch·adb·ruby
我救我自己4 分钟前
UE5运行时创建slate窗口
java·服务器·ue5
2401_8532757324 分钟前
ArrayList 源码分析
java·开发语言
爪哇学长29 分钟前
SQL 注入详解:原理、危害与防范措施
xml·java·数据库·sql·oracle
MoFe143 分钟前
【.net core】【sqlsugar】字符串拼接+内容去重
java·开发语言·.netcore
笨小古44 分钟前
路径规划——RRT-Connect算法
算法·路径规划·导航
_江南一点雨1 小时前
SpringBoot 3.3.5 试用CRaC,启动速度提升3到10倍
java·spring boot·后端
<但凡.1 小时前
编程之路,从0开始:知识补充篇
c语言·数据结构·算法
深情废杨杨1 小时前
后端-实现excel的导出功能(超详细讲解)
java·spring boot·excel
智汇探长1 小时前
EasyExcel自定义设置Excel表格宽高
java·excel·easyexcel