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;
}
相关推荐
小bo波12 小时前
从"任意文件复制"深挖Java I/O:字符流与字节流的本质抉择
java·nio·io流·后端开发·文件复制
JieE2121 天前
LeetCode 101. 对称二叉树|JS 递归 + 迭代双解法,彻底搞懂镜像判断
javascript·算法
nanxun8861 天前
记一次诡异的 Docker 容器"串包"故障排查
java
用户1563068103512 天前
Day01 | Java 基础(Java SE)
java
行者全栈架构师2 天前
Maven dependency:tree 的 8 个高级用法
java·后端
行者全栈架构师2 天前
IDEA 中 Maven 项目的 15 个红色报错快速解决方法
java·后端
令人头秃的代码0_02 天前
mac(m5)平台编译openjdk
java
JieE2122 天前
LeetCode 56. 合并区间|超清晰 JS 图解思路,面试高频区间题
javascript·算法·面试
Jack203 天前
HarmonyOS开发中错误处理策略:网络异常统一处理
算法
小小杨树3 天前
读懂色彩:拍照调色不再难
算法·计算机视觉·配色