A string $s$ of length $n$ ($1 \le n \le 26$) is called alphabetical if it can be obtained using the following algorithm:

first, write an empty string to $s$ (i.e. perform the assignment $s$ := "");

then perform the next step $n$ times;

at the $i$-th step take $i$-th lowercase letter of the Latin alphabet and write it either to the left of the string $s$ or to the right of the string $s$ (i.e. perform the assignment $s$ := $c+s$ or $s$ := $s+c$, where $c$ is the $i$-th letter of the Latin alphabet).

In other words, iterate over the $n$ first letters of the Latin alphabet starting from 'a' and etc. Each time we prepend a letter to the left of the string $s$ or append a letter to the right of the string $s$. Strings that can be obtained in that way are alphabetical.

For example, the following strings are alphabetical: "a", "ba", "ab", "bac" and "ihfcbadeg". The following strings are not alphabetical: "z", "aa", "ca", "acb", "xyz" and "ddcba".

From the given string, determine if it is alphabetical.


-----Input-----

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

Each test case is written on a separate line that contains one string $s$. String $s$ consists of lowercase letters of the Latin alphabet and has a length between $1$ and $26$, inclusive.


-----Output-----

Output $t$ lines, each of them must contain the answer to the corresponding test case. Output YES if the given string $s$ is alphabetical and NO otherwise.

You can output YES and NO in any case (for example, strings yEs, yes, Yes and YES will be recognized as a positive answer).


-----Examples-----

Input
11
a
ba
ab
bac
ihfcbadeg
z
aa
ca
acb
xyz
ddcba
Output
YES
YES
YES
YES
YES
NO
NO
NO
NO
NO
NO


-----Note-----

The example contains test cases from the main part of the condition.

Difficulty: EASY

Solutions:
def solve(s, n):
	idx = -1
	for i in range(n):
		if s[i] == 'a':
			idx = i
			break
	if idx == -1:
		print('NO')
		return
	L = idx
	R = idx
	ch = 'b'
	while L != 0 or R != n - 1:
		if L > 0 and s[L - 1] == ch:
			L -= 1
		elif R < n - 1 and s[R + 1] == ch:
			R += 1
		else:
			break
		ch = chr(ord(ch) + 1)
	if L == 0 and R == n - 1:
		print('YES')
	else:
		print('NO')
for _ in range(int(input())):
	s = input()
	n = len(s)
	solve(s, n)


def F(s):
	n = len(s)
	L = 'abcdefghijklmnopqrstuvwxyz'
	q = ''
	Q = ''
	for i in range(n):
		q = q + L[i]
		if q in s:
			Q = Q + L[i]
		else:
			Q = L[i] + Q
		q = Q
	print('YES' if Q == s else 'NO')
for _ in range(int(input())):
	s = input('')
	F(s)


import sys
_DEBUG = False
if _DEBUG:
	fd = open('input.txt', 'r')
	sys.stdin = fd
for t in range(int(sys.stdin.readline())):
	s = list(input())
	flag = False
	prev = max(ord(s[0]), ord(s[-1]))
	if not prev - ord('a') + 1 == len(s):
		print('NO')
		continue
	if prev == ord(s[0]):
		s.pop(0)
	else:
		s.pop()
	while s:
		x = max(ord(s[0]), ord(s[-1]))
		if not prev - x == 1:
			print('NO')
			flag = True
			break
		if x == ord(s[0]):
			s.pop(0)
		else:
			s.pop(-1)
		prev = x
	if flag:
		continue
	print('YES')
fd.close() if _DEBUG else None


for _ in range(int(input())):
	s = input()
	l = 'abcdefghijklmnopqrstuvwxyz'
	ans = 'YES'
	k = 1
	e = 'a'
	if 'a' in s:
		pass
	else:
		print('NO')
		continue
	st = len(s)
	for i in range(st - 1):
		n = len(e)
		ind = s.find(e)
		if ind == -1:
			ans = 'NO'
			break
		elif ind - 1 >= 0 and s[ind - 1] == l[k]:
			e = l[k] + e
		elif ind + n < st and s[ind + n] == l[k]:
			e = e + l[k]
		else:
			ans = 'NO'
			break
		k += 1
	print(ans)


for _ in range(int(input())):
	s = input()
	if not 'a' in s:
		print('NO')
		continue
	l = s.index('a')
	r = s.index('a')
	i = 97
	ans = 'YES'
	while l > 0 or r < len(s) - 1:
		i += 1
		if l > 0 and s[l - 1] == chr(i):
			l -= 1
		elif r < len(s) - 1 and s[r + 1] == chr(i):
			r += 1
		else:
			ans = 'NO'
			break
	print(ans)


total = int(input())
alpha = 'abcdefghijklmnopqrstuvwxyz'
for t in range(total):
	string = input()
	for i in range(len(string) - 1, -1, -1):
		if string[0] == alpha[i]:
			string = string[1:]
		elif string[-1] == alpha[i]:
			string = string[:-1]
		else:
			break
	if len(string) == 0:
		print('YES')
	else:
		print('NO')


import string
t = int(input())
for _ in range(t):
	s = input()
	res = ''.join(sorted(s)) == string.ascii_lowercase[:len(s)]
	if res:
		(left, right) = s.split('a')
		res = [*left] == sorted(left, reverse=True) and [*right] == sorted(right)
	res = 'YES' if res else 'NO'
	print(res)


for i in range(int(input())):
	s = input()
	if 'a' in s:
		li = s.index('a') - 1
		ri = s.index('a') + 1
		t = len(s)
		c = 97
		while True:
			c += 1
			l = '' if li < 0 else ord(s[li])
			r = '' if ri >= t else ord(s[ri])
			if l == '' and r == '':
				print('YES')
				break
			if l == c:
				li -= 1
			elif r == c:
				ri += 1
			else:
				print('NO')
				break
	else:
		print('NO')


t = int(input())
for i in range(0, t):
	s = list(input())
	s = [ord(s[j]) - 96 for j in range(0, len(s))]
	n = len(s)
	if 1 not in s:
		print('NO')
		continue
	l = s.index(1) - 1
	r = s.index(1) + 1
	k = 2
	f = 1
	while l >= 0 and r < n:
		if s[l] == k:
			l -= 1
			k += 1
		elif s[r] == k:
			r += 1
			k += 1
		else:
			f = 0
			break
	while l >= 0 and f == 1:
		if s[l] == k:
			l -= 1
			k += 1
		else:
			f = 0
			break
	while r < n and f == 1:
		if s[r] == k:
			r += 1
			k += 1
		else:
			f = 0
			break
	if f == 1:
		print('YES')
	else:
		print('NO')


n = int(input())
for i in range(n):
	s = input()
	s += '-'
	s = '-' + s
	l = []
	for i in s:
		l.append(ord(i))
	if 97 not in l:
		print('NO')
	else:
		i = l.index(97)
		j = i
		a = 97
		count = 1
		while j >= 0 and i < len(l):
			if l[i + 1] == a + 1:
				i += 1
				a += 1
				count += 1
			elif l[j - 1] == a + 1:
				j -= 1
				a += 1
				count += 1
			elif count == len(l) - 2:
				print('YES')
				break
			else:
				print('NO')
				break


def solve():
	s = input()
	while len(s) > 0:
		if s[0] == chr(97 + len(s) - 1):
			s = s[1:]
			continue
		if s[-1] == chr(97 + len(s) - 1):
			s = s[:-1]
			continue
		print('NO')
		return
	print('YES')
t = int(input())
while t > 0:
	solve()
	t -= 1


t = int(input())
for k in range(t):
	s = input()
	curr = 98
	start = -1
	n = len(s)
	for i in range(n):
		if s[i] == 'a':
			start = i
			break
	if start == -1:
		print('NO')
		continue
	i = start - 1
	j = start + 1
	flag = 0
	while j - i - 1 < n:
		req = chr(curr)
		if i >= 0 and req == s[i]:
			i -= 1
		elif j < n and req == s[j]:
			j += 1
		else:
			flag = 1
			break
		curr += 1
	if flag:
		print('NO')
	else:
		print('YES')


import math, string, itertools, fractions, heapq, collections, re, array, bisect, sys, random, time
inf = 10 ** 20
mod = 10 ** 9 + 7

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

def II():
	return int(input())

def LS():
	return list(input().split())

def S():
	return input()

def solve():
	s = S()
	ans = 'YES'
	n = len(s)
	l = 0
	r = n - 1
	a2x = string.ascii_lowercase[:n]
	for c in a2x[::-1]:
		if s[l] == c:
			l += 1
		elif s[r] == c:
			r -= 1
		else:
			return 'NO'
	return ans

def main():
	t = II()
	res = list()
	for _ in range(t):
		res.append(solve())
	for ans in res:
		print(ans)
	return 0
main()


from collections import deque

def solve(S):
	S = deque(list(S))
	last = -1
	while len(S) > 1:
		if S[0] < S[-1]:
			now = S.pop()
		elif S[0] > S[-1]:
			now = S.popleft()
		else:
			return 'NO'
		if last == -1:
			last = now
			continue
		elif ord(last) - ord(now) != 1:
			return 'NO'
		last = now
	if S[0] != 'a' or (last != -1 and last != 'b'):
		return 'NO'
	return 'YES'
T = int(input())
for t in range(T):
	S = input()
	print(solve(S))


t = int(input())
for i in range(0, t):
	s = list(input())
	o = [ord(j) for j in s]
	if len(set(o)) != len(o):
		print('NO')
	elif len(s) < 2:
		if s[0] == 'a':
			print('YES')
		else:
			print('NO')
	else:
		for k in range(0, len(o)):
			if len(o) == 2:
				break
			if o[0] > o[-1]:
				if o[0] - o[1] == 1 or o[0] - o[-1] == 1:
					o.remove(o[0])
			elif o[-1] - o[0] == 1 or o[-1] - o[-2] == 1:
				o.remove(o[-1])
		if sum(o) == 195:
			print('YES')
		else:
			print('NO')


T = int(input())
for _ in range(T):
	temp = 0
	s = input()
	if 'a' not in s:
		print('NO')
		continue
	string = list(s)
	temp = 0
	sizee = len(string)
	temp = 0
	sd = string[:]
	sd.sort()
	temp = 0
	arr = 'abcdefghijklmnopqrstuvwxyz'
	arr = list(arr)
	temp = 0
	if sd != arr[:sizee]:
		temp = 0
		print('NO')
		continue
	start = end = string.index('a')
	flag = 0
	for i in range(1, sizee):
		temp = 0
		if start > 0 and arr[i] == string[start - 1]:
			start -= 1
			temp = 0
		elif end < sizee - 1 and arr[i] == string[end + 1]:
			temp = 0
			end += 1
		else:
			temp = 0
			flag = 1
			print('NO')
			break
	if flag == 0:
		print('YES')


q = 'abcdefghijklmnopqrstuvwxyz'
s = ''
n = int(input())
for _ in range(n):
	e = input()
	p = e.find('a')
	p1 = p - 1
	p2 = p + 1
	p3 = 0
	res = 'NO'
	if p > -1:
		res = 'YES'
		while p2 - p1 < len(e) + 1:
			p3 += 1
			if p1 > -1 and e[p1] == q[p3]:
				p1 -= 1
			elif p2 < len(e) and e[p2] == q[p3]:
				p2 += 1
			else:
				res = 'NO'
				break
	print(res)


def main():
	for _ in range(int(input())):
		a = input()
		n = len(a)
		if 'a' in a:
			i = a.find('a')
			(l, r) = (i - 1, i + 1)
			nexte = 'b'
			f = True
			while l >= 0 and r < n:
				if l >= 0 and a[l] == nexte:
					nexte = chr(1 + ord(nexte))
					l -= 1
				elif r < n and a[r] == nexte:
					nexte = chr(1 + ord(nexte))
					r += 1
				else:
					f = False
					break
			while l >= 0:
				if l >= 0 and a[l] == nexte:
					nexte = chr(1 + ord(nexte))
					l -= 1
				else:
					f = False
					break
			while r < n:
				if r < n and a[r] == nexte:
					nexte = chr(1 + ord(nexte))
					r += 1
				else:
					f = False
					break
			if f:
				print('YES')
			else:
				print('NO')
		else:
			print('NO')
main()


from sys import stdin

def main():
	cases = int(stdin.readline().strip())
	for _ in range(cases):
		S = stdin.readline().strip()
		N = len(S)
		ans = True
		a = 0
		while a < N and S[a] != 'a':
			a += 1
		if a == N:
			ans = False
		(l, r, char) = (a - 1, a + 1, 98)
		while ans and (l >= 0 or r < N):
			if l >= 0 and S[l] == chr(char):
				l -= 1
			elif r < N and S[r] == chr(char):
				r += 1
			else:
				ans = False
			char += 1
		print('YES' if ans else 'NO')
main()


al = 'abcdefghijklmnopqrstuvwxyz'
for _ in range(int(input())):
	s = input()
	n = len(s)
	if 'a' in s:
		p = q = s.index('a')
	else:
		print('NO')
		continue
	p = p - 1
	q = q + 1
	if p < 0:
		p = 0
	if q > n - 1:
		q = n - 1
	flag = True
	for i in range(1, n):
		if p >= 0 and s[p] == al[i]:
			p = p - 1
		elif q < n and s[q] == al[i]:
			q = q + 1
		else:
			flag = False
			break
	if flag:
		print('YES')
	else:
		print('NO')


def main():
	for _ in range(int(input())):
		s = input()
		l = len(s)
		fi = 0
		se = l - 1
		flag = 0
		for i in range(l, 0, -1):
			if chr(i + 96) == s[fi]:
				fi += 1
			elif chr(i + 96) == s[se]:
				se -= 1
			else:
				flag = 1
				break
		print('NO' if flag == 1 else 'YES')
main()


check = 'abcdefghijklmnopqrstuvwxyz'
t = int(input())
for _ in range(t):
	flag = 0
	s = input()
	s_new = ''.join(sorted(s))
	for i in range(len(s_new)):
		if s_new[i] != check[i]:
			flag = 2
			break
	if flag == 0:
		for i in range(len(s) - 1):
			if s[i] > s[i + 1] and flag == 0:
				continue
			if s[i] < s[i + 1] and flag == 0:
				flag = 1
			elif s[i] > s[i + 1] and flag == 1:
				flag = 2
				break
	if flag == 2:
		print('NO')
	else:
		print('YES')


def alpha(s):
	if 'a' not in s:
		return 'NO'
	else:
		l = s.index('a')
	r = l
	for i in range(1, len(s)):
		if l >= 1 and s[l - 1] == chr(ord('a') + i):
			l -= 1
		elif r <= len(s) - 2 and s[r + 1] == chr(ord('a') + i):
			r += 1
		else:
			return 'NO'
	return 'YES'
t = int(input())
for _ in range(t):
	s = input()
	print(alpha(s))


def solve():
	s = input()
	n = len(s)
	y = n
	(l, r) = (0, n - 1)
	while l <= r:
		dl = ord(s[l]) - 97
		dr = ord(s[r]) - 97
		if dl >= y or dr >= y:
			return False
		if l != r and dl == dr:
			return False
		y = max(dl, dr)
		if dl > dr:
			l += 1
		else:
			r -= 1
	return True
for _ in range(int(input())):
	print('YES' if solve() else 'NO')


