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;
}
相关推荐
老王以为几秒前
前端视角下的 Java
java·javascript·程序员
隔壁大炮2 分钟前
Day07-RNN介绍
人工智能·pytorch·rnn·深度学习·神经网络·算法·numpy
看腻了那片水8 分钟前
开源一个对业务代码零侵入的透明数据治理框架 —— 【sangsang】
java·mybatis
Nyarlathotep011317 分钟前
JUC工具(3):StampedLock的基础和原理
java·后端
WL_Aurora30 分钟前
Python 算法基础篇之什么是算法
python·算法
呱牛do it37 分钟前
企业级门户网站设计与实现:基于SpringBoot + Vue3的全栈解决方案(Day 7)
java·vue
墨染天姬37 分钟前
[AI]DeepSeek-R1的GRPO算法
人工智能·算法·php
D_C_tyu40 分钟前
JavaScript | 数独游戏核心算法实现
javascript·算法·游戏
qiqsevenqiqiqiqi41 分钟前
MT2048三连 暴力→数学推导→O (n) 优化
数据结构·c++·算法
NE_STOP44 分钟前
Redis--SDS字符串与集合的底层实现原理
java