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;
}
相关推荐
布吉岛的石头6 分钟前
Java 程序员第 45 阶段11:网关统一路由大模型接口,配合 Nacos 配置治理,灰度路由:基于Nacos元数据实现大模型服务灰度发布与权重路由
java·服务发现
日拱一卒——功不唐捐17 分钟前
红黑树删除(C语言)
c语言·数据结构
我命由我1234533 分钟前
Android 开发问题:Cannot resolve method ‘repeat‘ in ‘String‘
android·java·java-ee·android studio·android jetpack·android-studio·android runtime
baozhengw1 小时前
信创改造-SpringBootJar包改为WAR包部署Tomcat
java·tomcat
清泓y1 小时前
RAG 技术
算法·ai
不如语冰1 小时前
AI大模型入门-Python进阶-上下文管理与with语句
开发语言·数据结构·数据库·人工智能·pytorch·redis·python
阿慧今天瘦了嘛1 小时前
计算机组成原理概述:从硬件到软件的桥梁
计算机网络·算法
M1A11 小时前
基于 Spring AOP 构建系统操作日志:从注解设计到异步落库的完整实战
java
RainCity1 小时前
Java Swing 自定义组件库分享(十五)
java·笔记·后端
farerboy2 小时前
23-Java 构造函数
java·后端