t = int(input())
for _ in range(t):
	s = input()
	idx = -1
	for i in range(len(s)):
		if s[i] == 'a':
			idx = i
			break
	f = 1
	if idx == -1:
		f = 0
	else:
		val = ord(s[idx])
		l = r = idx
		visited = 1
		while visited < len(s):
			if l - 1 >= 0 and ord(s[l - 1]) == val + 1:
				visited += 1
				l -= 1
				val += 1
			elif r + 1 < len(s) and ord(s[r + 1]) == val + 1:
				visited += 1
				r += 1
				val += 1
			else:
				break
		if visited < len(s):
			f = 0
	print('YES' if f else 'NO')


import os
import re
import sys
import math
from io import BytesIO, IOBase

def main():
	l = 'abcdefghijklmnopqrstuvwxyz'
	for _ in range(int(input())):
		s = input()
		ans = ''
		flag = 0
		res = []
		if len(s) == 1 and s[0] == 'a':
			ans = 'YES'
			flag = 1
		if 'a' not in s:
			ans = 'NO'
			flag = 1
		else:
			f = s.index('a')
		for i in range(len(s)):
			if l[i] not in s:
				ans = 'NO'
				flag = 1
				break
		for i in range(len(s)):
			if s[i] not in res:
				res.append(s[i])
			else:
				ans = 'NO'
				flag = 1
				break
		if flag == 0:
			test = ['a']
			for i in range(1, len(s)):
				if s.index(l[i]) < s.index(l[i - 1]):
					test.insert(0, l[i])
				else:
					test.append(l[i])
			temp = ''.join(test)
			if temp == s:
				ans = 'YES'
			else:
				ans = 'NO'
		if ans == '':
			print('YES')
		else:
			print(ans)
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')
if os.path.exists('input.txt'):
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')
main()


def temp(string):
	string = list(string)
	sizee = len(string)
	sd = string[:]
	sd.sort()
	arr = 'abcdefghijklmnopqrstuvwxyz'
	arr = list(arr)
	if sd != arr[:sizee]:
		return 'NO'
	start = end = string.index('a')
	for i in range(1, sizee):
		if start > 0 and arr[i] == string[start - 1]:
			start -= 1
		elif end < sizee - 1 and arr[i] == string[end + 1]:
			end += 1
		else:
			return 'NO'
	return 'YES'
for _ in range(int(input())):
	string = input()
	print(temp(string))


import sys
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep='\n')

def II():
	return int(sys.stdin.readline())

def LI():
	return list(map(int, sys.stdin.readline().split()))

def LLI(rows_number):
	return [LI() for _ in range(rows_number)]

def LI1():
	return list(map(int1, sys.stdin.readline().split()))

def LLI1(rows_number):
	return [LI1() for _ in range(rows_number)]

def SI():
	return sys.stdin.readline().rstrip()
inf = 10 ** 4 * (1 << 10)
md = 10 ** 9 + 7

def ok():
	s = SI()
	n = len(s)
	si = s.find('a')
	if si == -1:
		return False
	(l, r) = (si - 1, si + 1)
	c = 98
	while c - 97 < n:
		if l >= 0 and s[l] == chr(c):
			l -= 1
		elif r < n and s[r] == chr(c):
			r += 1
		else:
			return False
		c += 1
	return True
for testcase in range(II()):
	print('YES' if ok() else 'NO')


for _ in range(int(input())):
	s = input()
	l = list(s)
	a = len(l)
	for i in range(a, 0, -1):
		if chr(i + 96) == l[0]:
			l.pop(0)
		elif chr(i + 96) == l[-1]:
			l.pop()
		else:
			break
	if len(l) > 0:
		print('NO')
	else:
		print('YES')


for _ in range(int(input())):
	s = input()
	if sorted(s) != [chr(i + 97) for i in range(len(s))]:
		print('NO')
	elif sorted(s[s.index('a'):]) != list(s[s.index('a'):]) or sorted(s[:s.index('a')][::-1]) != list(s[:s.index('a')][::-1]):
		print('NO')
	else:
		print('YES')


import string

def solve(strng):
	if 'a' not in strng:
		return 'NO'
	if len(strng) > 26:
		return 'NO'
	alphabet_string = string.ascii_lowercase
	sorted_char = sorted(strng)
	sortedstrng = ''.join(sorted_char)
	if sortedstrng not in alphabet_string:
		return 'NO'
	increasing = False
	for i in range(len(strng) - 1):
		if strng[i] == 'a':
			increasing = True
		if increasing and strng[i] >= strng[i + 1]:
			return 'NO'
		elif not increasing and strng[i] <= strng[i + 1]:
			return 'NO'
	return 'YES'
t = int(input())
for m in range(t):
	strng = input()
	print(solve(strng))


from sys import stdin

def main():
	cases = int(stdin.readline().strip())
	for i in range(cases):
		S = stdin.readline().strip()
		id_ = 0
		find = 0
		for i in range(len(S)):
			if S[i] == 'a':
				id_ = i
				find = 1
		(i, j) = (id_, id_)
		ok = False
		if find == 1:
			ok = True
		while ok and find < len(S):
			if i - 1 >= 0 and S[i - 1] == chr(97 + find):
				find += 1
				i -= 1
			elif j + 1 < len(S) and S[j + 1] == chr(97 + find):
				find += 1
				j += 1
			else:
				ok = False
		if ok:
			print('YES')
		else:
			print('NO')
main()


for _ in range(int(input())):
	s = list(input())
	n = len(s)
	z = 'abcdefghijklmnopqrstuvwxyz'
	t = ''
	if 'a' in s:
		i = s.index('a')
		k = 0
		j = i + 1
		for m in range(n):
			if i >= 0 and z[k] == s[i]:
				k += 1
				i -= 1
			elif j < n and z[k] == s[j]:
				j += 1
				k += 1
			else:
				print('NO')
				break
		else:
			print('YES')
	else:
		print('NO')


def solution(s):
	l = s.find('a')
	if l == -1:
		return 'NO'
	(l, r) = (l - 1, l + 1)
	curr = ord('a')
	while l > -1 or r < len(s):
		curr += 1
		if l > -1 and curr == ord(s[l]):
			l -= 1
		elif r < len(s) and curr == ord(s[r]):
			r += 1
		else:
			return 'NO'
	return 'YES'
n = int(input())
for i in range(n):
	s = input()
	print(solution(s))


def main():
	import sys
	input = sys.stdin.readline
	M = int(1000000000.0 + 7)
	for _ in range(int(input())):
		q = input().strip()
		s = list(q)
		l = len(s)
		f = 0
		i = 0
		while len(s) > 0:
			x = chr(96 + l - i)
			if s[0] != x and s[-1] != x:
				f = 1
				break
			elif s[0] == x:
				s.pop(0)
			else:
				s.pop()
			i += 1
		if f:
			print('NO')
		else:
			print('YES')
main()


import sys
input = lambda : sys.stdin.readline()
mod = 1000000007

def solve(s):
	if len(set(s)) != len(s):
		print('NO')
		return
	n = len(s)
	al = 'abcdefghijklmnopqrstuvwxyz'
	d = {}
	for i in range(len(s)):
		d[s[i]] = i
	if n == 1 and s[0] == 'a':
		print('YES')
		return
	ss = al[:len(s)]
	if 'a' in s:
		(left, right) = (d[ss[0]] - 1, d[ss[0]] + 1)
		for i in ss[1:]:
			if i in d:
				if d[i] == left:
					left -= 1
				elif d[i] == right:
					right += 1
				else:
					print('NO')
					return
			else:
				print('NO')
				return
		print('YES')
		return
	else:
		print('NO')
		return
for _ in range(int(input())):
	s = str(input())[:-1]
	solve(s)


t = int(input())
for i in range(t):
	s = input()
	d = {'a': 1, 'b': 2, 'c': 3, 'd': 4, 'e': 5, 'f': 6, 'g': 7, 'h': 8, 'i': 9, 'j': 10, 'k': 11, 'l': 12, 'm': 13, 'n': 14, 'o': 15, 'p': 16, 'q': 17, 'r': 18, 's': 19, 't': 20, 'u': 21, 'v': 22, 'w': 23, 'x': 24, 'y': 25, 'z': 26}
	l = 0
	r = len(s) - 1
	flag = 0
	d1 = {}
	for j in s:
		if j in d1:
			print('NO')
			flag = 12
			break
		else:
			d1[j] = 1
	if flag == 12:
		continue
	for n in range(len(s)):
		if d[s[l]] < d[s[r]]:
			if d[s[r]] - 1 == d[s[r - 1]]:
				r = r - 1
			elif d[s[r]] - 1 == d[s[l]]:
				r = r - 1
			else:
				print('NO')
				flag = 1
				break
		elif d[s[l]] > d[s[r]]:
			if d[s[l]] - 1 == d[s[l + 1]]:
				l = l + 1
			elif d[s[l]] - 1 == d[s[r]]:
				l = l + 1
			else:
				print('NO')
				flag = 1
				break
	if flag == 0:
		if 'a' in s:
			print('YES')
		else:
			print('NO')


t = int(input())
for z in range(t):
	s = input()
	st = s.find('a')
	en = s.find('a')
	p = True
	if sorted(s) != [chr(ord('a') + i) for i in range(len(s))]:
		print('NO')
		p = False
	else:
		for i in range(1, len(s), 1):
			if s.find(chr(ord('a') + i)) == st - 1:
				st -= 1
			elif s.find(chr(ord('a') + i)) == en + 1:
				en += 1
			else:
				print('NO')
				p = False
				break
	if p:
		print('YES')


cases = int(input())
for z in range(cases):
	string = input()
	j = -1
	for i in range(0, len(string)):
		if string[i] == 'a':
			first_flag = True
			j = i
			break
	if j == -1:
		print('NO')
		continue
	pointer_left = j - 1
	pointer_right = j + 1
	alphabets = 'abcdefghijklmnopqrstuvwxyz'
	i = 1
	flag = True
	n = len(string)
	while pointer_left >= 0 or pointer_right < n:
		if i > 25:
			flag = False
			break
		flag1 = False
		flag2 = False
		if pointer_left >= 0:
			if string[pointer_left] == alphabets[i]:
				pointer_left -= 1
				flag1 = True
		if pointer_right < n:
			if string[pointer_right] == alphabets[i]:
				pointer_right += 1
				flag2 = True
		if flag1 == True and flag2 == True:
			flag = False
			break
		if flag1 == False and flag2 == False:
			flag = False
			break
		i += 1
	if flag:
		print('YES')
	else:
		print('NO')


import math
t = int(input())
while t:
	s = input()
	l = len(s)
	res = ''
	flag = 0
	m = ord('a') + l - 1
	ch = chr(m)
	i = 0
	j = l - 1
	while i <= j:
		if s[i] == ch:
			flag = 1
			i += 1
			m -= 1
			ch = chr(m)
		elif s[j] == ch:
			flag = 1
			j -= 1
			m -= 1
			ch = chr(m)
		else:
			flag = 0
			break
	if flag == 1 or (l == 1 and s == 'a'):
		print('YES')
	else:
		print('NO')
	t -= 1


import os
import sys
from io import BytesIO, IOBase
from types import GeneratorType
from collections import defaultdict
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')
t = int(input())
for _ in range(t):
	s = input()
	n = len(s)
	poss = 0
	currl = -1
	currr = -1
	for j in range(n):
		if s[j] == 'a':
			currl = j - 1
			currr = j + 1
			poss = 1
			break
	if poss == 0:
		print('NO')
	else:
		j = 1
		while j <= 25:
			if currl == -1 and currr == n:
				break
			curr = chr(97 + j)
			if currl >= 0 and s[currl] == curr:
				currl += -1
			elif currr < n and s[currr] == curr:
				currr += 1
			else:
				poss = 0
				break
			j += 1
		if poss:
			print('YES')
		else:
			print('NO')


for _ in range(int(input())):
	s = input()
	flag = True
	c = 1
	if 'a' not in s:
		print('NO')
		continue
	curr = s.index('a')
	(l, r) = (curr - 1, curr + 1)
	while c < len(s):
		(fl, fr) = (True, True)
		if l > -1:
			if ord(s[l]) - 97 == c:
				l -= 1
				c += 1
			else:
				fl = False
		else:
			fl = False
		if r < len(s):
			if ord(s[r]) - 97 == c:
				r += 1
				c += 1
			else:
				fr = False
		else:
			fr = False
		if not fl and (not fr):
			flag = False
			break
	if not flag:
		print('NO')
	else:
		print('YES')


t = int(input())
for _ in range(t):
	s = input()
	i = s.find('a')
	ln = len(s)
	l = i - 1
	r = i + 1
	f = ord('a') + 1
	k = True
	k2 = False
	while k:
		if l > -1 and s[l] == chr(f):
			l = l - 1
			f = f + 1
		elif r < ln and s[r] == chr(f):
			r = r + 1
			f = f + 1
		elif r == ln and l == -1:
			k2 = True
			k = False
		else:
			k = False
	if k or k2:
		print('YES')
	else:
		print('NO')


from collections import deque
import sys
input = sys.stdin.readline
T = int(input())
for _ in range(T):
	s = deque(input().rstrip())
	n = len(s)
	flg = True
	for i in range(n - 1, -1, -1):
		temp = chr(i + ord('a'))
		if s[0] == temp:
			s.popleft()
		elif s[-1] == temp:
			s.pop()
		else:
			flg = False
			break
	if flg:
		print('YES')
	else:
		print('NO')


def solve():
	k = 'bcdefghijklmnopqrstuvwxyz'
	a = input()
	n = len(a)
	m = -1
	for i in range(n):
		if a[i] == 'a':
			m = i
			break
	if m == -1:
		print('NO')
		return
	(l, r) = (m - 1, m + 1)
	for i in k:
		if l >= 0 and a[l] == i:
			l -= 1
		elif r < n and a[r] == i:
			r += 1
		elif l == -1 and r == n:
			print('YES')
			return
		else:
			print('NO')
			return
	print('YES')
t = int(input())
while t:
	solve()
	t -= 1


tt = int(input())
for _ in range(tt):
	s = input()
	if 'a' not in s:
		print('NO')
		continue
	inda = s.index('a')
	l = inda - 1
	r = inda + 1
	for i in 'bcdefghijklmnopqrstuvwxyz':
		if l >= 0 and s[l] == i:
			l -= 1
		elif r < len(s) and s[r] == i:
			r += 1
		else:
			break
	if l < 0 and r == len(s):
		print('YES')
	else:
		print('NO')


for i in range(int(input())):
	s = input()
	i = len(s) + 96
	while s:
		if s[0] == chr(i):
			s = s[1:]
		elif s[-1] == chr(i):
			s = s[:-1]
		else:
			print('NO')
			break
		i -= 1
	else:
		print('YES')


for _ in range(int(input())):
	s = str(input())
	n = len(s)
	beg = -1
	for i in range(n):
		if s[i] == 'a':
			beg = i
	if beg == -1:
		print('NO')
		continue
	end = beg
	prev = 'a'
	while beg >= 0 or end <= n - 1:
		if beg == 0 and end == n - 1:
			print('YES')
			break
		if beg - 1 >= 0 and ord(s[beg - 1]) == 1 + ord(prev):
			beg -= 1
			prev = s[beg]
		elif end + 1 < n and ord(s[end + 1]) == 1 + ord(prev):
			end += 1
			prev = s[end]
		else:
			print('NO')
			break


