A palindrome is a string that reads the same backward as forward. For example, the strings "z", "aaa", "aba", and "abccba" are palindromes, but "codeforces" and "ab" are not. You hate palindromes because they give you déjà vu.

There is a string $s$. You must insert exactly one character 'a' somewhere in $s$. If it is possible to create a string that is not a palindrome, you should find one example. Otherwise, you should report that it is impossible.

For example, suppose $s=$ "cbabc". By inserting an 'a', you can create "acbabc", "cababc", "cbaabc", "cbabac", or "cbabca". However "cbaabc" is a palindrome, so you must output one of the other options.


-----Input-----

The first line contains a single integer $t$ ($1\le t\le 10^4$) — the number of test cases.

The only line of each test case contains a string $s$ consisting of lowercase English letters.

The total length of all strings does not exceed $3\cdot 10^5$.


-----Output-----

For each test case, if there is no solution, output "NO".

Otherwise, output "YES" followed by your constructed string of length $|s|+1$ on the next line. If there are multiple solutions, you may print any.

You can print each letter of "YES" and "NO" in any case (upper or lower).


-----Examples-----

Input
6
cbabc
ab
zza
ba
a
nutforajaroftuna
Output
YES
cbabac
YES
aab
YES
zaza
YES
baa
NO
YES
nutforajarofatuna


-----Note-----

The first test case is described in the statement.

In the second test case, we can make either "aab" or "aba". But "aba" is a palindrome, so "aab" is the only correct answer.

In the third test case, "zaza" and "zzaa" are correct answers, but not "azza".

In the fourth test case, "baa" is the only correct answer.

In the fifth test case, we can only make "aa", which is a palindrome. So the answer is "NO".

In the sixth test case, "anutforajaroftuna" is a palindrome, but inserting 'a' elsewhere is valid.

Source: codeforces | Difficulty: EASY
Tags: String algorithms

Constructive algorithms


Solutions:
def check(s):
	l = len(s) // 2
	return s[:l] == s[len(s) - l:][::-1]
for _ in range(int(input())):
	s = str(input())
	d = {}
	f = 0
	if s.count('a') == len(s):
		print('NO')
		continue
	elif not check('a' + s):
		print('YES')
		print('a' + s)
	elif not check(s + 'a'):
		print('YES')
		print(s + 'a')


t = int(input())
ans = []
for i in range(t):
	s = input()
	if s.count('a') == len(s):
		ans.append('NO')
	elif (s + 'a')[::-1] != s + 'a':
		ans.append('YES')
		ans.append(s + 'a')
	elif ('a' + s)[::-1] != 'a' + s:
		ans.append('YES')
		ans.append('a' + s)
	else:
		ans.append('NO')
for i in ans:
	print(i)


for s in [*open(0)][1:]:
	s = s[:-1]
	a = ('a' + s, s + 'a')
	(x, y) = (t == t[::-1] for t in a)
	print(('YES ' + a[x], 'NO')[x & y])


t = int(input())
for _ in range(t):
	query = input()
	if query.count('a') == len(query):
		print('NO')
	else:
		front = 'a' + query
		back = query + 'a'
		if front != front[::-1]:
			print('YES')
			print(front)
		elif back != back[::-1]:
			print('YES')
			print(back)


import sys
input = sys.stdin.readline
from collections import Counter

