CF1606A AB Balance
题目描述
### 题意简述
给定一个字符串 $s$,定义 $\mathrm{AB}(s)$ 为 $s$ 中串 `ab` 出现的次数,$\mathrm{BA}(s)$,为 `ba` 出现的次数。
每次可以修改一个字符,要求通过尽量少的操作 ,使得 $\mathrm{AB}(s)=\mathrm{BA}(s)$。输出修改后的字符串。
输入格式
多组测试,先输入整数 $T\ (1\le T\le 1000)$。
接下来 $T$ 行,每行一个字符串 $s\ (1\le|s|\le 100)$。
输出格式
对于每组数据,输出一个字符串表示答案。
说明/提示
In the first test case, both $ \operatorname{AB}(s) = 0 $ and $ \operatorname{BA}(s) = 0 $ (there are no occurrences of ab (ba) in b), so can leave $ s $ untouched.
In the second test case, $ \operatorname{AB}(s) = 2 $ and $ \operatorname{BA}(s) = 2 $ , so you can leave $ s $ untouched.
In the third test case, $ \operatorname{AB}(s) = 1 $ and $ \operatorname{BA}(s) = 0 $ . For example, we can change $ s_1 $ to b and make both values zero.
In the fourth test case, $ \operatorname{AB}(s) = 2 $ and $ \operatorname{BA}(s) = 1 $ . For example, we can change $ s_6 $ to a and make both values equal to $ 1 $ .