answers = []

def solve(string):
	length = len(string)
	if length == 0:
		answers.append('YES')
		return
	newStore = {}
	for ele in string:
		if ele not in newStore:
			newStore[ele] = 1
		else:
			answers.append('NO')
			return
	order = 97
	temp = 0
	store = {}
	while temp != length:
		store[chr(order)] = 1
		temp += 1
		order += 1
	for ele in string:
		if ele not in store:
			answers.append('NO')
			return
	final = list(string)
	current = 97
	temp = 1
	limit = current + length - 1
	while current != limit:
		index = final.index(chr(current))
		prev = index - 1
		after = index + 1
		req = chr(current + 1)
		if after != len(final):
			if final[after] == req:
				final.pop(index)
				current += 1
			elif prev != -1:
				if final[prev] == req:
					final.pop(index)
					current += 1
				else:
					answers.append('NO')
					return
			else:
				answers.append('NO')
				return
		elif prev != -1:
			if final[prev] == req:
				final.pop(index)
				current += 1
			else:
				answers.append('NO')
				return
		else:
			answers.append('NO')
			return
	answers.append('YES')
T = int(input())
while T:
	s = input()
	solve(s)
	T -= 1
for ans in answers:
	print(ans)


def ques2():
	s = input()
	index = -1
	for i in range(len(s)):
		if s[i] == 'a':
			index = i
			break
	ans = 0
	if index == -1:
		ans = 1
	else:
		value = ord(s[index])
		l = index
		r = index
		visited_coor = 1
		while visited_coor < len(s):
			if l - 1 >= 0 and ord(s[l - 1]) == value + 1:
				visited_coor += 1
				l -= 1
				value += 1
			elif r + 1 < len(s) and ord(s[r + 1]) == value + 1:
				visited_coor += 1
				r += 1
				value += 1
			else:
				break
		if visited_coor < len(s):
			ans = 1
	if ans == 0:
		return 'YES'
	return 'NO'
number_of_testcases = int(input())
for _ in range(number_of_testcases):
	print(ques2())


a = 'abcdefghijklmnopqrstuvwxyz'

def alpha(r, n):
	if len(r) == 1 and r[0] == n:
		print('YES')
		return 0
	elif r[0] == n:
		alpha(r[1:], a[a.find(n) - 1])
	elif r[-1] == n:
		alpha(r[:-1], a[a.find(n) - 1])
	else:
		print('NO')
k = int(input())
for i in range(k):
	r = str(input())
	alpha(r, a[len(r) - 1])


for _ in range(int(input())):
	s = input().strip()
	n = len(s)

	def f():
		i = -1
		if n > 26:
			return -1
		for j in range(n):
			if s[j] == 'a':
				i = j
				break
		if i == -1:
			return -1
		j = i + 1
		i = i - 1
		t = 1
		while i >= 0 or j < n:
			if i >= 0:
				if ord(s[i]) - ord('a') == t:
					i -= 1
					t += 1
					continue
			if j < n:
				if ord(s[j]) - ord('a') == t:
					j += 1
					t += 1
					continue
			return -1
		return 1
	if f() == -1:
		print('NO')
	else:
		print('YES')


def alpha(st):
	a1 = -1
	for i in range(len(st)):
		if st[i] == 'a':
			a1 = i
	if a1 == -1:
		return 'NO'
	x = a1 + 1
	y = a1 - 1
	for i in range(len(st) - 1):
		if x <= len(st) - 1 and ord(st[x]) == 98 + i:
			x += 1
		elif y >= 0 and ord(st[y]) == 98 + i:
			y = y - 1
		else:
			return 'NO'
	return 'YES'
arr = []
for i in range(int(input())):
	arr.append(alpha(input()))
for i in arr:
	print(i)


a = int(input())
for x in range(a):
	b = input()
	c = []
	for y in b:
		c.append(y)
	d = sorted(c)
	e = len(d)
	s = 'a'
	for i in range(1, e):
		if chr(i + 97) in c and 'a' in c:
			if c.index(chr(i + 97)) - c.index('a') > 0:
				s = ''.join(s + chr(i + 97))
			elif c.index(chr(i + 97)) - c.index('a') < 0:
				s = ''.join(chr(i + 97) + s)
	if s == b:
		print('YES')
	else:
		print('NO')


alpha = 'abcdefghijklmnopqrstuvwxyz'

def solve(s):
	n = len(s)
	if n == 1:
		return s[0] == 'a'
	st = -1
	for i in range(n):
		if s[i] == 'a':
			st = i
			break
	if st == -1:
		return False
	(i, j) = (st - 1, st + 1)
	k = 1
	while True:
		if i >= 0 and s[i] == alpha[k]:
			i = i - 1
		elif j <= n - 1 and s[j] == alpha[k]:
			j = j + 1
		else:
			if i < 0 and j >= n:
				return True
			return False
		k = k + 1
for _ in range(int(input())):
	s = input()
	if solve(s):
		print('YES')
	else:
		print('NO')


for _ in range(int(input())):
	string = input()
	arr = []
	flag = 0
	for i in string:
		if ord(i) - 96 in arr:
			flag = 1
			break
		arr.append(ord(i) - 96)
	if flag == 1:
		print('NO')
		continue
	n = len(arr)
	if 1 not in arr:
		print('NO')
		continue
	if max(arr) != n:
		print('NO')
	else:
		idx = arr.index(1)
		for i in range(idx + 1, n - 1):
			if arr[i] >= arr[i + 1]:
				flag = 1
				break
		for i in range(0, idx - 1):
			if arr[i] <= arr[i + 1]:
				flag = 1
				break
		if flag == 0:
			print('YES')
		else:
			print('NO')


from sys import stdin, stdout
from math import floor, gcd, fabs, factorial, fmod, sqrt, inf, log
from collections import defaultdict as dd, deque
from heapq import merge, heapify, heappop, heappush, nsmallest
from bisect import bisect_left as bl, bisect_right as br, bisect
mod = pow(10, 9) + 7
mod2 = 998244353

def inp():
	return stdin.readline().strip()

def iinp():
	return int(inp())

def out(var, end='\n'):
	stdout.write(str(var) + '\n')

def outa(*var, end='\n'):
	stdout.write(' '.join(map(str, var)) + end)

def lmp():
	return list(mp())

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

def l1d(n, val=0):
	return [val for i in range(n)]

def l2d(n, m, val=0):
	return [l1d(m, val) for j in range(n)]

def ceil(a, b):
	return (a + b - 1) // b
S1 = 'abcdefghijklmnopqrstuvwxyz'
S2 = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'

def isprime(x):
	if x <= 1:
		return False
	if x in (2, 3):
		return True
	if x % 2 == 0:
		return False
	for i in range(3, int(sqrt(x)) + 1, 2):
		if x % i == 0:
			return False
	return True
for _ in range(int(inp())):
	s = inp()
	n = len(s)
	if 'a' not in s:
		print('NO')
		continue
	ind = s.index('a')
	i = ind
	j = ind
	c = 1
	while i >= 0 and j < n:
		if i and s[i - 1] == S1[c]:
			i -= 1
		elif j < n - 1 and s[j + 1] == S1[c]:
			j += 1
		else:
			break
		c += 1
	print('YES' if i == 0 and j == n - 1 else 'NO')


for i in range(int(input())):
	s = input()
	if 'a' not in s:
		print('NO')
		continue
	try:
		l = s.index('a')
		r = s.index('a')
		ans = 'YES'
		for i in range(1, len(s)):
			x = chr(97 + i)
			if x not in s:
				ans = 'NO'
				break
			if l > 0 and s[l - 1] == x:
				l = l - 1
			elif s[r + 1] == x:
				r = r + 1
			else:
				ans = 'NO'
				break
		print(ans)
	except:
		print('NO')


def main():
	s = 'abcdefghijklmnopqrstuvwxyz'
	for _ in range(int(input())):
		flag = False
		a = [x for x in input()]
		n = len(a) - 1
		for i in reversed(range(n + 1)):
			if s[i] == a[len(a) - 1]:
				t = a.pop()
			elif s[i] == a[0]:
				t = a.pop(0)
			else:
				print('NO')
				flag = True
				break
		if not flag:
			if len(a) > 0:
				print('NO')
			else:
				print('YES')
main()


from collections import deque

def A(s):
	q = deque(list(s))
	ch = ord(max(s))
	while ch >= 97:
		if len(q) == 0:
			return 'NO'
		if chr(ch) == q[0]:
			q.popleft()
		elif chr(ch) == q[-1]:
			q.pop()
		else:
			return 'NO'
		ch -= 1
	return 'YES' if len(q) == 0 else 'NO'
test_cases = int(input())
while test_cases:
	print(A(input()))
	test_cases -= 1


for _ in range(int(input())):
	s = input()
	index = None
	for i in range(len(s)):
		if s[i] == 'a':
			index = i
	if index == None:
		print('NO')
	else:
		left = index - 1
		rigth = index + 1
		next = 'b'
		flag = 0
		n = len(s)
		while left >= 0 or rigth < n:
			if left > -1 and rigth < n:
				if s[left] == next:
					left -= 1
				elif s[rigth] == next:
					rigth += 1
				else:
					flag = 1
					break
			elif left > -1:
				if s[left] == next:
					left -= 1
				else:
					flag = 1
					break
			elif rigth < n:
				if s[rigth] == next:
					rigth += 1
				else:
					flag = 1
					break
			next = chr(ord(next) + 1)
		if flag == 0:
			print('YES')
		else:
			print('NO')


n = int(input())
alphabet = 'abcdefghijklmnopqrstuvwxyz'
alphabetI = 1
res = []
for i in range(n):
	alphabetI = 1
	s = input()
	if len(set(s)) != len(s) or ''.join(sorted(s)) != alphabet[:len(s)]:
		res.append('NO')
	else:
		c = 1
		aCoord = s.find('a')
		left = aCoord
		right = len(s) - left - 1
		t = left + right
		res.append('YES')
		for i in range(t):
			if left != 0 and s[left - 1] == alphabet[alphabetI]:
				left -= 1
				alphabetI += 1
			elif right != 0 and s[aCoord + c] == alphabet[alphabetI]:
				right -= 1
				alphabetI += 1
				c += 1
			else:
				res.pop(-1)
				res.append('NO')
				break
for i in res:
	print(i)


def f(s):
	l = len(s)
	while l != 0:
		if s[0] == chr(96 + l):
			s.pop(0)
			l -= 1
			return f(s)
		elif s[l - 1] == chr(96 + l):
			s.pop()
			return f(s)
			l -= 1
		else:
			return 'NO'
	return 'YES'
t = int(input())
for i in range(0, t):
	s = list(input())
	print(f(s))


n = int(input())

def alg(s):
	length = len(s)
	ch_id = 97
	f = False
	for i in range(length):
		if s[i] == chr(ch_id):
			l = i - 1
			r = i + 1
			f = True
			break
	if not f:
		return False
	for i in range(length):
		ch_id += 1
		if l >= 0 and s[l] == chr(ch_id):
			l -= 1
			continue
		if r < length and s[r] == chr(ch_id):
			r += 1
			continue
		if l < 0 and r == length:
			return True
		return False
for i in range(n):
	s = input()
	print('YES' if alg(s) else 'NO')
a = 13.54


for _ in range(int(input())):
	s = list(input())
	a = [chr(97 + i) for i in range(len(s))]
	sol = 'YES'
	for i in a[::-1]:
		if s[0] == i:
			s.pop(0)
		elif s[-1] == i:
			s.pop()
		else:
			sol = 'NO'
	print(sol)


for i in range(int(input())):
	s = input()
	x = 97
	c = 0
	for i in range(len(s)):
		if chr(x) in s:
			c = c + 1
			x = x + 1
	if c == len(s):
		y = s.index('a')
		p = list(s[:y])
		l = list(s[y + 1:])
		p = p[::-1]
		if len(p) == 0 and len(l) == 0:
			print('YES')
		elif len(p) == 0 and len(l) > 0:
			if l == sorted(l):
				print('YES')
			else:
				print('NO')
		elif len(p) >= 0 and len(l) == 0:
			if p == sorted(p):
				print('YES')
			else:
				print('NO')
		elif p == sorted(p) and l == sorted(l):
			print('YES')
		else:
			print('NO')
	else:
		print('NO')


def solve(string):
	hasa = string.find('a')
	d = ord('a')
	if hasa == -1:
		return 'NO'
	l = hasa
	r = hasa
	for ele in range(1, len(string)):
		pos = string.find(chr(d + ele))
		if pos != -1:
			if pos == l - 1:
				l -= 1
			elif pos == r + 1:
				r += 1
			else:
				return False
		else:
			return False
	return True
for _ in range(int(input())):
	string = str(input())
	print('YES' if solve(string) == True else 'NO')


import sys
input = sys.stdin.readline
t = int(input())
for _ in range(t):
	s = input().strip()
	alpha = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z']
	if not 'a' in s:
		print('NO')
		continue
	a = 'a'
	b = s.find('a')
	an = 'YES'
	for i in range(1, len(s)):
		c = s.find(alpha[i])
		if c == -1:
			an = 'NO'
			break
		if c < b:
			a = alpha[i] + a
		else:
			a = a + alpha[i]
	if a == s:
		print(an)
	else:
		print('NO')


n = int(input())
b = 'abcdefghijklmnopqrstuvwxyz'
for _ in range(n):
	a = input()
	if len(a) > len(b):
		print('NO')
		continue
	l = r = a.find('a')
	if l == -1:
		print('NO')
		continue
	i = 1
	while i < len(a):
		if l != 0 and r != len(a) - 1 and (a[l - 1] == a[r + 1] == b[i]):
			print('NO')
			break
		if l != 0 and a[l - 1] == b[i]:
			l -= 1
			i += 1
			continue
		if r != len(a) - 1 and a[r + 1] == b[i]:
			r += 1
			i += 1
			continue
		print('NO')
		break
	else:
		print('YES')


t = int(input())
results = []
for i in range(t):
	s = input().lower()
	if len(s) == 0:
		results.append('YES')
		continue
	start = s.find('a')
	if start == -1:
		results.append('NO')
		continue
	current_before = start - 1
	current_after = start + 1
	for j in range(len(s) - 1):
		index = s.find(chr(ord('a') + j + 1))
		if index == -1:
			results.append('NO')
			break
		if index == current_before:
			current_before -= 1
		elif index == current_after:
			current_after += 1
		else:
			results.append('NO')
			break
	else:
		results.append('YES')
for i in range(t):
	print(results[i])


amnt = int(input())

def check(s):
	for i in range(26):
		if s.count(chr(97 + i)) > 1:
			return False
	chars = [symbol for symbol in s]
	for i in range(26):
		l = chr(97 + i)
		if l not in chars:
			if chars:
				return False
			break
		chars.pop(chars.index(l))
	chars = [symbol for symbol in s]
	for i in range(len(s) - 1):
		l = chr(97 + i)
		ind = chars.index(l)
		if abs(ind - chars.index(chr(98 + i))) != 1:
			return False
		chars.pop(ind)
	return True