def is_palind(s):
	if len(s) <= 1:
		return True
	f = s[:len(s) // 2]
	b = s[(len(s) + 1) // 2:][::-1]
	return b == f
t = int(input())
orda = ord('a')
for _ in range(t):
	s = input().rstrip()
	if s.count('a') == len(s):
		print('NO')
		continue
	t1 = 'a' + s
	print('YES')
	if is_palind(t1):
		print(s + 'a')
	else:
		print(t1)


try:
	t = int(input())
	for _ in range(t):
		s = input()
		t = ''
		if s != s[::-1]:
			t = 'a' + s
			if t != t[::-1]:
				print('YES')
				print(t)
				continue
			t = s + 'a'
			if t != t[::-1]:
				print('YES')
				print(t)
				continue
			else:
				for i in range(len(s) - 2):
					t = s[i] + 'a' + s[i + 1:]
					if t != t[::-1]:
						print('YES')
						print(t)
						break
					else:
						continue
		else:
			ab = set()
			ab.add('a')
			if ab == set(s):
				print('NO')
			else:
				t = 'a' + s
				if t != t[::-1]:
					print('YES')
					print(t)
					continue
				t = s + 'a'
				if t != t[::-1]:
					print('YES')
					print(t)
					continue
				else:
					for i in range(len(s) - 2):
						t = s[i] + 'a' + s[i + 1:]
						if t != t[::-1]:
							print('YES')
							print(t)
							break
						else:
							continue
except:
	pass


t = int(input())
for i in range(t):
	st = input()
	for j in range(len(st) // 2 + len(st) % 2):
		if st[len(st) - j - 1] != 'a':
			print('YES')
			print(st[0:j] + 'a' + st[j:len(st)])
			break
		if st[j] != 'a':
			print('YES')
			print(st[0:len(st) - j - 1] + 'a' + st[len(st) - j - 1:len(st)])
			break
	else:
		print('NO')


import sys
input = sys.stdin.readline
t = int(input())
for i in range(t):
	s = input()
	s = s[:len(s) - 1]
	flag = True
	temp1 = s + 'a'
	temp2 = 'a' + s
	if temp1 != temp1[::-1]:
		print('YES')
		print(temp1)
		continue
	if temp2 != temp2[::-1]:
		print('YES')
		print(temp2)
		continue
	print('NO')


def par(s):
	n = len(s)
	for i in range(n // 2):
		if s[i] != s[n - 1 - i]:
			return False
	return True

def solve(s):
	if not par('a' + s):
		return 'YES\n' + 'a' + s
	if not par(s + 'a'):
		return 'YES\n' + s + 'a'
	return 'NO'
t = int(input())
while t > 0:
	s = input()
	print(solve(s))
	t -= 1


for _ in range(int(input())):
	s = list(input())
	k = set(s)
	if len(k) == 1 and s[0] == 'a':
		print('NO')
	else:
		print('YES')
		b = s
		b.append('a')
		if b != b[::-1]:
			y = ''.join((i for i in b))
		else:
			b.pop()
			b.insert(0, 'a')
			if b != b[::-1]:
				y = ''.join((i for i in b))
		print(y)


def is_palindrome(s):
	reverse_s = s[::-1]
	status = True
	if s != reverse_s:
		status = False
	return status
t = int(input())
list1 = []
for i in range(t):
	string = str(input())
	if is_palindrome(string + 'a') == False:
		print('YES')
		print(string + 'a')
	elif is_palindrome('a' + string) == False:
		print('YES')
		print('a' + string)
	else:
		print('NO')


import sys
n_cases = int(sys.stdin.readline().strip())
for _ in range(n_cases):
	s = sys.stdin.readline().strip()
	l = len(s)
	i = 0
	while i != l and s[i] == 'a':
		i += 1
	if i == l:
		print('NO')
	else:
		print('YES')
		pos = l - i
		print(s[:pos] + 'a' + s[pos:])


import math
from collections import defaultdict
DEBUG = True

def log(*args, **kwargs):
	if DEBUG:
		print(*args, **kwargs)

def ri():
	return int(input())

def rl(f=int):
	return list(map(f, input().split()))

def rs():
	return input()

class Solution:

	def __init__(self):
		pass

	def run(self):
		s = rs()
		count = len([x for x in s if x == 'a'])
		if count == len(s):
			return 'NO'
		if not self.p('a' + s):
			print('YES')
			return 'a' + s
		print('YES')
		return s + 'a'

	def p(self, s):
		i = 0
		j = len(s) - 1
		while i <= j:
			if s[i] != s[j]:
				return False
			i += 1
			j -= 1
		return True
t = int(input())
s = Solution()
for i in range(t):
	print(s.run())


t = int(input())
for i in range(t):
	s = input()
	n = len(s)
	index = -1
	for j in range(n):
		if s[j] != 'a':
			index = j
			break
	if index == -1:
		print('NO')
	else:
		print('YES')
		print(s[0:n - j] + 'a' + s[n - j:])


import sys, math
from collections import deque, defaultdict
import operator as op
from functools import reduce
from itertools import permutations
I = sys.stdin.readline
alpha = 'abcdefghijklmnopqrstuvwxyz'

def ii():
	return int(I().strip())

def li():
	return list(map(int, I().strip().split()))

def mi():
	return map(int, I().strip().split())

def ncr(n, r):
	r = min(r, n - r)
	numer = reduce(op.mul, range(n, n - r, -1), 1)
	denom = reduce(op.mul, range(1, r + 1), 1)
	return numer // denom

def gcd(x, y):
	while y:
		(x, y) = (y, x % y)
	return x

def isPrime(n):
	if n <= 1:
		return False
	elif n <= 2:
		return True
	else:
		for i in range(2, int(n ** 0.5) + 1):
			if n % i == 0:
				return False
		return True

def main():
	ans = ''
	for _ in range(ii()):
		s = I().strip()
		n = len(s)
		i = 0
		j = n - 1
		first = -1
		last = -1
		while i <= j:
			if s[i] != 'a' or s[j] != 'a':
				first = i
				last = j
				break
			i += 1
			j -= 1
		if first == -1 and last == -1:
			ans += 'NO\n'
		else:
			pos = -1
			if s[first] == s[last]:
				pos = 0
			else:
				pos = 1
			tmp = ''
			for i in range(n):
				if i == first and pos == 0:
					tmp += 'a'
				tmp += s[i]
				if i == first and pos == 1:
					tmp += 'a'
			ans += 'YES\n'
			ans += tmp + '\n'
	print(ans)
main()


for i in range(int(input())):
	s = input()
	if s.count('a') == len(s):
		print('NO')
	else:
		s1 = 'a' + s
		print('YES')
		if s1 == s1[::-1]:
			print(s + 'a')
		else:
			print(s1)


for _ in range(int(input())):
	s = input()
	flag = 0
	for i in s:
		if i != 'a':
			flag = 1
			break
	if flag == 0:
		print('NO')
	else:
		print('YES')
		l = [0 for i in range(len(s) + 1)]
		j = 0
		for i in range(len(s)):
			if s[i] != 'a':
				j = len(s) - i
				break
		x = s[:j] + 'a' + s[j:]
		print(x)


for _ in range(int(input())):
	s = input()
	if s[0] == 'a' and len(set(s)) == 1:
		print('NO')
	else:
		print('YES')
		if s + 'a' == 'a' + s[::-1]:
			print('a' + s)
		else:
			print(s + 'a')


for i in range(int(input())):
	a = input()
	x = a + 'a'
	y = 'a' + a
	if x != x[::-1]:
		print('YES')
		print(x)
	elif y != y[::-1]:
		print('YES')
		print(y)
	else:
		print('NO')


from collections import deque, Counter, defaultdict
import heapq
import math
array = []
ncases = int(input())
q = []
while ncases:
	q.append(input())
	ncases -= 1

def function(string):
	if set(string) == {'a'}:
		return -1
	s1 = string + 'a'
	s2 = 'a' + string
	if s1 == s1[::-1]:
		return s2
	else:
		return s1
m = len(q)
i = 0
while i != m:
	val = function(q[i])
	if val != -1:
		print('YES')
		print(val)
	else:
		print('NO')
	i += 1


from functools import reduce
import os
import sys
from collections import *
from decimal import *
from math import *
from bisect import *
from heapq import *
from io import BytesIO, IOBase
input = lambda : sys.stdin.readline().rstrip('\r\n')

def value():
	return tuple(map(int, input().split()))

def arr():
	return [int(i) for i in input().split()]

def sarr():
	return [int(i) for i in input()]

def starr():
	return [str(x) for x in input().split()]

def inn():
	return int(input())

def svalue():
	return tuple(map(str, input().split()))

def parr():
	return [value() for i in range(n)]

def Ceil(a, b):
	return a // b + int(a % b > 0)
albhabet = 'abcdefghijklmnopqrstuvwxyz'
mo = 1000000007
inf = 1e+18
div = 998244353
for _ in range(inn()):
	s = input()
	if len(set(s)) == 1 and s[0] == 'a':
		print('NO')
	else:
		print('YES')
		n = len(s)
		for i in range(n):
			if s[i] != 'a':
				s = s[:n - i] + 'a' + s[n - i:]
				break
		print(s)


import sys
reader = (s.rstrip() for s in sys.stdin)
input = reader.__next__
t = int(input())
for _ in range(t):
	string = input()
	cnt = set(string)
	if len(cnt) == 1 and 'a' in cnt:
		print('NO')
		continue
	print('YES')
	temp = 'a' + string
	if temp == temp[::-1]:
		print(string + 'a')
	else:
		print(temp)


def solve(A):
	for i in range(len(A)):
		if A[i] != 'a':
			print('YES')
			print(A[:len(A) - i] + 'a' + A[len(A) - i:])
			return
	print('NO')
x = int(input())
A = []
for _ in range(x):
	A.append(input())
for a in A:
	solve(a)


import math
t = int(input())
o = []
while t > 0:
	flag = 0
	s = input()
	if s == len(s) * 'a':
		o.append(['NO'])
		flag = 1
	elif len(s) == 1:
		r = s + 'a'
	elif len(s) % 2 == 0:
		s1 = s[0:int(len(s) / 2)]
		s2 = s[-1:int(len(s) / 2) - 1:-1]
		if s1 == s2:
			r = s + 'a'
		else:
			r = s1 + 'a' + s2[-1::-1]
	else:
		s1 = s[0:int((len(s) - 1) / 2)]
		s2 = s[-1:-1 * math.ceil(len(s) / 2):-1]
		if s1 == s2:
			r = s + 'a'
		else:
			r = s1 + 'a' + s[int((len(s) - 1) / 2)] + s2[-1::-1]
	if flag == 0:
		o.append(['YES'])
		o.append([r])
	t = t - 1
for i in range(len(o)):
	if i > 0:
		print('\n', end='')
	for j in range(len(o[i])):
		print(o[i][j], ' ', end='', sep='')


a = int(input())
l = 0
while l != a:
	l += 1
	s = input()
	count = s.count('a')
	if count == len(s):
		print('NO')
	elif len(s) == 1:
		print('YES')
		print('a' + str(s))
	else:
		first = 'a' + str(s)
		b = True
		for i in range(len(first) // 2 + 1):
			if first[i] == first[-(i + 1)]:
				continue
			else:
				b = False
				break
		print('YES')
		if b == False:
			print(first)
		else:
			print(str(s) + 'a')


for _ in range(int(input())):
	s = input()
	rev = s[::-1]
	l = len(s)
	a = 'a'
	st = list(set(list(s)))
	if len(st) == 1 and st[0] == a:
		print('NO')
	elif rev == s:
		s1 = a + s
		print('YES')
		print(s1)
	else:
		r1 = a + s
		r2 = s + a
		if r1 == r1[::-1]:
			print('YES')
			print(r2)
		else:
			print('YES')
			print(r1)


def reverse(x):
	sl = len(x)
	rev = x[sl::-1]
	return rev

def main():
	n = int(input())
	s = [''] * n
	for i in range(n):
		s[i] = input()
	for i in range(n):
		if s[i] == len(s[i]) * 'a':
			print('NO')
			continue
		else:
			print('YES')
			if s[i][0] == s[i][len(s[i]) - 1]:
				if s[i][0] != 'a' and s[i][len(s[i]) - 1] != 'a':
					print('a' + s[i])
					continue
				tst = 'a' + s[i]
				tst2 = s[i] + 'a'
				if tst != reverse(tst):
					print(tst)
					continue
				if tst2 != reverse(tst2):
					print(tst2)
					continue
			else:
				print(s[i][0] + 'a' + s[i][1:len(s[i])])
main()


T_ON = 1
DEBUG_ON = 0
MOD = 998244353

def solve():
	s = input()
	if set(s) == {'a'}:
		NO()
		return
	n = len(s)
	i = 0
	while i < n and s[i] == 'a':
		i += 1
	j = n - 1
	while j >= 0 and s[j] == 'a':
		j -= 1
	left = i
	right = n - j
	YES()
	if left >= right:
		print('a' + s)
	else:
		print(s + 'a')

def main():
	T = read_int() if T_ON else 1
	for i in range(T):
		solve()

def debug(*xargs):
	if DEBUG_ON:
		print(*xargs)
from collections import *
import math
import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')

def read_int():
	return int(input())

def read_ints():
	return list(map(int, input().split()))

def print_nums(nums):
	print(' '.join(map(str, nums)))

def YES():
	print('YES')

def Yes():
	print('Yes')

def NO():
	print('NO')

def No():
	print('No')

def First():
	print('First')

def Second():
	print('Second')

def fib(n):
	(a, b) = (0, 1)
	for _ in range(n):
		(a, b) = (b, a + b)
	return a

def fib_ns(n):
	assert n >= 1
	f = [0 for _ in range(n + 1)]
	f[0] = 0
	f[1] = 1
	for i in range(2, n + 1):
		f[i] = f[i - 1] + f[i - 2]
	return f

def fib_to_n(n):
	f = []
	(a, b) = (0, 1)
	while a <= n:
		f.append(a)
		(a, b) = (b, a + b)
	return f

def gcd(a, b):
	if a == 0:
		return b
	return gcd(b % a, a)

def xgcd(a, b):
	(x0, x1, y0, y1) = (0, 1, 1, 0)
	while a != 0:
		((q, a), b) = (divmod(b, a), a)
		(y0, y1) = (y1, y0 - q * y1)
		(x0, x1) = (x1, x0 - q * x1)
	return (b, x0, y0)

def lcm(a, b):
	d = gcd(a, b)
	return a * b // d

def is_even(x):
	return x % 2 == 0

def is_odd(x):
	return x % 2 == 1

def modinv(a, m):
	(g, x, _) = xgcd(a, m)
	if g != 1:
		raise Exception('gcd(a, m) != 1')
	return x % m

def mod_add(x, y):
	x += y
	while x >= MOD:
		x -= MOD
	while x < 0:
		x += MOD
	return x

def mod_mul(x, y):
	return x * y % MOD

def mod_pow(x, y):
	if y == 0:
		return 1
	if y % 2:
		return mod_mul(x, mod_pow(x, y - 1))
	p = mod_pow(x, y // 2)
	return mod_mul(p, p)

def mod_inv(y):
	return mod_pow(y, MOD - 2)

def mod_div(x, y):
	return mod_mul(x, mod_inv(y))

def is_prime(n):
	if n == 1:
		return False
	for i in range(2, int(n ** 0.5) + 1):
		debug(n, i)
		if n % i == 0:
			return False
	return True

def gen_primes(n):
	P = [True for _ in range(n + 1)]
	P[0] = P[1] = False
	for i in range(int(n ** 0.5) + 1):
		if P[i]:
			for j in range(2 * i, n + 1, i):
				P[j] = False
	return P

def is_lucky(n):
	return set(list(str(n))).issubset({'4', '7'})
main()


def isPalindrome(str):
	for i in range(0, int(len(str) / 2)):
		if str[i] != str[len(str) - i - 1]:
			return i
	return -1
task = int(input())
while task > 0:
	s = input()
	flag = 0
	for item in s:
		if item != 'a':
			flag = 1
			break
	if flag == 0:
		print('NO')
	else:
		print('YES')
		temp = isPalindrome(s)
		if temp == -1:
			print('a' + s)
		else:
			print(s[:temp + 1] + 'a' + s[temp + 1:])
	task -= 1


from math import *
t = int(input())
while t:
	str1 = input()
	l = len(str1)
	str2 = str1[l::-1]
	count = 0
	if str1 == str2:
		for i in str1:
			if i == 'a':
				count += 1
		if count != l:
			print('YES')
			print('a' + str1)
		else:
			print('NO')
	elif 'a' + str1 != str2 + 'a':
		print('YES')
		print('a' + str1)
	else:
		print('YES')
		print(str1 + 'a')
	t -= 1


for i in range(int(input())):
	s = input()
	if s + 'a' != (s + 'a')[::-1]:
		print('YES')
		print(s + 'a')
	elif 'a' + s != ('a' + s)[::-1]:
		print('YES')
		print('a' + s)
	else:
		print('NO')


t = int(input())
while t:
	s = input()
	ss = s + 'a'
	s = 'a' + s
	if ss != ss[::-1]:
		print('YES')
		print(ss)
	elif s != s[::-1]:
		print('YES')
		print(s)
	else:
		print('NO')
	t -= 1


t = int(input())
while t:
	s = input()
	temp1 = 'a' + s
	temp2 = s + 'a'
	if temp1 != temp1[::-1]:
		print('YES')
		print(temp1)
	elif temp2 != temp2[::-1]:
		print('YES')
		print(temp2)
	else:
		print('NO')
	t -= 1


t = int(input())
while t > 0:
	a = input()
	j = 0
	k = 'a'
	res = k + a[0:]
	tes = a[0:] + k
	if res == res[::-1] and tes == tes[::-1]:
		print('NO')
	elif res != res[::-1]:
		print('YES')
		print(res)
	elif tes != tes[::-1]:
		print('YES')
		print(tes)
	else:
		print('ERROR')
	t -= 1


t = int(input())

def is_palindrome(s):
	return s == s[::-1]
for _ in range(t):
	s = input().strip()
	is_all_a = True
	for c in s:
		if c != 'a':
			is_all_a = False
			break
	if is_all_a:
		print('NO\n')
	else:
		print('YES\n')
		if is_palindrome('a' + s):
			print(f"{s + 'a'}\n")
		else:
			print(f"{'a' + s}\n")


def check_if_palindrome(s):
	if s == s[::-1]:
		return True
	return False

def check_if_possible(string, character):
	if str.count(string, character) == len(string):
		return (string, False)
	if string[0] != character:
		string += character
		return (string, True)
	elif string[-1] != character:
		string = string[0:-1] + character + string[-1]
		return (string, True)
	else:
		length = len(string)
		for i in range(1, length):
			if string[i] != character:
				string = string[0:-i] + character + string[-i:]
				return (string, True)
		return (string, False)

def start_test():
	strings = []
	character = 'a'
	t = int(input())
	for i in range(0, t):
		string = input()
		strings.append(string)
	for string in strings:
		(result, possible) = check_if_possible(string, character)
		if possible:
			print('YES')
			print(result)
		else:
			print('NO')
start_test()


t = int(input())
for _ in range(t):
	s = input()
	ans = ''
	n = len(s)
	f = 1
	if s != s[::-1]:
		ans = s[0:n // 2] + 'a' + s[n // 2:n]
	elif s.count('a') == n:
		f = 0
	else:
		ans = 'a' + s[0:n]
	if not f:
		print('NO')
	else:
		print('YES')
		print(ans)


for _ in range(int(input())):
	s = input()
	s1 = 'a' + s
	s2 = s + 'a'
	if s1 != s1[::-1]:
		print('YES', s1, sep='\n')
	elif s2 != s2[::-1]:
		print('YES', s2, sep='\n')
	else:
		print('NO')


try:
	for _ in range(int(input())):
		s = input()
		if s.count('a') == len(s):
			print('No')
		else:
			print('Yes')
			a = s[0:len(s) // 2] + 'a' + s[len(s) // 2:]
			b = s + 'a'
			c = 'a' + s
			if a != a[::-1]:
				print(a)
			elif b != b[::-1]:
				print(b)
			else:
				print(c)
except:
	pass


for _ in range(int(input())):
	s = input()
	if s + 'a' != (s + 'a')[::-1]:
		print('YES\n', s + 'a')
	elif 'a' + s != 'a' + s[::-1]:
		print('YES\n', 'a' + s)
	else:
		print('NO')


def isPalindrome(word):
	return word == word[::-1]
t = int(input())
for i in range(t):
	str1 = input()
	if not isPalindrome('a' + str1):
		print('YES')
		print('a' + str1)
	elif not isPalindrome(str1 + 'a'):
		print('YES')
		print(str1 + 'a')
	else:
		print('NO')


for t in range(int(input())):
	s = input()
	if s.count('a') == len(s):
		print('No')
	else:
		print('Yes')
		st = s = 'a' + s
		st = st[::-1]
		if s != st:
			print(s)
		else:
			s = s[1:]
			s = s + 'a'
			print(s)


def isPalindrome(s):
	return s == s[::-1]
for _ in range(int(input())):
	s = input()
	l = len(s)
	tmp = s
	totalA = s.count('a')
	check = False
	if len(s) == totalA:
		print('NO')
	else:
		print('YES')
		check = True
	if check:
		s = tmp + 'a'
		if isPalindrome(s):
			print('a' + tmp)
		else:
			print(s)


def is_pallin(s):
	n = len(s)
	s = list(s)
	nl = s.copy()
	nl.reverse()
	if s[0:n // 2] == nl[0:n // 2]:
		return True
	return False
t = int(input())
for i in range(t):
	s = input()
	s = list(s)
	b = list(set(s))
	val = len(b)
	if val == 1 and b[0] == 'a':
		print('NO')
	elif is_pallin(s):
		print('YES')
		s.append('a')
		print(''.join(s))
	else:
		tmp = s.copy()
		tmp.append('a')
		if is_pallin(tmp) == False:
			print('YES')
			print(''.join(tmp))
		else:
			tmp.pop()
			ui = ['a']
			ui.extend(tmp)
			print('YES')
			print(''.join(ui))


import math
import operator

def solve():
	s = input()
	c = s.count('a')
	if c == len(s):
		print('NO')
	else:
		print('YES')
		t = 'a' + s
		if t != t[::-1]:
			print(t)
			return
		t = s + 'a'
		if t != t[::-1]:
			print(t)
			return
		for i in range(len(s)):
			s1 = s[:i]
			s2 = s[i + 1:]
			t = s1 + 'a' + s2
			if t != t[::-1]:
				print(t)
				return
t = int(input())
while t > 0:
	t -= 1
	solve()


import sys
input = lambda : sys.stdin.readline().rstrip('\r\n')
inp = lambda : list(map(int, sys.stdin.readline().rstrip('\r\n').split()))
mod = 10 ** 9 + 7
Mod = 998244353
INF = float('inf')
tc = 1
tc = int(input())
for test in range(1, tc + 1):
	s = str(input())
	n = len(s)
	if s == s[::-1]:
		for i in range(n):
			if s[i] != 'a':
				s = s[:i] + 'a' + s[i:]
				break
		else:
			s = s[:(n + 1) // 2] + 'a' + s[(n + 1) // 2:]
	else:
		s = s[:(n + 1) // 2] + 'a' + s[(n + 1) // 2:]
	if s != s[::-1]:
		print('YES')
		print(s)
	else:
		print('NO')


for s in [*open(0)][1:]:
	s = s[:-1]
	a = ('a' + s, s + 'a')
	b = [t == t[::-1] for t in a]
	print(*(['NO'], ['YES', a[b[0]]])[0 in b])


import sys

def check(s):
	n = len(s) // 2
	if len(s) % 2 and s[:n + 1] != s[n:][::-1]:
		return True
	if len(s) % 2 == 0 and s[:n] != s[n:][::-1]:
		return True
	return False

def Main():
	t = int(sys.stdin.readline().strip())
	for _ in range(t):
		s = sys.stdin.readline().strip()
		n = len(s)
		if s == 'a' * n:
			print('NO')
			continue
		print('YES')
		ans = s + 'a'
		if check(ans):
			print(ans)
		else:
			print('a' + s)
Main()


import os
import sys
from io import BytesIO, IOBase
import threading
from bisect import bisect_right
from math import gcd, log
from collections import Counter
from pprint import pprint
from itertools import permutations
from bisect import bisect_right

def main():
	s = input()
	if len(set(s)) == 1 and s[0] == 'a':
		print('NO')
	n = len(s)
	s = [c for c in s]
	for i in range(n):
		if s[i] != 'a':
			s.insert(n - i, 'a')
			print('YES')
			print(''.join(s))
			return
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
for _ in range(int(input())):
	main()


import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
for t in range(int(input())):
	s = input()
	if s.count('a') == len(s):
		print('NO')
	else:
		print('YES')
		j = 0
		for i in range(len(s)):
			if s[len(s) - 1 - i] != 'a':
				j = i
				break
		print(s[:j] + 'a' + s[j:])


n = int(input())
for i in range(0, n):
	h = input()
	h1 = h + 'a'
	h2 = 'a' + h
	if h1 != h1[::-1]:
		print('YES')
		print(h1)
	elif h2 != h2[::-1]:
		print('YES')
		print(h2)
	else:
		print('NO')


x = int(input())
for i in range(x):
	a = input()
	s = a + 'a'
	d = 'a' + a
	if s == s[::-1]:
		if d == d[::-1]:
			print('NO')
		else:
			print('YES')
			print(d)
	else:
		print('YES')
		print(s)


from __future__ import division, print_function
from fractions import Fraction
import sys
import os
from io import BytesIO, IOBase
from functools import cmp_to_key
from heapq import *
from math import gcd, factorial, floor, ceil, sqrt, log2
from copy import deepcopy
from collections import deque
from bisect import bisect_left as bl
from bisect import bisect_right as br
from bisect import bisect
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')

def print(*args, **kwargs):
	(sep, file) = (kwargs.pop('sep', ' '), kwargs.pop('file', sys.stdout))
	at_start = True
	for x in args:
		if not at_start:
			file.write(sep)
		file.write(str(x))
		at_start = False
	file.write(kwargs.pop('end', '\n'))
	if kwargs.pop('flush', False):
		file.flush()
if sys.version_info[0] < 3:
	(sys.stdin, sys.stdout) = (FastIO(sys.stdin), FastIO(sys.stdout))
else:
	(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
from types import GeneratorType

def iterative(f, stack=[]):

	def wrapped_func(*args, **kwargs):
		if stack:
			return f(*args, **kwargs)
		to = f(*args, **kwargs)
		while True:
			if type(to) is GeneratorType:
				stack.append(to)
				to = next(to)
				continue
			stack.pop()
			if not stack:
				break
			to = stack[-1].send(to)
		return to
	return wrapped_func

def inp():
	return sys.stdin.readline().rstrip('\r\n')

def out(var):
	sys.stdout.write(str(var))

def lis():
	return list(map(int, inp().split()))

def stringlis():
	return list(map(str, inp().split()))

def sep():
	return map(int, inp().split())

def strsep():
	return map(str, inp().split())

def testcase(t):
	for pp in range(t):
		solve(pp)

def google(p):
	print('Case #' + str(p) + ': ', end='')

def lcm(a, b):
	return a * b // gcd(a, b)

def modInverse(b):
	g = gcd(b, mod)
	if g != 1:
		return -1
	else:
		return pow(b, mod - 2, mod)

def power(x, y, p):
	y %= p - 1
	res = 1
	x = x % p
	if x == 0:
		return 0
	while y > 0:
		if y & 1 == 1:
			res = res * x % p
		y = y >> 1
		x = x * x % p
	return res

def isPrime(n):
	if n <= 1:
		return False
	if n <= 3:
		return True
	if n % 2 == 0 or n % 3 == 0:
		return False
	i = 5
	while i * i <= n:
		if n % i == 0 or n % (i + 2) == 0:
			return False
		i = i + 6
	return True
inf = pow(10, 20)
mod = 10 ** 9 + 7

def solve(case):
	s = list(inp())
	if s == s[::-1]:
		if s == ['a'] * len(s):
			print('NO')
		else:
			print('YES')
			ind = -1
			for i in range(len(s)):
				if s[-(i + 1)] == 'a':
					continue
				ind = i
				break
			ans = s[:ind] + ['a'] + s[ind:]
			print(''.join(ans))
	else:
		print('YES')
		ind = -1
		for i in range(len(s)):
			if s[-(i + 1)] == 'a':
				continue
			ind = i
			break
		ans = s[:ind] + ['a'] + s[ind:]
		print(''.join(ans))
testcase(int(inp()))


for _ in range(int(input())):
	s = input()
	if set(s) == {'a'}:
		print('NO')
	else:
		i = 0
		while s[~i] == 'a':
			i += 1
		print('YES')
		print(s[:i] + 'a' + s[i:])


import re
import math

def palindrome(string):
	left = 0
	right = len(string) - 1
	while left < right:
		if string[left] == string[right]:
			left += 1
			right -= 1
		else:
			return True
	return False
nums = int(input())
for i in range(nums):
	string = input()
	if palindrome(string + 'a'):
		print('YES')
		print(string + 'a')
	elif palindrome('a' + string):
		print('YES')
		print('a' + string)
	else:
		print('NO')


def ispal(n, l):
	for i in range(0, l // 2):
		if n[i] != n[l - i - 1]:
			return False
	return True
for _ in range(int(input())):
	n = input()
	l = len(n)
	f = n + 'a'
	s = 'a' + n
	if not ispal(f, len(f)):
		print('YES')
		print(f)
	elif not ispal(s, len(s)):
		print('YES')
		print(s)
	else:
		print('NO')


t = int(input())
for _ in range(t):
	s = input()
	q = s.count('a')
	if q == len(s):
		print('NO')
	else:
		w = 'a' + s
		e = s + 'a'
		if w != w[::-1]:
			print('YES')
			print(w)
		elif e != e[::-1]:
			print('YES')
			print(e)
		else:
			print('NO')


for t in range(int(input())):
	s = input()
	t = s + 'a'
	w = 'a' + s
	if t != t[::-1]:
		print('YES')
		print(t)
	elif w != w[::-1]:
		print('YES')
		print(w)
	else:
		print('NO')


test = int(input())
for t in range(test):
	a = input()
	l = len(a)
	f = 0
	for i in range(0, l):
		if a[i] != 'a':
			f = 1
			print('YES')
			for j in range(0, l - i):
				print(a[j], end='')
			print('a', end='')
			for j in range(l - i, l):
				print(a[j], end='')
			print()
			break
	if f == 0:
		print('NO')


t = int(input().strip())
for i in range(t):
	s = input().strip()
	if s == '':
		print('NO')
	else:
		same = True
		for j in range(len(s) - 1):
			if s[j] != s[j + 1]:
				same = False
				break
		if same:
			if s[0] == 'a':
				print('NO')
			else:
				print('YES')
				print('a' + s)
		else:
			print('YES')
			rs = s[::-1]
			pos = -1
			for j in range(len(s)):
				if s[j] != rs[j]:
					pos = j
					break
			print(s[:pos + 1] + 'a' + s[pos + 1:])


c = int(input())
while c > 0:
	s = input()
	a = s.count('a')
	if a == len(s):
		print('NO')
	else:
		print('YES')
		t = 'a' + s
		if t != t[::-1]:
			print(t)
		else:
			print(s + 'a')
	c -= 1


for _ in range(int(input())):
	n = input()
	t1 = n + 'a'
	t2 = 'a' + n
	if t1 != t1[::-1]:
		print('YES')
		print(t1)
	elif t2 != t2[::-1]:
		print('YES')
		print(t2)
	else:
		print('NO')


t = int(input())
while t:
	t -= 1
	s = input()
	if s == 'a' * len(s):
		print('NO')
		continue
	s1 = s + 'a'
	if s1 != s1[::-1]:
		print('YES')
		print(s1)
	else:
		print('YES')
		print('a' + s)


t = int(input())
for _ in range(t):
	s = list(input())
	if s.count('a') == len(s):
		print('NO')
	else:
		print('YES')
		s.append('a')
		if s == s[::-1]:
			del s[-1]
			print('a' + ''.join(s))
		else:
			print(''.join(s))


from sys import stdin as si, stdout as so
for _ in range(int(si.readline())):
	s = si.readline().strip()
	l = len(s)
	if s == 'a':
		so.write('NO\n')
	else:
		f = False
		d = ''
		for i in range(l):
			if s[i] != 'a':
				d += s[:l - i] + 'a' + s[l - i:]
				f = True
				break
		if f:
			so.write('YES\n')
			so.write(d + '\n')
		else:
			so.write('NO\n')


for _ in range(int(input())):
	A = input()
	if len(set(list(A))) == 1 and A[0] == 'a':
		print('NO')
	else:
		for i in range(len(A)):
			if A[i] != 'a':
				j = abs(len(A) - i)
				print('YES')
				print(A[:j] + 'a' + A[j:])
				break


def check(s):
	x = s
	y = ''.join(reversed(s))
	if x == y:
		return True
	return False

def ans(s):
	c = 'a'
	m = s
	n = ''
	n = c + s
	if check(n) == False:
		print(n)
	else:
		n = s + c
		if check(n) == False:
			print(n)
t = int(input())
while t > 0:
	s = str(input())
	f = ''.join(dict.fromkeys(s))
	if f == 'a':
		print('NO')
	else:
		print('YES')
		ans(s)
	t -= 1


for t in range(int(input())):
	string = str(input())
	arr = []
	for _ in string:
		arr.append(_)
	if len(string) == string.count('a'):
		print('NO')
	else:
		print('YES')
		for i in range(len(arr) - 1, -1, -1):
			if arr[i] != 'a':
				arr.insert(len(arr) - i - 1, 'a')
				print(''.join(arr))
				break


for i in range(int(input())):
	s = input()
	k = s + 'a'
	v = 'a' + s
	if s.count('a') == len(s):
		print('NO')
	elif k != k[::-1]:
		print('YES')
		print(k)
	else:
		print('YES')
		print(v)


m = int(input())
l = []
for _ in range(m):
	a = input()
	t = len(a)
	for i in range(t):
		if a[i] != 'a':
			a = a[:t - i] + 'a' + a[t - i:]
			l.append('YES')
			l.append(a)
			break
	else:
		l.append('NO')
for i in l:
	print(i)


t = int(input())
for _ in range(t):
	s = input()
	s = list('a' + s)
	n = len(s) - 1
	i = f = 0
	while i < n:
		if s[i] == s[n]:
			(s[i], s[i + 1]) = (s[i + 1], s[i])
		if s[i] != s[n]:
			f = 1
			break
		i += 1
		n -= 1
	if f == 1:
		print('YES', ''.join(s), sep='\n')
	else:
		print('NO')


def dejavu():
	s = str(input())
	if s:
		str1 = 'a' + s
		if str1 != str1[::-1]:
			print('YES')
			print(str1)
			return
		else:
			str2 = s + 'a'
			if str2 != str2[::-1]:
				print('YES')
				print(str2)
				return
		print('NO')
		return
for _ in range(int(input())):
	dejavu()


for _ in range(int(input())):
	s = input()
	length = len(s)
	if set(s) != {'a'}:
		if s != s[::-1]:
			print('YES')
			print(s[:length // 2] + 'a' + s[length // 2:])
		else:
			print('YES')
			print('a' + s)
	else:
		print('NO')


import sys
import math

def get_line():
	return list(map(float, sys.stdin.readline().strip().split()))

def in1():
	return int(input())
for _ in range(in1()):
	s1 = list(str(input()))
	s2 = s1[::-1]
	if s1 == s2:
		t1 = len(set(s1))
		if t1 == 1 and s1[0] == 'a':
			print('NO')
		else:
			print('YES')
			print('a' + ''.join(s1))
	else:
		t1 = len(set(s1))
		if t1 == 1 and s1[0] == 'a':
			print('NO')
		elif t1 == 1 and s1[0] != 'a':
			print('YES')
			print('a' + ''.join(s1))
		else:
			p = len(s1)
			if p % 2 == 0:
				s1.insert(p // 2, 'a')
			else:
				s1.insert(p // 2 + 1, 'a')
			print('YES')
			print(''.join(s1))


import sys
input = lambda : sys.stdin.readline().rstrip()
Q = int(input())
for _ in range(Q):
	s = input()
	if s.count('a') != len(s):
		print('YES')
		l = len(s)
		idx = 0
		for i in range(l):
			if s[l - i - 1] != 'a':
				break
			else:
				idx += 1
		print(s[:idx] + 'a' + s[idx:])
	else:
		print('NO')


def is_pal(s):
	return s == s[::-1]

def solve():
	s = input()
	if max(s) == 'a':
		print('NO')
		return
	print('YES')
	if not is_pal('a' + s):
		print('a' + s)
	else:
		print(s + 'a')
for _ in range(int(input())):
	solve()


tests = int(input())

def is_palindrome(word):
	if word == word[::-1]:
		return True
	return False
for _ in range(tests):
	word = input()
	a = word + 'a'
	if not is_palindrome(a):
		print('YES')
		print(a)
		continue
	a = 'a' + word
	if not is_palindrome(a):
		print('YES')
		print(a)
		continue
	print('NO')


t = int(input())

def check_pal(s):
	mid = len(s) // 2
	for i in range(mid):
		if s[i] != s[len(s) - i - 1]:
			return False
	return True
for _ in range(t):
	s = input()
	if not check_pal('a' + s):
		print('YES')
		print('a' + s)
	elif not check_pal(s + 'a'):
		print('YES')
		print(s + 'a')
	else:
		print('NO')


import sys

def solve():
	s = input()
	n = len(s)
	for (i, c) in enumerate(s):
		if c != 'a':
			after = s[:i] + 'a' + s[i:]
			if after != after[::-1]:
				print('YES')
				print(after)
				break
			before = s[:i + 1] + 'a' + s[i + 1:]
			if before != before[::-1]:
				print('YES')
				print(before)
				break
	else:
		print('NO')
T = int(input())
for _ in range(T):
	solve()


from sys import stdin, stdout

def main():
	input = [x for x in stdin.read().split()]
	for i in range(int(input[0])):
		string = input[i + 1]
		l = len(string)
		flag = True
		for j in range(l):
			if string[j] != 'a':
				if j < int(l / 2):
					x = l - j
				else:
					x = l - j - 1
				s1 = string[0:x] + 'a' + string[x:]
				print('YES')
				print(s1)
				flag = False
				break
		if flag:
			print('NO')
main()


t = int(input())
for i in range(t):
	s = input()
	s1 = 'a' + s
	s2 = s + 'a'
	if s1[::-1] != s1:
		print('YES')
		print(s1)
	elif s2[::-1] != s2:
		print('YES')
		print(s2)
	else:
		print('NO')


def palindrome(s):
	return s == s[::-1]

def solve():
	x = input()
	if not palindrome(x + 'a'):
		print('YES\n' + x + 'a')
	elif not palindrome('a' + x):
		print('YES\n' + 'a' + x)
	else:
		print('NO')

def main():
	for i in range(int(input())):
		solve()
main()


from sys import stdin, stdout
t = int(stdin.readline().rstrip())
for _ in range(t):
	s = stdin.readline().rstrip()
	if len(set(list(s))) == 1 and set(list(s)) == {'a'}:
		print('NO')
	else:
		sNew = s + 'a'
		sNew2 = 'a' + s
		if sNew == ''.join(list(reversed(sNew))):
			print('YES')
			print(sNew2)
		else:
			print('YES')
			print(sNew)


def possible(s):
	for x in s:
		if x != 'a':
			return False
	return True

def palindrome(s):
	l = len(s)
	for i in range(l // 2):
		if s[i] != s[l - i - 1]:
			return False
	return True

def solve(s):
	i = 0
	original = s
	if not palindrome(s):
		s = s + 'a'
	while palindrome(s):
		s = original
		s = s[:i] + 'a' + s[i:]
		if not palindrome(s):
			return s
		i += 1
	return s
n = int(input())
for i in range(n):
	s = input()
	l = len(s)
	if possible(s):
		print('NO')
	else:
		print('YES')
		print(solve(s))


t = int(input())
while t:
	s = input()
	t = t - 1
	if s == s[::-1] and (not s.count('a') == len(s)):
		print('YES')
		print(s + 'a')
	elif s.count('a') == len(s):
		print('NO')
	elif len(s) == 2:
		print('YES')
		print(s[0] + 'a' + s[1])
	else:
		print('YES')
		print(s[0:int(len(s) / 2)] + 'a' + s[int(len(s) / 2):len(s)])


t = int(input())
for tc in range(t):
	s = input()
	if len(set(s)) == 1 and s[0] == 'a':
		print('NO')
	elif s + 'a' != (s + 'a')[::-1]:
		print('YES')
		print(s + 'a')
	elif 'a' + s != ('a' + s)[::-1]:
		print('YES')
		print('a' + s)
	else:
		print('NO')


n = int(input())
for i in range(n):
	line = input()
	yn = False
	for j in range(0, len(line)):
		if line[j] != 'a':
			if j == 0:
				t_line = 'YES\n' + line + 'a'
			else:
				t_line = 'YES\n' + line[:-j] + 'a' + line[-j:]
			print(t_line)
			yn = True
			break
	if yn is False:
		print('NO')


t = int(input())

def countA(string):
	i = 0
	while string[i] == 'a':
		i += 1
	j = -1
	while string[j] == 'a':
		j -= 1
	if i >= -j:
		return 'a' + string
	else:
		return string + 'a'
for i in range(t):
	str1 = input()
	if set(str1) == {'a'}:
		print('NO')
	else:
		print('YES')
		if str1[0] == 'a' and str1[-1] == 'a':
			print(countA(str1))
		elif str1[0] != 'a':
			print(str1 + 'a')
		elif str1[-1] != 'a':
			print('a' + str1)


def palindrome(st):
	return st == st[::-1]

def solve(lst):
	for i in range(len(lst)):
		if not palindrome(lst[i] + 'a'):
			print(f"YES\n{lst[i] + 'a'}")
		elif not palindrome('a' + lst[i]):
			print(f"YES\n{'a' + lst[i]}")
		else:
			print('NO')

def main():
	t = int(input())
	lst = []
	for i in range(t):
		lst.append(input())
	solve(lst)
main()


n = int(input())
for i in range(0, n):
	s = input()
	a1 = 'a' + s
	a2 = s + 'a'
	swt = 1
	for j in range(0, len(a1)):
		if a1[j] != a1[len(a1) - 1 - j]:
			swt = 0
	if swt == 0:
		print('YES')
		print(a1)
		continue
	for j in range(0, len(a2)):
		if a2[j] != a2[len(a2) - 1 - j]:
			swt = 0
	if swt == 0:
		print('YES')
		print(a2)
		continue
	print('NO')


n = int(input())
for case in range(n):
	data = input()
	lenth = len(data)
	flag = 0
	for i in range(lenth):
		if data[i] != 'a':
			D = list(data)
			D.insert(lenth - i, 'a')
			d = ''.join(D)
			print('Yes')
			print(d)
			flag = 1
			break
	if flag == 0:
		print('NO')


nbTest = int(input())
for loop in range(nbTest):
	text = list(input())
	init = len(text)
	ref = 0
	isValid = True
	if text.count('a') == init:
		isValid = False
	if not isValid:
		print('NO')
	else:
		text.insert(0, 'a')
		if text == list(reversed(text)):
			text.pop(0)
			text.insert(-1, 'a')
		print('YES')
		print(''.join(text))


T = int(input())
output = []

def isPalindrome(string):
	left = 0
	right = len(string) - 1
	while left < right:
		if string[left] != string[right]:
			return False
		left += 1
		right -= 1
	return True
for t in range(T):
	ogString = input()
	if not isPalindrome('a' + ogString):
		output.append('YES\n' + 'a' + ogString)
	elif not isPalindrome(ogString + 'a'):
		output.append('YES\n' + ogString + 'a')
	else:
		output.append('NO')
print('\n'.join(output))


for i in range(int(input())):
	l = input()
	l1 = l + 'a'
	l2 = 'a' + l
	if l1 != l1[::-1]:
		print('YES')
		print(l1)
	elif l2 != l2[::-1]:
		print('YES')
		print(l2)
	else:
		print('NO')


import sys
input = sys.stdin.readline
for _ in range(int(input())):
	start = input().rstrip()
	if set(list(start)) == {'a'}:
		print('NO')
	else:
		print('YES')
		i = 0
		while True:
			if start[i] != 'a':
				print(start[:len(start) - i] + 'a' + start[len(start) - i:len(start)])
				break
			else:
				i += 1


t = int(input())
while t > 0:
	t = t - 1
	s = input()
	d = dict()
	c = 0
	for i in range(0, len(s)):
		if s[i] == 'a':
			c = c + 1
	if c == len(s):
		print('NO')
	else:
		s11 = s + 'a'
		s12 = 'a' + s
		if s11 != s11[::-1]:
			print('YES')
			print(s11)
		elif s12 != s12[::-1]:
			print('YES')
			print(s12)


import sys
import math

def ans(n):
	count = n.count('a')
	if count == len(n):
		return 'NO'
	if count == 0:
		print('YES')
		return 'a' + n
	size = len(n)
	if len(n) == 2:
		if n[0] == 'a':
			print('YES')
			return 'a' + n
		else:
			print('YES')
			return n + 'a'
	if n == n[::-1]:
		print('YES')
		return 'a' + n
	print('YES')
	return n[0:size // 2] + 'a' + n[size // 2:size]
for _ in range(int(input())):
	n = input()
	print(ans(n))


import collections
import math
from functools import lru_cache

def process(tc, v):
	(l, res, n) = (0, '', len(v))
	for i in range(n):
		if v[n - 1 - i] != 'a':
			res = v[:i] + 'a' + v[i:]
			l = 1
			print('YES')
			print(res)
			return
	print('NO')
tcs = int(input())
for tc in range(tcs):
	v = input().rstrip()
	process(tc + 1, v)


def prints(x, j):
	x.insert(j, 'a')
	str1 = ''
	for i in x:
		str1 += i
	print(str1)
t = int(input())
for i in range(t):
	x = list(input())
	n = len(x)
	flag = 0
	for j in range(n):
		if x[n - j - 1] == 'a':
			continue
		else:
			flag = 1
			break
	if flag == 1:
		print('YES')
		prints(x, j)
	else:
		print('NO')


def insert_char_at_position(char, position, string):
	return string[:position] + char + string[position:]
import sys
inp = sys.stdin.readlines()
inp = [line[:-1] for line in inp]
number_of_inputs = int(inp[0])
for line in inp[1:]:
	non_palindrome_found = False
	for (char_position, char) in enumerate(line):
		if char != 'a':
			desired_position = len(line) - char_position
			not_a_palindrome = insert_char_at_position('a', desired_position, line)
			print('YES')
			print(not_a_palindrome)
			non_palindrome_found = True
			break
	if not non_palindrome_found:
		print('NO')


t = int(input())
for _ in range(t):
	s = input()
	l = len(s)
	if l == s.count('a'):
		print('NO')
	else:
		print('YES')
		r = s + 'a'
		if r == r[::-1]:
			print('a' + r[:-1])
		else:
			print(r)


for s in [*open(0)][1:]:
	s = s[:-1]
	r = s[::-1]
	if s == 'a' * len(s):
		a = 'NO'
	elif 'a' + s != r + 'a':
		a = 'YES\na' + s
	else:
		a = 'YES\n' + s + 'a'
	print(a)


for _ in range(int(input())):
	s = [*input()]
	for i in range(len(s)):
		if s[-i - 1] != 'a':
			s.insert(i, 'a')
			print('YES')
			for i in s:
				print(i, end='')
			print()
			break
	else:
		print('NO')


import sys
from collections import defaultdict
import math
t = int(sys.stdin.readline())
for _ in range(t):
	s = sys.stdin.readline()[:-1]
	pos = True
	n = len(s)
	for i in range(n):
		if s[i] != 'a':
			pos = False
			break
	if pos:
		print('NO')
		continue
	if n == 1:
		res = 'a' + s
		print('YES')
		print(res)
		continue
	idx = -1
	for i in range(n):
		if s[i] != 'a':
			idx = i
			break
	k = n - idx
	res = s[:k] + 'a' + s[k:]
	print('YES')
	print(res)


t = int(input())
for x in range(t):
	s = input()
	if s.count('a') == len(s):
		print('NO')
	else:
		print('YES')
		if s == s[::-1]:
			print('a' + s)
		else:
			print(s[0:len(s) // 2] + 'a' + s[len(s) // 2:len(s)])


n = int(input())
for _ in range(n):
	s = input()
	if all((i == 'a' for i in s)):
		print('NO')
		continue
	print('YES')
	ans = 'a' + s
	if ans != ans[::-1]:
		print(ans)
		continue
	else:
		print(s + 'a')


t = int(input())

def check(s):
	l = len(s)
	if l % 2 != 0:
		mido = (l + 1) // 2
		ll = s[:mido]
		lo = s[mido - 1:]
		lo = lo[::-1]
		if ll == lo:
			return True
		else:
			return False
	else:
		mide = (l + 1) // 2
		l1 = s[:mide]
		l2 = s[mide:]
		l2 = l2[::-1]
		if l1 == l2:
			return True
		else:
			return False
while t != 0 and t > 0:
	s = input()
	if s == 'a':
		print('NO')
	elif len(set(s)) == 1 and list(set(s))[0] == 'a':
		print('NO')
	else:
		cc = 'a' + s
		if check(cc):
			s += 'a'
			print('YES')
			print(s)
		else:
			s = cc
			print('YES')
			print(s)
	t -= 1


t = int(input())
for z in range(t):
	s = input()
	if s.count('a') == len(s):
		print('NO')
	else:
		print('YES')
		c = 'a' + s
		if c != c[::-1]:
			print(c)
		else:
			print(s + 'a')


def isPalindrome(s):
	return s[::-1] == s

def main():
	t = int(input())
	for tx in range(t):
		s = input()
		if not isPalindrome(s + 'a'):
			print('YES')
			print(s + 'a')
		elif not isPalindrome('a' + s):
			print('YES')
			print('a' + s)
		else:
			print('NO')
	return 0
main()


for _ in range(int(input())):
	s = input()
	a1 = s + 'a'
	a2 = 'a' + s
	if a1 != a1[::-1]:
		print('YES')
		print(a1)
	elif a2 != a2[::-1]:
		print('YES')
		print(a2)
	else:
		print('NO')


for t in range(int(input())):
	s = input()
	if set(s) == {'a'}:
		print('NO')
	else:
		print('YES')
		if s + 'a' == (s + 'a')[::-1]:
			print('a' + s)
		else:
			print(s + 'a')


def main():
	t = int(input())
	for _ in range(t):
		s = input()
		n = len(s)
		aas = s.count('a')
		if n == aas:
			print('NO')
			continue
		print('YES')
		s = 'a' + s
		if s != s[::-1]:
			print(s)
			continue
		print(s[1:] + 'a')
main()


t = int(input())
for _ in range(t):
	s = input()
	n = len(s)
	(count, flag) = (0, 0)
	temp = ''
	for i in range(n // 2):
		if s[i] != s[n - i - 1]:
			if s[i] != 'a' and s[n - 1 - i] != 'a' and (flag == 0):
				temp += 'a'
				temp += s[i]
				flag = 1
			elif (s[i] != 'a' or s[n - 1 - i] != 'a') and flag == 0:
				if s[i] == 'a':
					temp += 'a'
					temp += s[i]
					flag = 1
				else:
					temp += s[i]
					temp += 'a'
					flag = 1
			else:
				temp += s[i]
		elif s[i] != 'a' and s[n - 1 - i] != 'a' and (flag == 0):
			flag = 1
			temp += 'a'
			temp += s[i]
		else:
			temp += s[i]
	if flag:
		temp += s[n // 2:]
		print('YES')
		print(temp)
	elif n % 2 != 0:
		if s[n // 2] != 'a':
			temp += 'a'
			temp += s[n // 2:]
			print('YES')
			print(temp)
		else:
			print('NO')
	else:
		print('NO')


n = int(input())
for _ in range(n):
	str1 = input()
	flag = 0
	for index in range(len(str1)):
		if str1[index] != 'a':
			flag = 1
			print('YES')
			print(str1[:len(str1) - index] + 'a' + str1[len(str1) - index:])
			break
	if flag == 0:
		print('NO')


import sys
import io
import math
import collections
import decimal
import itertools
import bisect
import heapq

def input():
	return sys.stdin.readline()[:-1]
YES = 'YES'
NO = 'NO'

def solve(S):
	flag_a = True
	for c in S:
		if c != 'a':
			flag_a = False
			break
	if flag_a:
		return [False]
	if 'a' + S != ('a' + S)[::-1]:
		return [True, 'a' + S]
	if S + 'a' != (S + 'a')[::-1]:
		return [True, S + 'a']

def main():
	T0 = int(input())
	for _ in range(T0):
		S = input()
		ans = solve(S)
		if ans[0]:
			print('YES')
			print(ans[1])
		else:
			print('NO')
main()


for _ in range(int(input())):
	s = list(input())
	if len(set(s)) == 1 and s[0] == 'a':
		print('NO')
		continue
	print('YES')
	n = len(s)
	flag = 0
	for i in range(n // 2 + 1):
		if s[i] != 'a':
			s.insert(n - i, 'a')
			print(''.join(s))
			flag = 1
			break
	if flag == 0:
		s.append('a')
		print(''.join(s))


t = int(input())
while t:
	s = input()
	if len(set(s)) == 1 and s[0] == 'a':
		print('NO')
	else:
		for i in range(len(s)):
			if s[len(s) - i - 1] != 'a':
				print('YES')
				print(s[:i] + 'a' + s[i:])
				break
	t -= 1


t = int(input())
for i in range(t):
	s = input()
	for x in s:
		if x != 'a':
			print('YES')
			for y in range(-1, -len(s) - 1, -1):
				if s[y] != 'a':
					print(s[:-y - 1] + 'a' + s[-y - 1:])
					break
			break
	else:
		print('NO')