for i in range(amnt):
	string = input()
	if not check(string):
		print('NO')
	else:
		print('YES')


def removeDupWithoutOrder(str):
	return ''.join(set(str))

def isAlphabaticOrder(s):
	n = len(s)
	c = [s[i] for i in range(len(s))]
	c.sort(reverse=False)
	for i in range(n):
		if c[i] != s[i]:
			return False
	return True
for t in range(int(input())):
	s = input()
	len1 = len(s)
	len2 = len(removeDupWithoutOrder(s))
	arr1 = s.split('a')
	arr = [c for c in arr1 if c]
	ans = 'NO'
	if len1 != len2:
		ans = 'NO'
	elif 'a' not in s:
		ans = 'NO'
	elif len(arr) == 0:
		ans = 'YES'
	elif max(ord(s[0]), ord(s[-1])) - ord('a') + 1 != len1:
		ans = 'NO'
	elif len(arr) == 2:
		x = arr[0]
		x = x[::-1]
		y = arr[1]
		if isAlphabaticOrder(x) and isAlphabaticOrder(y):
			ans = 'YES'
	elif len(arr) == 1 and s[-1] == 'a':
		x = arr[0]
		x = x[::-1]
		if isAlphabaticOrder(x):
			ans = 'YES'
	elif len(arr) == 1 and s[0] == 'a':
		y = arr[0]
		if isAlphabaticOrder(y):
			ans = 'YES'
	print(ans)


alph = 'abcdefghijklmnopqrstuvwxyz'
for _ in range(int(input())):
	s = input()
	if len(s) != len(set(s)):
		print('NO')
	else:
		n = len(s)
		start = 0
		end = n - 1
		for i in alph[:n][::-1]:
			if i == s[start]:
				start += 1
			elif i == s[end]:
				end -= 1
			else:
				print('NO')
				break
		else:
			print('YES')


for _ in range(int(input())):
	s = input()
	n = len(s)
	l = 0
	r = n - 1
	ans = 'YES'
	for i in range(96 + n, 96, -1):
		if chr(i) == s[l]:
			l += 1
		elif chr(i) == s[r]:
			r -= 1
		else:
			ans = 'NO'
			break
	print(ans)


from collections import Counter as count
from bisect import bisect
import sys
from math import ceil, gcd
from itertools import groupby
input = lambda : sys.stdin.readline().rstrip('\r\n')
for i in range(int(input())):
	s = input()
	a = s.find('a')
	if a < 0 or len(s) > 26:
		print('NO')
		continue
	i = j = a
	i -= 1
	j += 1
	n = len(s)
	k = 1
	al = 'abcdefghijklmnopqrstuvwxyz'
	while (i >= 0 or j < n) and k < n:
		if i >= 0 and s[i] == al[k]:
			i -= 1
			k += 1
		elif j < n and s[j] == al[k]:
			j += 1
			k += 1
		else:
			print('NO')
			break
	else:
		print('YES')


import sys
import math
mod = 10 ** 9 + 7
LI = lambda : [int(k) for k in input().split()]
input = lambda : sys.stdin.readline().rstrip()
IN = lambda : int(input())
S = lambda : input()
r = range
alpha = 'abcdefghijklmnopqrstuvwxyz'
for t in r(IN()):
	s = S()
	s = list(s)
	n = len(s)
	chk = []
	for ele in s:
		if ele not in alpha[:n] or ele in chk:
			print('NO')
			break
		else:
			chk += [ele]
	else:
		for i in range(1, n):
			it = alpha[i]
			fer = s.index(it)
			iit = alpha[i - 1]
			ffer = s.index(iit)
			if abs(fer - ffer) > 1:
				print('NO')
				break
			s.remove(iit)
		else:
			print('YES')


from itertools import permutations, combinations, combinations_with_replacement
from typing import List
import string

def solve(s, n, index):
	ans = True
	if index == -1:
		ans = False
	else:
		res = ord(s[index])
		(l, r) = (index, index)
		tracked = 1
		while tracked < n:
			if l - 1 >= 0 and ord(s[l - 1]) == res + 1:
				tracked += 1
				l -= 1
				res += 1
			elif r + 1 < n and ord(s[r + 1]) == res + 1:
				tracked += 1
				r += 1
				res += 1
			else:
				break
		if tracked < n:
			ans = False
	if ans:
		return 'YES'
	return 'NO'
tt = int(input())
for _ in range(tt):
	s = input()
	n = len(s)
	index = -1
	for i in range(n):
		if s[i] == 'a':
			index = i
			break
	rr = solve(s, n, index)
	print(rr)


t = int(input())
output = []
for i in range(t):
	s = input()
	if len(s) == 1:
		if s == 'a':
			output.append('YES')
		else:
			output.append('NO')
	else:
		right = len(s) - 1
		left = 0
		if ord(s[0]) > ord(s[-1]):
			curr = 0
		else:
			curr = len(s) - 1
		alph = True
		while left <= right:
			if left == right and s[curr] == 'a':
				break
			if curr == right:
				if ord(s[curr]) == ord(s[right - 1]) + 1:
					curr = right - 1
				elif ord(s[curr]) == ord(s[left]) + 1:
					curr = left
				else:
					alph = False
					break
				right = right - 1
			else:
				if ord(s[curr]) == ord(s[left + 1]) + 1:
					curr = left + 1
				elif ord(s[curr]) == ord(s[right]) + 1:
					curr = right
				else:
					alph = False
					break
				left = left + 1
		if alph:
			output.append('YES')
		else:
			output.append('NO')
for out in output:
	print(out)


def sol(s):
	chars = {}
	left = right = s.find('a')
	if left == -1:
		print('NO')
	else:
		flag = True
		chars['a'] = 1
		l = len(s)
		next_char = chr(ord('a') + 1)
		while right - left < l - 1:
			if right + 1 < l and s[right + 1] == next_char:
				right += 1
			elif left - 1 >= 0 and s[left - 1] == next_char:
				left -= 1
			else:
				print('NO')
				flag = False
				break
			next_char = chr(ord(next_char) + 1)
		if flag:
			print('YES')
t = int(input())
for i in range(t):
	s = input()
	sol(s)


t = int(input())
for amp in range(t):
	s = input()
	n = len(s)
	y = -1
	for i in range(n):
		if s[i] == 'a':
			y = i
			break
	sol = 'YES'
	if y == -1:
		sol = 'NO'
	else:
		val = ord(s[y])
		l = z = y
		q = 1
		while q < n:
			if l - 1 >= 0 and ord(s[l - 1]) == val + 1:
				q += 1
				l -= 1
				val += 1
			elif z + 1 < n and ord(s[z + 1]) == val + 1:
				q += 1
				z += 1
				val += 1
			else:
				break
		if q < n:
			sol = 'NO'
	print(sol)


import sys
t = int(sys.stdin.readline())
for _ in range(t):
	string = sys.stdin.readline().rstrip()
	n = len(string)
	st = -1
	answer = 'NO'
	for i in range(n):
		if string[i] == 'a':
			st = i
			break
	if st != -1:
		answer = 'YES'
		(l, r) = (st - 1, st + 1)
		alpha = ord('b')
		for _ in range(n - 1):
			if l >= 0:
				if string[l] == chr(alpha):
					l -= 1
					alpha += 1
				elif r < n:
					if string[r] == chr(alpha):
						r += 1
						alpha += 1
					else:
						answer = 'NO'
				else:
					answer = 'NO'
			elif r < n:
				if string[r] == chr(alpha):
					r += 1
					alpha += 1
				else:
					answer = 'NO'
			else:
				answer = 'NO'
	print(answer)


from string import ascii_lowercase
t = int(input())
for i in range(t):
	s = input().rstrip()
	(l, r) = (0, len(s) - 1)
	ok = True
	for c in ascii_lowercase[:len(s)][::-1]:
		if s[l] == c:
			l += 1
		elif s[r] == c:
			r -= 1
		else:
			ok = False
			break
	if ok:
		print('YES')
	else:
		print('NO')


from sys import stdin

def A():
	t = int(stdin.readline())
	while t:
		aaa = stdin.readline()
		t -= 1
		d = [int(x) for x in stdin.readline().split()]
		(xa, ya) = (d[0], d[1])
		c = [int(x) for x in stdin.readline().split()]
		(xb, yb) = (c[0], c[1])
		b = [int(x) for x in stdin.readline().split()]
		(xf, yf) = (b[0], b[1])
		sava = abs(xa - xb)
		savb = abs(ya - yb)
		res = sava + savb
		if xa == xb == xf:
			if ya < yf < yb:
				res += 2
			elif yb < yf < ya:
				res += 2
		elif ya == yb == yf:
			if xa < xf < xb:
				res += 2
			elif xb < xf < xa:
				res += 2
		elif xa == ya and xb == yb and (xf == yf):
			if xa < xf < xb:
				res += 0
			elif xb < xf < xa:
				res += 0
			else:
				res = sava
		print(res)

def B():
	t = int(stdin.readline())
	while t:
		s = input()
		t -= 1
		s1 = []
		for i in s:
			s1.append(ord(i) - ord('a'))
		sav = max(s1)
		l = 0
		r1 = len(s1) - 1
		res = True
		k = [0] * 30
		for i in s1:
			if k[i] > 1:
				res = False
				break
			k[i] += 1
		for i in k:
			if i > 1:
				res = False
				break
		if len(s1) > 1 and res:
			while sav == s1[l] or sav == s1[r1]:
				if sav == s1[l] == s1[r1]:
					res = False
					break
				if sav == s1[l]:
					l += 1
				elif sav == s1[r1]:
					r1 -= 1
				else:
					res = False
					break
				sav -= 1
				if sav <= 0 or l >= r1:
					break
		if sav <= 0 and res:
			print('YES')
		else:
			print('NO')
B()


for s in [*open(0)][1:]:
	i = 0
	j = k = len(s) - 1
	while k and (c := chr(96 + k)) in (s[i], s[j - 1]):
		if c == s[i]:
			i += 1
		else:
			j -= 1
		k -= 1
	print('YNEOS'[k > 0::2])


t = int(input())

def solve(string):
	n = len(string)
	uniques = set(string)
	if len(uniques) != n:
		return False
	alpha_pos = [ord(char) - ord('a') + 1 for char in string]
	if max(alpha_pos) != n or min(alpha_pos) != 1:
		return False
	start_index = alpha_pos.index(1)
	right_arr = alpha_pos[start_index:]
	left_arr = alpha_pos[:start_index]
	if sorted(right_arr) != right_arr or sorted(left_arr, reverse=True) != left_arr:
		return False
	return True
for _ in range(t):
	string = input()
	ans = solve(string)
	print('YES' if ans else 'NO')


A = ['z', 'y', 'x', 'w', 'v', 'u', 't', 's', 'r', 'q', 'p', 'o', 'n', 'm', 'l', 'k', 'j', 'i', 'h', 'g', 'f', 'e', 'd', 'c', 'b', 'a']
j = int(input())
while j > 0:
	s = input()
	l = len(s)
	S = list(s)
	a = A[26 - l:26]
	for i in a:
		if S[0] == i:
			S = S[1:]
		elif S[-1] == i:
			S.pop()
		else:
			print('NO')
			break
	if S == []:
		print('YES')
	j = j - 1


import string

def func(n, words_list):
	letters_string = string.ascii_lowercase
	target_list = []
	for i in range(0, n, 1):
		s = ''
		s_right = ''
		s_left = ''
		target = 0
		for j in range(0, len(letters_string), 1):
			s_right = s + letters_string[j]
			s_left = letters_string[j] + s
			if s_right in words_list[i]:
				s = s_right
			elif s_left in words_list[i]:
				s = s_left
			else:
				target = 'NO'
				target_list.append(target)
				break
			if s == words_list[i]:
				target = 'YES'
				target_list.append(target)
				break
	return target_list

def main():
	n = int(input())
	words_list = []
	for i in range(0, n, 1):
		c = input()
		words_list.append(c)
	var = func(n, words_list)
	for i in var:
		print(i)
main()


from string import ascii_lowercase
for _ in range(int(input())):
	s = input().strip()
	t = sorted(s)
	for i in range(len(t)):
		if t[i] != ascii_lowercase[i]:
			print('NO')
			break
	else:
		left = s.index('a') - 1
		right = s.index('a') + 1
		for i in range(1, len(s)):
			if 0 <= left and s[left] == ascii_lowercase[i]:
				left -= 1
				continue
			if right < len(s) and s[right] == ascii_lowercase[i]:
				right += 1
				continue
			break
		else:
			print('YES')
			continue
		print('NO')


from math import *
from sys import *
input = stdin.readline
for _ in range(int(input())):
	s = input()
	l = []
	for i in s:
		l.append(i)
	l = l[:len(l) - 1]
	n = len(l)
	cntr = 1
	for i in range(n + 96, 96, -1):
		if l[0] == chr(i):
			l = l[1:]
		elif l[len(l) - 1] == chr(i):
			l = l[:len(l) - 1]
		else:
			cntr = 0
			break
	if cntr:
		print('YES')
	else:
		print('NO')


t = int(input())

def test(s):
	n = len(s)
	if n == 1:
		if s == 'a':
			return 'YES'
		else:
			return 'NO'
	maxi = 0
	r = n - 1
	l = 0
	while r - l > 0:
		left = s[l]
		right = s[r]
		if ord(left) > ord(right):
			l += 1
			act = ord(left)
		elif ord(left) < ord(right):
			r -= 1
			act = ord(right)
		else:
			return 'NO'
		if maxi == 0:
			maxi = act
		elif act != maxi - 1:
			return 'NO'
		else:
			maxi -= 1
	last = ord(s[l])
	if last != maxi - 1 or last != ord('a'):
		return 'NO'
	return 'YES'
for _ in range(t):
	s = input()
	print(test(s))


def check_string(s):
	l = len(s)
	max_char_ord = chr(ord('a') + l - 1)
	present_chars = set()
	prev_char = s[0]
	up = False
	for char in s:
		if char > max_char_ord or char in present_chars or (char < prev_char and up):
			return 'NO'
		if char > prev_char:
			up = True
		present_chars.add(char)
		prev_char = char
	return 'YES'
n_tests = int(input())
for _ in range(n_tests):
	s = input().strip()
	print(check_string(s))


from string import ascii_lowercase
t = int(input())
for _ in range(t):
	s = input()
	print(['NO', 'YES'][any([sorted(s[:i], reverse=True) == list(s[:i]) and sorted(s[i:]) == list(s[i:]) for i in range(26)]) and ''.join(sorted(s)) == ascii_lowercase[:len(s)]])


from __future__ import division, print_function
import os, sys
from io import BytesIO, IOBase
if sys.version_info[0] < 3:
	from __builtin__ import xrange as range
	from future_builtins import ascii, filter, hex, map, oct, zip

def ii():
	return int(input())

def si():
	return input()

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

def msi():
	return map(str, input().strip().split(' '))

def li():
	return list(mi())

def dmain():
	sys.setrecursionlimit(1000000)
	threading.stack_size(1024000)
	thread = threading.Thread(target=main)
	thread.start()
abc = 'abcdefghijklmnopqrstuvwxyz'
abd = {'a': 0, 'b': 1, 'c': 2, 'd': 3, 'e': 4, 'f': 5, 'g': 6, 'h': 7, 'i': 8, 'j': 9, 'k': 10, 'l': 11, 'm': 12, 'n': 13, 'o': 14, 'p': 15, 'q': 16, 'r': 17, 's': 18, 't': 19, 'u': 20, 'v': 21, 'w': 22, 'x': 23, 'y': 24, 'z': 25}
mod = 1000000007
inf = float('inf')
vow = ['a', 'e', 'i', 'o', 'u']
(dx, dy) = ([-1, 1, 0, 0], [0, 0, 1, -1])

def getKey(item):
	return item[1]

def sort2(l):
	return sorted(l, key=getKey, reverse=True)

def d2(n, m, num):
	return [[num for x in range(m)] for y in range(n)]

def isPowerOfTwo(x):
	return x and (not x & x - 1)

def decimalToBinary(n):
	return bin(n).replace('0b', '')

def ntl(n):
	return [int(i) for i in str(n)]

def ncr(n, r):
	return factorial(n) // (factorial(r) * factorial(max(n - r, 1)))

def ceil(x, y):
	if x % y == 0:
		return x // y
	else:
		return x // y + 1

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

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

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

def read():
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')

def main():
	for _ in range(ii()):
		s = si()
		n = len(s)
		l = -1
		r = -1
		for i in range(n):
			if s[i] == 'a':
				l = i
				r = i
				break
		if l == -1:
			print('NO')
			continue
		f = 1
		for i in range(1, min(26, n)):
			if l > 0 and s[l - 1] == abc[i]:
				l -= 1
			elif r < n - 1 and s[r + 1] == abc[i]:
				r += 1
			else:
				f = 0
				break
		if f:
			print('YES')
		else:
			print('NO')
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))
input = lambda : sys.stdin.readline().rstrip('\r\n')
main()


import bisect
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')
nl = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z']
for _ in range(int(input())):
	ast = input()
	last = len(ast)
	news = []
	for i in range(last):
		x = nl.index(ast[i])
		news.append(str(x + 1))
	yon = False
	for i in range(last):
		tk = last - i
		if int(news[0]) == tk:
			news = news[1:]
		elif int(news[-1]) == tk:
			news = news[:len(news) - 1]
		else:
			yon = True
			break
	if yon:
		print('NO')
	else:
		print('YES')


def main():
	abc = 'abcdefghijklmnopqrstuvwxyz'
	for _ in range(int(input())):
		s = input()
		cnt = 0
		l = r = -1
		ans = 1
		n = len(s)
		for i in abc:
			if cnt < n:
				ind = s.find(i)
				if ind == -1:
					ans = 0
				if l == -1 or r == -1:
					l = r = ind
					cnt += 1
				elif ind == l - 1 or ind == r + 1:
					cnt += 1
					l = min(l, ind)
					r = max(r, ind)
				else:
					ans = 0
			else:
				break
			if ans == 0:
				break
		if ans:
			print('YES')
		else:
			print('NO')
main()


import sys
t = int(sys.stdin.readline().strip())
for i in range(t):
	s = str(sys.stdin.readline().strip())
	if not 'a' in s:
		print('NO')
		continue
	else:
		pos = rp = lp = s.find('a')
		flag = True
		for j in range(1, len(s)):
			pos = s.find(chr(ord('a') + j))
			if pos == -1 or (pos != lp - 1 and pos != rp + 1):
				flag = False
				break
			else:
				lp = min(lp, pos)
				rp = max(rp, pos)
		if flag:
			print('YES')
		else:
			print('NO')


t = int(input())
for _ in range(t):
	s = [i for i in input()]
	flag = True
	letters = [chr(i) for i in range(len(s) + 96, 96, -1)]
	for i in range(len(letters)):
		if letters[i] == s[0]:
			s.pop(0)
			continue
		if letters[i] == s[-1]:
			s.pop()
			continue
		else:
			flag = False
			break
	if flag:
		print('YES')
	else:
		print('NO')


import math
t = int(input())
for i in range(t):
	s = input()
	i = 0
	j = len(s) - 1
	start = max(ord(s[i]), ord(s[j])) + 1
	f = -1
	while i != j:
		next = max(ord(s[i]), ord(s[j]))
		if next + 1 != start:
			f = 0
			break
		elif ord(s[i]) == next:
			i += 1
		else:
			j -= 1
		start = next
	if ord(s[i]) == 97 and f == -1 and (start == 98):
		print('YES')
	else:
		print('NO')


from sys import stdin
input = stdin.readline
rn = lambda : int(input())
rns = lambda : map(int, input().split())
rl = lambda : list(map(int, input().split()))
rs = lambda : input().strip()
YN = lambda x: print('YES') if x else print('NO')
mod = 10 ** 9 + 7
for _ in range(rn()):
	s = rs()
	a = [(ord(s[i]), i) for i in range(len(s))]
	a.sort()
	ans = a[0][0] == 97
	l = a[0][1]
	r = a[0][1]
	for i in range(1, len(s)):
		if a[i][0] != a[i - 1][0] + 1:
			ans = False
		elif a[i][1] == r + 1:
			r += 1
		elif a[i][1] == l - 1:
			l -= 1
		else:
			ans = False
	YN(ans)


n = int(input())
s2 = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z']
for i in range(n):
	s = input()
	a = len(s)
	b = len(s)
	c = 0
	for j in range(a):
		if s2[a - 1] == s[0]:
			c += 1
			s = s[1:]
		elif s2[a - 1] == s[a - 1]:
			c += 1
			s = s[:a - 1]
		a = a - 1
	if c == b:
		print('YES')
	else:
		print('NO')


t = int(input())
for i in range(t):
	a = input()
	prev1 = a.find('a')
	prev2 = prev1
	if prev1 == -1:
		print('NO')
		continue
	teksimv = 'a'
	fl = True
	while prev1 > 0 or prev2 < len(a) - 1:
		if prev1 > 0 and ord(a[prev1 - 1]) - ord(teksimv) == 1:
			teksimv = a[prev1 - 1]
			prev1 -= 1
		elif prev2 < len(a) - 1 and ord(a[prev2 + 1]) - ord(teksimv) == 1:
			teksimv = a[prev2 + 1]
			prev2 += 1
		else:
			fl = False
			break
	if fl:
		print('YES')
	else:
		print('NO')


for _ in range(int(input())):
	s = input()
	c = s[:]
	s = ''.join(sorted(s))
	if 'abcdefghijklmnopqrstuvwxyz'[:len(s)] == s:
		d = c.index('a')
		l = d - 1
		j = d + 1
		flag = True
		for i in 'bcdefghijklmnopqrstuvwxyz'[:len(s) - 1]:
			if l >= 0 and i == c[l]:
				l -= 1
			elif j < len(s) and i == c[j]:
				j += 1
			else:
				flag = False
				print('NO')
				break
		if flag:
			print('YES')
	else:
		print('NO')


import sys
input = sys.stdin.readline
I = lambda : list(map(int, input().split()))
alpha = 'abcdefghijklmnopqrstuvwxyz'
(t,) = I()
for _ in range(t):
	s = input().strip()
	x = len(s)
	ans = 'YES'
	i = 0
	j = x - 1
	x -= 1
	while i < j:
		if alpha[x] == s[i]:
			i += 1
		elif alpha[x] == s[j]:
			j -= 1
		else:
			ans = 'NO'
			break
		x -= 1
	if s[i] != 'a':
		ans = 'NO'
	print(ans)


def letter_for(i):
	return chr(i + ord('a'))

def solve(s: str) -> bool:
	start = 0
	end = len(s) - 1
	looking_for = len(s) - 1
	target = letter_for(looking_for)
	while start <= end:
		if start == end and s[start] == target == 'a':
			return 'YES'
		if s[start] == target:
			looking_for -= 1
			target = letter_for(looking_for)
			start += 1
		elif s[end] == target:
			looking_for -= 1
			target = letter_for(looking_for)
			end -= 1
		else:
			return 'NO'
	return 'NO'

def main():
	import sys
	test_cases = int(sys.stdin.readline().strip())
	for _ in range(test_cases):
		line = sys.stdin.readline().strip()
		print(solve(line))
main()


T = int(input())
for i in range(T):
	s = input()
	r = len(s) - 1
	l = 0
	r = len(s) - 1
	flag = False
	if ord(s[r]) > ord(s[l]):
		k = ord(s[r])
		r = r - 1
	elif ord(s[l]) > ord(s[r]):
		k = ord(s[l])
		l = l + 1
	elif len(s) == 1:
		if s != 'a':
			flag = True
		k = 98
	else:
		flag = True
		k = 0
	while l != r and k != 0:
		if ord(s[r]) > ord(s[l]) and ord(s[r]) == k - 1:
			k = k - 1
			r = r - 1
		elif ord(s[r]) < ord(s[l]) and ord(s[l]) == k - 1:
			k = k - 1
			l = l + 1
		else:
			flag = True
			break
	k = k - 1
	if k != 97:
		flag = True
	if flag:
		print('NO')
	else:
		print('YES')


t = int(input())
for i in range(t):
	s = input()
	indl = 0
	indr = len(s) - 1
	f = True
	for let in range(len(s) + ord('a') - 1, ord('a') - 1, -1):
		if indl > indr:
			f = False
			break
		elif s[indl] == chr(let):
			indl += 1
		elif s[indr] == chr(let):
			indr -= 1
		else:
			f = False
			break
	if f:
		print('YES')
	else:
		print('NO')


res = []
for _ in range(int(input())):
	s = input()
	l = len(s)
	flag = False
	x = chr(97 + l - 1)
	cnt = [0] * l
	while ord(x) - 97 >= 0 and s != '' and (flag == False):
		if s[0] == x:
			s = s[1:]
		elif s[len(s) - 1] == x:
			s = s[:len(s) - 1]
		else:
			flag = True
		x = chr(ord(x) - 1)
	if flag:
		res.append('NO')
	else:
		res.append('YES')
for i in res:
	print(i)


t = int(input())
for p in range(t):
	s = input()
	s = s.upper()
	ls = [x for x in s]
	pas = False
	if ls.count('A') != 1:
		print('NO')
		continue
	else:
		left_limit = ls.index('A')
		right_limit = ls.index('A')
		for i in range(65 + 1, 65 + 27):
			if not left_limit and right_limit == len(ls) - 1:
				print('YES')
				pas = True
				break
			else:
				if ls.count(chr(i)) != 1:
					print('NO')
					pas = True
					break
				if left_limit > 0 and ls[left_limit - 1] == chr(i):
					left_limit -= 1
					continue
				elif right_limit < len(ls) - 1 and ls[right_limit + 1] == chr(i):
					right_limit += 1
					continue
				else:
					print('NO')
					pas = True
					break
		if not pas:
			print('NO')


n = int(input())
dic = {}
for i in range(0, 26):
	dic[str(i)] = chr(97 + i)
for i in range(n):
	inp = input()
	s = ''
	for j in range(len(inp)):
		if s + dic[str(j)] in inp:
			s = s + dic[str(j)]
		elif dic[str(j)] + s in inp:
			s = dic[str(j)] + s
		else:
			print('NO')
			break
	else:
		print('YES')


n = int(input())
for i in range(n):
	lst = []
	s = input()
	if 'a' not in s:
		print('NO')
		continue
	for j in range(len(s)):
		lst.append(ord(s[j]))
	flag_0 = 0
	for k in range(0, lst.index(97)):
		if lst[k] < lst[k + 1]:
			flag_0 = 1
			break
	for k in range(lst.index(97) + 1, len(lst) - 1):
		if lst[k] > lst[k + 1]:
			flag_0 = 1
			break
	if flag_0 == 1:
		print('NO')
		continue
	lst.sort()
	flag = 0
	for j in range(1, len(lst)):
		if lst[j - 1] - lst[j] != -1:
			flag = 1
			break
	if flag == 1:
		print('NO')
	else:
		print('YES')


import sys
t = int(input())

def ostacle(a, b, f):
	if a[0] == b[0] or a[1] == b[1]:
		if a[0] == b[0]:
			check_index = 1
		else:
			check_index = 0
		return f[1 - check_index] == a[1 - check_index] and (f[check_index] < a[check_index] and f[check_index] > b[check_index] or (f[check_index] > a[check_index] and f[check_index] < b[check_index]))
	return False
for z in range(t):
	try:
		s = input()
		l = len(s)
		index = s.find('a')
		if index != -1:
			f = 1
			r_index = index + 1
			l_index = index - 1
			for i in range(1, l):
				if r_index < l and ord(s[r_index]) == 97 + i:
					r_index += 1
				elif l_index >= 0 and ord(s[l_index]) == 97 + i:
					l_index -= 1
				else:
					f = 0
					break
			if f:
				print('YES')
			else:
				print('NO')
		else:
			print('NO')
	except ValueError as e:
		pass


def ans():
	s = input()
	i = 0
	j = len(s) - 1
	for x in range(len(s) - 1, -1, -1):
		c = chr(x + 97)
		if c == s[i]:
			i += 1
			continue
		if c == s[j]:
			j -= 1
			continue
		print('NO')
		return
	print('YES')
t = int(input())
for i in range(t):
	ans()


for i in range(int(input())):
	s = input()
	for i in range(len(s)):
		if s[i] == 'a':
			break
	ans = 0
	x = 0
	if i == len(s) - 1 and s[i] != 'a':
		print('NO')
	elif s == 'a':
		print('YES')
	else:
		j = i - 1
		k = i + 1
		alpha = ord('a') + 1
		while j >= 0 and k < len(s):
			x = 2
			if i > 0 and s[j] == chr(alpha):
				j -= 1
				alpha += 1
			elif s[k] == chr(alpha):
				k += 1
				alpha += 1
			else:
				ans = 1
				break
		while j >= 0:
			x = 2
			if i > 0 and s[j] == chr(alpha):
				j -= 1
				alpha += 1
			else:
				ans = 1
				break
		while k < len(s):
			x = 2
			if s[k] == chr(alpha):
				k += 1
				alpha += 1
			else:
				ans = 1
				break
		if ans == 1 and x == 2:
			print('NO')
		elif ans == 0 and x == 0:
			print('NO')
		else:
			print('YES')


t = int(input())
ans = []
abc = 'abcdefghijklmnopqrstuvwxyz'
for _ in range(t):
	s = input()
	n = len(s)
	abc1 = abc[:n][::-1]
	for i in range(n):
		if s[0] == abc1[i]:
			s = s[1:]
		elif s[-1] == abc1[i]:
			s = s[:-1]
		else:
			ans.append('NO')
			break
	else:
		ans.append('YES')
for i in ans:
	print(i)


def solve():
	if s.count('a') != 1:
		return 'NO'
	start = s.index('a') - 1
	end = s.index('a') + 1
	for i in range(1, 26):
		cnt = s.count(chr(i + 97))
		if cnt == 0:
			if i != len(s):
				return 'NO'
			break
		elif cnt > 1:
			return 'NO'
		else:
			idx = s.index(chr(i + 97))
			if idx == start:
				start -= 1
			elif idx == end:
				end += 1
			else:
				return 'NO'
	return 'YES'
for t in range(int(input())):
	s = input()
	print(solve())


def crawlArray(n, index, inc):
	return ((index + inc) % n + n) % n

def solve(s):
	n = len(s)
	start = s.find('a')
	if start == -1:
		return False
	cnt = 1
	next_letter_to_check = 'b'
	i = start
	head = start
	tail = start
	while cnt < n:
		new_head = head + 1
		new_tail = tail - 1
		if 0 <= new_head < n and s[new_head] == next_letter_to_check:
			i = new_head
			head += 1
		elif 0 <= new_tail < n and s[new_tail] == next_letter_to_check:
			i = new_tail
			tail -= 1
		else:
			return False
		next_letter_to_check = chr(ord(next_letter_to_check) + 1)
		cnt += 1
	return True
t = int(input())
for _ in range(t):
	s = input()
	res = solve(s)
	print('YES' if res else 'NO')


t = int(input())
for _ in range(t):
	s = input()
	if not s.isalpha():
		print('NO')
	else:
		flag = 0
		ma = max(s[-1], s[0])
		while s != '':
			if s[0] == ma:
				s = s[1:]
			elif s[-1] == ma:
				s = s[:-1]
			else:
				flag = 1
				break
			if s == '':
				break
			ma = chr(ord(ma) - 1)
		if flag == 0 and ma == 'a':
			print('YES')
		else:
			print('NO')


t = int(input())
for i in range(t):
	s = input()
	d = 0
	if 'a' in s:
		n = s.index('a')
		d = 1
	x = 'abcdefghijklmnopqrstuvwxyz'
	if d == 1 and len(s) == 1 and (s == 'a'):
		print('YES')
	elif d == 1 and len(s) == 2 and (s == 'ab' or s == 'ba'):
		print('YES')
	elif d == 1 and n != -1 and (len(s) >= 3):
		r = 1
		l = 1
		j = 1
		q = 0
		for k in range(len(s)):
			if 0 <= n - l < len(s) and s[n - l] == x[j]:
				j += 1
				l = l + 1
			elif 0 <= n + r < len(s) and s[n + r] == x[j]:
				r = r + 1
				j += 1
			else:
				print('NO')
				q = 1
				break
			if j == len(s):
				break
		if q == 0:
			print('YES')
	else:
		print('NO')


def exe():
	n = len(s)
	if 'a' not in s:
		return 'NO'
	ia = s.index('a')
	i = ia - 1
	j = ia + 1
	p = ord('a')
	flag = 0
	while i != -1 or j != n:
		p += 1
		if i != -1 and s[i] == chr(p):
			i -= 1
		elif j != n and s[j] == chr(p):
			j += 1
		else:
			flag = 1
			break
	if flag == 0:
		return 'YES'
	else:
		return 'NO'
for i in range(int(input())):
	s = input()
	print(exe())


t = int(input())
for i in range(t):
	s = []
	a = str(input())
	for i in a:
		s.append(ord(i))
	if len(set(s)) != len(s):
		print('NO')
	else:
		control = 0
		if 97 in s:
			c = s.index(97)
		else:
			print('NO')
			continue
		(x, y) = (1, 1)
		counter = 98
		for i in range(len(a) - 1):
			try:
				if s.index(counter) == c - x and c - x >= 0:
					counter += 1
					x += 1
					continue
				if s.index(counter) == c + y:
					counter += 1
					y += 1
					continue
				if (s.index(counter) != c - x and s.index(counter) != c + y) and c - x >= 0:
					control += 1
					break
				elif s.index(counter) != c + y and c - x < 0:
					control += 1
					break
			except ValueError:
				control += 1
				break
		if control != 0:
			print('NO')
		else:
			print('YES')


n = int(input())
full = 'abcdefghijklmnopqrstuvwxyz'

def is_alphabetical(s):
	subs = ''
	result = 'YES'
	for i in range(0, len(s)):
		s1 = subs + full[i]
		s2 = full[i] + subs
		if s1 in s:
			subs = s1
			continue
		elif s2 in s:
			subs = s2
			continue
		else:
			result = 'NO'
			break
	return result
for i in range(n):
	s = str(input())
	print(is_alphabetical(s))


from string import ascii_lowercase

def is_alpha(string):
	chunks = string.split('a')
	if len(chunks) != 2:
		return False
	(left, right) = chunks
	left = list(left)
	right = list(right)
	for c in ascii_lowercase[1:]:
		if left:
			if c == left[-1]:
				left.pop(-1)
				continue
		if right:
			if c == right[0]:
				right.pop(0)
				continue
		return not left and (not right)
	return not left and (not right)
for _ in range(int(input())):
	print('YES' if is_alpha(input()) else 'NO')


t = int(input())
it = list()
for i in range(t):
	sp = input()
	n = len(sp)
	kola = 0
	kolb = n - 1
	f1 = True
	for j in range(96 + n, 96, -1):
		if chr(j) == sp[kola]:
			kola += 1
		elif chr(j) == sp[kolb]:
			kolb -= 1
		else:
			f1 = False
			break
	if f1:
		it.append('YES')
	else:
		it.append('NO')
for i in it:
	print(i)


def check(s):
	if len(s) != len(set(s)):
		return False
	n = len(s)
	(i, j) = (0, n - 1)
	cur = chr(97 + n - 1)
	for _ in range(n):
		if s[i] == cur:
			i += 1
		elif s[j] == cur:
			j -= 1
		else:
			return False
		cur = chr(ord(cur) - 1)
	return True
t = int(input())
for _ in range(t):
	s = input()
	print('YES' if check(s) else 'NO')


import sys
from string import ascii_lowercase as alph
input = sys.stdin.readline

def print(*args, end='\n', sep=' '):
	sys.stdout.write(sep.join(map(str, args)) + end)

def solve():
	s = input().strip()
	i = len(s) - 1
	right = i
	left = 0
	while i >= 0:
		if alph[i] == s[left]:
			left += 1
		elif alph[i] == s[right]:
			right -= 1
		else:
			print('NO')
			break
		i -= 1
	else:
		print('YES')

def main():
	t = int(input())
	for _ in range(t):
		solve()
main()


alph = 'abcdefghijklmnopqrstuvwxyz'
for _ in range(int(input())):
	s = input()
	n = len(s)
	sti = n - 1
	flg = 0
	while len(s) > 0:
		if s[0] == alph[sti]:
			s = s[1:]
			sti -= 1
		elif s[-1] == alph[sti]:
			s = s[:-1]
			sti -= 1
		else:
			flg = 1
			break
	if flg == 0:
		print('YES')
	else:
		print('NO')


n = int(input())
while n > 0:
	n -= 1
	s = input()
	pos = s.find('a')
	z = True
	if pos == -1:
		z = False
	else:
		l = pos
		r = pos
		i = 1
		siz = len(s)
		for i in range(siz - 1):
			temp = s.find(chr(98 + i))
			if temp == -1:
				z = False
				break
			elif temp == l - 1:
				l -= 1
				continue
			elif temp == r + 1:
				r += 1
				continue
			else:
				z = False
				break
	if z:
		print('YES')
	else:
		print('NO')


for i in range(int(input())):
	s = input()
	l = len(s)
	if s.count('a') == 0:
		print('NO')
		continue
	a = s.index('a')
	le = a
	ri = a + 1
	alp = 'abcdefghijklmnopqrstuvwxyz'
	FL = True
	for i in range(l):
		if le >= 0 and s[le] == alp[i]:
			le -= 1
		elif ri < l and s[ri] == alp[i]:
			ri += 1
		else:
			FL = False
			break
	print('YES' if FL else 'NO')


t = int(input())
for _ in range(t):
	dummy = input()
	l = list(dummy)
	start = 0
	end = len(l) - 1
	count = len(l)
	while start <= end and count:
		if ord(l[start]) == count + 96:
			start += 1
		elif ord(l[end]) == count + 96:
			end -= 1
		else:
			break
		count -= 1
	if start > end:
		print('YES')
	else:
		print('NO')


n = int(input())
for i in range(n):
	a = input()
	x = ord('a') + len(a) - 1
	l = 0
	r = len(a) - 1
	for i in range(len(a)):
		if a[l] == chr(x):
			l += 1
			x -= 1
		elif a[r] == chr(x):
			r -= 1
			x -= 1
		else:
			print('NO')
			break
	else:
		print('YES')


import sys
import collections
input = sys.stdin.readline

def main():
	t = int(input())
	for _ in range(t):
		S = input().strip()
		q = collections.deque(list(S))
		ma = max(list(S))
		l = ord(ma) - ord('a') + 1
		if len(S) != l:
			print('NO')
			continue
		f = True
		while q:
			if q[0] == ma:
				q.popleft()
				ma = chr(ord(ma) - 1)
				continue
			if q[-1] == ma:
				q.pop()
				ma = chr(ord(ma) - 1)
				continue
			f = False
			break
		if f:
			print('YES')
		else:
			print('NO')
main()


def fun(s):
	l = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z']
	lst = l[:len(s)]
	s1 = set(lst)
	s2 = set(list(s))
	s3 = s1.intersection(s2)
	if len(s1) != len(s2) or len(s3) != len(s1):
		return 'NO'
	flag = 0
	if s[0] == 'a':
		flag = 1
	for i in range(1, len(s)):
		if flag == 0:
			if s[i] > s[i - 1]:
				flag += 1
		elif flag == 1:
			if s[i] < s[i - 1]:
				return 'NO'
		else:
			return 'NO'
	return 'YES'
t = int(input())
for i in range(t):
	s = input()
	res = fun(s)
	print(res)


t = int(input())
for i in range(t):
	text = input()
	length = len(text)
	ans = True
	for j in range(length):
		if text[0] == chr(97 + length - j - 1):
			text = text[1:]
		elif text[-1] == chr(97 + length - j - 1):
			text = text[:-1]
		else:
			print('NO')
			ans = False
			break
	if ans:
		print('YES')


for j in range(0, int(input())):
	s = input()
	ans = 'YES'
	l = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z']
	l1 = list(s)
	l1.sort()
	if l[0:len(s)] != l1:
		ans = 'NO'
	else:
		for i in range(0, s.index('a') - 1):
			if s[i] < s[i + 1]:
				ans = 'NO'
				break
		for x in range(s.index('a') + 1, len(s) - 1):
			if s[x] > s[x + 1]:
				ans = 'NO'
				break
	print(ans)


def x(s):
	pos = -1
	for i in range(len(s)):
		if s[i] == 'a':
			pos = i
	if pos == -1:
		return False

	def xx(s, i, j):
		l = j - i + 1
		nex = ord('a') + l
		if i == 0 and j == len(s) - 1:
			return True
		if i == 0:
			if ord(s[j + 1]) == nex:
				return xx(s, i, j + 1)
			else:
				return False
		if j == len(s) - 1:
			if ord(s[i - 1]) == nex:
				return xx(s, i - 1, j)
			else:
				return False
		if ord(s[i - 1]) != nex:
			if ord(s[j + 1]) != nex:
				return False
			else:
				return xx(s, i, j + 1)
		if ord(s[j + 1]) != nex:
			if ord(s[i - 1]) != nex:
				return False
			else:
				return xx(s, i - 1, j)
		return False
	return xx(s, pos, pos)
t = int(input())
for _ in range(t):
	st = input()
	ans = x(st)
	if ans:
		print('YES')
	else:
		print('NO')


for _ in range(int(input())):
	string = input().strip()
	alphabets = 'abcdefghijklmnopqrstuvwxyz'
	x = len(string)
	i = 0
	j = x - 1
	k = x - 1
	flag = 1
	while i <= j and k >= 0:
		if string[i] == alphabets[k]:
			i += 1
		elif string[j] == alphabets[k]:
			j -= 1
		else:
			flag = 0
			break
		k -= 1
	print('YES' if flag == 1 else 'NO')


for i in range(int(input())):
	s = input()
	pos = s.find('a')
	l = pos
	r = pos
	c = 98
	ok = True
	while not (l == 0 and r == len(s) - 1):
		if l > 0 and s[l - 1] == chr(c):
			l -= 1
		elif r < len(s) - 1 and s[r + 1] == chr(c):
			r += 1
		else:
			ok = False
			break
		c += 1
	if ok:
		print('YES')
	else:
		print('NO')


import string
lett = string.ascii_lowercase

def isAlf(ss):
	start = ss.find('a')
	if start == -1:
		return False
	n = len(ss)
	if n == 1:
		return True
	l = start - 1
	r = start + 1
	ll = 1
	for i in range(1, 26):
		if l < 0 and r >= n:
			break
		if l >= 0 and lett[ll] == ss[l]:
			l -= 1
			ll += 1
			continue
		if r < n and lett[ll] == ss[r]:
			r += 1
			ll += 1
			continue
		return False
	return True

def main(input, print):
	toPrint = []
	t = int(input())
	for i in range(t):
		ss = input().strip()
		r = isAlf(ss)
		if r:
			toPrint.append('YES')
		else:
			toPrint.append('NO')
	print('\n'.join(toPrint))
main(input, print)


str = 'abcdefghijklmnopqrstuvwxyz'
for _ in range(int(input())):
	s = input()
	if len(s) == 1:
		if s[0] == 'a':
			print('YES')
		else:
			print('NO')
		continue
	(i, j) = (-1, -1)
	for k in range(len(s)):
		if k > 0:
			if s[k] == 'a' and s[k - 1] == 'b':
				(i, j) = (k, k - 1)
				break
		if k < len(s) - 1:
			if s[k] == 'a' and s[k + 1] == 'b':
				(i, j) = (k, k + 1)
				break
	if i == -1:
		print('NO')
		continue
	if i > j:
		(i, j) = (j, i)
	(k, f) = (int(0), int(0))
	while k < len(s):
		if i >= 0 and s[i] == str[k]:
			k += 1
			i -= 1
			continue
		if j < len(s) and s[j] == str[k]:
			k += 1
			j += 1
			continue
		f = 1
		break
	if f:
		print('NO')
	else:
		print('YES')


from collections import deque
import heapq
from math import sqrt
import operator
from operator import itemgetter
import sys
import copy
inf_var = 0
if inf_var == 1:
	inf = open('input.txt', 'r')
else:
	inf = sys.stdin
input = inf.readline

def read_one_int():
	return int(input().rstrip('\n'))

def read_one_float():
	return float(input().rstrip('\n'))

def read_list_of_ints():
	res = [int(val) for val in input().rstrip('\n').split(' ')]
	return res

def read_str():
	return input().rstrip()

def main():
	tests = read_one_int()
	alph = 'abcdefghijklmnopqrstuvwxyz'
	for _ in range(tests):
		s = read_str()
		pos = -1
		for (i, ch) in enumerate(s):
			if ch == 'a':
				pos = i
		if pos == -1:
			print('NO')
			continue
		l = pos - 1
		r = pos + 1
		alph_ind = 1
		while True:
			if l == -1 and r == len(s):
				print('YES')
				break
			if l >= 0:
				if s[l] == alph[alph_ind]:
					l -= 1
					alph_ind += 1
					continue
			if r < len(s):
				if s[r] == alph[alph_ind]:
					r += 1
					alph_ind += 1
					continue
			print('NO')
			break
main()


t = int(input())
answers = []
for i in range(0, t):
	s = input()
	n = len(s) - 1
	begpos = s.find('a')
	endpos = begpos
	flag1 = 0
	flag2 = 0
	if begpos != -1:
		for x in range(2, 27):
			if n > 0:
				ch = chr(x + 96)
				curt = s.find(str(ch))
				n -= 1
				if curt == -1:
					flag2 = 1
					break
				if curt == begpos - 1:
					begpos = curt
				elif curt == endpos + 1:
					endpos = curt
				else:
					flag2 = 1
					break
			else:
				break
	else:
		flag1 = 1
	if flag1 == 0 and flag2 == 0:
		answers.append('YES')
	else:
		answers.append('NO')
for i in answers:
	print(i)


import sys

def yes():
	print('YES')

def no():
	print('NO')

def isinc(string):
	t = list(string)
	if t == sorted(t):
		return True
	return False

def isdec(string):
	t = list(string)
	if t == sorted(t, reverse=True):
		return True
	return False
L = 'abcdefghijklmnopqrstuvwxyz'
for _ in range(int(input())):
	s = sys.stdin.readline().strip()
	if set(list(s)) != set(list(L[:len(s)])):
		no()
		continue
	y = s.index('a')
	if y == 0:
		if isinc(s[1:]):
			yes()
			continue
		else:
			no()
			continue
	elif y == len(s) - 1:
		if isdec(s[:-1]):
			yes()
			continue
		else:
			no()
			continue
	else:
		s1 = s[:y]
		s2 = s[y + 1:]
		if not isinc(s2):
			no()
			continue
		if not isdec(s1):
			no()
			continue
		yes()
		continue


from sys import stdin

def input():
	return stdin.readline().rstrip('\r\n')
a = int(input())
for x in range(a):
	b = input()
	c = []
	for y in b:
		c.append(y)
	d = sorted(c)
	e = len(d)
	s = 'a'
	for i in range(1, e):
		if chr(i + 97) in c and 'a' in c:
			if c.index(chr(i + 97)) - c.index('a') > 0:
				s = ''.join(s + chr(i + 97))
			elif c.index(chr(i + 97)) - c.index('a') < 0:
				s = ''.join(chr(i + 97) + s)
	if s == b:
		print('YES')
	else:
		print('NO')


for _ in range(int(input())):
	n = input()
	a = 0
	b = len(n) - 1
	m = chr(ord(max(n)) + 1)
	if b + 1 == 2 or len(set(n)) != b + 1:
		if n == 'ab' or n == 'ba':
			print('YES')
			continue
		else:
			print('NO')
			continue
	while a <= b:
		p = max(n[a], n[b])
		if p < m and abs(ord(p) - ord(m)) == 1:
			m = p
			a += m == n[a]
			b -= m == n[b]
		else:
			print('NO')
			break
			continue
	else:
		print('YES' * ('a' in n) + 'NO' * ('a' not in n))
		continue


import sys, math
from collections import deque, defaultdict
import operator as op
from functools import reduce
from itertools import permutations
import heapq
I = sys.stdin.readline
alpha = 'abcdefghijklmnopqrstuvwxyz'
mod = 10 ** 9 + 7

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 ispali(s):
	i = 0
	j = len(s) - 1
	while i < j:
		if s[i] != s[j]:
			return False
		i += 1
		j -= 1
	return True

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)
		lst = s.find('a')
		tmp = 1
		posi = [lst - tmp, lst + tmp]
		x = 1
		if lst != -1:
			for i in range(1, n):
				c = alpha[i]
				f = 0
				for j in range(n):
					if s[j] == c:
						if posi[0] == j:
							lst = j
							tmp += 1
							posi[0] = lst - 1
							posi[1] = lst + tmp
							f = 1
						elif posi[1] == j:
							lst = j
							tmp += 1
							posi[0] = lst - tmp
							posi[1] = lst + 1
							f = 1
						break
				if f == 0:
					x = 0
					break
		else:
			x = 0
		if x:
			ans += 'YES\n'
		else:
			ans += 'NO\n'
	print(ans)
main()


def res():
	st = input()
	fin = st.find('a')
	if fin == -1:
		return 'NO'
	else:
		le = len(st)
		i = 0
		lp = fin
		rp = fin
		while i < le - 1:
			qw = chr(98 + i)
			if rp + 1 < le and st[rp + 1] == qw:
				rp += 1
			elif lp - 1 >= 0 and st[lp - 1] == qw:
				lp -= 1
			else:
				return 'NO'
				break
			i += 1
		return 'YES'
for i in range(int(input())):
	print(res())


def solve():
	s = input()
	n = len(s)
	(l, r) = (0, n - 1)
	flag = False
	for i in range(n, 0, -1):
		if chr(i + 96) == s[l]:
			l += 1
		elif chr(i + 96) == s[r]:
			r -= 1
		else:
			flag = True
	if not flag:
		return 'YES'
	else:
		return 'NO'
t = int(input())
while t:
	print(solve())
	t -= 1


alph = 'abcdefghijklmnopqrstuvwxyz'
t = int(input())
S = [''] * t
A = ['NO'] * t
for i in range(t):
	S[i] = input()
for i in range(t):
	is_alph = True
	s = S[i]
	for j in reversed(range(len(s))):
		if s[0] == alph[j]:
			s = s[1:]
		elif s[-1] == alph[j]:
			s = s[:-1]
		else:
			is_alph = False
	if is_alph:
		A[i] = 'YES'
for i in range(t):
	print(A[i])


def solve(strg):
	str = ''.join(sorted(strg))
	pos_a = strg.index('a')
	Left = pos_a
	Right = pos_a
	for j in range(98, 98 + len(strg)):
		l = chr(j)
		pos_l = strg.find(l)
		if j == len(strg) + 97:
			print('YES')
			break
		if l not in strg:
			print('NO')
			break
		elif pos_l == Right + 1:
			Right = Right + 1
		elif pos_l == Left - 1:
			Left = Left - 1
		else:
			print('NO')
			break
t = int(input())
for i in range(t):
	strg = input()
	s = set(strg)
	if 'a' not in strg:
		print('NO')
	elif len(strg) != len(s):
		print('NO')
	else:
		solve(strg)


alphabets = 'abcdefghijklmnopqrstuvwxyz'

def solve():
	S = input()
	N = len(S)
	indexes = {}
	for i in range(N):
		indexes[alphabets[i]] = -1
	for i in range(N):
		indexes[S[i]] = i
	for i in indexes.values():
		if i == -1:
			print('NO')
			return
	req = []
	a = indexes['a']
	if a == 0:
		req = [-1, 1]
	elif a == N - 1:
		req = [N - 2, N + 1]
	else:
		req = [a - 1, a + 1]
	for i in range(1, N):
		a = indexes[alphabets[i]]
		if req[0] == a and a >= 0:
			req[0] = a - 1
		elif req[1] == a and a <= N - 1:
			req[1] = a + 1
		else:
			print('NO')
			return
	print('YES')
for _ in range(int(input())):
	solve()


import os
import sys
from io import BytesIO, IOBase

def main():
	from collections import deque

	def alpha_to_num(alpha):
		return ord(alpha) - 96

	def check(s):
		deq = deque(s)
		while deq:
			if alpha_to_num(deq[0]) == len(deq):
				deq.popleft()
			elif alpha_to_num(deq[-1]) == len(deq):
				deq.pop()
			else:
				return 'NO'
		return 'YES'
	for _ in range(int(input())):
		s = input()
		print(check(s))
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')
main()


def calc():
	s = input()
	n = len(s)
	a_pos = -1
	for i in range(n):
		if s[i] == 'a':
			a_pos = i
			break
	if a_pos == -1:
		print('NO')
		return
	l = a_pos - 1
	r = a_pos + 1
	while l >= 0 or r < n:
		if l >= 0 and ord(s[l]) == ord(s[a_pos]) + 1:
			a_pos = l
			l -= 1
		elif r < n and ord(s[r]) == ord(s[a_pos]) + 1:
			a_pos = r
			r += 1
		elif l == -1 and r == n:
			print('YES')
			return
		else:
			print('NO')
			return
	print('YES')
t = int(input())
for _i in range(t):
	calc()


def solve(s):
	n = len(s)
	n = len(s)
	temp = s
	temp = ''.join(sorted(temp))
	flag = 0
	a = 'a'
	for i in range(n):
		if ord(a) + i != ord(temp[i]):
			flag = 1
			break
	if flag:
		return 'NO'
	elif n == 1 or n == 2:
		return 'YES'
	else:
		i = 1
		f = 0
		while i < n - 1:
			if s[i] > s[i - 1] and s[i] > s[i + 1]:
				f = 1
				break
			i += 1
		if f:
			return 'NO'
		else:
			return 'YES'
t = int(input())
for i in range(t):
	s = input()
	print(solve(s))


for _ in range(int(input())):
	a = input()
	s = ''
	while len(a) != 1:
		if a[0] > a[-1]:
			s += a[0]
			a = a[1:]
		else:
			s += a[-1]
			a = a[:-1]
		if len(a) == 1:
			break
	s += 'a'
	if a != 'a' or s[::-1] not in 'abcdefghijklmnopqrstuvwxyz':
		print('NO')
	else:
		print('YES')


t = int(input())
for xr in range(t):
	s = input()
	n = len(s)
	i1 = -1
	i2 = -1
	us = [0] * 26
	k = [0] * 26
	for i in range(len(s)):
		if s[i] == 'a':
			if i1 != -1:
				i2 = i
			else:
				i1 = i
		us[ord(s[i]) - ord('a')] += 1
		k[ord(s[i]) - 97] = i
	if i2 != -1 or i1 == -1:
		print('NO')
		continue
	i2 = i1
	x = 1
	f = 1
	for i in range(1, 26):
		if us[i] == 0:
			continue
		if us[i] != 0 and us[i - 1] == 0:
			print('NO')
			f = 0
			break
		elif us[i] > 1:
			print('NO')
			f = 0
			break
		t = chr(97 + i)
		if k[i] == i1 - 1:
			i1 -= 1
		elif k[i] == i2 + 1:
			i2 += 1
		else:
			print('NO')
			f = 0
			break
	if f:
		print('YES')


def solve():
	s = [ord(x) - ord('a') for x in input()]
	n = len(s) - 1
	while s:
		if s[0] == n:
			s = s[1:]
		elif s[-1] == n:
			s = s[:-1]
		else:
			return False
		n -= 1
	return True
for _ in ' ' * int(input()):
	print(('NO', 'YES')[solve()])


from sys import *
input = lambda : stdin.readline()
int_arr = lambda : list(map(int, stdin.readline().strip().split()))
str_arr = lambda : list(map(str, stdin.readline().split()))
get_str = lambda : map(str, stdin.readline().strip().split())
get_int = lambda : map(int, stdin.readline().strip().split())
get_float = lambda : map(float, stdin.readline().strip().split())
mod = 1000000007
setrecursionlimit(1000)
lst = list('abcdefghijklmnopqrstuvwxyz')

def ans(s):
	ind = {}
	n = len(s)
	for i in range(n):
		ind[s[i]] = i
	if n == 1 and s[0] == 'a':
		print('YES')
		return
	arr = lst[:n]
	if 'a' in s:
		(l, r) = (ind[arr[0]] - 1, ind[arr[0]] + 1)
		for i in arr[1:]:
			if i in ind:
				if ind[i] == l:
					l -= 1
				elif ind[i] == r:
					r += 1
				else:
					print('NO')
					return
			else:
				print('NO')
				return
		print('YES')
		return
	else:
		print('NO')
		return
for _ in range(int(input())):
	s = str(input())[:-1]
	ans(s)


for _ in range(int(input())):
	s = input()
	end = len(s) - 1
	while len(s) > 0:
		if ord(s[0]) - 97 == end:
			s = s[1:]
		elif ord(s[-1]) - 97 == end:
			s = s[0:len(s) - 1]
		else:
			break
		end -= 1
	print('YES' if len(s) == 0 else 'NO')


import os
import sys
from io import BytesIO, IOBase
from functools import lru_cache, reduce
import heapq
import cProfile
from collections import Counter, defaultdict, deque
from bisect import bisect, bisect_left, bisect_right
import math
import threading
import time

def I():
	return input()

def get_int():
	return int(input())

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

def get_map():
	return map(int, input().split())

def get_list_str(li, s=' '):
	print(s.join(map(str, li)))
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 solve():
	st = input()
	n = len(st)
	ans = 'YES'
	dq = deque(list(st))
	while dq:
		ch = chr(ord('a') + n - 1)
		if dq[0] == ch:
			dq.popleft()
		elif dq[-1] == ch:
			dq.pop()
		else:
			ans = 'NO'
			break
		n -= 1
	print(ans)

def main():
	testcases = True
	if testcases:
		t = get_int()
		for _ in range(t):
			solve()
	else:
		solve()
main()


from collections import deque

def solution(st):
	q = deque()
	maxi = 'a'
	for i in range(len(st)):
		maxi = max(st[i], maxi)
		q.append(st[i])
	for i in range(ord(maxi), 96, -1):
		if len(q) == 0:
			print('NO')
			return
		if q[0] == chr(i):
			q.popleft()
		elif q[len(q) - 1] == chr(i):
			q.pop()
		else:
			print('NO')
			return
	if len(q) == 0:
		print('YES')
	else:
		print('NO')
	return
for _ in range(int(input())):
	st = input().strip()
	solution(st)


for _ in range(int(input())):
	s = str(input())
	n = len(s)
	if ord(max(s)) - 96 > n or len(set(s)) != len(s):
		print('NO')
		continue
	a = list(s)
	b = []
	ind_front = 0
	ind_back = n - 1
	while ind_front <= ind_back:
		if a[ind_front] < a[ind_back]:
			b.append(a[ind_back])
			ind_back -= 1
		else:
			b.append(a[ind_front])
			ind_front += 1
	a.sort(reverse=True)
	if a != b:
		print('NO')
		continue
	print('YES')


import sys
from collections import deque
input = sys.stdin.readline
alpha = [chr(i) for i in range(97, 123)]
t = int(input())
results = []
while t > 0:
	t -= 1
	input_s = input().rstrip()
	string = deque([])
	flag = True
	for i in input_s:
		string.append(i)
	for i in range(len(input_s) - 1, -1, -1):
		if string[0] == alpha[i]:
			temp = string.popleft()
		elif string[-1] == alpha[i]:
			temp = string.pop()
		else:
			flag = False
			break
	if flag:
		results.append('YES')
	else:
		results.append('NO')
for i in results:
	print(i)


for _ in range(int(input())):
	s = input()
	(size, indx, ans) = (len(s), -1, 'YES')
	for i in range(size):
		if s[i] == 'a':
			indx = i
			break
	if indx == -1:
		ans = 'NO'
	else:
		v = ord(s[indx])
		left = ryt = indx
		trace = 1
		while trace < size:
			if 0 <= left - 1 and ord(s[left - 1]) == v + 1:
				trace += 1
				v += 1
				left -= 1
			elif ryt + 1 < size and ord(s[ryt + 1]) == v + 1:
				trace += 1
				ryt += 1
				v += 1
			else:
				break
		if trace < size:
			ans = 'NO'
	print(ans)


for _ in range(int(input())):
	s = input()
	A_idx = -1
	mx = 0
	mp = {}
	dup = False
	for i in range(len(s)):
		if s[i] == 'a':
			A_idx = i
		if s[i] not in mp:
			mp[s[i]] = 1
		else:
			dup = True
			break
		mx = max(mx, ord(s[i]))
	if dup:
		print('NO')
	else:
		(l, r) = (A_idx - 1, A_idx + 1)
		ok = True
		i = 98
		while i <= mx:
			if r < len(s) and s[r] == chr(i):
				r += 1
			elif l >= 0 and s[l] == chr(i):
				l -= 1
			else:
				ok = False
				break
			i += 1
		if A_idx != -1 and i > mx:
			print('YES')
		else:
			print('NO')


for t in range(int(input())):
	s = input()
	ans = 1
	if s.count('a') != 1:
		print('NO')
		continue
	(leftindex, rightindex) = (s.index('a'), s.index('a'))
	for i in range(98, ord(max(s)) + 1):
		if s.count(chr(i)) != 1:
			ans = 0
			break
		if leftindex < s.index(chr(i)) < rightindex:
			ans = 0
			break
		if s.index(chr(i)) > rightindex:
			rightindex = s.index(chr(i))
		else:
			leftindex = min(s.index(chr(i)), leftindex)
	if ans:
		print('YES')
	else:
		print('NO')


def solve():
	s = input()
	it = s.find('a')
	if it == -1:
		return 'NO'
	L = R = it
	n = len(s)
	for i in range(1, n):
		it = s.find(chr(ord('a') + i))
		if it != -1:
			if it == L - 1:
				L -= 1
			elif it == R + 1:
				R += 1
			else:
				return 'NO'
		else:
			return 'NO'
	return 'YES'
n = int(input())
for _ in range(n):
	print(solve())


def f(s):
	alph = 'abcdefghijklmnopqrstuvwxyz'
	if 'a' not in s:
		return 'NO'
	else:
		pivot = s.find('a')
		l = pivot - 1
		r = pivot + 1
		i = 1
		while i <= len(s) - 1:
			k = 0
			if s[l] == alph[i] and l > -1:
				k = 1
				l -= 1
				i += 1
			elif s[r % len(s)] == alph[i] and r < len(s):
				k = 1
				r += 1
				i += 1
			if k == 0:
				return 'NO'
		return 'YES'
n = int(input())
for i in range(n):
	s = input()
	print(f(s))


def is_alphabetical(s):
	pos_a = s.find('a')
	if pos_a == -1:
		return 'NO'
	left_cursor = pos_a - 1
	right_cursor = pos_a + 1
	for i in range(1, len(s)):
		target = chr(97 + i)
		if left_cursor >= 0 and s[left_cursor] == target:
			left_cursor -= 1
			continue
		if right_cursor < len(s) and s[right_cursor] == target:
			right_cursor += 1
			continue
		return 'NO'
	return 'YES'
import sys
T = int(input())
while T:
	s = input()
	print(is_alphabetical(s))
	T -= 1


t = int(input())
for i in range(t):
	s = input()
	n = len(s)
	while n > 0:
		ch = chr(ord('a') + n - 1)
		if s[0] == ch:
			s = s[1:]
		elif s[-1] == ch:
			s = s[:-1]
		else:
			break
		n -= 1
	print('NO' if n else 'YES')


for _ in range(int(input())):
	s = input()
	ch = 'a'
	flag = True
	if ch in s:
		l = r = s.index(ch)
		r += 1
		while flag and l >= 0 and (r < len(s)):
			if s[l] == ch:
				l -= 1
				ch = chr(ord(ch) + 1)
			elif s[r] == ch:
				r += 1
				ch = chr(ord(ch) + 1)
			else:
				flag = False
		while flag and l >= 0:
			if s[l] == ch:
				l -= 1
				ch = chr(ord(ch) + 1)
			else:
				flag = False
		while flag and r < len(s):
			if s[r] == ch:
				r += 1
				ch = chr(ord(ch) + 1)
			else:
				flag = False
		if flag:
			print('YES')
		else:
			print('NO')
	else:
		print('NO')


def isalpha(s):
	start = 0
	end = len(s) - 1
	t = len(s) + 96
	while start <= end:
		if s[start] == chr(t):
			start += 1
			t -= 1
		elif s[end] == chr(t):
			end -= 1
			t -= 1
		else:
			return 'NO'
	return 'YES'
t = int(input())
for i in range(t):
	s = input()
	print(isalpha(s))


(YES, NO) = ('YES', 'NO')

def solve(s):
	if 'a' not in s:
		return NO
	sl = list(s)
	(l, r) = (sl.index('a') - 1, sl.index('a') + 1)
	i = 'b'
	while l >= 0 and r < len(sl):
		if sl[l] == i:
			l -= 1
			i = chr(ord(i) + 1)
		elif sl[r] == i:
			r += 1
			i = chr(ord(i) + 1)
		else:
			return NO
	if ord(i) > ord('z'):
		return YES
	while l >= 0:
		if sl[l] != i:
			return NO
		else:
			i = chr(ord(i) + 1)
			l -= 1
	while r < len(sl):
		if sl[r] != i:
			return NO
		else:
			i = chr(ord(i) + 1)
			r += 1
	return YES
tc = int(input())
for _ in range(tc):
	s = input()
	print(solve(s))


import sys, os, io
import math, bisect, operator
(inf, mod) = (float('inf'), 10 ** 9 + 7)
from itertools import groupby, accumulate
from heapq import heapify, heappop, heappush
from collections import deque, Counter, defaultdict
input = iter(sys.stdin.buffer.read().decode().splitlines()).__next__
Neo = lambda : list(map(int, input().split()))
(test,) = Neo()
for i in range(test):
	s = deque(input())
	S = s.copy()
	A = []
	prev = inf
	f = 1
	while s:
		if len(s) == 1:
			a = s.pop()
			if prev == inf:
				prev = ord(a)
				continue
			if prev - ord(a) != 1:
				prev = ord(a)
				f = 0
				break
		else:
			a = -1
			if s[0] > s[-1]:
				a = s.popleft()
			else:
				a = s.pop()
			if prev == inf:
				prev = ord(a)
				continue
			if prev - ord(a) != 1:
				f = 0
				break
			prev = ord(a)
	if f and min(S) == 'a':
		print('YES')
	else:
		print('NO')


def func(s):
	if len(s) == 1:
		if s == 'a':
			return True
		else:
			return False
	elif s[0] > s[-1]:
		if s[0] == chr(ord('a') + len(s) - 1):
			return func(s[1:])
		else:
			return False
	elif s[0] == s[-1]:
		return False
	elif s[-1] == chr(ord('a') + len(s) - 1):
		return func(s[0:-1])
	else:
		return False
t = int(input())
for i in range(t):
	s = input()
	if func(s):
		print('YES')
	else:
		print('NO')


from collections import defaultdict
for _ in range(int(input())):
	x = input()
	arr = [0] * 123
	c = len(x)
	aa = 0
	for i in range(c):
		arr[ord(x[i])] += 1
		if x[i] == 'a':
			aa = i
	flag = 0
	for j in range(97, 97 + c):
		if arr[j] != 1:
			flag = 1
	if flag == 0:
		xx = x[:aa]
		yy = ''.join(sorted(xx, reverse=True))
		zz = x[aa:]
		zzz = ''.join(sorted(zz))
		if xx == yy and zz == zzz:
			print('YES')
		else:
			print('NO')
	else:
		print('NO')


import sys
from collections import deque
input = sys.stdin.readline
for _ in range(int(input())):
	data = deque(list(input().rstrip()))
	n = len(data)
	while data:
		find = chr(96 + n)
		if data[0] == find:
			n -= 1
			data.popleft()
			continue
		if data[-1] == find:
			n -= 1
			data.pop()
			continue
		break
	if data:
		print('NO')
	else:
		print('YES')


for i in range(int(input())):
	a = input()
	(m, n, z) = (0, len(a) - 1, 0)
	for j in range(len(a) + 96, 96, -1):
		if a[m] == chr(j):
			m += 1
		elif a[n] == chr(j):
			n -= 1
		else:
			z = 1
	print('YNEOS'[z::2])


def check(s):
	letters = 'abcdefghijklmnopqrstuvwxyz'
	l = []
	if s.find(letters[0]) == -1:
		return False
	else:
		l = [s.find(letters[0]), s.find(letters[0])]
	for i in range(1, len(s)):
		letter = letters[i]
		if l[0] == 0:
			if s[l[1] + 1] == letter:
				l[1] += 1
				continue
			return False
		elif l[1] == len(s) - 1:
			if s[l[0] - 1] == letter:
				l[0] -= 1
				continue
			return False
		else:
			if s[l[1] + 1] == letter:
				l[1] += 1
				continue
			if s[l[0] - 1] == letter:
				l[0] -= 1
				continue
			return False
	return True
n = int(input())
for i in range(n):
	s = input()
	print('YES' if check(s) else 'NO')


for _ in range(int(input())):
	abc = 'bcdefghijklmnopqrstuvwxyz'
	temp = 'a'
	s = input()
	f = 1
	for i in range(25):
		if len(temp) == len(s):
			if temp == s:
				break
			else:
				f = 0
				break
		if temp + abc[i] in s:
			temp += abc[i]
		elif abc[i] + temp in s:
			temp = abc[i] + temp
		else:
			f = 0
			break
	if f == 1:
		print('YES')
	else:
		print('NO')


for _ in range(int(input())):
	s = list(input())
	start = 0
	end = len(s) - 1
	flag = 0
	for i in range(len(s), 0, -1):
		z = chr(i + 96)
		if z == s[start]:
			start += 1
		elif z == s[end]:
			end -= 1
		else:
			flag = 1
			break
	if flag == 0:
		print('YES')
	else:
		print('NO')


import sys
t = int(sys.stdin.readline())
for _ in range(t):
	s = sys.stdin.readline()
	s = s.replace('\n', '')
	arr = [c for c in s]
	alphabet = '_abcdefghijklmnopqrstuvwxyz'
	j = len(s)
	flag = True
	while j >= 1:
		if arr[0] == alphabet[j]:
			arr.pop(0)
			j -= 1
			continue
		elif arr[-1] == alphabet[j]:
			arr.pop(-1)
			j -= 1
			continue
		else:
			flag = False
			break
	if flag:
		print('YES')
	else:
		print('NO')


from string import ascii_lowercase as alph

def isAlph(s):
	if s == 'a':
		return 'YES'
	else:
		t = len(s)
		if s[0] == alph[t - 1]:
			return isAlph(s[1:])
		if s[-1] == alph[t - 1]:
			return isAlph(s[:-1])
		return 'NO'
for i in range(int(input())):
	print(isAlph(input()))


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')
import math
from bisect import *
from heapq import *
from collections import defaultdict as dd
from collections import OrderedDict as odict
from collections import Counter as cc
from collections import deque
from itertools import groupby
sys.setrecursionlimit(20 * 20 * 20 * 20 + 10)

def solve():
	string = takesr()
	n = len(string)
	arr = [''] * n
	if len(string) == 1 and string[0] == 'a':
		print('YES')
		return
	if 'a' not in string:
		print('NO')
		return
	else:
		index = string.index('a')
		lower = upper = index
		arr[index] = 'a'
		first = 98
		while lower > 0 or upper < n - 1:
			element = chr(first)
			if lower - 1 >= 0 and string[lower - 1] == element:
				arr[lower - 1] = element
				lower = lower - 1
			elif upper + 1 < n and string[upper + 1] == element:
				arr[upper + 1] = element
				upper += 1
			else:
				print('NO')
				return
			first += 1
	print('YES')
	return

def main():
	global tt
	if not ONLINE_JUDGE:
		sys.stdin = open('input.txt', 'r')
		sys.stdout = open('output.txt', 'w')
	t = 1
	t = takein()
	for tt in range(1, t + 1):
		solve()
	if not ONLINE_JUDGE:
		print('Time Elapsed :', time.time() - start_time, 'seconds')
		sys.stdout.close()

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

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

def takeiar():
	return list(map(int, sys.stdin.readline().rstrip('\r\n').split()))

def takesar():
	return list(map(str, sys.stdin.readline().rstrip('\r\n').split()))

def takeivr():
	return map(int, sys.stdin.readline().rstrip('\r\n').split())

def takesvr():
	return map(str, sys.stdin.readline().rstrip('\r\n').split())

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

def invert(bit_s):
	temp = int(bit_s, 2)
	inverse_s = temp ^ 2 ** (len(bit_s) + 1) - 1
	rslt = bin(inverse_s)[3:]
	return str(rslt)

def counter(a):
	q = [0] * max(a)
	for i in range(len(a)):
		q[a[i] - 1] = q[a[i] - 1] + 1
	return q

def counter_elements(a):
	q = dict()
	for i in range(len(a)):
		if a[i] not in q:
			q[a[i]] = 0
		q[a[i]] = q[a[i]] + 1
	return q

def string_counter(a):
	q = [0] * 26
	for i in range(len(a)):
		q[ord(a[i]) - 97] = q[ord(a[i]) - 97] + 1
	return q

def factorial(n, m=1000000007):
	q = 1
	for i in range(n):
		q = q * (i + 1) % m
	return q

def factors(n):
	q = []
	for i in range(1, int(n ** 0.5) + 1):
		if n % i == 0:
			q.append(i)
			q.append(n // i)
	return list(sorted(list(set(q))))

def prime_factors(n):
	q = []
	while n % 2 == 0:
		q.append(2)
		n = n // 2
	for i in range(3, int(n ** 0.5) + 1, 2):
		while n % i == 0:
			q.append(i)
			n = n // i
	if n > 2:
		q.append(n)
	return list(sorted(q))

def transpose(a):
	(n, m) = (len(a), len(a[0]))
	b = [[0] * n for i in range(m)]
	for i in range(m):
		for j in range(n):
			b[i][j] = a[j][i]
	return b

def power_two(x):
	return x and (not x & x - 1)

def ceil(a, b):
	return -(-a // b)

def seive(n):
	a = [1]
	prime = [True for i in range(n + 1)]
	p = 2
	while p * p <= n:
		if prime[p] == True:
			for i in range(p ** 2, n + 1, p):
				prime[i] = False
		p = p + 1
	for p in range(2, n + 1):
		if prime[p]:
			a.append(p)
	return a

def pref(li):
	pref_sum = [0]
	for i in li:
		pref_sum.append(pref_sum[-1] + i)
	return pref_sum

def kadane(x):
	sum_so_far = 0
	current_sum = 0
	for i in x:
		current_sum += i
		if current_sum < 0:
			current_sum = 0
		else:
			sum_so_far = max(sum_so_far, current_sum)
	return sum_so_far

def binary_search(li, val):
	ans = -1
	lb = 0
	ub = len(li) - 1
	while lb <= ub:
		mid = (lb + ub) // 2
		if li[mid] > val:
			ub = mid - 1
		elif val > li[mid]:
			lb = mid + 1
		else:
			ans = mid
			break
	return ans

def upper_bound(li, num):
	answer = -1
	start = 0
	end = len(li) - 1
	while start <= end:
		middle = (end + start) // 2
		if li[middle] <= num:
			answer = middle
			start = middle + 1
		else:
			end = middle - 1
	return answer

def lower_bound(li, num):
	answer = -1
	start = 0
	end = len(li) - 1
	while start <= end:
		middle = (end + start) // 2
		if li[middle] >= num:
			answer = middle
			end = middle - 1
		else:
			start = middle + 1
	return answer
ONLINE_JUDGE = __debug__
if ONLINE_JUDGE:
	input = sys.stdin.readline
main()