Recently Polycarp noticed that some of the buttons of his keyboard are malfunctioning. For simplicity, we assume that Polycarp's keyboard contains $26$ buttons (one for each letter of the Latin alphabet). Each button is either working fine or malfunctioning. 

To check which buttons need replacement, Polycarp pressed some buttons in sequence, and a string $s$ appeared on the screen. When Polycarp presses a button with character $c$, one of the following events happened:

  if the button was working correctly, a character $c$ appeared at the end of the string Polycarp was typing;  if the button was malfunctioning, two characters $c$ appeared at the end of the string. 

For example, suppose the buttons corresponding to characters a and c are working correctly, and the button corresponding to b is malfunctioning. If Polycarp presses the buttons in the order a, b, a, c, a, b, a, then the string he is typing changes as follows: a $\rightarrow$ abb $\rightarrow$ abba $\rightarrow$ abbac $\rightarrow$ abbaca $\rightarrow$ abbacabb $\rightarrow$ abbacabba.

You are given a string $s$ which appeared on the screen after Polycarp pressed some buttons. Help Polycarp to determine which buttons are working correctly for sure (that is, this string could not appear on the screen if any of these buttons was malfunctioning).

You may assume that the buttons don't start malfunctioning when Polycarp types the string: each button either works correctly throughout the whole process, or malfunctions throughout the whole process.


-----Input-----

The first line contains one integer $t$ ($1 \le t \le 100$) — the number of test cases in the input.

Then the test cases follow. Each test case is represented by one line containing a string $s$ consisting of no less than $1$ and no more than $500$ lowercase Latin letters.


-----Output-----

For each test case, print one line containing a string $res$. The string $res$ should contain all characters which correspond to buttons that work correctly in alphabetical order, without any separators or repetitions. If all buttons may malfunction, $res$ should be empty.


-----Example-----
Input
4
a
zzaaz
ccff
cbddbb

Output
a
z

bc

Difficulty: EASY

Solutions:
t = int(input())
for _ in range(t):
	s = input() + '-'
	ok = {c: False for c in 'qwertyuiopasdfghjklzxcvbnm'}
	cur = 0
	p = ''
	for c in s:
		if c == p:
			cur += 1
		else:
			if cur % 2:
				ok[p] = True
			cur = 1
			p = c
	for (c, f) in sorted(ok.items()):
		if f:
			print(c, end='')
	print()


t = int(input())
for _ in range(t):
	s = input()
	n = len(s)
	ans = ''
	l = ''
	ind = 0
	while ind < n:
		if ind < n - 1:
			if s[ind] == s[ind + 1]:
				ind += 2
				continue
			else:
				ans += s[ind]
				ind += 1
		if ind == n - 1:
			ans += s[ind]
			ind += 1
	ans = list(set(list(ans)))
	ans.sort()
	print(''.join(ans))


t = int(input())
for i in range(t):
	s = input()
	ans = set()
	prev = None
	i = 0
	while i != len(s):
		count = 1
		while i + 1 < len(s) and s[i] == s[i + 1]:
			count += 1
			i += 1
		if count % 2 == 1:
			ans.add(s[i])
		i += 1
	print(''.join(sorted(ans)))


import sys
readline = sys.stdin.readline

def RLC(S):
	pre = None
	sp = []
	num = []
	cnt = 0
	for s in S + [None]:
		if pre != s:
			sp.append(pre)
			num.append(cnt)
			cnt = 1
		else:
			cnt += 1
		pre = s
	return (sp[1:], num[1:])
T = int(readline())
Ans = [None] * T
for qu in range(T):
	S = list(map(ord, readline().strip()))
	(sp, num) = RLC(S)
	An = set()
	L = len(sp)
	for i in range(L):
		if num[i] % 2 == 1:
			An.add(sp[i])
	Ans[qu] = An
for a in Ans:
	if a:
		a = list(a)
		a.sort()
	sys.stdout.write(''.join(list(map(chr, a)) + ['\n']))


for _ in range(int(input())):
	s = input()
	d = []
	a = 1
	for i in range(1, len(s)):
		if s[i] == s[i - 1]:
			a += 1
		else:
			d.append((s[i - 1], a))
			a = 1
	d.append((s[-1], a))
	a = []
	for (i, j) in d:
		if j % 2:
			a.append(i)
	a = sorted(list(set(a)))
	print(''.join(a))


import collections

def solve():
	t = int(input().strip())
	while t > 0:
		s = list(input().strip())
		prev = None
		groups = []
		for c in s:
			if groups:
				if groups[-1][-1] != c:
					groups.append([c])
				elif len(groups[-1]) == 2:
					groups.append([c])
				else:
					groups[-1].append(c)
			else:
				groups.append([c])
		groups = [''.join(g) for g in groups]
		mp = collections.defaultdict(set)
		for g in groups:
			mp[g[0]].add(len(g))
		print(''.join(sorted([k for k in mp if len(mp[k]) == 2 or mp[k] == {1}])))
		t -= 1
solve()


def rint():
	return int(input())

def rints():
	return list(map(int, input().split()))
t = rint()
for _ in range(t):
	s = input()
	w = [False] * 26
	i = 0
	while i < len(s):
		if i + 1 < len(s) and s[i] == s[i + 1]:
			i += 2
		else:
			w[ord(s[i]) - ord('a')] = True
			i += 1
	for i in range(26):
		if w[i]:
			print(chr(ord('a') + i), end='')
	print()


from itertools import groupby
t = int(input())
for _ in range(t):
	correct = set()
	for (k, it) in groupby(input()):
		if len(tuple(it)) % 2:
			correct.add(k)
	print(*sorted(correct), sep='')


a = int(input())
while a > 0:
	s = input()
	ans = set()
	lis = sorted(list(set([i for i in s])))
	for i in lis:
		count = 0
		for j in s:
			if j == i:
				count += 1
			else:
				if count % 2 != 0:
					ans.add(i)
				count = 0
		if count % 2 != 0:
			ans.add(i)
	ans = sorted(list(ans))
	print(''.join(ans))
	a -= 1


for _ in range(int(input())):
	s = input()
	res = ''
	n = len(s)
	i = 0
	while i <= len(s) - 1:
		ans = 1
		j = i + 1
		while j < len(s) and s[i] == s[j]:
			ans += 1
			j += 1
		if ans % 2 != 0:
			res += s[i]
		i = j
	if len(s) == 1:
		print(s[0])
	else:
		print(''.join(sorted(set(sorted(res)))))


import string
T = int(input())
for t in range(T):
	s = input()
	if len(s) == 1:
		print(s)
		continue
	res = ''
	c = [False for i in range(26)]
	f = []
	count = 1
	for i in range(len(s)):
		if i < len(s) - 1 and s[i] == s[i + 1]:
			count += 1
		else:
			if count % 2 == 1:
				c[ord(s[i]) - 97] = True
			count = 1
	for i in range(26):
		if c[i]:
			res += string.ascii_lowercase[i]
	print(res)


for _ in range(int(input())):
	s = input()
	c = 1
	st = set()
	e = 0
	for i in range(len(s)):
		if i == 0:
			e = s[0]
			if len(s) == 1:
				st.add(e)
			continue
		if s[i] == e:
			c += 1
		else:
			if c % 2 == 1:
				st.add(e)
			c = 1
			e = s[i]
	if c % 2 == 1:
		st.add(s[len(s) - 1])
	k = ''.join(sorted(list(st)))
	print(k)


n = int(input())
for ct in range(n):
	s = input()
	r = set()
	i = 0
	j = 0
	while i < len(s):
		while i + 1 < len(s) and s[i + 1] == s[i]:
			i += 1
		if (i - j + 1) % 2 == 1:
			r.add(s[i])
		i += 1
		j = i
	print(*sorted([i for i in r]), sep='')


t = int(input())
for _ in range(0, t):
	s = input()
	n = len(s)
	c = 0
	d = dict()
	s1 = ''
	for i in range(97, 123):
		d[chr(i)] = 0
	i = 0
	j = 0
	while i < n:
		j = i + 1
		c = 1
		while j < n and s[i] == s[j]:
			c = c + 1
			j = j + 1
		if c % 2 == 1:
			d[s[i]] = 1
		i = j
	for i in range(97, 123):
		if d[chr(i)] == 1:
			s1 = s1 + chr(i)
	print(s1)


for _ in range(int(input())):
	s = input()
	nach = s[0]
	k = 0
	ans = []
	for i in range(len(s)):
		if s[i] == nach:
			k += 1
		else:
			if k % 2 != 0:
				if nach not in ans:
					ans.append(nach)
			nach = s[i]
			k = 1
	if k % 2 != 0:
		if nach not in ans:
			ans.append(nach)
	ans.sort()
	print(''.join(ans))


t = int(input())
for _ in range(t):
	l = list(input())
	odd = set()
	i = 0
	while i < len(l):
		z = l[i]
		j = i
		cnt = 0
		while l[j] == l[i]:
			cnt += 1
			j += 1
			if j == len(l):
				break
		if cnt % 2 != 0:
			odd.add(z)
		i = j
	odd = sorted(odd)
	print(''.join(odd))


t = int(input())
for _ in range(t):
	string = input()
	last_letra = string[0]
	cont = 1
	resp = []
	if len(string) == 1:
		resp.append(last_letra)
	for i in range(1, len(string)):
		if last_letra != string[i]:
			if cont % 2 == 1 and last_letra not in resp:
				resp.append(last_letra)
			last_letra = string[i]
			cont = 1
		else:
			cont += 1
	if cont % 2 == 1 and len(string) != 1 and (last_letra not in resp):
		resp.append(last_letra)
	if len(resp) == 0:
		print()
	else:
		print(''.join(sorted(resp)))


import sys
import os
import math
from io import BytesIO, IOBase
from math import sqrt, floor, factorial, gcd, log, ceil
from collections import deque, Counter, defaultdict
from itertools import permutations, combinations
from math import gcd
from bisect import bisect

def MOD():
	return 1000000007

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

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

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

def LStr():
	return list(sys.stdin.readline().strip())

def Str():
	return sys.stdin.readline().strip()

def MStr():
	return map(str, sys.stdin.readline().strip().split())

def solution():
	for _ in range(Int()):
		a = Str()
		res = sorted(set(a))
		for i in res:
			if a.count(i) != 2 * a.count(i + i):
				print(i, end='')
		print()
solution()


tc = int(input())
for _ in range(tc):
	arr = input()
	unique = set(list(arr))
	not_kharab = set()
	cnt = dict()
	for q in arr:
		cnt[q] = cnt.get(q, 0) + 1
	for (i, j) in cnt.items():
		if j % 2 != 0:
			not_kharab.add(i)
		else:
			s = 0
			while s < len(arr) - 1:
				if arr[s] == i and arr[s + 1] != i:
					not_kharab.add(i)
					s += 1
				elif arr[s] == i and arr[s + 1] == i:
					s += 2
				else:
					s += 1
	d = unique - not_kharab
	not_kharab = list(not_kharab)
	not_kharab.sort()
	print(''.join(not_kharab))


Q = int(input())
for q in range(Q):
	s = input()
	ans = set()
	last = s[0]
	count = 1
	for i in s[1:]:
		if i == last:
			count += 1
		else:
			if count % 2 == 1:
				ans.add(last)
			last = i
			count = 1
	if count % 2 == 1:
		ans.add(last)
	print(*sorted(list(ans)), sep='')


def t(s):
	dict_1 = {}
	for i in range(len(s)):
		if s[i] not in dict_1.keys():
			dict_1[s[i]] = 2
	i = 0
	while i < len(s):
		if i == len(s) - 1:
			if s[i] == s[i - 1] and dict_1 == 2:
				dict_1[s[i]] = 1
			else:
				dict_1[s[i]] = 0
			i += 1
		elif s[i] == s[i + 1] and (dict_1[s[i]] == 2 or dict_1[s[i]] == 1):
			dict_1[s[i]] = 1
			i += 2
		else:
			dict_1[s[i]] = 0
			i += 1
	for i in sorted(dict_1.keys()):
		if dict_1[i] == 0:
			print(i, end='')
test = int(input())
while test > 0:
	s = input()
	t(s)
	print()
	test -= 1


for t in range(int(input())):
	s = input()
	i = 1
	freq = 1
	ans = [[s[0], 1]]
	for i in range(1, len(s)):
		if s[i] == ans[-1][0]:
			ans[-1][1] += 1
		else:
			ans += [[s[i], 1]]
	f = []
	for i in ans:
		if i[1] % 2 and i[0] not in f:
			f += [i[0]]
	f.sort()
	for i in f:
		print(i, end='')
	print()


for _ in range(int(input())):
	s = input()
	n = len(s)
	o = set()
	i = 0
	while i < n:
		if i < n - 1 and s[i + 1] == s[i]:
			i += 2
			continue
		o.add(s[i])
		i += 1
	print(''.join(sorted(list(o))))


t = int(input())
s = []
ee = ['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 krnr in range(0, t):
	qq = input()
	pp = []
	q = list(qq)
	for i in ee:
		if i in qq:
			f = q.count(i)
			if f % 2 == 1:
				pp.append(i)
			else:
				g = 0
				p = 0
				for j in range(0, len(qq)):
					if p == 0 and qq[j] == i and (j == len(qq) - 1):
						g = 0
						p = 0
						pp.append(i)
					elif p == 0 and qq[j] == i:
						g += 1
						p = 1
					elif p == 1 and qq[j] == i and (qq[j - 1] == i):
						g += 1
						if j == len(qq) - 1:
							if g % 2 == 1 and i not in p:
								pp.append(i)
								g = 0
					elif p == 1 and qq[j] != i and (qq[j - 1] == i):
						p = 0
						if g % 2 == 1:
							pp.append(i)
							break
						g = 0
	pp.sort()
	s.append(pp)
for i in s:
	for j in i:
		print(j, end='')
	print()


t = int(input())
aR = []
for z in range(t):
	inS = input()
	inS += ' '
	gL = {}
	c = 0
	for i in range(0, len(inS) - 1):
		c += 1
		if inS[i] != inS[i + 1]:
			if c % 2 == 1:
				gL[inS[i]] = 1
			c = 0
	a = []
	if len(inS) == 1:
		a.append(inS)
	for i in gL.keys():
		a.append(i)
	a.sort()
	s = ''
	for k in a:
		s += k
	aR.append(s)
for a in aR:
	print(a)


def main():
	for _ in range(int(input())):
		s = list(input())
		(arr, i) = ([], 1)
		if len(s) == 1:
			print(s[0])
			continue
		while i < len(s):
			if s[i] != s[i - 1]:
				arr.append(s[i - 1])
			else:
				(s[i], s[i - 1]) = (-1, -1)
				i += 1
			i += 1
		if s[-2] == -1:
			if s[-1] != -1:
				arr.append(s[-1])
		elif s[-1] != s[-2]:
			arr.append(s[-1])
		arr = list(set(arr))
		arr.sort()
		print(''.join(arr))
main()


for i in range(int(input())):
	kol = 1
	s = input()
	byk = s[0]
	vse = set(s)
	net = set(s)
	for j in range(1, len(s)):
		if s[j - 1] == s[j]:
			kol += 1
		else:
			if kol % 2 == 1:
				net -= set(byk)
			kol = 1
			byk = s[j]
	if kol % 2 == 1:
		net -= set(byk)
	print(*sorted(vse - net), sep='')


num_queries = int(input())
for _ in range(num_queries):
	string = input()
	if len(string) <= 1:
		print(string)
	else:
		working = set()
		i = 0
		while i < len(string):
			if i == len(string) - 1:
				working.add(string[i])
				break
			if string[i] == string[i + 1]:
				i += 1
			else:
				working.add(string[i])
			i += 1
		if string[-1] != string[-2]:
			working.add(string[-1])
		print(''.join(sorted(working)))


_author_ = 'stefan'
n = int(input())
for _ in range(n):
	s = input()
	not_broken = set()
	i = 0
	while i < len(s):
		if i == len(s) - 1 or s[i] != s[i + 1]:
			not_broken.add(s[i])
		else:
			i += 1
		i += 1
	not_broken = sorted(not_broken)
	print(''.join(not_broken))


def repeat(index, s, aux):
	if index < len(s):
		if index == len(s) - 1:
			if not s[index] in aux:
				aux.append(s[index])
		elif s[index] == s[index + 1]:
			repeat(index + 2, s, aux)
		else:
			if not s[index] in aux:
				aux.append(s[index])
			repeat(index + 1, s, aux)

def order(s):
	sort = sorted(s)
	join = ''
	for el in sort:
		join += el
	return join
n = int(input())
for i in range(n):
	s = str(input())
	aux = []
	repeat(0, s, aux)
	join = order(aux)
	print(join)


n = int(input())
for test in range(n):
	s = input()
	i = 0
	j = 0
	l = len(s)
	ans = set()
	if l <= 1:
		print(s)
	else:
		while j < l:
			count = 1
			if j != l - 1:
				while s[j + 1] == s[i]:
					count += 1
					j += 1
					if j >= l - 1:
						break
				if count % 2 != 0:
					ans.add(s[i])
				i = j + 1
				j = i
			else:
				ans.add(s[j])
				j += 1
		ans = list(ans)
		ans.sort()
		print(''.join(ans))


testCase = int(input())
for i in range(testCase):
	string = str(input())
	lenString = len(string)
	working = []
	count = 0
	string = string + '0'
	for i in range(1, lenString + 1):
		if string[i - 1] == string[i]:
			count += 1
		else:
			if count % 2 == 0:
				if string[i - 1] not in working:
					working.append(string[i - 1])
			count = 0
	working.sort()
	print(''.join(working))


test_cases = int(input())
for i in range(test_cases):
	line = input()
	ok_buttons = []
	if len(line) == 1:
		print(line)
	else:
		char = line[0]
		count = 0
		for j in range(len(line)):
			if line[j] == char:
				count += 1
				if j == len(line) - 1 and count % 2 != 0 and (char not in ok_buttons):
					ok_buttons.append(char)
			else:
				if count % 2 != 0 and char not in ok_buttons:
					ok_buttons.append(char)
				char = line[j]
				if j == len(line) - 1 and char not in ok_buttons:
					ok_buttons.append(char)
				count = 1
		ok_buttons.sort()
		print(''.join(ok_buttons))


for _ in range(int(input())):
	s = input()
	print(''.join((c for c in sorted(set(s)) if s.count(c) > 2 * s.count(c + c))))


for t in range(int(input())):
	x = list(input())
	s = set(x)
	ans = []
	for i in s:
		if x.count(i) % 2 != 0:
			ans.append(i)
	s1 = s.difference(set(ans))
	for i in s1:
		flag = 0
		count = 0
		for j in range(len(x)):
			if x[j] == i:
				count += 1
			elif count % 2 != 0:
				flag = 1
				break
			else:
				count = 0
		if flag == 1:
			ans.append(i)
	ans.sort()
	print(''.join(ans))


import string
n = int(input())
for i in range(n):
	s = input()
	d = {}
	res = ''
	for c in string.ascii_lowercase:
		d[c] = False
	ch = ''
	n = 1
	for (i, c) in enumerate(s):
		if c == ch:
			n += 1
		else:
			if n % 2 == 1 and ch != '':
				d[ch] = True
			ch = c
			n = 1
	if n % 2 == 1:
		d[ch] = True
	for (key, value) in d.items():
		if value:
			res += key
	print(res)


t = int(input())
for i in range(t):
	s = input()
	a = [0] * 26
	for j in s:
		a[ord(j) - 97] += 1
	res = []
	for j in range(26):
		if a[j] & 1:
			res.append(chr(j + 97))
		else:
			k = chr(j + 97)
			r = 0
			while r < len(s) - 1:
				if s[r] == k and s[r + 1] != k:
					res.append(k)
					break
				elif s[r] == k and s[r + 1] == k:
					r += 1
				r += 1
	if res:
		for l in range(len(res) - 1):
			print(res[l], end='')
		print(res[-1])
	else:
		print()


import math, string, itertools, fractions, heapq, collections, re, array, bisect, sys, copy, functools
sys.setrecursionlimit(10 ** 7)
inf = 10 ** 20
eps = 1.0 / 10 ** 10
mod = 10 ** 9 + 7
mod2 = 998244353
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)]

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

def LLI():
	return [list(map(int, l.split())) for l in sys.stdin.readlines()]

def LI_():
	return [int(x) - 1 for x in sys.stdin.readline().split()]

def LF():
	return [float(x) for x in sys.stdin.readline().split()]

def LS():
	return sys.stdin.readline().split()

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

def F():
	return float(sys.stdin.readline())

def S():
	return input()

def pf(s):
	return print(s, flush=True)

def pe(s):
	return print(str(s), file=sys.stderr)

def JA(a, sep):
	return sep.join(map(str, a))

def JAA(a, s, t):
	return s.join((t.join(map(str, b)) for b in a))

def IF(c, t, f):
	return t if c else f

def YES(c):
	return IF(c, 'YES', 'NO')

def Yes(c):
	return IF(c, 'Yes', 'No')

def main():
	t = I()
	rr = []
	for _ in range(t):
		s = S()
		t = []
		c = '--'
		for u in s:
			if u == c[0]:
				c += u
			else:
				t.append(c)
				c = u
		t.append(c)
		r = set()
		for v in t:
			if len(v) % 2 == 1:
				r.add(v[0])
		rr.append(JA(sorted(r), ''))
	return JA(rr, '\n')
print(main())


import sys

def input():
	return sys.stdin.readline().strip()

def list2d(a, b, c):
	return [[c] * b for i in range(a)]

def list3d(a, b, c, d):
	return [[[d] * c for j in range(b)] for i in range(a)]

def list4d(a, b, c, d, e):
	return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]

def ceil(x, y=1):
	return int(-(-x // y))

def INT():
	return int(input())

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

def LIST(N=None):
	return list(MAP()) if N is None else [INT() for i in range(N)]

def Yes():
	print('Yes')

def No():
	print('No')

def YES():
	print('YES')

def NO():
	print('NO')
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7
for _ in range(INT()):
	S = input()
	N = len(S)
	if N == 1:
		print(S)
		continue
	i = 1
	ans = []
	while i < N:
		if S[i] == S[i - 1]:
			i += 2
		else:
			ans.append(S[i - 1])
			i += 1
		if i == N:
			ans.append(S[i - 1])
	print(''.join(sorted(set(ans))))


from collections import defaultdict as dc
import math
import sys
input = sys.stdin.readline
for _ in range(int(input())):
	s = input()[:-1]
	x = dc(int)
	p = s[0]
	c = 1
	for i in range(1, len(s)):
		if s[i] == s[i - 1]:
			c += 1
		else:
			if c % 2:
				x[p] = 1
			p = s[i]
			c = 1
	if c % 2:
		x[s[-1]] = 1
	k = sorted(x.keys())
	for i in k:
		if x[i] % 2:
			print(i, end='')
	print()


for _ in range(int(input())):
	s = input()
	b = set()
	i = 0
	while i < len(s):
		if i == len(s) - 1:
			b.add(s[-1])
			break
		if s[i] != s[i + 1]:
			b.add(s[i])
			i += 1
		else:
			i += 2
	print(''.join(sorted(b)))


T = int(input())
for t in range(T):
	string = str(input())
	n = len(string)
	workingKeys = set()
	i = 0
	while i < n:
		try:
			if string[i] != string[i + 1]:
				workingKeys.add(string[i])
				i += 1
			else:
				i += 2
		except IndexError:
			workingKeys.add(string[i])
			i += 1
	workingKeys = list(workingKeys)
	workingKeys.sort()
	res = ''
	for key in workingKeys:
		res += key
	print(res)


from collections import defaultdict
t = int(input())
while t > 0:
	s = input()
	dic = defaultdict(bool)
	i = 0
	if len(s) != 1:
		while i < len(s) - 1:
			if s[i] == s[i + 1] and (not dic[s[i]]):
				dic[s[i]] = False
				j = s.find(s[i], i + 1)
				if (j - i) % 2 == 0:
					dic[s[i]] = True
				i = j + 1
				continue
			else:
				dic[s[i]] = True
			i += 1
		if i == len(s) - 1:
			dic[s[i]] = True
		res = ''
		for (i, j) in dic.items():
			if j:
				res = res + i
		print(''.join(sorted(res)))
	else:
		print(s)
	t -= 1


t = int(input())
for _ in range(t):
	n = input()
	s = sorted(set(n))
	p = ''
	for i in s:
		if n.count(i) > 2 * n.count(i + i):
			p = p + i
	print(p)


q = int(input())
for _ in range(q):
	s = list(input())
	n = len(s)
	if n == 1:
		print(s[0])
	else:
		ans = ''
		z = 1
		i = 1
		x = s[0]
		while i < n:
			if s[i] == s[i - 1]:
				z += 1
				x = s[i]
			else:
				if z % 2 != 0:
					ans += x
				z = 1
				x = s[i]
			i += 1
		if z % 2 != 0:
			ans += s[n - 1]
		ans = list(ans)
		ans = set(ans)
		ans = list(ans)
		ans.sort()
		print(''.join(ans))


from functools import reduce
from sys import stdin
from bisect import bisect_left, bisect_right

def main():
	st = stdin.readline().strip()
	cnt = [[st[0], 0]]
	for i in st:
		if i == cnt[-1][0]:
			cnt[-1][1] += 1
		else:
			cnt.append([i, 1])
	res = set()
	for i in cnt:
		if i[1] % 2 != 0:
			res.add(i[0])
	res = list(sorted(res))
	print(''.join(res))
[main() for _ in range(int(input()))]


for _ in range(int(input())):
	a = input()
	ss = [0] * 26
	l = 1
	for i in range(1, len(a)):
		if a[i] == a[i - 1]:
			l += 1
		else:
			if l % 2 == 1:
				ss[ord(a[i - 1]) - 97] += 1
			l = 1
	if l % 2 == 1:
		ss[ord(a[-1]) - 97] += 1
	for i in range(26):
		if ss[i] >= 1:
			print(chr(i + 97), end='')
	print()


for i in range(int(input())):
	s = input()
	s_norm = []
	if len(s) != 1:
		i = 0
		while i < len(s):
			if i + 1 <= len(s) - 1:
				if s[i] != s[i + 1]:
					s_norm.append(s[i])
					i += 1
				else:
					i += 2
			elif i < len(s):
				s_norm.append(s[i])
				break
	else:
		s_norm.append(s)
	print(*sorted(set(s_norm)), sep='')


n = int(input())
for i in range(n):
	s = input() + '5'
	m = set()
	k = 1
	for x in range(len(s) - 1):
		if s[x + 1] != s[x] and k % 2:
			m.add(s[x])
			k = 1
		elif s[x + 1] == s[x]:
			k += 1
		else:
			k = 1
	print(*sorted(m), sep='')


for t in range(int(input())):
	s = input()
	n = len(s)
	l = set()
	i = j = 0
	s1 = ''
	while i < n:
		while j < n and s[i] == s[j]:
			j += 1
		if (j - i) % 2 == 1:
			l.add(s[i])
		i = j
	l = list(l)
	l.sort()
	for i in l:
		s1 += i
	print(s1)


testCases = int(input())
for t in range(testCases):
	string = input()
	certainlyWork = 26 * [False]
	i = 0
	while i < len(string):
		currentChar = string[i]
		groupSize = 1
		i += 1
		while i < len(string) and string[i] == currentChar:
			groupSize += 1
			i += 1
		if groupSize % 2 == 1:
			certainlyWork[ord(currentChar) - ord('a')] = True
	output = ''
	for i in range(26):
		if certainlyWork[i]:
			output += chr(i + ord('a'))
	print(output)


q = int(input())
for j in range(q):
	s = input() + ' '
	for i in s:
		s = s.replace(i * 2, ' ')
	print(*sorted(set(s))[1:], sep='')


for _ in range(int(input())):
	l = list(input())
	i = 0
	c1 = [0] * 26
	while i < len(l):
		c = 1
		j = i + 1
		while j < len(l) and l[j] == l[i]:
			c += 1
			j += 1
		if c % 2 != 0:
			c1[ord(l[i]) - 97] = 1
		i = j
	for i in range(len(c1)):
		if c1[i] == 1:
			print(chr(i + 97), end='')
	print()


for _ in range(int(input())):
	s = input()
	stack = []
	res = []
	for c in s:
		if stack:
			if stack[-1] == c:
				stack.pop()
			else:
				res.append(stack.pop())
				stack.append(c)
		else:
			stack.append(c)
	res = res + stack
	res = list(set(res))
	res.sort()
	print(''.join(res))


n = int(input())
for i in range(n):
	s = input()
	st = sorted(set(s))
	for j in st:
		if s.count(j) != 2 * s.count(j + j):
			print(j, end='')
	print()


def main():
	n = input()
	st = set()
	prev = '0'
	cnt = 1
	for i in range(len(n)):
		tr1 = True
		tr2 = True
		if i > 0:
			if n[i] == n[i - 1]:
				tr1 = False
				prev = n[i]
				cnt += 1
		if i < len(n) - 1:
			if n[i] == n[i + 1]:
				tr2 = False
		if tr1 and tr2:
			st.add(n[i])
		if tr1:
			if cnt % 2 == 1 and cnt > 2:
				st.add(prev)
				cnt = 1
				prev = '0'
			cnt = 1
	if cnt % 2 == 1 and cnt > 2:
		st.add(prev)
		cnt = 0
		prev = '0'
	lst = list(st)
	lst = sorted(lst)
	for i in lst:
		print(i, end='')
	print()
t = int(input())
for i in range(t):
	main()


c = input()
for i in range(int(c)):
	d = input()
	if len(d) == 1:
		print(d[0])
		continue
	r = [0] * 26
	i = 0
	while True:
		if i == len(d) - 1:
			r[ord(d[i]) - ord('a')] = d[i]
			break
		elif d[i] == d[i + 1]:
			i += 2
			if i == len(d):
				break
			continue
		else:
			r[ord(d[i]) - ord('a')] = d[i]
			i += 1
			continue
	for i in r:
		if i != 0:
			print(i, end='')
	print()


a = int(input())
for i in range(a):
	s = input()
	p = 0
	f = [0 for j in range(26)]
	for j in range(len(s)):
		if j < p:
			continue
		while p < len(s):
			if not s[j] == s[p]:
				break
			p += 1
		if p - j & 1:
			f[ord(s[j]) - ord('a')] = 1
	ans = ''
	for j in range(26):
		if f[j]:
			ans += chr(j + ord('a'))
	print(ans)


for _ in range(int(input())):
	L = list(input())
	N = len(L)
	for i in range(N - 1):
		if L[i] == L[i + 1]:
			L[i] = ''
			L[i + 1] = ''
	L = list(set(L))
	L.sort()
	print(''.join(L))


import sys
t = int(sys.stdin.readline())
while t > 0:
	s = input()
	a = dict()
	b = dict()
	for i in range(len(s)):
		if s.count(s[i]) % 2 == 0:
			a[s[i]] = s.count(s[i])
	for (k, v) in a.items():
		c = 0
		o = 0
		while o < len(s) - 1:
			if s[o] == k and s[o] == s[o + 1]:
				c += 1
				o += 2
			else:
				o += 1
		if c == v / 2:
			b[k] = v
	re = []
	key = list(b.keys())
	for i in range(len(s)):
		if key.count(s[i]) == 0 and re.count(s[i]) == 0:
			re.append(s[i])
	re = sorted(re)
	res = ''
	for i in range(len(re)):
		res += re[i]
	sys.stdout.write(res + '\n')
	t -= 1


t = int(input())
for _ in range(t):
	inp = input()
	temp = 0
	fin = []
	if len(inp) == 1:
		print(inp)
	else:
		while temp < len(inp):
			if temp == len(inp) - 1:
				fin.append(inp[temp])
				break
			if inp[temp] == inp[temp + 1]:
				temp = temp + 2
			else:
				fin.append(inp[temp])
				temp = temp + 1
		x = list(sorted(set(fin)))
		count = ''
		for i in range(len(x)):
			count = count + str(x[i])
		print(count)


import sys

def count(line):
	if len(line) == 1:
		return line
	freq = dict()
	idx = 0
	while idx < len(line):
		if idx < len(line) - 1 and line[idx] == line[idx + 1]:
			if line[idx] not in freq:
				freq[line[idx]] = False
			idx += 2
		else:
			freq[line[idx]] = True
			idx += 1
	res = [k for (k, v) in sorted(freq.items()) if v]
	return ''.join(res)
t = int(input())
ans = []
for _ in range(t):
	s = sys.stdin.readline().rstrip()
	s = count(s)
	ans.append(s)
print(*ans, sep='\n')


t = int(input())
for _ in range(t):
	s = input()
	s += '1'
	indSlast = len(s) - 2
	i = 0
	answer = ''
	while i <= indSlast:
		if s[i] != s[i + 1]:
			answer += s[i]
		else:
			i += 1
		i += 1
	print(''.join(sorted(set(answer))))


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')
testcases = int(input())
for j in range(testcases):
	vals = [ord(k) - 97 for k in input()]
	n = len(vals)
	dict1 = {}
	for s in range(n):
		if not vals[s] in dict1:
			dict1[vals[s]] = []
	for s in dict1.keys():
		chain = 0
		for b in range(n):
			if vals[b] == s:
				chain += 1
			else:
				if chain >= 1:
					dict1[s].append(chain)
				chain = 0
		if chain >= 1:
			dict1[s].append(chain)
	fine = set([k for k in dict1.keys()])
	for s in dict1.keys():
		broke = False
		for b in range(len(dict1[s])):
			if dict1[s][b] % 2 == 0:
				continue
			else:
				broke = True
				break
		if broke == False:
			fine.remove(s)
	fine = [chr(s + 97) for s in fine]
	fine.sort()
	print(''.join(fine))


t = int(input())
for _ in range(t):
	s = input()
	working = set()
	cur_ch = None
	cnt = 0
	for ch in s:
		if cur_ch and cur_ch != ch and (cnt % 2 != 0):
			working.add(cur_ch)
			cnt = 0
		cur_ch = ch
		cnt += 1
	if cnt % 2 != 0:
		working.add(cur_ch)
	print(''.join(sorted(working)))


t = int(input())
for x in range(t):
	s = input() + '_'
	(l, q) = ([], [])
	r = []
	c = 1
	for x in range(len(s) - 1):
		if s[x] == s[x + 1]:
			c = c + 1
		else:
			q.append(s[x])
			l.append(c)
			c = 1
	for x in range(len(l)):
		if l[x] % 2 == 1:
			r.append(q[x])
	r = list(set(r))
	r.sort()
	s = ''
	for x in r:
		s = s + x
	print(s)


import sys
input = lambda : sys.stdin.readline().strip()
li = lambda : list(map(int, input().split()))
I = lambda : int(input())
for _ in range(I()):
	s = input()
	(p, e) = (0, 0)
	ans = set()
	while e < len(s):
		while e < len(s) and s[p] == s[e]:
			e += 1
		if (e - p) % 2 == 1:
			ans.add(s[p])
		p = e
	print(''.join(sorted(list(ans))))


q = int(input())
for i in range(q):
	s = input()
	working = []
	i = 0
	while i < len(s):
		if s[i] not in working:
			start = s[i]
			c = 0
			while i < len(s) and s[i] == start:
				i += 1
				c += 1
			if c % 2 == 1:
				working.append(start)
			i -= 1
		i += 1
	working.sort()
	for i in working:
		print(i, end='')
	print()


for _ in range(int(input())):
	s = input()
	u = set()
	n = len(s)
	if n == 1:
		u.add(s)
	elif n == 2:
		if s[0] != s[1]:
			u.add(s[0])
			u.add(s[1])
	else:
		i = 0
		while i < n - 2:
			if s[i] == s[i + 1]:
				i += 2
			else:
				u.add(s[i])
				i += 1
		if i == n - 1:
			u.add(s[i])
		elif i == n - 2:
			if s[i] != s[i + 1]:
				u.add(s[i])
				u.add(s[i + 1])
	print(*sorted(u), sep='')


for _ in [0] * int(input()):
	s = set()
	p = f = 0
	for x in input() + ' ':
		if x != p:
			s |= (s, {p})[f]
			p = x
			f = 0
		f ^= 1
	print(''.join(sorted(s)))


t = int(input())
while t > 0:
	s = input()
	a = dict()
	b = dict()
	for i in range(len(s)):
		if s.count(s[i]) % 2 == 0:
			a[s[i]] = s.count(s[i])
	for (k, v) in a.items():
		c = 0
		o = 0
		while o < len(s) - 1:
			if s[o] == k and s[o] == s[o + 1]:
				c += 1
				o += 2
			else:
				o += 1
		if c == v / 2:
			b[k] = v
	re = []
	key = list(b.keys())
	for i in range(len(s)):
		if key.count(s[i]) == 0 and re.count(s[i]) == 0:
			re.append(s[i])
	re.sort()
	res = ''
	for i in range(len(re)):
		res += re[i]
	print(res)
	t -= 1


def main():
	import sys
	input = sys.stdin.readline
	t = int(input())
	for _ in range(t):
		S = input().rstrip('\n')
		N = len(S)
		ans = {}
		i = 0
		while True:
			if i == N - 1:
				ans[S[i]] = 1
				break
			if S[i] == S[i + 1]:
				i += 2
				if i == N:
					break
			else:
				ans[S[i]] = 1
				i += 1
		ret = []
		for s in ans.keys():
			ret.append(s)
		ret.sort()
		print(''.join(ret))
main()


t = int(input())
for i in range(t):
	res = set()
	s = input()
	if len(s) == 1:
		print(s)
	else:
		if s[0] != s[1]:
			res.add(s[0])
		if s[-1] != s[-2]:
			res.add(s[-1])
		k_eq = 1
		for si in range(len(s) - 1):
			if s[si + 1] == s[si]:
				k_eq += 1
			else:
				if k_eq % 2 == 1:
					res.add(s[si])
				k_eq = 1
		if k_eq % 2 == 1:
			res.add(s[-1])
		print(''.join(sorted(res)))


n = int(input())
aux1 = 0
while aux1 < n:
	vet = input()
	correct = []
	aux2 = 0
	if len(vet) == 1:
		correct.append(vet[0])
	else:
		while aux2 < len(vet) - 1:
			if vet[aux2] == vet[aux2 + 1]:
				aux2 += 2
			else:
				correct.append(vet[aux2])
				aux2 += 1
		if aux2 == len(vet) - 1:
			correct.append(vet[len(vet) - 1])
	correct = sorted(correct)
	saida = ''.join(sorted(set(correct), key=correct.index))
	print(saida)
	aux1 += 1


from itertools import groupby
for _ in range(int(input())):
	ins = input()
	insg = groupby(ins)
	okk = set()
	for (key, items) in insg:
		if len(list(items)) % 2 == 0:
			continue
		else:
			okk.add(key)
	print(''.join(sorted(okk)))


n = int(input())
t = 0
while t != n:
	dict = {}
	l = []
	ii = 0
	s = input()
	ss = list(s)
	ll = []
	for i in ss:
		if i not in l:
			l.append(i)
	while ii != len(l):
		y = str(l[ii] + l[ii])
		r = ss.count(l[ii])
		rr = s.count(y)
		q = rr * 2
		if q != r:
			ll.append(l[ii])
		ii = ii + 1
	ll.sort()
	for i in ll:
		print(i, end='')
	print()
	t = t + 1


import sys
from heapq import heappop
from heapq import heappush
from heapq import heapify
from bisect import insort
from bisect import bisect_right
from bisect import bisect_left
from sys import stdin, stdout
from collections import defaultdict, deque
from math import log2, ceil, floor
inp = lambda : int(input())
sip = lambda : input()
mulip = lambda : map(int, input().split())
lst = lambda : list(map(int, input().split()))
slst = lambda : list(sip())
arr2d = lambda x: [[int(j) for j in input().split()] for i in range(x)]
odds = lambda l: len(list(filter(lambda x: x % 2 != 0, l)))
evens = lambda l: len(list(filter(lambda x: x % 2 == 0, l)))
mod = pow(10, 9) + 7
for _ in range(inp()):
	s = list(input())
	x = defaultdict(list)
	y = []
	for i in range(len(s)):
		if len(y) == 0:
			y = [s[0]]
			cnt = 1
		elif y[-1] == s[i]:
			cnt += 1
		else:
			x[y[-1]].append(cnt)
			cnt = 1
			y.append(s[i])
	x[y[-1]].append(cnt)
	res = []
	for i in x:
		for j in x[i]:
			if j % 2 == 1:
				res.append(i)
				break
	if len(res) == 0:
		print('')
	else:
		print(''.join(sorted(res)))


q = int(input())
for _ in range(q):
	c = input()
	working_keys = set()
	p = c[0]
	co = 1
	for el in c[1:]:
		if el == p:
			co += 1
		else:
			if co % 2 == 1:
				working_keys.add(p)
			p = el
			co = 1
	if co % 2 == 1:
		working_keys.add(p)
	print(''.join(sorted(working_keys)))


for _ in range(int(input())):
	s = input() + '#'
	correct = set()
	cnt = 1
	for i in range(1, len(s)):
		if s[i] == s[i - 1]:
			cnt += 1
		else:
			if cnt % 2 == 1:
				correct.add(s[i - 1])
			cnt = 1
	print(*sorted(correct - {'#'}), sep='')


t = int(input())
for j in range(t):
	s = input()
	a = ''
	b = ''
	i = 0
	if len(s) == 1:
		print(s)
	else:
		while i < len(s):
			if i == len(s) - 1:
				if s[i] not in b:
					b = b + s[i]
				i = i + 1
			elif s[i] == s[i + 1]:
				if s[i] not in a:
					a = a + s[i]
				i = i + 2
			elif s[i] != s[i + 1]:
				if s[i] not in b:
					b = b + s[i]
				i = i + 1
		k = ''
		for i in b:
			k = k + i
		k = sorted(k)
		print(''.join(k))


t = int(input())
for i in range(t):
	s = input()
	res = ''
	if len(s) == 1:
		res += s
	else:
		i = 0
		j = 1
		while j < len(s):
			if s[i] == s[j]:
				i += 2
				j += 2
			else:
				res += s[i]
				i += 1
				j += 1
		if i < len(s):
			res += s[i]
		temp = list(res)
		temp = sorted(set(temp))
		res = ''.join(map(str, temp))
	print(res)


def is_R(b):
	if len(b) == 1:
		return [[b[0], 1]]
	r = []
	cur = []
	for i in range(len(b)):
		if cur == []:
			cur = [b[i], 1]
		elif cur[0] == b[i]:
			cur[1] += 1
		else:
			r.append(cur)
			cur = [b[i], 1]
	if cur != []:
		r.append(cur)
	return r
q = int(input())
for i in range(q):
	res = []
	a = input()
	a1 = []
	for x in a:
		a1.append(x)
	t = is_R(a1)
	for x in t:
		if x[1] % 2 == 1 and x[0] not in res:
			res.append(x[0])
	res = sorted(res)
	t = ''
	for x in res:
		t += x
	print(t)


t = int(input())
for j in range(t):
	x = list(input())
	count = 1
	while count < len(x):
		if len(x) == 1:
			s = x
			break
		if x[count] == x[count - 1]:
			x[count] = ''
			x[count - 1] = ''
			count += 2
		else:
			count += 1
	x = sorted(list(set(x)))
	print(''.join(x))


for _ in range(int(input())):
	s = input()
	ss = sorted(set(s))
	t = 0
	for x in ss:
		if s.count(x) != 2 * s.count(x + x):
			t += 1
			print(x, end='')
	print()


def solution(entrada):
	letras = []
	if len(entrada) == 1:
		print(entrada)
		return
	i = 0
	while i < len(entrada):
		if i == len(entrada) - 1:
			letras.append(entrada[i])
		elif entrada[i] != entrada[i + 1]:
			letras.append(entrada[i])
		else:
			i += 1
		i += 1
	lista_lestras = list(set(letras))
	lista_lestras.sort()
	print(''.join(lista_lestras))
n_entradas = int(input())
entradas = []
for i in range(n_entradas):
	entradas.append(input())
for entrada in entradas:
	solution(entrada)


n = int(input())
while n > 0:
	working = set()
	(last, count) = (None, 0)
	for c in list(input()) + [None]:
		if c == last:
			count += 1
		else:
			if count & 1 and last is not None:
				working.add(last)
			count = 1
		last = c
	print(''.join(sorted(working)))
	n -= 1


tcs = int(input())
for _ in range(tcs):
	res = [0] * 26
	s = input()
	idx = 0
	while idx < len(s):
		c = 0
		ch = s[idx]
		while ch == s[idx]:
			idx += 1
			c += 1
			if idx >= len(s):
				break
		if c % 2 == 1:
			res[ord(ch) - ord('a')] += 1
	for i in range(26):
		if res[i] != 0:
			print(chr(i + ord('a')), end='')
	print()


class Solution(object):

	def broken_keyboard(self, s: str) -> str:
		s = [c for c in s]
		(i, n) = (0, len(s))
		ans = []
		while i < n:
			j = i
			while j + 1 < n and s[j + 1] == s[i]:
				j += 1
			if (j - i) % 2 == 0:
				ans.append(s[i])
			i = j + 1
		return ''.join(sorted(list(set(ans))))
t = int(input())
for i in range(t):
	print(Solution().broken_keyboard(input()))


t = int(input())
for _ in range(t):
	s = input()
	d = {}
	valid = set()
	curr = None
	count = 0
	for i in range(len(s)):
		if curr != s[i]:
			if count % 2 == 1:
				valid.add(curr)
			count = 0
			curr = s[i]
		count += 1
	if count % 2 == 1:
		valid.add(curr)
	print(''.join(sorted(list(valid))))


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 li():
	return list(mi())

def dmain():
	sys.setrecursionlimit(100000000)
	threading.stack_size(40960000)
	thread = threading.Thread(target=main)
	thread.start()
from collections import deque, Counter, OrderedDict, defaultdict
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[0]

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

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 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()):
		f = defaultdict(list)
		s = si()
		n = len(s)
		cnt = 1
		for i in range(1, n):
			if s[i] == s[i - 1]:
				cnt += 1
			else:
				f[abd[s[i - 1]]].append(cnt)
				cnt = 1
		f[abd[s[-1]]].append(cnt)
		ans = []
		for i in f:
			fl = 0
			for j in range(len(f[i])):
				if f[i][j] % 2:
					fl = 1
					ans.append(abc[i])
					break
		ans = sorted(ans)
		for i in ans:
			print(i, end='')
		print()
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()


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

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

def lmii():
	return list(map(int, input().split()))
nqq = ii()
for i in range(nqq):
	n = input()
	x = ['aa', 'bb', 'cc', 'dd', 'ee', 'ff', 'gg', 'hh', 'ii', 'jj', 'kk', 'll', 'mm', 'nn', 'oo', 'pp', 'qq', 'rr', 'ss', 'tt', 'uu', 'vv', 'ww', 'xx', 'yy', 'zz']
	y = ['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']
	p = []
	q = []
	s = []
	ans = ''
	for i in range(len(x)):
		xx = n.count(x[i])
		p.append(xx)
	for j in range(len(y)):
		yy = n.count(y[j])
		q.append(yy)
	for i in range(len(q)):
		if q[i] > 0:
			if q[i] - 2 * p[i] > 0:
				s.append(y[i])
	s.sort()
	print(''.join(s))


for _ in range(int(input())):
	s = input()
	s = list(s)
	n = len(s)
	res = []
	while 1:
		if len(s) == 0:
			break
		elif len(s) == 1:
			res.append(s[0])
			s.remove(s[0])
		elif s[0] == s[1]:
			s.remove(s[0])
			s.remove(s[0])
		else:
			res.append(s[0])
			s.remove(s[0])
	res = ''.join(set(res))
	res = list(res)
	res.sort()
	print(''.join(res))


for _ in range(int(input())):
	s = input()
	i = 0
	s1 = []
	s2 = ''
	if len(s) == 1:
		print(s)
		continue
	while i < len(s) - 1:
		c = 1
		while i < len(s) - 1 and s[i] == s[i + 1]:
			c += 1
			i += 1
		if c % 2 != 0:
			s1.append(s[i])
		i += 1
	if s[len(s) - 1] != s[len(s) - 2]:
		s1.append(s[len(s) - 1])
	s1 = list(set(s1))
	s1.sort()
	for i in s1:
		s2 += i
	print(s2)


for _ in range(int(input())):
	ans = ''
	arr = input()
	for i in arr:
		if arr.count(i) / 2 != arr.count(i * 2):
			if i not in ans:
				ans += i
	print(''.join(sorted(ans)))


q = int(input())
for i in range(q):
	string = input()
	arr = []
	current = ''
	for index in range(len(string)):
		if not current:
			current += string[index]
			continue
		if string[index] == current[-1]:
			current += string[index]
		else:
			arr.append(current)
			current = string[index]
	if current:
		arr.append(current)
	answer = set()
	for j in arr:
		if len(j) % 2:
			answer.add(j[0])
	print(''.join(sorted(answer)))


import sys
get_string = lambda : sys.stdin.readline().strip()
get_int_list = lambda : list(map(int, sys.stdin.readline().strip().split()))
get_intList_from_str = lambda : list(map(int, list(sys.stdin.readline().strip())))
get_charList_from_str = lambda : list(sys.stdin.readline().strip())
get_char_list = lambda : sys.stdin.readline().strip().split()
get_int = lambda : int(sys.stdin.readline())
pt = lambda x: sys.stdout.write(str(x))
for _ in range(get_int()):
	string = get_string()
	res = ''
	for i in sorted(set(string)):
		if string.count(i) > 2 * string.count(i + i):
			res += i
	print(res)


for i in range(int(input())):
	s = input()
	r = ''
	if len(s) == 1:
		print(s)
		continue
	l = True
	for i in range(len(s) - 1):
		if s[i + 1] != s[i] and l:
			r += s[i]
		else:
			l = not l
	if s[-1] != s[-2] or l:
		r += s[-1]
	print(''.join(map(str, sorted(set(r)))))


q = int(input())
answer = []
for i in range(q):
	s = str(input())
	ans = ''
	while len(s) > 1:
		if s[0] == s[1]:
			s = s[2:]
		else:
			if ans.find(s[0]) == -1:
				ans += s[0]
			s = s[1:]
	if len(s) == 1:
		if ans.find(s[0]) == -1:
			ans += s[0]
	answer.append(''.join(sorted(ans)))
for i in range(q):
	print(answer[i])


mod = 10 ** 9 + 7
import sys
sys.setrecursionlimit(10 ** 6)
from sys import stdin, stdout
import bisect
from bisect import bisect_left as bl
from bisect import bisect_right as br
import itertools
import collections
import math
import heapq
import random

def modinv(n, p):
	return pow(n, p - 2, p)

def ncr(n, r, p):
	t = fact[n] * (ifact[r] * ifact[n - r] % p) % p
	return t

def cin():
	return map(int, sin().split())

def ain():
	return list(map(int, sin().split()))

def sin():
	return input()

def inin():
	return int(input())

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

def main():
	t = inin()
	for _ in range(t):
		s = sin()
		n = len(s)
		ss = []
		i = 0
		while i <= n - 1:
			if i == n - 1 or s[i] != s[i + 1]:
				ss.append(s[i])
				i += 1
			else:
				i += 2
		ss = list(set(ss))
		ss.sort()
		for i in ss:
			print(i, end='')
		print()
py2 = round(0.5)
if py2:
	from future_builtins import ascii, filter, hex, map, oct, zip
	range = xrange
import os, sys
from io import IOBase, BytesIO
BUFSIZE = 8192

class FastIO(BytesIO):
	newlines = 0

	def __init__(self, file):
		self._file = file
		self._fd = file.fileno()
		self.writable = 'x' in file.mode or 'w' in file.mode
		self.write = super(FastIO, self).write if self.writable else None

	def _fill(self):
		s = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
		self.seek((self.tell(), self.seek(0, 2), super(FastIO, self).write(s))[0])
		return s

	def read(self):
		while self._fill():
			pass
		return super(FastIO, self).read()

	def readline(self):
		while self.newlines == 0:
			s = self._fill()
			self.newlines = s.count(b'\n') + (not s)
		self.newlines -= 1
		return super(FastIO, self).readline()

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

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		if py2:
			self.write = self.buffer.write
			self.read = self.buffer.read
			self.readline = self.buffer.readline
		else:
			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')
import sys

class ostream:

	def __lshift__(self, a):
		sys.stdout.write(str(a))
		return self
cout = ostream()
endl = '\n'

def readnumbers(zero=0):
	conv = ord if py2 else lambda x: x
	A = []
	numb = zero
	sign = 1
	i = 0
	s = sys.stdin.buffer.read()
	try:
		while True:
			if s[i] >= b'0'[0]:
				numb = 10 * numb + conv(s[i]) - 48
			elif s[i] == b'-'[0]:
				sign = -1
			elif s[i] != b'\r'[0]:
				A.append(sign * numb)
				numb = zero
				sign = 1
			i += 1
	except:
		pass
	if s and s[-1] >= b'0'[0]:
		A.append(sign * numb)
	return A
main()


from collections import *
from math import *
n = int(input())
for y in range(n):
	t = list(input())
	s = len(t)
	ct = 1
	ans = []
	for i in range(1, s):
		if t[i] != t[i - 1]:
			if ct % 2 == 1:
				ans.append(t[i - 1])
			ct = 1
		else:
			ct += 1
	if ct % 2 == 1:
		ans.append(t[-1])
	ans = list(set(ans))
	ans.sort()
	print(''.join(ans))


def test():
	s = input()
	n = len(s)
	ans = set()
	count = 1
	prev = s[0]
	for i in range(1, n):
		if s[i] == prev:
			count += 1
		else:
			if count % 2 == 1:
				ans.add(prev)
			count = 1
			prev = s[i]
	if count % 2 == 1:
		ans.add(prev)
	print(''.join(sorted(ans)))
for i in range(int(input())):
	test()


t = int(input())
ans = []
while t > 0:
	s = input()
	n = len(s)
	otv = set()
	s = '#' + s + '#'
	i = 1
	while i <= n:
		l = 1
		start = i
		while s[i] == s[i + 1]:
			l += 1
			i += 1
		if l % 2 == 1:
			otv.add(s[start])
		i += 1
	otv = sorted(list(otv))
	ans.append(otv)
	t -= 1
for elem in ans:
	print(''.join(elem))


t = int(input())
for _ in range(t):
	s = input()
	res = ''
	subs = []
	i = 0
	while i < len(s):
		j = i
		while j < len(s) and s[i] == s[j]:
			j += 1
		subs.append(s[i:j])
		i = j
	for i in sorted(subs):
		if len(i) % 2 == 0:
			continue
		if i[0] not in res:
			res += i[0]
	print(res)


import re
for _ in range(int(input())):
	s = input()
	good = ''
	for n in sorted(set(s)):
		x = re.compile('{}+'.format(n))
		y = any(map(lambda a: len(a) % 2 != 0, x.findall(s)))
		if y:
			good += n
	print(good)


def main():
	testcase = int(input())
	result = []
	for i in range(testcase):
		str = input()
		check = 1
		check_char = str[0]
		dummy_result = []
		for j in range(1, len(str)):
			if str[j] == check_char:
				check += 1
			else:
				if check & 1:
					dummy_result.append(check_char)
				check = 1
				check_char = str[j]
		if check & 1:
			dummy_result.append(check_char)
		if len(dummy_result) == 0:
			dummy_result.append('')
		dummy_result = sorted(list(set(dummy_result)))
		result.append(dummy_result)
	for i in result:
		for j in i:
			print(j, end='')
		print()
main()


import sys
input = lambda : sys.stdin.readline()
int_arr = lambda : list(map(int, input().split()))
str_arr = lambda : list(map(str, input().split()))
get_str = lambda : map(str, input().split())
get_int = lambda : map(int, input().split())
get_flo = lambda : map(float, input().split())
mod = 1000000007

def solve(s):
	i = 0
	s = list(s)
	if len(s) == 1:
		print(s[0])
	else:
		for j in range(1, len(s)):
			if s[j] == s[i]:
				s[j] = '#'
				s[i] = '#'
			i += 1
		s = ''.join(sorted(set(s)))
		s = s.replace('#', '')
		print(s)
for _ in range(int(input())):
	s = str(input())[:-1]
	solve(s)


for _ in range(int(input())):
	s = input()
	i = 0
	g = set()
	while i < len(s):
		char = s[i]
		count = 0
		while i < len(s) and s[i] == char:
			count += 1
			i += 1
		if count % 2 == 1:
			g.add(ord(s[i - 1]))
	l = []
	x = ''
	for i in g:
		l.append(i)
	l.sort()
	for i in l:
		x = x + chr(i)
	print(x)


n = int(input())
k = 1
for i in range(n):
	j = 0
	k = 1
	a = []
	s = input()
	if len(s) == 1:
		a.append(s[0])
	while j < len(s) - 1:
		while j < len(s) - 1 and s[j] == s[j + 1]:
			k += 1
			j += 1
		if k % 2 == 1:
			if s[j] not in a:
				a.append(s[j])
		j += 1
		k = 1
	if s[len(s) - 1] != s[len(s) - 2]:
		if s[len(s) - 1] not in a:
			a.append(s[len(s) - 1])
	a.sort()
	print(*a, sep='')


n = int(input())
for i in range(n):
	flag = input()
	if len(flag) == 1:
		print(flag)
		continue
	res = []
	flag += '#'
	flag = list(flag)
	i = 0
	while i < len(flag) - 1:
		if flag[i] != flag[i + 1]:
			if flag[i] not in res:
				res.append(flag[i])
			i += 1
		else:
			i += 2
	res1 = ''
	res.sort()
	for i in res:
		res1 += i
	print(res1)


t = int(input())
for i in range(t):
	valid = set()
	word = input()
	count = 0
	j = 0
	while j < len(word):
		k = j + 1
		while k < len(word) and word[j] == word[k]:
			k += 1
		if (k - j) % 2 == 1:
			valid.add(word[j])
		j = k
	print(''.join(sorted(list(valid))))


t = int(input())
ans = 'abcdefghijklmnopqrstuvwxyz'
ans_a = dict()
for i in range(t):
	s = str(input())
	if len(s) == 1:
		print(s)
	else:
		for x in range(26):
			ans_a[ans[x]] = 0
		now = s[0]
		for j in range(1, len(s)):
			if s[j] == s[j - 1]:
				now += s[j]
			else:
				if len(now) % 2 != 0:
					ans_a[s[j - 1]] = 1
				now = s[j]
		if len(now) % 2 == 1:
			ans_a[s[-1]] = 1
		if s[len(s) - 1] != s[len(s) - 2]:
			ans_a[s[len(s) - 1]] = 1
		for x in range(26):
			if ans_a[ans[x]] == 1:
				print(ans[x], end='')
		print()


import sys
from collections import deque
readline = sys.stdin.readline
n = int(readline())
for _ in range(n):
	s = str(readline().split()[0])
	sl = len(s)
	c = 1
	tmp = set()
	for i in range(1, sl, 1):
		if s[i] == s[i - 1]:
			c += 1
		else:
			if c % 2 == 1:
				tmp.add(s[i - 1])
			c = 1
	if c % 2 == 1:
		tmp.add(s[sl - 1])
	asd = list(tmp)
	asd.sort()
	for x in asd:
		print(x, end='')
	print()


from sys import stdin, stdout
t = int(stdin.readline())
for x in range(t):
	s = input()
	l = len(s)
	if l == 1:
		print(s)
	else:
		j = 0
		c = []
		for i in range(l):
			ss = ''
			if i + 1 < l:
				if s[i] != s[i + 1]:
					ss = s[j:i + 1]
					j = i + 1
			else:
				ss = s[j:]
			if s != '':
				if len(ss) % 2 == 1 and ss[0] not in c:
					c.append(ss[0])
		c.sort()
		ans = ''.join(c)
		stdout.write(ans + '\n')


t = int(input())
for _ in range(t):
	s = list(input())
	stf = []
	alf = [[] for _ in range(26)]
	st = list(set(s))
	for i in st:
		co = 0
		ind = ord(i) - 97
		for j in range(len(s)):
			if s[j] == i:
				co += 1
			else:
				alf[ind].append(co)
				co = 0
		alf[ind].append(co)
	for i in range(26):
		if len(alf[i]) > 0:
			set_ = set(alf[i])
			for ii in set_:
				if ii % 2 != 0:
					stf.append(chr(97 + i))
					break
	print(''.join(stf))


q = int(input())
for i in range(q):
	a = [0] * 26
	w = input() + ' '
	k = 1
	last = w[0]
	for j in range(1, len(w)):
		if w[j] == last:
			k += 1
		else:
			a[ord(last) - 97] = max(k % 2, a[ord(last) - 97])
			k = 1
			last = w[j]
	for j in range(26):
		if a[j]:
			print(chr(97 + j), end='')
	print()


def solve(string):
	lista = []
	s = ' '
	for l in string:
		if l == s[-1]:
			s += l
		else:
			lista.append(s)
			s = l
	lista.append(s)
	lista.pop(0)
	dicionario = {}
	for l in lista:
		letra = l[0]
		if letra not in dicionario:
			dicionario[letra] = 0
		if len(l) % 2 == 1:
			dicionario[letra] += 1
	new_list = []
	for l in dicionario:
		if dicionario[l] >= 1:
			new_list.append(l)
	new_list.sort()
	return ''.join(new_list)
n = int(input())
for _ in range(n):
	print(solve(input()))


t = int(input())
for i in range(t):
	s = input()
	c = ''
	if len(s) == 1:
		print(s)
		continue
	else:
		j = 0
		while j < len(s) - 1:
			if s[j] == s[j + 1]:
				j += 2
			else:
				c += s[j]
				j += 1
		if j == len(s) - 1:
			c += s[j]
		c = list(set(c))
	print(''.join(sorted(c)))


for _ in range(int(input())):
	l = input() + '.'
	a = []
	i = 0
	while True:
		if i < len(l) - 1:
			if l[i] == l[i + 1]:
				i += 2
				continue
			elif l[i] not in a:
				a += [l[i]]
			i += 1
		else:
			break
	a.sort()
	print(*a, sep='')


t = int(input())
for i in range(t):
	s = input()
	correct = set()
	count = 0
	curr = s[0]
	for ch in s:
		if ch != curr:
			if count % 2 != 0:
				correct.add(curr)
			count = 0
			curr = ch
		count += 1
	if count % 2 != 0:
		correct.add(curr)
	print(*sorted(list(correct)), sep='')


def solution(chars):
	if len(chars) == 1:
		return chars
	n = len(chars)
	result = []
	count = 0
	for i in range(n):
		if i == n - 1 or chars[i] != chars[i + 1]:
			count += 1
			if count % 2 != 0:
				result.append(chars[i])
			count = 0
		else:
			count += 1
	result = set(result)
	result = list(result)
	result.sort()
	return ''.join(result)
n = int(input())
for i in range(n):
	chars = input()
	print(solution(chars))


for _ in range(int(input())):
	s = input()
	ans = set()
	if len(s) == 1:
		print(s[0])
	elif len(s) == 0:
		print()
	else:
		pre = s[0]
		c = 1
		for i in range(1, len(s)):
			if s[i] == pre:
				c += 1
			else:
				if c & 1:
					ans.add(s[i - 1])
				else:
					c = 1
				pre = s[i]
		if c & 1:
			ans.add(s[-1])
		ret = list(ans)
		ret.sort()
		print(''.join(ret))


from collections import defaultdict
for _ in range(int(input())):
	s = input()
	d = defaultdict(int)
	if len(s) == 1:
		print(s)
		continue
	i = 0
	while True:
		if i == len(s) - 1:
			d[s[i]] += 1
			break
		if s[i] != s[i + 1]:
			d[s[i]] += 1
			i += 1
		else:
			i += 2
		if i > len(s) - 1:
			break
	x = list(d.keys())
	y = list(d.values())
	m = ''
	for i in range(len(y)):
		if y[i] >= 1:
			m += x[i]
	m = list((x for x in m))
	m.sort()
	print(''.join(m))


for _ in [0] * int(input()):
	r = set()
	l = c = 0
	for x in input():
		if x != l:
			r |= [set(), {l}][c % 2]
			c = 0
		l = x
		c += 1
	r |= [set(), {l}][c % 2]
	print(*sorted(r), sep='')


t = int(input())
for q in range(0, t):
	a = input()
	a = a[::-1]
	ans = []
	while len(a) > 1:
		if a[0] == a[1]:
			a = a[2:]
		else:
			ans.append(a[0])
			a = a[1:]
	if len(a) == 1:
		ans.append(a[0])
	ans = set(ans)
	ans = sorted(ans)
	print(*ans, sep='')


MOD = 1000000007
ii = lambda : int(input())
si = lambda : input()
dgl = lambda : list(map(int, input()))
f = lambda : list(map(int, input().split()))
il = lambda : list(map(int, input().split()))
ls = lambda : list(input())
from itertools import groupby
t = ii()
for _ in range(t):
	s = si()
	l = [0] * 26
	for (i, j) in groupby(s):
		x = ord(i) - ord('a')
		if len(list(j)) % 2:
			l[x] = 1
	for i in range(26):
		if l[i] == 1:
			print(chr(i + ord('a')), end='')
	print()


import re
values = 'abcdefghijklmnopqrstuvwxyz'
for i in range(int(input())):
	res = []
	s = input()
	for p in values:
		current = re.findall('{p}+'.format(p=p), s)
		if [i for i in current if len(i) % 2] != []:
			res.append(p)
	print(''.join(res))


def check(n):
	prov = set()
	i = 0
	while i < len(n):
		j = i + 1
		counter = 0
		if j < len(n):
			while n[j] == n[i]:
				counter += 1
				j += 1
				if j == len(n):
					break
		if counter % 2 == 0:
			prov.add(n[i])
		i += counter + 1
	return prov
k = int(input())
ans = []
for _ in range(k):
	vvod = str(input())
	ans.append(sorted(check(vvod)))
for i in range(len(ans)):
	print(*ans[i], sep='')


t = [int(k) for k in input().split(' ')][0]
for k in range(t):
	s = input()
	ss = set()
	k = 0
	n = len(s)
	while k < n:
		kk = k
		while kk < n and s[kk] == s[k]:
			kk += 1
		if (kk - k) % 2:
			ss.add(s[k])
		k = kk
	print(''.join(sorted(list(ss))))


t = int(input(''))
for _ in range(t):
	s = input('')
	n = len(s)
	d = {}
	if len(s) > 1:
		if s[0] != s[1]:
			if s[0] not in d:
				d[s[0]] = True
		if s[n - 1] != s[n - 2]:
			if s[n - 1] not in d:
				d[s[-1]] = True
	else:
		d[s] = True
	i = 0
	while i < n - 1:
		if s[i] != s[i + 1]:
			if s[i] not in d:
				d[s[i]] = True
		else:
			i = i + 1
		i = i + 1
	if i == n - 1:
		if s[-1] not in d:
			d[s[-1]] = True
	a = list(d.keys())
	a.sort()
	for c in a:
		print(c, end='')
	print('')


for i in range(int(input())):
	X = input() + '*'
	for j in set(X):
		X = X.replace(j * 2, '*')
	print(*sorted(set(X))[1:], sep='')


t = int(input())
for j in range(t):
	s = input()
	x = ''
	f = 0
	c = 1
	if len(s) == 1:
		x += s[0]
	for i in range(len(s) - 1):
		if s[i] == s[i + 1]:
			c += 1
		else:
			if c % 2 != 0:
				x += s[i]
			c = 1
			if i == len(s) - 2:
				f = 1
	if f == 1:
		x += s[len(s) - 1]
	elif c % 2 != 0:
		x += s[len(s) - 2]
	x = list(set(x))
	x.sort()
	print(''.join(x))


t = int(input())
for i in range(t):
	n = input()
	ans = ''
	if len(n) == 0:
		print('')
	elif len(n) == 1:
		print(n)
	else:
		j = 0
		while j < len(n):
			if j == len(n) - 1:
				if n[j] not in ans:
					ans += n[j]
				j += 1
			elif n[j] != n[j + 1]:
				if n[j] not in ans:
					ans += n[j]
				j += 1
			else:
				j += 2
		ans = ''.join(sorted(ans))
		print(ans)


def foo():
	dic = {i: 0 for i in 'abcdefghijklmnopqrstuvwxyz'}
	s = list(input())
	i = 0
	while i < len(s):
		ch = s[i]
		if dic[ch] == 1:
			i += 1
			continue
		l = 1
		while i + 1 < len(s) and s[i] == s[i + 1]:
			l += 1
			i += 1
		if l % 2 == 1:
			dic[ch] = 1
		else:
			dic[ch] = -1
		i += 1
	l = []
	for i in dic:
		if dic[i] == 1:
			l.append(i)
	l.sort()
	print(''.join(l))
	return
t = int(input())
for i in range(t):
	foo()


def odd_Number(s):
	if len(s) == 1:
		return [s[0]]
	data = [0] * 26
	j = 0
	while j < len(s):
		if j + 1 < len(s) and s[j] != s[j + 1]:
			data[ord(s[j]) - 97] = 1
			j += 1
		elif j + 1 >= len(s):
			data[ord(s[j]) - 97] = 1
			j += 1
		else:
			j += 2
	Res = []
	for j in range(len(data)):
		if data[j] != 0:
			Res.append(chr(j + 97))
	return Res
t = int(input())
while t > 0:
	t -= 1
	XD = input().split()
	s = XD[0]
	data = odd_Number(s)
	for x in data:
		print(x, end='')
	print()


for i in range(int(input())):
	a = set()
	j = 1
	l = 1
	s = input()
	n = len(s)
	while j < n:
		if s[j] == s[j - 1]:
			l += 1
		else:
			if l % 2 == 1:
				a.add(s[j - 1])
			l = 1
		j += 1
	if l % 2 == 1:
		a.add(s[j - 1])
	print(''.join(sorted(list(a))))


last = []
for _ in range(int(input())):
	s = input()
	ans = set()
	for i in s:
		if len(last) and last[-1] != i:
			if len(last) & 1:
				ans.add(last[-1])
			last = []
		last.append(i)
	if len(last) & 1:
		ans.add(last[-1])
	last = []
	print(''.join(sorted(list(ans))))


t = int(input())
for _ in range(t):
	s = input()
	n = len(s)
	i = 0
	ans = set()
	while i < n:
		t = s[i]
		c = 0
		while t == s[i]:
			i = i + 1
			c = c + 1
			if i == n:
				break
		if c % 2 == 1:
			ans.add(t)
	ans = list(ans)
	if len(ans) == 0:
		print('')
	else:
		ans.sort()
		x = ''
		for i in range(len(ans)):
			x = x + ans[i]
		print(x)


for _ in range(int(input())):
	a = input()
	s = sorted(set(a))
	ans = ''
	for i in s:
		if 2 * a.count(2 * i) != a.count(i):
			ans += i
	print(ans)


n = int(input())
for _ in range(n):
	row = str(input()) + '*'
	working = []
	count = 1
	prev = row[0]
	for i in range(1, len(row)):
		if prev == row[i]:
			count += 1
		else:
			if count % 2 == 1 and prev not in working:
				working.append(prev)
			count = 1
		prev = row[i]
	working.sort()
	print(''.join(working))


def solve():
	s = input()
	myset = set()
	prev = s[0]
	cnt = 1
	for i in range(1, len(s)):
		if s[i] == prev:
			cnt += 1
		else:
			if cnt % 2 == 1:
				myset.add(prev)
			cnt = 1
		prev = s[i]
	if cnt % 2 == 1:
		myset.add(prev)
	print(''.join(sorted(list(myset))))
n = int(input())
for _ in range(n):
	solve()


for _ in range(int(input())):
	s = input() + '*'
	i = 0
	alp = []
	while i < len(s) - 1:
		if s[i] == s[i + 1]:
			i += 2
		else:
			alp.append(s[i])
			i += 1
	print(''.join(sorted(list(set(alp)))))


n = int(input())
for x in range(n):
	string = input()
	length = len(string)
	y = 0
	dic = {}
	correct = {}
	while True:
		if y + 1 >= length:
			if y < length:
				if string[y] in dic:
					correct[string[y]] = 5
					break
				else:
					correct[string[y]] = 5
					break
			else:
				break
		elif string[y] == string[y + 1] and string[y] not in correct:
			dic[string[y]] = 5
			y += 2
		elif string[y] in dic:
			dic.pop(string[y])
			correct[string[y]] = 5
			y += 1
		else:
			correct[string[y]] = 5
			y += 1
	array = []
	for it in correct:
		array.append(it)
	array.sort()
	print(''.join(array))


t = int(input())
for l in range(t):
	s = str(input())
	i = 0
	ans = ''
	while i < len(s) - 1:
		if s[i] == s[i + 1]:
			i += 2
		else:
			ans += s[i]
			i += 1
	if i == len(s) - 1:
		ans += s[-1]
	print(''.join(sorted(set(ans.lower()))))


n_consultas = int(input())

def remove_b_function(lista):
	length = len(lista)
	walk = 0
	while length - 1 > walk and length > 1:
		if lista[walk] == lista[walk + 1]:
			lista.remove(lista[walk])
			lista.remove(lista[walk])
			length -= 2
			walk -= 1
		walk += 1
	return lista
for i in range(n_consultas):
	string = list(input())
	length = len(string)
	aux = []
	remove_b_function(string)
	for l in string:
		if l not in aux:
			aux.append(l)
	aux.sort()
	new_string = ''
	for l in aux:
		new_string += l
	print(new_string)


from collections import Counter

def split(word):
	return list(word)
n = int(input())
for i in range(n):
	w = input()
	size = len(w)
	char = split(w)
	char.append('#')
	lista = []
	atual = ''
	contador = 1
	if size != 1:
		anterior = char[0]
		for j in range(1, size + 1):
			atual = char[j]
			if anterior == atual:
				contador = contador + 1
			else:
				if contador % 2 == 1 and anterior not in lista:
					lista.append(anterior)
				contador = 1
			anterior = atual
		l3 = ''.join(sorted(lista))
		print(l3)
	else:
		print(w)


T = int(input())
for _ in range(T):
	s = input()
	odd = set()
	curr = None
	cnt = 0
	for x in s:
		if curr is None:
			curr = x
		elif curr != x:
			if cnt % 2 == 1:
				odd.add(curr)
			curr = x
			cnt = 0
		cnt += 1
	if cnt % 2 == 1:
		odd.add(curr)
	curr = x
	print(''.join(map(str, sorted(odd))))


t = int(input())
for _ in range(t):
	sr = input()
	a = [0] * 26
	if len(sr) <= 1:
		print(sr)
	else:
		i = 0
		j = 0
		count = 0
		while j < len(sr):
			if sr[i] == sr[j]:
				count += 1
				j += 1
			else:
				if count & 1:
					a[ord(sr[i]) - 97] = 1
				i = j
				count = 0
		if count & 1:
			a[ord(sr[i]) - 97] = 1
		ans = ''
		for i in range(26):
			if a[i]:
				ans += chr(97 + i)
		print(ans)


for t in range(int(input())):
	char = [1] * 26
	done = []
	string = input()
	j = 0
	string += '&'
	while j < len(string) - 1:
		ct = 1
		i = j
		while i < len(string) - 1 and string[i] == string[i + 1]:
			enter = 0
			ct += 1
			i += 1
		if ct & 1 and char[ord(string[j]) - ord('a')]:
			done.append(string[j])
			char[ord(string[j]) - ord('a')] = 0
		j = i + 1
	done.sort()
	for i in range(len(done)):
		print(done[i], end='')
	print()


Q = int(input())
Query = []
for _ in range(Q):
	S = input()
	Query.append(S)
for S in Query:
	L = len(S)
	OK = set()
	pa = False
	for i in range(L):
		if pa:
			pa = False
			continue
		if i == L - 1:
			OK.add(S[i])
			break
		if S[i] != S[i + 1]:
			OK.add(S[i])
		else:
			pa = True
	ans = sorted(list(OK))
	print(''.join(ans))


def checkDuplicacy(x):
	x = x + '0'
	filtered = []
	i = 0
	while i < len(x) - 1:
		if x[i] == x[i + 1]:
			i += 1
		else:
			filtered.append(x[i])
		i += 1
	filtered = list(set(filtered))
	filtered.sort()
	print(*filtered, sep='')
n = input()
for _ in range(int(n)):
	checkDuplicacy(input())


from collections import Counter
from string import ascii_lowercase

def run_testcase():
	string = input()
	correct_chars = set()
	current_char = None
	current_length = 0
	for (i, char) in enumerate(string):
		if char == current_char:
			current_length += 1
		else:
			if current_length % 2 == 1:
				correct_chars.add(current_char)
			current_char = char
			current_length = 1
	if current_length % 2 == 1:
		correct_chars.add(current_char)
	correct_chars_str = ''.join(sorted(correct_chars))
	return correct_chars_str
testcase_count = int(input())
for i in range(testcase_count):
	print(str(run_testcase()))


import sys
import re
sys.setrecursionlimit(10 ** 9)
input = sys.stdin.readline
N = int(input())
for _ in range(N):
	ans = set()
	result = re.sub('([a-z])\\1', '', input()[:-1])
	for r in result:
		ans.add(r)
	ans = sorted(list(ans))
	print(''.join(ans))


for i in range(int(input())):
	b = [2] * 26
	s = input()
	l = 0
	a = 0
	while l != len(s):
		if s[l] == s[a]:
			l += 1
		else:
			if len(s[a:l]) % 2 == 0:
				if b[ord(s[a]) - 97] != 1:
					b[ord(s[a]) - 97] = 0
			else:
				b[ord(s[a]) - 97] = 1
			a = l
			l = a
	if len(s[a:l]) % 2 == 0:
		if b[ord(s[a]) - 97] != 1:
			b[ord(s[a]) - 97] = 0
	else:
		b[ord(s[a]) - 97] = 1
	for j in range(len(b)):
		if b[j] == 1:
			print(chr(j + 97), end='')
	print()


for i in range(0, int(input())):
	a = list(input())
	b = [0] * 200
	k = []
	t = ''
	p = 0
	for i in range(0, len(a)):
		if p == 0:
			t = a[i]
			p = 1
		elif t == a[i]:
			p += 1
		else:
			if p % 2 != 0:
				k.append(t)
			t = a[i]
			p = 1
	if p >= 1:
		if p % 2 != 0:
			k.append(t)
	k = sorted(k)
	k = list(dict.fromkeys(k))
	for j in range(0, len(k)):
		print(k[j], end='')
	print()


def isodd(n):
	return n % 2 == 1
t = int(input())
for t_ in range(t):
	s = input()
	ans = []
	count = 1
	for i in range(len(s)):
		if i == len(s) - 1:
			if isodd(count):
				ans.append(s[i])
			break
		if s[i] == s[i + 1]:
			count += 1
		else:
			if isodd(count):
				ans.append(s[i])
			count = 1
	for c in sorted(set(ans)):
		print(c, end='')
	print()


for _ in range(int(input())):
	s = list(input())
	out = []
	i = 0
	n = len(s)
	while i < n:
		if i < n - 1 and s[i + 1] == s[i]:
			i += 2
			continue
		out.append(s[i])
		i += 1
	print(''.join(sorted(list(set(out)))))


from itertools import groupby as gb
for i in range(int(input())):
	print(''.join(sorted(set((i for (i, j) in gb(input()) if len([*j]) % 2)))))


t = int(input())
for _ in range(t):
	s = input()
	n = len(s)
	i = 0
	ans = ''
	while i < n:
		if i == n - 1:
			ans += s[i]
			break
		if s[i] != s[i + 1]:
			ans += s[i]
		else:
			i += 1
		i += 1
	ans = sorted(set(ans))
	for ch in ans:
		print(ch, end='')
	print('\n', end='')


from sys import stdin, stdout
from collections import defaultdict as df
import bisect
t = int(input())
for ii in range(t):
	s = input().rstrip()
	s = [i for i in s]
	d = df(list)
	count = 1
	for i in range(1, len(s)):
		if s[i] == s[i - 1]:
			count += 1
		else:
			d[s[i - 1]].append(count % 2)
			count = 1
	d[s[-1]].append(count % 2)
	corr = []
	for i in set(s):
		y = d[i]
		if 1 in y:
			corr.append(i)
	corr = set(corr)
	corr = list(corr)
	corr.sort()
	print(''.join(corr))


import array
import math
import os
import sys

def main():
	T = read_int()
	for _ in range(T):
		S = inp()
		print(solve(S))

def solve(S):
	orda = ord('a')
	b = [0] * 26
	i = 0
	while i < len(S):
		j = i + 1
		while j < len(S) and S[j] == S[i]:
			j += 1
		if (j - i) % 2 == 1:
			b[ord(S[i]) - orda] = 1
		i = j
	return ''.join([chr(orda + v) for v in range(26) if b[v]])
DEBUG = 'DEBUG' in os.environ

def inp():
	return sys.stdin.readline().rstrip()

def read_int():
	return int(inp())

def read_ints():
	return [int(e) for e in inp().split()]

def dprint(*value, sep=' ', end='\n'):
	if DEBUG:
		print(*value, sep=sep, end=end)
main()


for i in range(int(input())):
	s = input()
	arr = [0 for _ in range(26)]
	j = 0
	while j < len(s):
		if j < len(s) - 1 and s[j] == s[j + 1]:
			j += 2
		else:
			arr[ord(s[j]) - 97] = 1
			j += 1
	for l in range(26):
		if arr[l] == 1:
			print(chr(l + 97), end='')
	print()


n = int(input())
strings = [input() for n in range(n)]
for s in strings:
	set_ = set(s)
	ww = list()
	for c in set_:
		if s.count(c) % 2 == 1:
			ww.append(c)
		else:
			temp = s.replace(f'{c}{c}', '')
			if c in temp:
				ww.append(c)
	print(''.join(sorted(ww)))


n = int(input())
t = []
for i in range(n):
	x = input()
	t.append(x)
for i in range(n):
	k = len(t[i])
	h = set()
	if k == 1:
		print(t[i])
	else:
		j = 0
		while j < k:
			if j == k - 1:
				h.add(t[i][j])
				break
			if t[i][j] == t[i][j + 1]:
				j += 2
			else:
				h.add(t[i][j])
				j += 1
		if h == {}:
			print(' ')
		else:
			f = list(h)
			m = sorted(h)
			ch = str(m)
			ch1 = ch[1:]
			ch2 = ch1[:-1]
			ch3 = ch2.replace("'", '')
			ch4 = ch3.replace(',', '')
			ch5 = ch4.replace(' ', '')
			print(ch5)


t = int(input())
res = []
for x in range(t):
	s = str(input())
	s_list = list(s)
	s_list.append(0)
	x = 0
	while x < len(s_list) - 1:
		if s_list[x] != s_list[x + 1]:
			if s_list[x] not in res:
				res.append(s_list[x])
			x += 1
		else:
			x += 2
	res.sort()
	print(''.join(res))
	res.clear()


def ip():
	return input().split()
t = int(input())
for i in range(t):
	e = []
	p = []
	s = input()
	l = len(s)
	for k in s:
		e.append(k)
	j = 0
	while j < l - 1:
		z = j + 1
		if e[j] == e[z]:
			e.remove(e[j])
			e.remove(e[j])
			l = len(e)
		else:
			j += 1
	for j in range(len(e)):
		if p.count(e[j]) == 0:
			p.append(e[j])
	p.sort()
	for j in range(len(p)):
		print(p[j], end='')
	print()


w = int(input())
for x in range(w):
	s = input()
	l = []
	if len(s) == 1:
		print(s)
	else:
		l.append(s[0])
		for y in range(1, len(s)):
			if s[y] == l[-1][0]:
				l[-1] += s[y] + ''
			else:
				l.append(s[y])
		l = list(filter(lambda a: len(a) % 2 == 1, l))
		l = list(set(map(lambda a: a[0], l)))
		l.sort()
		print(''.join(l))


T = int(input())
for t in range(T):
	s = input()
	res = ''
	d = {}
	if len(s) >= 2:
		for i in range(len(s)):
			if i == 0:
				res += s[0]
			elif res[0] == s[i]:
				res += s[i]
			else:
				if len(res) % 2 == 1:
					d[res[0]] = res[0]
				res = s[i]
		if len(res) % 2 == 1:
			d[res[0]] = res[0]
	else:
		res += s[0]
		d[res[0]] = res[0]
	for a in sorted(d):
		print(a, end='')
	print('')


n = int(input())
begin = ord('a')
for i in range(n):
	t = [0 for i in range(26)]
	s = input()
	i = 0
	while i < len(s):
		c = s[i]
		count = 0
		while i < len(s) and s[i] == c:
			count += 1
			i += 1
		if count % 2:
			t[ord(c) - begin] = 1
	for i in range(26):
		if t[i]:
			print(chr(begin + i), end='')
	print()


n = int(input())
for j in range(n):
	s = input()
	ans = ''
	for i in range(26):
		c = chr(ord('a') + i)
		if s.count(c) - s.count(c * 2) * 2 and s.count(c) * 2 != s.count(c * 2):
			ans += c
	print(ans)


tc = int(input())
for _ in range(tc):
	s = input()
	fine = set()
	i = 1
	prev = s[0]
	count = 1
	while i < len(s):
		if s[i] == prev:
			count += 1
		else:
			prev = s[i]
			if count % 2 != 0:
				fine.add(s[i - 1])
			count = 1
		i += 1
	if count % 2 != 0:
		fine.add(s[i - 1])
	print(*sorted(fine), sep='')


R = lambda : list(map(int, input().split()))
(q,) = R()
for w in range(q):
	ans = [0] * 27
	s = input()
	for i in range(27):
		s = s.replace(chr(i + 97) * 2, '--')
	for i in s:
		try:
			ans[ord(i) - 97] = 1
		except:
			pass
	for i in range(27):
		if ans[i] == 1:
			print(chr(i + 97), end='')
	print()


from sys import stdin
t = int(stdin.readline())
for i in range(t):
	s = stdin.readline().strip()
	count = 0
	cur = ''
	ans = ''
	found = set()
	for c in s:
		if c == cur:
			count += 1
		else:
			if count % 2 != 0 and cur not in found:
				ans += cur
				found.add(cur)
			cur = c
			count = 1
	if count % 2 != 0 and cur not in found:
		ans += cur
		found.add(cur)
	print(''.join(sorted(ans)))


a = int(input())
for _ in range(a):
	correct = ''
	strIn = input()
	last = ''
	counter = 0
	for i in range(len(strIn)):
		if strIn[i] == last:
			counter += 1
		else:
			if counter % 2 == 1:
				if not last in correct:
					correct += last
			last = strIn[i]
			counter = 1
	if counter % 2 == 1:
		if not last in correct:
			correct += last
	print(''.join(sorted(correct)))


for _ in range(int(input())):
	s = input()
	res = ()
	c = 1
	cc = 0
	if len(s) == 1:
		res = {s[0]}
	else:
		for i in range(1, len(s)):
			if s[i] == s[i - 1]:
				c += 1
			elif c % 2 != 0:
				if cc == 0:
					res = {s[i - 1]}
					cc += 1
				else:
					res.add(s[i - 1])
					c = 1
			else:
				c = 1
			if i == len(s) - 1:
				if c % 2 != 0:
					if cc == 0:
						res = {s[i]}
					else:
						res.add(s[i])
	res = sorted(res)
	for i in res:
		print(i, end='')
	print()


for case in range(0, int(input())):
	sq = input()
	res = set()
	count = 1
	for i in range(0, len(sq)):
		if i < len(sq) - 1 and sq[i] == sq[i + 1]:
			count += 1
			continue
		if count % 2 == 0:
			count = 1
			continue
		count = 1
		res.add(sq[i])
	print(''.join(sorted(list(res))))


t = int(input())
for i in range(t):
	s = input()
	li = [0] * 3000
	cur = s[0]
	occ = 1
	for j in range(1, len(s)):
		if s[j] == cur:
			occ += 1
		else:
			if occ % 2:
				li[ord(cur)] = 1
			occ = 1
			cur = s[j]
	if occ % 2:
		li[ord(cur)] = 1
	sor = []
	for x in s:
		sor.append(x)
	sor = list(set(sor) | set(sor))
	sor.sort()
	for x in sor:
		if li[ord(x)]:
			print(x, end='')
	print()


t = int(input())

def main():
	s = input() + '1'
	ans = set()
	pre = '1'
	cnt = 1
	for i in s:
		if pre == i:
			cnt += 1
		if pre != i:
			if cnt % 2 == 1:
				ans.add(pre)
			cnt = 1
		pre = i
	print(''.join(sorted(list(set(ans)))[1:]))
for _ in range(t):
	main()


t = int(input())
while t > 0:
	a = input()
	ans = ''
	j = 0
	while j < len(a) - 1:
		if a[j] != a[j + 1]:
			ans += a[j]
			j += 1
		else:
			j += 2
	if j == len(a) - 1:
		ans += a[j]
	print(''.join(sorted(set(ans))))
	t -= 1


for _ in range(int(input())):
	s = input()
	z = []
	part = []
	for i in s:
		if not part:
			part.append(i)
		elif part[-1] == i:
			part.append(i)
		else:
			z.append(part)
			part = [i]
	z.append(part)
	ans = set([])
	for i in z:
		if len(i) % 2:
			ans.add(i[-1])
	ans = list(ans)
	ans.sort()
	print(''.join(ans))


n = int(input())
for test in range(n):
	s = input()
	ans = list()
	mas = [0] * 26
	symb = 'a'
	for j in range(26):
		symb = chr(ord('a') + j)
		count = 0
		for i in s:
			if i == symb:
				count += 1
			else:
				if count % 2:
					mas[j] = 1
				count = 0
		if count % 2:
			mas[j] = 1
		count = 0
	for j in range(26):
		if mas[j] == 1:
			print(chr(ord('a') + j), end='')
	print()


t = int(input().strip())
for case in range(t):
	inputStr = input().strip()
	i = 0
	workingKey = set()
	while i <= len(inputStr) - 1:
		cnt = 0
		j = i
		c = inputStr[i]
		while j < len(inputStr):
			if inputStr[i] == inputStr[j]:
				cnt += 1
				j += 1
			else:
				break
		i = j
		if cnt % 2 == 1:
			workingKey.add(c)
	workingKey = sorted(workingKey)
	for k in workingKey:
		print(k, end='')
	print()


I = input
for _ in [0] * int(I()):
	s = I()
	print(''.join((c for c in sorted(set(s)) if s.count(c) > 2 * s.count(c + c))))


t = int(input())
while t > 0:
	s = list(input())
	sett = set()
	l = len(s)
	i = 0
	if l == 1:
		print(s[0])
	else:
		while i < l:
			if i + 1 < l and s[i] != s[i + 1]:
				sett.add(s[i])
				i += 1
			elif i == l - 1:
				sett.add(s[i])
				i += 1
			else:
				i += 2
		s = sorted(sett)
		print(''.join(s))
	t -= 1


from math import *
from sys import *
from heapq import *
from collections import defaultdict
from itertools import permutations
import os, sys
from io import IOBase, BytesIO
M = 10 ** 9 + 7

def graph_as_tree_1_root():
	n = int(input())
	dict = defaultdict(list)
	for _ in range(n - 1):
		(x, y) = list(map(int, input().split()))
		dict[x].append(y)
		dict[y].append(x)
	tree = [[1]]
	temp = [1]
	vall = 0
	seen = set([i for i in range(2, n + 1)])
	lol = []
	while len(seen) > 0:
		lol = list(seen)
		tt = []
		for x in temp:
			aa = []
			for val in dict[x]:
				if val in seen:
					aa += [val]
					seen.remove(val)
			dict[x] = aa
			tt += aa
		tree.append(tt)
		temp = tt
		vall += 1
	for x in lol:
		dict[x] = []
	print(tree, dict)

def pow(a, b):
	res = 1
	while b > 0:
		if b & 1:
			res *= a
		a *= a
		b >>= 1
	return res

def powmod(a, b, m):
	res = 1
	while b > 0:
		if b & 1:
			res = res * a % m
		a = a * a % m
		b //= 2
	return res

def inv(a, m):
	return powmod(a, m - 2, m)

def alldivisors(n):
	list = []
	arr = []
	for i in range(1, int(sqrt(n) + 1)):
		if n % i == 0:
			if n / i == i:
				arr += [i]
			else:
				arr += [i]
				list.append(n // i)
	arr += list[::-1]
	return arr

def primefactorisation(n):
	potentional_p = 3
	itog_list = defaultdict(int)
	if n % 2 == 0:
		itog_list[2] = 0
	while n % 2 == 0:
		n = n // 2
		itog_list[2] += 1
	while n - 1:
		if potentional_p > n ** 0.5:
			itog_list[n] += 1
			return itog_list
		while n % potentional_p == 0:
			n = n // potentional_p
			itog_list[potentional_p] += 1
		potentional_p += 2
	return itog_list

def main():
	t = int(input())
	for _ in range(t):
		s = input()
		cnt = 1
		prev = s[0]
		arr = []
		for i in range(1, len(s)):
			if s[i] == prev:
				cnt += 1
			else:
				if cnt % 2 == 1:
					arr.append(prev)
				prev = s[i]
				cnt = 1
		if cnt % 2 == 1:
			arr.append(s[-1])
		arr = list(set(arr))
		arr.sort()
		print(''.join(arr))
BUFSIZE = 8192

class FastIO(BytesIO):
	newlines = 0

	def __init__(self, file):
		self._file = file
		self._fd = file.fileno()
		self.writable = 'x' in file.mode or 'w' in file.mode
		self.write = super(FastIO, self).write if self.writable else None

	def _fill(self):
		s = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
		self.seek((self.tell(), self.seek(0, 2), super(FastIO, self).write(s))[0])
		return s

	def read(self):
		while self._fill():
			pass
		return super(FastIO, self).read()

	def readline(self):
		while self.newlines == 0:
			s = self._fill()
			self.newlines = s.count(b'\n') + (not s)
		self.newlines -= 1
		return super(FastIO, self).readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.getvalue())
			(self.truncate(0), self.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()


for _ in range(int(input())):
	s = input()
	st = set()
	i = 0
	cnta = 1
	while i < len(s) - 1:
		if s[i] == s[i + 1]:
			cnta += 1
		elif cnta % 2 == 1:
			st.add(s[i])
		else:
			cnta = 1
		i += 1
	if cnta % 2 == 1:
		st.add(s[-1])
	a = list(st)
	a.sort()
	print(*a, sep='')


t = int(input())
for _ in range(t):
	s = list(str(input()))
	cur = s[0]
	cnt = 0
	X = []
	for c in s:
		if c != cur:
			X.append((cur, cnt))
			cnt = 1
			cur = c
		else:
			cnt += 1
	else:
		X.append((cur, cnt))
	res = set()
	for (c, cnt) in X:
		if cnt % 2 == 1:
			res.add(c)
	res = list(res)
	res.sort()
	print(''.join(res))


for _ in range(int(input())):
	a = input()
	res = ''
	i = 0
	if len(a) == 1:
		res = a
	while i < len(a) - 1:
		if a[i] == a[i + 1]:
			i += 2
		else:
			res += a[i]
			i += 1
	if i == len(a) - 1:
		res += a[-1]
	print(''.join(sorted(set(res))))


for _ in range(int(input())):
	s = input()
	ans = set()
	cnt = 1
	c = s[0]
	for c1 in s[1:]:
		if c1 != c:
			if cnt % 2 == 1:
				ans.add(c)
			cnt = 1
			c = c1
		else:
			cnt += 1
	if cnt % 2 == 1:
		ans.add(c)
	print(''.join(sorted(ans)))


t = int(input())
for i in range(t):
	s = str(input())
	m = ord('a')
	c = [0] * 26
	l = 0
	for i in range(len(s)):
		if i == 0:
			l = ord(s[i])
			c[l - m] = 1
			continue
		if l == ord(s[i]):
			if c[l - m] == 1:
				c[l - m] = 0
			elif c[l - m] == 0:
				c[l - m] = 1
			else:
				continue
		else:
			if c[l - m] == 1:
				c[l - m] = 10
			if c[ord(s[i]) - m] <= 1:
				c[ord(s[i]) - m] = 1
		l = ord(s[i])
	ans = ''
	for i in range(26):
		if c[i] > 0:
			ans += chr(i + m)
	print(ans)


import sys
input = sys.stdin.readline
sys.setrecursionlimit(100000)

def getN():
	return int(input())

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

def solve():
	s = input().strip()
	coll = [0 for i in range(26)]
	tmp = ''
	ln = 0
	for c in s:
		if tmp == c:
			ln += 1
		else:
			if ln % 2 == 1:
				coll[ord(tmp) - ord('a')] = 1
			ln = 1
			tmp = c
	if ln % 2 == 1:
		coll[ord(tmp) - ord('a')] = 1
	ans = ''
	for (i, c) in enumerate(coll):
		if c:
			ans += chr(ord('a') + i)
	print(ans)
	return

def main():
	t = getN()
	for times in range(t):
		solve()
main()


n = int(input())
for _ in range(n):
	s = input()
	ans = set()
	kkk = 1
	for i in range(1, len(s)):
		if s[i] == s[i - 1]:
			kkk += 1
		else:
			if kkk % 2 == 1:
				ans.add(s[i - 1])
			kkk = 1
	if kkk % 2 == 1:
		ans.add(s[-1])
	print(''.join(sorted(ans)))


t = int(input())
for i in range(t):
	s = input()
	s += '$'
	correto = []
	cAnt = s[0]
	count = 1
	for j in range(1, len(s)):
		if s[j] == cAnt:
			count += 1
		else:
			if count % 2 == 1 and cAnt not in correto:
				correto.append(cAnt)
			count = 1
		cAnt = s[j]
	print(''.join(sorted(correto)))


for u in range(int(input())):
	s = input()
	n = len(s)
	if n == 1:
		print(s)
	else:
		bul = [False] * 26
		temp = s[0]
		if s[0] != s[1]:
			bul[ord(s[0]) - 97] = True
		if s[-1] != s[-2]:
			bul[ord(s[-1]) - 97] = True
		count = 1
		for i in range(1, n):
			if s[i] == temp:
				count += 1
			elif s[i] != temp:
				if count % 2 == 1:
					bul[ord(s[i - 1]) - 97] = True
				temp = s[i]
				count = 1
			else:
				print('wtf')
		if count % 2 == 1:
			bul[ord(s[-1]) - 97] = True
		for j in range(26):
			if bul[j]:
				print(chr(j + 97), end='')
		print()


from collections import Counter
t = int(input())
for _ in range(t):
	s = input()
	n = len(s)
	if n == 1:
		print(s)
		continue
	i = 0
	ans = set()
	while i < n - 1:
		if s[i] != s[i + 1]:
			ans.add(s[i])
			i = i + 1
		else:
			i = i + 2
	if i == n - 1 and s[n - 1] != s[n - 2]:
		ans.add(s[n - 1])
	dic = Counter(s)
	for i in dic.keys():
		if dic[i] % 2 == 1:
			ans.add(i)
	ans = list(ans)
	ans = sorted(ans)
	print(''.join(ans))


t = int(input())
while t:
	s = input()
	n = len(s)
	i = 1
	j = 0
	a = ''
	while i <= n:
		if i == n:
			s += '0'
		if s[j] not in a:
			if s[j] == s[i]:
				j += 2
				i += 2
			else:
				a += s[j]
				j += 1
				i += 1
		else:
			j += 1
			i += 1
	d = sorted(a)
	print(''.join(d))
	t -= 1


for __ in range(int(input())):
	s = input()
	l = []
	k = []
	n = len(s)
	i = 0
	c = 0
	while i < n - 1:
		if s[i] is s[i + 1]:
			c = c + 1
		elif c % 2 is 1 and s[i] is not s[i + 1]:
			c = 0
		elif c % 2 is 0 and s[i] is not s[i + 1]:
			l.append(s[i])
			c = 0
		i = i + 1
	if c % 2 is 0:
		l.append(s[n - 1])
	l.sort()
	j = 0
	for i in l:
		j = j + 1
	i = 0
	c = 0
	o = 0
	while i < j - 1:
		if l[i] is not l[i + 1]:
			k.append(l[i])
		i = i + 1
	if j is not 0:
		k.append(l[j - 1])
		for i in k:
			o = o + 1
		for i in range(o):
			print(k[i], end='')
		print()
	else:
		print()


for _ in range(int(input())):
	s = input() + ' '
	chars = set()
	prev = ''
	cnt = 1
	for i in s:
		if i != prev:
			if cnt % 2:
				chars.add(prev)
			cnt = 1
		if i == prev:
			cnt += 1
		prev = i
	print(''.join(sorted(chars)))


t = int(input())

def solve():
	s = input()
	d = dict()
	for i in s:
		d[i] = []
	for i in range(len(s)):
		d[s[i]].append(i)
	works = []
	for i in d.keys():
		segs = d[i]
		arr = ['0'] * len(s)
		for j in segs:
			arr[j] = '1'
		arr = ''.join(arr)
		arr = arr.split('0')
		for j in arr:
			if len(j) % 2 != 0:
				works.append(i)
				break
	works.sort()
	print(''.join(works))
for i in range(t):
	solve()


for i in range(int(input())):
	p = ''
	c = 0
	s = ''
	for j in input():
		if j == p:
			c += 1
		else:
			if c % 2 == 1 and p not in s:
				s += p
			p = j
			c = 1
	if c % 2 == 1 and p not in s:
		s += p
	print(''.join(sorted(s)))


import re
cases = int(input())
for i in range(cases):
	case = input()
	case += '99'
	last = ''
	sol = ''
	count = 1
	for char in case:
		if last == char:
			count += 1
		else:
			if count % 2 == 1:
				if last not in sol:
					sol += last
			last = char
			count = 1
	print(''.join(sorted(sol)))


n = int(input())
for i in range(n):
	a = [0 for i in range(26)]
	s = input()
	ans = ''
	last_char = ''
	k = 1
	for c in s:
		if not last_char:
			last_char = c
			continue
		if c == last_char:
			k += 1
			continue
		x = ord(last_char) - ord('a')
		a[x] = k if k % 2 else a[x]
		last_char = c
		k = 1
	x = ord(last_char) - ord('a')
	a[x] = k if k % 2 else a[x]
	for i in range(26):
		if a[i] % 2:
			ans += chr(i + ord('a'))
	print(ans)


t = int(input())
used = False
for a in range(t):
	ls = []
	output = []
	test = input()
	seq = [str(x) for x in str(test)]
	for x in seq:
		if used == True:
			used = False
			continue
		ind = seq.index(x)
		if ind + 1 != len(seq):
			if x != seq[ind + 1]:
				ls.append(x)
				seq = seq[ind + 1:]
			else:
				seq = seq[ind + 2:]
				used = True
		else:
			ls.append(x)
	ls = set(ls)
	if len(ls) > 0:
		for x in ls:
			output.append(x)
		output.sort()
		print(''.join(output))
	else:
		print('')


tests = int(input())
for _ in range(tests):
	s = input()
	tochno_net = []
	s += '1'
	i = 0
	while i < len(s) - 1:
		if s[i] == s[i + 1]:
			i += 1
		else:
			tochno_net.append(s[i])
		i += 1
	tochno_net = sorted(set(tochno_net))
	for i in tochno_net:
		print(i, end='')
	print()


for _ in range(int(input())):
	s = input() + '0'
	pre = '0'
	ans = set()
	l = 0
	for c in s:
		if c != pre:
			if l:
				ans.add(pre)
			l = 0
		l ^= 1
		pre = c
	print(*sorted(ans), sep='')


t = int(input())
for _ in range(t):
	s = input()
	l = []
	a = len(s)
	if len(s) == 1:
		print(s[0], end='')
	else:
		i = 0
		while i < a:
			count = 0
			for j in range(i + 1, a):
				if s[i] != s[j]:
					break
				else:
					count += 1
			if count % 2 == 0:
				l.append(s[i])
			i = i + count + 1
	l.sort()
	l = list(dict.fromkeys(l))
	b = len(l)
	for k in range(0, b):
		print(l[k], end='')
	print()


for _ in range(int(input())):
	s = input()
	right = set()
	cur = s[0]
	cnt = 1
	for i in range(1, len(s)):
		if cur != s[i]:
			if cur not in right and cnt % 2 == 1:
				right.add(cur)
			cur = s[i]
			cnt = 1
		else:
			cnt += 1
	if cur not in right and cnt % 2 == 1:
		right.add(cur)
	right = sorted(list(right))
	for c in right:
		print(c, end='')
	print()


from collections import defaultdict
INF = float('inf')

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

def main():
	T = int(input())
	for i in range(T):
		D = defaultdict(int)
		L = []
		s = list(input())
		N = len(s)
		cal = s[0]
		cnt = 0
		for i in range(N):
			if s[i] == cal:
				cnt += 1
			else:
				L.append([s[i - 1], cnt])
				cnt = 1
			cal = s[i]
		L.append([s[N - 1], cnt])
		for i in range(len(L)):
			if L[i][1] % 2 == 1:
				D[L[i][0]] = L[i][1]
			elif D[L[i][0]] == 0:
				D[L[i][0]] = L[i][1]
		ans = ''
		for i in D:
			if D[i] % 2 == 1:
				ans += i
		print(''.join(sorted(ans)))
main()


import sys
line_count = 0
for line in sys.stdin.readlines():
	inputs = line.split()
	if line_count == 0:
		t = int(inputs[0])
	else:
		strg = ' ' + inputs[0] + ' '
		working = set()
		i = 1
		while i < len(strg) - 1:
			char = strg[i]
			counter = 0
			while strg[i] == char:
				counter += 1
				i += 1
			i -= 1
			if counter % 2 == 1:
				working.add(char)
			i += 1
		alph_order = list(working)
		alph_order.sort()
		print(''.join(alph_order))
	if line_count == t:
		break
	line_count += 1


n = int(input())
for i in range(n):
	l = input()
	d = ''
	e = list(set(l))
	e.sort()
	for j in e:
		if l.count(j + j) * 2 != l.count(j):
			d = d + j
	print(d)


for _ in range(int(input())):
	s = input()
	i = 0
	correct = set()
	while i < len(s):
		if i == len(s) - 1:
			correct.add(s[i])
			break
		if s[i] == s[i + 1]:
			i += 2
			continue
		correct.add(s[i])
		i += 1
	r = list(correct)
	r.sort()
	print(''.join(r))


from sys import stdin, stdout

def quicksort(string):
	if string == '':
		return string
	left = ''
	right = ''
	center = ''
	for i in range(string.__len__()):
		if ord(string[i]) < ord(string[0]):
			left += string[i]
		elif ord(string[i]) > ord(string[0]):
			right += string[i]
		else:
			center += string[i]
	return quicksort(left) + center + quicksort(right)

def distinct(string):
	distinct_char = ''
	for char in string:
		if char not in distinct_char:
			distinct_char += char
	return distinct_char

def get_strings(n):
	strings = []
	while n > 0:
		strings.append(stdin.readline().replace('\n', ''))
		n -= 1
	return strings

def count_equal_neighbors(i, string):
	count = 0
	j = i + 1
	while j < string.__len__() and string[i] == string[j]:
		count += 1
		j += 1
	return count

def check_buttons(string):
	working_buttons = ''
	i = 0
	while i < string.__len__():
		c = count_equal_neighbors(i, string) + 1
		if c % 2 != 0:
			working_buttons += string[i]
		i += c
	return distinct(quicksort(working_buttons))

def check_strings(array_strings):
	i = 1
	for string in array_strings:
		stdout.write(check_buttons(string) + '\n')
		i += 1
check_strings(get_strings(int(stdin.readline())))


for _ in range(int(input())):
	s = input()
	out = set()
	i = 0
	while i < len(s):
		if i + 1 < len(s) and s[i] == s[i + 1]:
			i += 2
		else:
			out.add(s[i])
			i += 1
	print(''.join(sorted(out)))


def broken_keys(string):
	if len(string) == 1:
		return string
	d = {}
	res = []
	for i in range(len(string)):
		if string[i] not in d:
			d[string[i]] = 1
		elif string[i] != string[i - 1] and d[string[i]] % 2 != 0:
			res.append(string[i])
		else:
			d[string[i]] += 1
	for x in d:
		if d[x] % 2 == 1:
			res.append(x)
	return sorted(set(res))
q = int(input())
for i in range(q):
	string = input()
	ans = broken_keys(string)
	ans = ''.join(ans)
	print(ans)


for _ in range(int(input())):
	s = input()
	st = set()
	s = s + '-'
	cnt = 1
	for i in range(1, len(s)):
		if s[i] == s[i - 1]:
			cnt += 1
		else:
			if cnt % 2 != 0:
				st.add(s[i - 1])
			cnt = 1
	print(*sorted(list(st)), sep='')


from math import ceil, sqrt, log, gcd

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

def si():
	return input()

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

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

def main():
	for _ in range(ii()):
		s = si()
		x = []
		c = 1
		for i in range(1, len(s)):
			if s[i] == s[i - 1]:
				c += 1
			else:
				if c % 2:
					x.append(s[i - 1])
				c = 1
		if c % 2:
			x.append(s[len(s) - 1])
		x = list(set(x))
		x.sort()
		for i in x:
			print(i, end='')
		print()
main()


for _ in range(int(input())):
	ans = set()
	s = input()
	i = 0
	while i < len(s):
		if i == len(s) - 1:
			ans.add(s[i])
			i += 1
		elif s[i] != s[i + 1]:
			ans.add(s[i])
			i += 1
		elif s[i] == s[i + 1]:
			i += 2
	ans1 = ''
	for i in sorted(ans):
		ans1 += i
	print(ans1)


import math
for _ in range(int(input())):
	res = []
	s = input()
	y = [x for x in s]
	x = list(set(y))
	for i in x:
		if y.count(i) % 2 != 0:
			res += [i]
			continue
		j = 0
		c = 0
		while j < len(y) - 1 - y[::-1].index(i):
			if y[y.index(i, j)] == y[y.index(i, j) + 1]:
				j = y.index(i, j) + 2
			else:
				c = 1
				break
		if c == 1:
			res += [i]
	res.sort()
	print(''.join(res))


import sys, itertools

def isWorkingButton(s):
	res = []
	for (c, grp) in itertools.groupby(s):
		if len(list(grp)) % 2 != 0:
			res.append(c)
	return ''.join(sorted(set(res)))
n = int(input().strip())
for _ in range(n):
	s = input().strip()
	print(isWorkingButton(s))


for _ in range(int(input())):
	s = input()
	n = len(s)
	s += '$'
	i = 0
	ans = set()
	while i < n:
		c = s[i]
		if c != s[i + 1]:
			ans.add(c)
			i += 1
		else:
			i += 2
	print(''.join(sorted(ans)))


from collections import Counter
for i in range(int(input())):
	s = []
	s = input()
	a = list(s)
	l = len(a)
	d = []
	ans = []
	for j in range(l - 1):
		if a[j] == a[j + 1]:
			a[j] = '0'
			a[j + 1] = '0'
	for aaa in a:
		if aaa != '0':
			ans.append(aaa)
	ansset = list(set(ans))
	ansset.sort()
	print(''.join(ansset))


g = int(input())
k = []
for i in range(0, g):
	v = []
	str1 = input()
	x = 0
	y = 0
	x = str1[0]
	for j in range(0, len(str1)):
		if str1[j] == x:
			y += 1
		else:
			if y % 2 != 0:
				v.append(str1[j - 1])
			y = 1
			x = str1[j]
	if y % 2 != 0 or len(str1) == 1:
		v.append(str1[-1])
		y = 1
		x = str1[j]
	v = list(set(v))
	v.sort()
	v = ''.join(v)
	k.append(v)
print('\n'.join(k))


for _ in range(int(input())):
	st = input()
	se = set()
	i = 1
	if len(st) > 1:
		while i < len(st):
			if st[i] == st[i - 1]:
				i += 1
			else:
				se.add(st[i - 1])
			i += 1
		c = st[-1]
		co = 0
		for j in range(len(st) - 1, -1, -1):
			if c == st[j]:
				co += 1
			else:
				break
		if co % 2 == 1:
			se.add(c)
	else:
		se.add(st[0])
	print(''.join(sorted(se)))


q = int(input())
for _ in range(q):
	s = input()
	t = {}
	j = 0
	arr = {}
	while j < len(s) - 1:
		if s[j] == s[j + 1]:
			if s[j] not in t:
				if s[j] not in arr:
					arr[s[j]] = 0
			j += 2
		else:
			t[s[j]] = 1
			if s[j] in arr:
				del arr[s[j]]
			j += 1
	p = len(s) - 1
	count = 0
	while p > 0:
		if s[p] == s[p - 1]:
			count += 1
		else:
			break
		p -= 1
	if count % 2 == 0:
		chk = True
	else:
		chk = False
	if len(s) >= 2:
		if s[len(s) - 1] != s[len(s) - 2] or chk:
			if s[len(s) - 1] in arr:
				del arr[s[len(s) - 1]]
	else:
		ch = s
	g = ''
	g = s
	g = list(set(list(g)))
	g.sort()
	if len(s) == 1:
		print(ch)
	else:
		for h in g:
			if h not in arr:
				print(h, end='')
		print()


for i in range(int(input())):
	s = input()
	l = [-1] * 26
	j = 0
	while j < len(s):
		if j == len(s) - 1:
			l[ord(s[j]) - 97] = 0
			j += 1
		elif s[j] == s[j + 1] and l[ord(s[j]) - 97] != 0:
			l[ord(s[j]) - 97] = 1
			j += 2
		else:
			l[ord(s[j]) - 97] = 0
			j += 1
	count = 0
	st = ''
	for j in range(26):
		if l[j] == 0:
			st += chr(j + 97)
	print(st)


import math

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

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

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

def solve():
	string = input() + ' '
	last = ''
	num = 0
	s = set()
	for char in string:
		if char != last:
			if num % 2 == 1:
				s.add(last)
			last = char
			num = 1
		else:
			num += 1
	print(''.join(sorted(s)))
	return
[q] = input_int()
for _ in range(0, q):
	solve()


n = int(input())
for _ in range(n):
	s = input()
	l = len(s)
	if l == 1:
		print(s)
		continue
	inx = 0
	ones = set()
	while inx < l - 1:
		if s[inx] == s[inx + 1]:
			inx += 1
		else:
			ones.update(s[inx])
		inx += 1
	if inx == l - 1:
		ones.update(s[-1])
	print(''.join(sorted(ones)))


a = int(input())
m = str()
c = str()
x = 0
for i in range(0, a):
	s = str(input())
	if len(s) > 1:
		c = s[0]
		x = 0
		for j in range(1, len(s) + 1):
			if c == s[j - 1]:
				x += 1
			elif x % 2 != 0:
				m = m + c
				c = s[j - 1]
				x = 1
			else:
				c = s[j - 1]
				x = 1
		if x % 2 != 0:
			m = m + c
		m = list(m)
		if len(m) == 0:
			print('')
		else:
			m = set(m)
			m = list(m)
			m.sort()
			print(''.join([str(zz) for zz in m]))
		m = str()
	else:
		print(s)


n = int(input())
for _ in range(n):
	s = input()
	ans = set()
	i = 0
	while i < len(s):
		j = i
		cnt = 0
		while j < len(s) and s[i] == s[j]:
			cnt += 1
			j += 1
		if cnt % 2 == 1:
			ans.add(s[i])
		i = j
	print(''.join(map(str, sorted(ans))))


def getAns(test):
	ans = ''
	test = test
	newAns = []
	s = 1
	for i in range(1, len(test)):
		if test[i] == test[i - 1]:
			s += 1
		else:
			newAns.append([s, test[i - 1]])
			s = 1
	newAns.append([s, test[-1]])
	se = set()
	for i in range(len(newAns)):
		if newAns[i][0] % 2 == 1:
			se.add(newAns[i][1])
	while se:
		ans += se.pop()
	return ''.join(sorted(list(ans)))
n = int(input())
for i in range(n):
	test = input()
	print(getAns(test))


t = int(input())
for x in range(t):
	s = input()
	res = ''
	prev = ''
	count = 1
	if len(s) == 1:
		print(s)
		continue
	for ch in s:
		if ch == prev:
			count += 1
		else:
			if count % 2 != 0:
				if prev not in res:
					res = res + prev
			count = 1
		prev = ch
	if count % 2 != 0 and prev not in res:
		res = res + prev
	res = sorted(res)
	res = ''.join(res)
	print(res)


n = int(input())
for i in range(n):
	s = input()
	l = len(s)
	curr = s[0]
	cnt = 1
	lst = []
	for j in range(1, l, 1):
		if s[j] == s[j - 1]:
			cnt += 1
		else:
			if cnt % 2 == 1 and curr not in lst:
				lst.append(curr)
			curr = s[j]
			cnt = 1
	if cnt % 2 == 1 and curr not in lst:
		lst.append(curr)
	lst.sort()
	ans = ''.join(lst)
	print(ans)


for t in range(int(input())):
	inp = input()
	ans = set()
	prev = inp[0]
	count = 1
	for i in inp[1:]:
		if i == prev:
			count += 1
		else:
			if count % 2 == 1:
				ans.add(prev)
			count = 1
			prev = i
	if count % 2 == 1:
		ans.add(inp[-1])
	print(''.join(sorted(ans)))


for t in range(int(input())):
	a = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
	s = input()
	l = len(s)
	cur = s[0]
	w = 0
	for i in range(l):
		if s[i] == cur:
			w += 1
		else:
			if w % 2 == 1:
				a[ord(cur) - ord('a')] = 1
			w = 1
			cur = s[i]
	if w % 2 == 1:
		a[ord(cur) - ord('a')] = 1
	x = ''
	for i in range(26):
		if a[i] == 1:
			x += chr(i + ord('a'))
	print(x)


import sys
for _ in range(int(sys.stdin.readline())):
	a = [i for i in input()]
	strr = []
	stack = []
	for i in a:
		if i in stack:
			stack.remove(i)
		else:
			stack.append(i)
		if len(stack) > 1:
			strr.append(stack[0])
			stack.remove(stack[0])
	if len(stack) > 0:
		strr.append(stack[0])
	strr = sorted(set(strr))
	print(''.join(strr))


t = int(input())
for _ in range(t):
	s = input()
	c = 1
	d = {}
	l = len(s)
	arr = []
	for i in range(l - 1):
		if s[i] == s[i + 1]:
			c += 1
		else:
			if c % 2 != 0:
				arr.append(s[i])
			c = 1
	if s[l - 1] != s[l - 2]:
		arr.append(s[l - 1])
	elif c % 2 != 0:
		arr.append(s[l - 1])
	arr = list(set(arr))
	arr.sort()
	for i in arr:
		print(i, end='')
	print()


import operator
for _ in range(int(input())):
	st = input()
	dic = {}
	if len(st) == 1:
		print(st[0])
		continue
	i = 0
	while i < len(st) - 1:
		if st[i] != st[i + 1]:
			dic[st[i]] = 1
			i += 1
		else:
			i += 2
	if i == len(st) - 1:
		dic[st[i]] = 1
	dic = dict(sorted(dic.items(), key=operator.itemgetter(0)))
	if len(dic) == 0:
		print('')
	else:
		for (k, it) in dic.items():
			print(k, end='')
		print()


q = int(input())
for i in range(q):
	s = input()
	ans = set()
	count = 1
	for c in range(len(s) - 1):
		if s[c] == s[c + 1]:
			count += 1
		else:
			if count % 2 == 1:
				ans.add(s[c])
			count = 1
	if count % 2 == 1:
		ans.add(s[-1])
	print(''.join(sorted(list(ans))))


for _ in range(int(input())):
	word = input()
	ans = []
	cur = word[0]
	cnt = 1
	i = 0
	while i < len(word) - 1:
		if word[i] == word[i + 1]:
			i += 2
		else:
			ans.append(word[i])
			i += 1
	if i == len(word) - 1:
		ans.append(word[-1])
	ans = list(set(ans))
	ans.sort()
	print(''.join((str(x) for x in ans)))


for _ in range(int(input())):
	s = input().strip()
	if len(s) == 1:
		print(s)
		continue
	l = []
	c = 1
	ss = s[0]
	for i in range(1, len(s)):
		if s[i] == ss:
			c += 1
		else:
			l.append((ss, c))
			ss = s[i]
			c = 1
	l.append((ss, c))
	ans = set()
	for i in l:
		if i[1] % 2 == 1:
			ans.add(i[0])
	ans = ''.join(sorted(ans))
	print(ans)


from itertools import groupby as gb

def func(c):
	return ord(c) - ord('a')
n = int(input())
for i in range(n):
	res = [set() for _ in range(n)]
	l = [-1] * 26
	s = input()
	g = gb(list(s))
	for (k, v) in g:
		vv = len(list(v))
		res[i].add(k)
		if l[func(k)] == -1:
			if vv % 2 == 1:
				l[func(k)] = 2
	ll = sorted(res[i])
	for j in ll:
		if l[func(j)] == 2:
			print(j, end='')
	print()


for _ in range(int(input())):
	a = input()
	ans = []
	n = len(a)
	b = [0] * n
	if n == 1:
		print(a)
		continue
	for i in range(0, n):
		if not b[i] and i != n - 1:
			if a[i] != a[i + 1]:
				ans.append(a[i])
			else:
				b[i + 1] = 1
		elif i == n - 1 and (not b[i]):
			ans.append(a[i])
	ans = set(ans)
	ans = list(ans)
	ans.sort()
	print(''.join(ans))


for _ in [0] * int(input()):
	s = input()
	sl = len(s)
	if sl == 1:
		print(s)
		continue
	i = 1
	ans = [0] * 26
	count = 1
	for i in range(sl):
		if i == 0:
			if s[i] != s[i + 1]:
				ans[ord(s[i]) - ord('a')] = 1
		elif i == sl - 1:
			if s[i] != s[i - 1]:
				ans[ord(s[i]) - ord('a')] = 1
				if count % 2 == 1:
					ans[ord(s[i - 1]) - ord('a')] = 1
			elif (count + 1) % 2 == 1:
				ans[ord(s[i]) - ord('a')] = 1
		elif s[i] != s[i - 1]:
			if count % 2 == 1:
				ans[ord(s[i - 1]) - ord('a')] = 1
			count = 1
		else:
			count += 1
	for i in range(26):
		if ans[i] > 0:
			print(chr(ord('a') + i), end='')
	print('')


import sys
from collections import defaultdict as dd
from collections import deque
from fractions import Fraction as f

def eprint(*args):
	print(*args, file=sys.stderr)
zz = 1
from math import *
import copy
if zz:
	input = sys.stdin.readline
else:
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('all.txt', 'w')

def li():
	return [int(x) for x in input().split()]

def fi():
	return int(input())

def si():
	return list(input().rstrip())

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

def gh():
	sys.stdout.flush()

def bo(i):
	return ord(i) - ord('a')
from copy import *
from bisect import *
from itertools import permutations
t = fi()
while t > 0:
	t -= 1
	s = si()
	i = 1
	n = len(s)
	i = 0
	p = [1 for i in range(26)]
	while i < n:
		c = 1
		pp = s[i]
		while i < n - 1 and s[i] == s[i + 1]:
			c += 1
			i += 1
		i += 1
		if c % 2 == 1:
			p[bo(pp)] = 0
	for i in range(26):
		if p[i] == 0:
			print(chr(i + ord('a')), end='')
	print()


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

def sieve(n):
	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 += 1
	prime[0] = prime[1] = False
	r = [p for p in range(n + 1) if prime[p]]
	return r

def divs(n, start=1):
	r = []
	for i in range(start, int(math.sqrt(n) + 1)):
		if n % i == 0:
			if n / i == i:
				r.append(i)
			else:
				r.extend([i, n // i])
	return r

def ceil(n, k):
	return n // k + (n % k != 0)

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

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

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

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

def prr(a, sep=' '):
	print(sep.join(map(str, a)))

def dd():
	return collections.defaultdict(int)
t = ii()
for _ in range(t):
	s = input()
	d = Counter(s)
	res = set()
	i = 0
	while i < len(s) - 1:
		j = i + 1
		while j < len(s) - 1 and s[j] == s[j - 1]:
			j += 1
		if (j - i) % 2:
			res.add(s[i])
		i = j
	prr(sorted(list(res)), '')


import sys
import math
Input = sys.stdin.readline
tmp = 1
for i in range(int(input())):
	s = input() + ' '
	j = 0
	z = []
	while j < len(s) - 1:
		if s[j] != s[j + 1]:
			z.append(s[j])
			j += 1
		else:
			j += 2
	print(*sorted(set(z)), sep='')


t = int(input())
for test in range(t):
	string = input()
	ans = []
	if len(string) == 1:
		print(string)
	else:
		i = 0
		while i < len(string) - 1:
			e = string[i]
			prox = string[i + 1]
			if e != prox and e not in ans:
				ans.append(e)
				i += 1
			elif e == prox:
				i += 2
			else:
				i += 1
		if string[-1] != string[-2] and string[-1] not in ans:
			ans.append(string[-1])
		elif string[-1] == string[-2] and string[-1] not in ans:
			iguais = 0
			e = string[-1]
			i = len(string) - 1
			while e == string[-1] and i >= 0:
				iguais += 1
				i -= 1
				e = string[i]
			if iguais % 2 != 0:
				ans.append(string[-1])
		ans.sort()
		ansF = ''
		for e in ans:
			ansF += e
		print(ansF)


z = int(input())
for i in range(z):
	s = input()
	n = len(s)
	res = ''
	i = 0
	l = [0] * 130
	while i < n - 1:
		if s[i] != s[i + 1]:
			if l[ord(s[i])] == 0:
				res += s[i]
				l[ord(s[i])] = 1
		else:
			i += 1
		i += 1
	if i == n - 1:
		if l[ord(s[i])] == 0:
			res += s[i]
	print(''.join(sorted(res)))


import sys
t = int(input())
for i in range(t):
	j = 0
	s = input()
	ans = ''
	if len(s) == 1:
		print(s)
		continue
	while j < len(s) - 1:
		if s[j] != s[j + 1]:
			ans += s[j]
			j += 1
		else:
			j += 2
	if j == len(s) - 1:
		ans += s[len(s) - 1]
	print(''.join(sorted(set(ans))))


def remove_repetidos(lista):
	l = []
	for i in lista:
		if i not in l:
			l.append(i)
	return l

def verificar(x):
	x = list(x)
	index = 0
	tamanho = len(x)
	while index < tamanho - 1 and tamanho > 1:
		if x[index] == x[index + 1]:
			x.remove(x[index])
			x.remove(x[index])
			tamanho -= 2
			index -= 1
		index += 1
	x = remove_repetidos(x)
	x.sort()
	retorno = ''.join(x)
	return retorno
n = int(input())
for i in range(n):
	entrada = input()
	print(verificar(entrada))


for _ in range(int(input())):
	s = input()
	n = len(s)
	i = 0
	valid = set()
	while i < n:
		j = i + 1
		while j < n and s[j] == s[i]:
			j += 1
		if j - i & 1:
			valid.add(s[i])
		i = j
	print(''.join(sorted(valid)))


t = int(input())
lt = 'abcdefghijklmnopqrstuvwxyz'
for _ in range(t):
	s = input()
	ans = ''
	for i in lt:
		p = 0
		c = 0
		b = False
		while p < len(s):
			if s[p] == i:
				c += 1
			if s[p] != i:
				if c % 2 == 1:
					ans += i
					b = True
					break
				c = 0
			p += 1
		if c % 2 == 1 and (not b):
			ans += i
	print(ans)


def solve():
	s = input()
	count = dict()
	i = 0
	while i < len(s):
		j = i
		flag = False
		c = 0
		while i < len(s) and j < len(s) and (s[i] == s[j]):
			j += 1
			flag = True
			c += 1
		if flag:
			i = j - 1
		if s[i] in count:
			count[s[i]].add(c % 2)
		else:
			count[s[i]] = set()
			count[s[i]].add(c % 2)
		i += 1
	alp = sorted(count.keys())
	for a in alp:
		if 1 in count[a]:
			print(a, end='')
	print()
for _ in range(int(input())):
	solve()


t = int(input())
for _ in range(t):
	s = input()
	res = set()
	if len(s) < 2:
		print(s)
		continue
	while s != '':
		if len(s) < 2:
			res.add(s[0])
			break
		elif s[0] != s[1]:
			res.add(s[0])
			s = s[1:]
		else:
			s = s[2:]
	print(''.join(sorted(res)))


for _ in ' ' * int(input()):
	a = input() + '.'
	b = len(a) - 1
	x = 0
	k = ''
	while x < b:
		if a[x] != a[x + 1]:
			k += a[x]
			x += 1
		else:
			z = x + 1
			while a[x] == a[z] and z < b:
				z += 1
			if (z - x) % 2:
				k += a[x]
			x = z
	print(*sorted(set(k)), sep='')


t = int(input())
for j in range(0, t):
	s = input()
	s1 = list(s)
	n = []
	if len(s) == 1:
		print(s)
		continue
	for i in range(0, len(s1) - 1):
		if s1[i] != s1[i + 1]:
			n.append(s1[i])
			n.append(' ')
		else:
			n.append(s1[i])
	n.append(s1[i + 1])
	n1 = ''.join(n)
	k = n1.split()
	an = []
	for i in range(0, len(k)):
		if len(k[i]) % 2 != 0:
			an.append(k[i][0])
	an1 = set(an)
	an2 = list(an1)
	an2.sort()
	print(''.join(an2))


tests = int(input())
for t in range(tests):
	correct = set()
	inp = input()
	c = 0
	while c < len(inp):
		if c == len(inp) - 1:
			correct.add(inp[c])
		elif inp[c] == inp[c + 1]:
			c += 1
		else:
			correct.add(inp[c])
		c += 1
	l = list(correct)
	l.sort()
	print(*l, sep='')


import string

def solve():
	alp = string.ascii_lowercase
	mydict = dict(zip(alp, [False] * len(alp)))
	s = input() + '#'
	prev = '#'
	cnt = 0
	for c in s:
		if c != prev:
			if cnt % 2 == 1:
				mydict[prev] = True
			prev = c
			cnt = 0
		cnt += 1
	for c in mydict:
		if mydict[c]:
			print(c, end='')
	print()
t = int(input())
while t > 0:
	solve()
	t -= 1


q = int(input())
for i in range(q):
	w = input()
	k = 0
	s = []
	while k <= len(w) - 1:
		e = w[k]
		l = 1
		while k + 1 <= len(w) - 1 and e == w[k + 1]:
			l += 1
			k += 1
		if l % 2 == 1:
			s.append(w[k])
		k += 1
	print(''.join(sorted(list(set(s)))))


t = int(input())
while t > 0:
	t -= 1
	a = input()
	a = list(a)
	c = 0
	s = set()
	if len(a) == 1:
		print(a[0])
		continue
	i = 0
	while i < len(a):
		flag = 0
		c = 1
		if a[i] == a[i + 1]:
			while a[i] == a[i + 1]:
				i += 1
				c += 1
				if i == len(a) - 1:
					break
			if c % 2 == 1:
				s.add(a[i])
			i += 1
			if i == len(a) - 1:
				if a[i] != a[i - 1]:
					s.add(a[i])
				break
		else:
			s.add(a[i])
			i += 1
		if i == len(a) - 1:
			if a[i] != a[i - 1]:
				s.add(a[i])
			break
	s = list(s)
	s.sort()
	print(''.join(s))


cases = int(input())
for _ in range(cases):
	line = input()
	working = set()
	if len(line) == 1:
		working.add(line[0])
		print(line[0])
	else:
		conseq = 1
		for i in range(1, len(line)):
			if line[i - 1] == line[i]:
				conseq += 1
			else:
				if conseq % 2 == 1:
					working.add(line[i - 1])
				conseq = 1
		if conseq % 2 == 1:
			working.add(line[len(line) - 1])
		if len(working) != 0:
			for n in sorted(list(working)):
				print(n, end='')
		print()


for _ in range(int(input())):
	n = list(input())
	al = [0 for i in range(26)]
	i = 0
	le = len(n)
	while i < le:
		if i + 1 < le and n[i] == n[i + 1] and (al[ord(n[i]) - 97] != 1):
			al[ord(n[i]) - 97] = -1
			i += 2
		else:
			al[ord(n[i]) - 97] = 1
			i += 1
	s = ''
	for i in range(26):
		if al[i] == 1:
			s += chr(97 + i)
	print(s)


t = int(input())
for i in range(t):
	s = input()
	zeros = [0 for j in range(26)]
	char = [chr(k) for k in range(97, 123)]
	count = dict(zip(char, zeros))
	l = len(s)
	if l == 1:
		result = s
	else:
		count1 = {}
		c = 1
		for y in range(1, l):
			if s[y] != s[y - 1]:
				count1[y - 1] = c
				c = 1
			else:
				c = c + 1
		if s[l - 1] == s[l - 2]:
			count1[l - 1] = c
		else:
			count1[l - 1] = 1
		for key in count1.keys():
			if count1[key] % 2 == 1:
				count[s[key]] = 1
		result = ''
		for key in char:
			if count[key] == 1:
				result = result + key
	print(result)


t = int(input())
for _ in range(t):
	s = input()
	flag = False
	for i in range(0, 26):
		ch = chr(97 + i)
		j = 0
		while j < len(s):
			if s[j] == ch and (j == len(s) - 1 or s[j + 1] != ch):
				flag = True
				print(ch, end='')
				j += 1
				break
			if s[j] == ch and j != len(s) - 1:
				j += 2
			else:
				j += 1
	print()


for _ in range(int(input())):
	s = input()
	n = len(s)
	x = set(range(n))
	i = 0
	while i < n - 1:
		if s[i] == s[i + 1]:
			x.remove(i)
			x.remove(i + 1)
			i += 1
		i += 1
	print(''.join(sorted(set((s[i] for i in x)))))


import itertools
n = int(input())
for i in range(n):
	st = input()
	ls = itertools.groupby(st)
	res = [list(val) for (k, val) in ls]
	ans = set()
	for item in res:
		if len(item) % 2 != 0:
			ans.add(item[0])
	ls = sorted(ans)
	print(''.join(ls))


T = int(input())
for _ in range(T):
	s = input()
	t = [s[0]]
	for i in range(1, len(s)):
		if t[-1][0] == s[i]:
			t[-1] += s[i]
		else:
			t.append(s[i])
	d = {k: False for k in s}
	for k in t:
		if len(k) % 2 != 0:
			d[k[0]] = True
	ans = [k for k in d if d[k]]
	ans.sort()
	print(''.join(ans))


import sys
ip = sys.stdin

def input():
	return ip.readline().strip()
t = int(input())
for _ in range(t):
	ch_set = set()
	s = input()
	temp = set()
	count = 1
	prev = s[0]
	i = 1
	n = len(s)
	while i < n:
		if s[i] == prev:
			count += 1
		elif count & 1:
			temp.add(prev)
			prev = s[i]
			count = 1
		else:
			prev = s[i]
			count = 1
		i += 1
	if count & 1:
		temp.add(prev)
	temp = sorted(temp)
	print(''.join(temp))


def f(L):
	d = {}
	i = 0
	while i < len(L):
		if L[i] not in d:
			counter = i
			counter2 = 1
			if i != len(L) - 1:
				i = i + 1
				while i < len(L) and L[i] == L[counter]:
					counter2 = counter2 + 1
					i = i + 1
				if counter2 % 2 != 0:
					d[L[counter]] = True
			else:
				d[L[counter]] = True
		else:
			i = i + 1
	L2 = []
	for i in d:
		L2.append(i)
	L2.sort()
	s = ''
	for i in range(len(L2)):
		s = s + L2[i]
	return s
x = int(input(''))
L = []
for i in range(x):
	L.append(input(''))
for i in range(len(L)):
	print(f(L[i]))


t = int(input())
for i in range(t):
	string = list(input())
	string.append('0')
	working = set()
	i = 0
	while i < len(string):
		try:
			if string[i] == string[i + 1]:
				i += 2
			else:
				working.add(string[i])
				i += 1
		except IndexError:
			i += 1
	working = list(working)
	working.sort()
	for w in working:
		print(w, end='')
	print()


for item in [0] * int(input()):
	x = input()
	d = sorted(set(x))
	answer = ''
	for tiem in d:
		if x.count(tiem) > 2 * x.count(tiem + tiem):
			answer = answer + tiem
	print(answer)


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

def ss():
	return [x for x in input()]

def si():
	return [int(x) for x in input().split()]

def mi():
	return map(int, input().split())
for _ in range(ii()):
	s = ss()
	norep = [None]
	ok = []
	slen = len(s)
	for i in s:
		if i != norep[-1]:
			norep.append(i)
	it = 0
	for i in norep:
		icount = 0
		while it != slen and s[it] == i:
			icount += 1
			it += 1
		if icount != 0 and icount % 2 and (not i in ok):
			ok.append(i)
	ok.sort()
	print(''.join(ok))


for _ in range(int(input())):
	s = input()
	s = s.replace('aa', ' ')
	s = s.replace('bb', ' ')
	s = s.replace('cc', ' ')
	s = s.replace('dd', ' ')
	s = s.replace('ee', ' ')
	s = s.replace('ff', ' ')
	s = s.replace('gg', ' ')
	s = s.replace('hh', ' ')
	s = s.replace('ii', ' ')
	s = s.replace('jj', ' ')
	s = s.replace('kk', ' ')
	s = s.replace('ll', ' ')
	s = s.replace('mm', ' ')
	s = s.replace('nn', ' ')
	s = s.replace('oo', ' ')
	s = s.replace('pp', ' ')
	s = s.replace('qq', ' ')
	s = s.replace('rr', ' ')
	s = s.replace('ss', ' ')
	s = s.replace('tt', ' ')
	s = s.replace('uu', ' ')
	s = s.replace('vv', ' ')
	s = s.replace('ww', ' ')
	s = s.replace('xx', ' ')
	s = s.replace('yy', ' ')
	s = s.replace('zz', ' ')
	s = list(set(list(s)))
	if ' ' in s:
		s.remove(' ')
	s.sort()
	a = ''
	for i in s:
		a += i
	print(a)


n = int(input())
for ni in range(n):
	s = input()
	res = []
	count = 1
	if len(s) == 1:
		res.append(s[0])
	else:
		for i in range(len(s) - 1):
			if s[i] == s[i + 1]:
				count += 1
			else:
				if count % 2 == 1:
					if s[i] not in res:
						res.append(s[i])
				count = 1
		if s[-1] != s[-2] or count % 2 == 1:
			if s[-1] not in res:
				res.append(s[-1])
	res = sorted(list(set(res)))
	print(''.join(res))


T = int(input())
for j in range(T):
	s = input()
	arr = []
	for i in range(ord('a'), ord('z') + 1):
		b = s.count(chr(i))
		if b % 2 == 1:
			arr.append(chr(i))
		elif b == 0:
			continue
		else:
			l = 0
			flag = 0
			while s.find(chr(i), l) != -1:
				im = s.find(chr(i), l)
				l = s.find(chr(i), im + 1)
				if im + 1 != l and im != -1 and (l != -1):
					flag = 1
					break
				l += 1
			if flag == 1:
				arr.append(chr(i))
	arr.sort()
	print(''.join(arr))


from itertools import groupby
for _ in range(int(input())):
	res = set()
	for (k, v) in groupby(input()):
		if len(list(v)) % 2:
			res.add(k)
	print(''.join(sorted(res)))


import sys
input = sys.stdin.readline
N = int(input())
for _ in range(N):
	s = input()
	table = [0] * 26
	a = ord('a')
	res = []
	c = 1
	for i in range(len(s) - 1):
		if s[i] == s[i + 1]:
			c += 1
		else:
			if table[ord(s[i]) - a] % 2 == 0:
				table[ord(s[i]) - a] = c
			c = 1
	for i in range(26):
		if table[i] > 0 and table[i] % 2:
			res.append(chr(i + a))
	print(''.join(res))


t = int(input())
for i in range(t):
	s = input()
	li = []
	n = len(s)
	j = 0
	while j < n:
		st = s[j]
		if j == n - 1:
			li.append(s[j])
			j += 1
		elif st != s[j + 1]:
			li.append(s[j])
			j += 1
		else:
			j += 2
	li = list(set(li))
	li.sort()
	for k in li:
		print(k, end='')
	print()


n = int(input())
for q in range(n):
	s = input()
	last = s[0]
	ct = 1
	ans = ''
	for i in s[1:]:
		if last != i:
			if ct % 2:
				if last not in ans:
					ans += last
			ct = 0
		last = i
		ct += 1
	if ct % 2:
		if last not in ans:
			ans += last
	print(''.join(sorted(ans)))


nqueries = int(input())
outputs = []
for q in range(nqueries):
	testStr = input()
	strLen = len(testStr)
	res = ''
	ind = 0
	while ind < strLen:
		currChar = testStr[ind]
		if ind + 1 < strLen:
			if currChar == testStr[ind + 1]:
				ind += 1
			elif currChar not in res:
				res += currChar
		elif currChar not in res:
			res += currChar
		ind += 1
	sortedResLst = sorted(res)
	res = ''
	for char in sortedResLst:
		res += char
	outputs.append(res)
for o in outputs:
	print(o)


t = int(input())
for x in range(t):
	l1 = list(input())
	if len(l1) == 1:
		print(l1[0])
	elif len(l1) == 2:
		if l1[0] == l1[1]:
			print()
		else:
			c = sorted([l1[0], l1[1]])
			print(''.join(c))
	else:
		i = 0
		ans = []
		while i < len(l1):
			targ = l1[i]
			j = 1
			i += 1
			while i < len(l1) and l1[i] == targ:
				i += 1
				j += 1
			if j % 2 and targ not in ans:
				ans.append(targ)
		ans.sort()
		print(''.join(ans))


noc = int(input())
for i in range(noc):
	inputString = input()
	sequenceOfChar = 0
	lastChar = ''
	out = set([])
	for (idx, char) in enumerate(inputString):
		if char == lastChar:
			sequenceOfChar += 1
			if sequenceOfChar % 2 == 1 and len(inputString) == idx + 1:
				out.add(lastChar)
		else:
			if sequenceOfChar % 2 == 1 or len(inputString) == 1:
				out.add(lastChar)
			if len(inputString) == idx + 1:
				out.add(char)
			sequenceOfChar = 1
			lastChar = char
	print(''.join(sorted(out)))


n = int(input())
for i in range(n):
	st = input()
	st += '#'
	k = len(st)
	lastch = '.'
	lastl = 0
	able = [False for i in range(256)]
	for j in range(k):
		if st[j] != lastch:
			if lastl % 2 == 1:
				able[ord(lastch)] = True
			lastl = 1
			lastch = st[j]
		else:
			lastl += 1
	for j in range(ord('a'), ord('z') + 1):
		if able[j]:
			print(chr(j), end='')
	print()


t = int(input())
i = 0
while i < t:
	stroka = str(input())
	strOS = list(set(stroka))
	ans = []
	for j in strOS:
		Q = stroka.count(j)
		if Q % 2 == 1:
			ans.append(j)
			continue
		else:
			QQ = j
			valid = 0
			ind = stroka.index(j)
			for j in stroka[ind:]:
				if j == QQ:
					valid += 1
				elif valid % 2 == 1:
					ans.append(QQ)
					break
	answer = ''
	Q = len(ans)
	j = 0
	while j < Q:
		answer += min(ans)
		ind = ans.index(min(ans))
		del ans[ind]
		j += 1
	print(answer)
	i += 1


for _ in range(int(input())):
	alpha = dict()
	for x in range(97, 123):
		alpha[chr(x)] = 0
	s = input()
	sub = [s[0]]
	for x in s[1:]:
		if x == sub[-1][0]:
			sub[-1] += x
		else:
			sub.append(x)
	for x in sub:
		if len(x) & 1:
			alpha[x[0]] = 1
	for x in alpha:
		if alpha[x]:
			print(x, end='')
	print()


n = int(input())
for j in range(n):
	t = input()
	(s, i, count) = (set(), 0, 1)
	z = len(t)
	while i < z - 1:
		if t[i] == t[i + 1]:
			count += 1
		elif count % 2 == 1:
			s.add(t[i])
		else:
			count = 1
		i += 1
	if count % 2 == 1:
		s.add(t[-1])
	a = list(s)
	print(*sorted(a), sep='')


t = int(input())
for i in range(t):
	s = input()
	b = list(s)
	b.append(-1)
	i = 0
	a = []
	while i != len(b) - 1:
		if b[i] == b[i + 1]:
			i = i + 2
		else:
			a.append(s[i])
			i = i + 1
	x = set(a)
	print(''.join(sorted(x)))


for _ in range(int(input())):
	str = input()
	t = len(str)
	i = 0
	f = 1
	li = [0 for i in range(26)]
	di = {}
	while i < t:
		if i == t - 1:
			di[str[i]] = di.get(str[i], 0)
			break
		if str[i + 1] == str[i]:
			i += 2
		else:
			di[str[i]] = di.get(str[i], 0)
			i += 1
	lst = sorted(di.keys())
	for i in lst:
		print(i, end='')
	print()


import re
test = int(input())
while test > 0:
	test -= 1
	x = input()
	alpha = []
	for i in range(26):
		alpha.append(0)
	for i in x:
		y = ord(i) - 97
		alpha[y] += 1
	for i in range(26):
		if alpha[i] > 0:
			z = x.count(chr(97 + i) * 2)
			if z * 2 < alpha[i]:
				print(chr(97 + i), end='')
	print()


n = int(input())
while n > 0:
	n -= 1
	s = list(input())
	i = 0
	j = len(s) - 1
	f = [0] * 26
	i = 0
	while i < len(s):
		j = i
		while j + 1 < len(s) and s[j + 1] == s[i]:
			j += 1
		if (j - i) % 2 == 0:
			f[ord(s[i]) - 97] = 1
		i = j
		i += 1
	ans = ''
	for i in range(26):
		if f[i] == 1:
			ans += chr(97 + i)
	print(ans)


querys = int(input())
while querys != 0:
	query = input()
	aux = ''
	if len(query) <= 1:
		aux += query
	else:
		index = 0
		while index < len(query):
			if index != len(query) - 1:
				if query[index] != query[index + 1]:
					if query[index] not in aux:
						aux += query[index]
					index += 1
				else:
					index += 2
			else:
				if query[index] not in aux:
					aux += query[index]
				index += 1
	print(''.join(sorted(aux)))
	querys -= 1


t = int(input())
for i in range(t):
	a = input()
	a = a + ' '
	respfin = []
	passado = ' '
	valor = 0
	for i in range(len(a)):
		if a[i] == passado:
			valor += 1
		else:
			if passado not in respfin and valor & 1:
				respfin.append(passado)
			valor = 1
		passado = a[i]
	respfin.sort()
	for i in respfin:
		print(i, end='')
	print()


def broken_keyboard(s1):
	if len(s1) == 1:
		return s1
	size = len(s1)
	letters = []
	count = 0
	for i in range(size):
		if i == size - 1 or s1[i] != s1[i + 1]:
			count += 1
			if count % 2 != 0:
				letters.append(s1[i])
			count = 0
		else:
			count += 1
	letters = set(letters)
	letters = list(letters)
	letters.sort()
	result = ''
	return result.join(letters)
t = int(input())
for i in range(t):
	s1 = input()
	print(broken_keyboard(s1))


N = int(input())
for T in range(N):
	s = input()
	cnt = set()
	i = 0
	while i < len(s):
		j = i + 1
		length = 1
		while j < len(s) and s[j] == s[i]:
			j += 1
			length += 1
		if length % 2 == 1:
			cnt.add(s[i])
		i = j
	res = ''
	for i in cnt:
		res += i
	print(''.join(sorted(res)))


for u in range(int(input())):
	s = list(input())
	n = len(s)
	l = []
	for i in range(n - 1):
		if s[i] == s[i + 1]:
			s[i] = ''
			s[i + 1] = ''
	l = list(set(s))
	l.sort()
	print(''.join(l))


n = int(input())
for bla in range(n):
	word = input()
	i = 0
	result = ''
	while i < len(word) - 1:
		if word[i] == word[i + 1]:
			i = i + 2
		else:
			result = result + word[i]
			i = i + 1
	if i == len(word) - 1:
		result = result + word[len(word) - 1]
	if len(word) == 1:
		result = word
	result = ''.join(sorted(set(result), key=result.index))
	sortedString = sorted(result)
	printable = ''
	for letter in sortedString:
		printable = printable + letter
	print(printable)


from collections import Counter
t = int(input())
while t > 0:
	t -= 1
	s = input()
	l = len(s)
	tmp = []
	st = [i for i in s]
	c = Counter(st)
	k = list(c.keys())
	for x in k:
		if c[x] % 2 != 0:
			tmp.append(x)
	i = 0
	while i < l - 1:
		ch = st[i]
		if ch not in tmp:
			if st[i + 1] != ch:
				tmp.append(ch)
			else:
				i += 1
		i += 1
	tmp = sorted(tmp)
	ans = ''
	for g in range(len(tmp)):
		ans += tmp[g]
	print(ans)


t = int(input())
for _ in range(t):
	lastChar = '1'
	cnt = 0
	inp = input()
	n = len(inp)
	res = set()
	for i in range(n):
		if lastChar == inp[i]:
			cnt += 1
		else:
			if cnt % 2 == 1:
				res.add(lastChar)
			lastChar = inp[i]
			cnt = 1
		if i == n - 1 and cnt % 2 == 1:
			res.add(lastChar)
	res = sorted(res)
	print(*res, sep='')


T = int(input())
for _ in range(T):
	X = [0] * 26
	s = input()
	while s:
		if len(s) == 1:
			X[ord(s[0]) - 97] = 1
			break
		if s[0] == s[1]:
			s = s[2:]
		else:
			X[ord(s[0]) - 97] = 1
			s = s[1:]
	print(''.join([chr(97 + i) for i in range(26) if X[i]]))


t = int(input())
for case in range(t):
	s = input()
	d = {}
	p = s[0]
	c = 1
	for i in s[1:]:
		if p == i:
			c += 1
		else:
			if c % 2 == 1:
				d[p] = True
			c = 1
		p = i
	if c % 2 == 1:
		d[p] = True
	print(''.join(sorted(d.keys())))


for _ in range(int(input())):
	s = input()
	t = ''
	lc = s[0]
	cnt = 1
	for i in range(1, len(s)):
		if s[i] == lc:
			cnt += 1
		else:
			t += lc * (cnt % 2)
			lc = s[i]
			cnt = 1
	t += lc * (cnt % 2)
	print(''.join(sorted(list(set(t)))))


n = int(input())
r = []
for i in ' ' * n:
	s = input()
	m = []
	t = set()
	j = 0
	while j < len(s):
		if s[j] not in t:
			c = 1
			while j < len(s) - 1 and s[j] == s[j + 1]:
				j += 1
				c += 1
			if c % 2 == 1:
				t.add(s[j])
		j += 1
	r += [t]
for i in r:
	print(*sorted(i), sep='')


try:
	T = int(input())
	for i in range(T):
		s = input()
		l = list(s)
		l1 = []
		for i in range(len(l) - 1):
			if l[i] == l[i + 1]:
				l[i] = '1'
				l[i + 1] = '1'
		for i in l:
			if i != '1':
				l1.append(i)
		S = set(l1)
		res = ''.join(S)
		res1 = ''.join(sorted(res))
		print(res1)
except EOFError:
	pass


t = int(input())
for _ in range(t):
	a = input()
	s = set()
	b = []
	for x in a:
		if len(b) == 0:
			b.append([1, x])
		elif b[-1][1] != x:
			b.append([1, x])
		else:
			b[-1][0] += 1
	for x in b:
		if x[0] % 2 == 1:
			s.add(x[1])
	print(''.join(sorted(s)))


t = int(input())
for i in range(t):
	s = input()
	if len(s) == 1:
		print(s)
	else:
		s += 'Z'
		A = set()
		A.add('Z')
		count = 1
		for j in range(len(s) - 1):
			if count % 2 != 0 and s[j] != s[j + 1]:
				A.add(s[j])
				count = 1
			elif s[j] != s[j + 1] and s[j] != s[j - 1]:
				A.add(s[j])
				count = 1
			else:
				count += 1
		B = sorted(list(A))
		for j in B:
			if j != 'Z':
				print(j, end='')
		print()


def get(s):
	hao = set()
	c = 0
	last = '@'
	for e in s:
		if last == '@':
			last = e
			c = 1
			continue
		elif e == last:
			c += 1
		else:
			if c % 2 == 1:
				hao.add(last)
			c = 1
		last = e
	if c % 2 == 1:
		hao.add(last)
	return hao

def main():
	num = input()
	for i in range(int(num)):
		s = input()
		h = get(s)
		for e in sorted(h):
			print(e, end='')
		print('')
main()


t = int(input())
for i in range(t):
	res = input().strip()
	broken = set(res)
	j = 0
	while j < len(res):
		if j == len(res) - 1 or res[j] != res[j + 1]:
			if res[j] in broken:
				broken.remove(res[j])
		else:
			j += 1
		j += 1
	output = ''
	for char in sorted(set(res)):
		if char not in broken:
			output += char
	print(output)


t = int(input())
for a in range(t):
	x = input()
	if len(x) == 1:
		print(x)
	else:
		L = []
		k = 0
		while k < len(x):
			ch = x[k]
			c = 0
			m = k
			for b in range(m, len(x)):
				if x[b] != ch:
					break
				else:
					c += 1
					k += 1
			if c == 0:
				L.append(ch)
			if c != 0 and c % 2 == 0:
				L.append(ch * 2)
			if c != 0 and c % 2 == 1:
				L.append(ch)
		for d in range(97, 123):
			if chr(d) in L:
				print(chr(d), end='')
		print()


for _ in range(int(input())):
	s = input()
	l3 = [s[0]]
	l4 = [1]
	for i in range(1, len(s)):
		if l3[-1] == s[i]:
			l4[-1] += 1
		else:
			l3.append(s[i])
			l4.append(1)
	l = []
	for i in range(len(l3)):
		if l4[i] % 2 != 0:
			l.append(l3[i])
	print(''.join(sorted(list(set(l)))))


a = int(input())
gg = []
for i in range(a):
	a = input()
	for i in 'qwertyuiopasdfghjklzxcvbnm':
		a = a.replace(2 * i, ' ')
	a = a.replace(' ', '')
	a = set(a)
	a = list(a)
	a.sort()
	gg.append(a)
for i in gg:
	for ii in i:
		print(ii, end='')
	print()


for i in range(int(input())):
	s = input() + '-'
	j = 0
	res = ''
	while j < len(s) - 1:
		if s[j] != s[j + 1]:
			res += s[j]
			j += 1
		else:
			j += 2
	print(''.join(sorted(set(' '.join(res).split()))))


t = int(input())
for _ in range(t):
	s = input()
	s = s + '$'
	ans = set()
	prev = ''
	cnt = 2
	for x in s:
		if x != prev:
			if cnt % 2 == 1:
				ans.add(prev)
			cnt = 0
			prev = x
		cnt += 1
	ans2 = sorted(list(ans))
	print(''.join(ans2))


t = int(input())
for _ in range(t):
	a = input()
	n = []
	if len(a) == 1:
		print(a)
		continue
	i = 0
	while i < len(a):
		if a[i] not in n:
			if i == len(a) - 1:
				n.append(a[i])
				i += 1
				break
			if a[i] != a[i + 1]:
				n.append(a[i])
				i += 1
			else:
				i += 2
		else:
			i += 1
	n.sort()
	res = ''.join(n)
	print(res)


try:
	import pytest

	@pytest.mark.parametrize('items, result', [('a', 'a'), ('zzaaz', 'z'), ('ccff', ''), ('cbddbb', 'bc')])
	def test(items, result):
		assert solve(items) == result
except Exception:
	pass

def batch_gen(string: str):
	while string:
		length = 1
		char = string[0]
		try:
			while string[length] == char:
				length += 1
		except IndexError:
			pass
		yield string[0:length]
		string = string[length:]

def solve(string: str) -> str:
	chars = set()
	for batch in batch_gen(string):
		if len(batch) % 2 == 1:
			chars.add(batch[0])
	return ''.join(sorted(chars))

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


def main():
	t = int(input())
	for i in range(t):
		s = input()
		curr = s[0]
		count = 0
		ans = set()
		for j in s:
			if j == curr:
				count += 1
			else:
				if count % 2 != 0:
					ans.add(curr)
				curr = j
				count = 1
		if count % 2 != 0:
			ans.add(curr)
		ans = list(ans)
		ans.sort()
		for j in ans:
			print(j, end='')
		print()
main()


t = int(input())
b = []
for i in range(t):
	a = input()
	b.append('')
	s = []
	if len(a) > 1:
		a = list(a)
		for j in range(len(a) - 1):
			if a[j] == a[j + 1]:
				a[j] = '0'
				a[j + 1] = '0'
		for j in range(len(a)):
			if a[j] != '0' and a[j] not in b[i]:
				b[i] += a[j]
	else:
		b[i] = a[i]
	if b[i]:
		b[i] = sorted(b[i])
		b[i] = ''.join(b[i])
for i in range(len(b)):
	print(b[i])


from itertools import groupby
for i in range(int(input())):
	s = input()
	res = ''
	for (group, items) in groupby(s):
		if len(list(items)) % 2 == 1:
			res += group
	res = sorted(list(set(res)))
	print(''.join(res))


t = int(input())
for i in range(t):
	S = []
	S1 = []
	S2 = []
	j = 0
	s = input()
	for i in s:
		S.append(i)
	while j < len(s):
		if len(S) == 1:
			S1.append(S[0])
			break
		elif j == len(s) - 1:
			S1.append(S[j])
			j = j + 1
		elif S[j] == S[j + 1]:
			c = 0
			while S[j] == S[j + 1]:
				j = j + 1
				c = c + 1
				if j == len(S) - 1:
					break
			if c % 2 == 0:
				S1.append(S[j])
			j = j + 1
		else:
			S1.append(S[j])
			j = j + 1
	for m in S1:
		if m not in S2:
			S2.append(m)
	S2.sort()
	for k in S2:
		print(k, end='')
	print()


t = int(input())
for i in range(t):
	seq = input()
	letras = set()
	(j, k) = (0, 0)
	while True:
		k = k + 1
		while k < len(seq) and seq[j] == seq[k]:
			k = k + 1
		if (k - j) % 2 == 1:
			letras.add(seq[j])
		j = k
		if j >= len(seq):
			break
	print(''.join(sorted(letras)))


T = int(input())
while T:
	T -= 1
	s1 = input()
	l = len(s1)
	arr = [0 for i in range(26)]
	i = 0
	while i < l:
		key = s1[i]
		j = i + 1
		count = 1
		while j < l and s1[j] == key:
			j += 1
			count += 1
		if count % 2 == 1:
			arr[ord(key) - 97] = 1
		if j == i + 1:
			i += 1
		else:
			i = j
	for i in range(26):
		if arr[i] > 0:
			print(chr(i + 97), end='')
	print()


def func(string):
	working = []
	i = 0
	while i < len(string):
		if i == len(string) - 1:
			if string[i] not in working:
				working.append(string[i])
			break
		elif string[i] != string[i + 1]:
			if string[i] not in working:
				working.append(string[i])
			i += 1
		else:
			i += 2
	return ''.join(sorted(working))
for _ in range(int(input())):
	str = input()
	print(func(str))


q = int(input())
for i in range(q):
	s = input()
	r = set()
	i = 1
	if len(s) == 1:
		print(s)
	else:
		n = s[0]
		k = 1
		while i < len(s):
			if s[i] == n:
				k += 1
			else:
				if k % 2 != 0:
					r.add(n)
				n = s[i]
				k = 1
			i += 1
		if k % 2 != 0:
			r.add(s[len(s) - 1])
		print(*sorted(list(r)), sep='')


n = int(input())
for i in range(n):
	s = input()
	good = []
	now = 1
	last = 0
	for i in range(1, len(s)):
		if s[i] == s[i - 1]:
			now += 1
			last = i
		else:
			if now % 2 == 1:
				good.append(s[i - 1])
			now = 1
			last = i
	if s[last] not in good and now % 2 == 1:
		good.append(s[last])
	if len(s) == 1:
		print(s)
	else:
		good = set(good)
		good = list(good)
		good.sort()
		print(''.join(good))


for _ in range(int(input())):
	s = input()
	i = 0
	t = ''
	while i != len(s):
		if i != len(s) - 1 and s[i] == s[i + 1]:
			i += 2
		else:
			t = t + s[i]
			i += 1
	print(''.join(sorted(list(set(list(t))))))


t = int(input())
while t > 0:
	t -= 1
	s = input().strip()
	ans = ''
	l = len(s)
	i = 0
	if l == 1:
		print(s)
		continue
	while i < l:
		if i + 1 < l and s[i] == s[i + 1]:
			i += 1
		else:
			ans += s[i]
		i += 1
	ans = ''.join(sorted(ans))
	if ans == '':
		print()
		continue
	ans1 = ''
	ans1 += ans[0]
	a = ans1
	for i in range(1, len(ans)):
		if a != ans[i]:
			ans1 += ans[i]
			a = ans[i]
	print(ans1)


t = int(input())
for _ in range(t):
	s = input()
	ans = []
	x = 1
	for i in range(1, len(s)):
		if s[i] == s[i - 1]:
			x += 1
		else:
			if x % 2 == 1:
				ans.append(s[i - 1])
			x = 1
	if x % 2 == 1:
		ans.append(s[-1])
	ans.sort()
	ans2 = []
	for i in range(len(ans)):
		if not ans[i] in ans2:
			ans2.append(ans[i])
	print(''.join(ans2))


for i in range(int(input())):
	s = input()
	working = []
	j = 0
	while j < len(s):
		nextJ = j + 1
		while nextJ < len(s) and s[nextJ] == s[j]:
			nextJ += 1
		if (nextJ - j) % 2 == 1:
			if s[j] not in working:
				working.append(s[j])
		j = nextJ
	working.sort()
	print(''.join(working))


for _ in range(int(input())):
	s = input()
	l = []
	i = 0
	if len(s) == 1:
		print(s)
		continue
	while i < len(s) - 1:
		if s[i] == s[i + 1]:
			i += 2
		else:
			l.append(s[i])
			i += 1
	if i <= len(s) - 1:
		l.append(s[len(s) - 1])
	s = set(l)
	l = sorted(list(s))
	print(*l, sep='')


n = int(input())
a = []
for ikl in range(n):
	s = input()
	a.append(s)

def find_working(si):
	if len(si) < 2:
		return si
	(i, j) = (0, 0)
	count = 0
	res = []
	while i < len(si) and j < len(si):
		if si[i] == si[j]:
			j += 1
			count += 1
		else:
			if count % 2 != 0 and si[i] not in res:
				res.append(si[i])
			i = j
			count = 0
	if count % 2 != 0 and si[i] not in res:
		res.append(si[i])
	res.sort()
	res = ''.join(res)
	return res
for wer in range(n):
	s = a[wer]
	print(find_working(s))


T = int(input())
for _ in range(T):
	s = input()
	l = [0 for i in range(26)]
	i = 0
	while i < len(s):
		if i < len(s) - 1 and s[i] == s[i + 1]:
			i += 1
		else:
			l[ord(s[i]) - 97] = 1
		i += 1
	for i in range(26):
		if l[i] == 1:
			print(chr(97 + i), end='')
	print()


t = int(input())
for i in range(t):
	s = str(input())
	a = len(s)
	A = []
	for i in range(a):
		A.append(s[i])
	B = []
	for i in range(a - 1):
		if A[i] == A[i + 1]:
			A[i] = ' '
			A[i + 1] = ' '
	for i in range(a):
		if A[i] != ' ' and A[i] not in B:
			B.append(A[i])
	B.sort()
	B = ''.join(B)
	print(B)


import math
t = int(input())
for _ in range(t):
	s = input()
	l = [0] * 26
	curr = s[0]
	temp = s[0]
	val = 0
	for i in range(len(s)):
		if s[i] == temp:
			val += 1
		else:
			if val & 1:
				l[ord(temp) - 97] = 1
			temp = s[i]
			val = 1
	if val & 1:
		l[ord(temp) - 97] = 1
	for i in range(26):
		if l[i]:
			print(chr(i + 97), end='')
	print('')


n = int(input())
for _ in range(n):
	a = input()
	s = ''
	for i in a:
		if a.count(i) / 2 != a.count(i * 2):
			if i not in s:
				s += i
	z = list(s)
	z.sort()
	print(*z, sep='')


import sys

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

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

def oint():
	return int(input())
t = oint()
for _ in range(t):
	s = input()
	ans = set()
	cnt = 1
	for i in range(len(s) - 1):
		if s[i] == s[i + 1]:
			cnt += 1
		else:
			if cnt % 2:
				ans.add(s[i])
			cnt = 1
	if cnt % 2:
		ans.add(s[-1])
	if len(ans):
		ans = list(ans)
		ans.sort()
		print(''.join(ans))
	else:
		print()


p = int(input())
for _ in range(p):
	j = 0
	s = input()
	s += '1'
	n = len(s)
	ans = ''
	d = dict()
	while j != n - 1:
		if s[j] != s[j + 1]:
			d[s[j]] = s[j]
			j += 1
		else:
			j += 2
	l = [i for i in d]
	l = sorted(l)
	print(''.join(l))


ans = []
for _ in range(int(input())):
	s = input()
	ans.append(''.join((ch for ch in sorted(set(s)) if s.count(ch) > 2 * s.count(ch + ch))))
print(*ans, sep='\n')


def resoudreProbleme(tests):
	for test in tests:
		if len(test) != 1:
			touchesOK = []
			for i in range(1, len(test) - 1):
				if test[i - 1] != test[i] != test[i + 1] and test[i] not in touchesOK:
					touchesOK.append(test[i])
			if test[0] != test[1] and test[0] not in touchesOK:
				touchesOK.append(test[0])
			if test[-1] != test[-2] and test[0] not in touchesOK:
				touchesOK.append(test[-1])
			car = test[0]
			cpt = 1
			for i in range(1, len(test)):
				if test[i] == car:
					cpt += 1
				elif cpt % 2 == 1 and test[i] not in touchesOK:
					touchesOK.append(car)
					cpt = 1
					car = test[i]
				else:
					pass
			touchesOK.sort()
			chaine = ''
			for car in touchesOK:
				chaine += car
			print(chaine)
		else:
			print(test)

def resoudreProbleme_v2(tests):
	for test in tests:
		test += ' '
		if len(test) != 1:
			touches = []
			car = test[0]
			cpt = 1
			for i in range(1, len(test)):
				if test[i] == car:
					cpt += 1
				else:
					if cpt % 2 == 1 and car not in touches:
						touches.append(car)
					cpt = 1
					car = test[i]
			touches.sort()
			chaine = ''
			for car in touches:
				chaine += car
			print(chaine)
		else:
			print(test)
tests = []
nbTests = int(input())
for i in range(nbTests):
	tests.append(input())
resoudreProbleme_v2(tests)


t = int(input())
for i in range(t):
	s = list(str(input()))
	j = 0
	s.append('7')
	answer = []
	while j < len(s) - 1:
		if s[j] != s[j + 1]:
			answer.append(s[j])
			j += 1
		else:
			j += 2
	answer = list(set(answer))
	answer.sort()
	print(''.join(answer))


n = int(input())
for _ in range(n):
	str = input()
	prev = ','
	sec_len = 0
	ans = []
	for i in range(len(str)):
		if str[i] == prev:
			sec_len += 1
		else:
			if i != 0 and sec_len % 2 == 1:
				ans.append(str[i - 1])
			sec_len = 1
		prev = str[i]
		if i == len(str) - 1:
			if sec_len % 2 == 1:
				ans.append(str[i])
	ans_str = ''
	for c in sorted(set(ans)):
		ans_str += c
	print(ans_str)


def init():
	t = int(input())
	for i in range(t):
		input_str = input()
		working_letters = ''
		last_letter = ''
		letter_count = 0
		for j in range(len(input_str)):
			letter = input_str[j]
			if letter == last_letter:
				letter_count += 1
			else:
				if letter_count % 2 == 1 and last_letter not in working_letters:
					working_letters += last_letter
				last_letter = letter
				letter_count = 1
			if letter in working_letters:
				continue
			is_working = False
			counter = 0
			if j > 0:
				if input_str[j - 1] != letter:
					counter += 1
			else:
				counter += 1
			if j < len(input_str) - 1:
				if input_str[j + 1] != letter:
					counter += 1
			else:
				counter += 1
			if counter == 2:
				working_letters += letter
		if letter_count % 2 == 1 and last_letter not in working_letters:
			working_letters += last_letter
		working_letters = sorted(working_letters)
		print(''.join(working_letters))
init()


def removeElement(thisalist, x):
	return [i for i in thisalist if i != x]
q = int(input())
for i in range(q):
	s = input()
	x = [i for i in str(s)]
	for i in range(len(x) - 1):
		if x[i] == x[i + 1] and x[i] != 1:
			x[i] = 1
			x[i + 1] = 1
	x = removeElement(x, 1)
	x.sort()
	for i in range(len(x) - 1):
		if x[i] == x[i + 1] and x[i] != 1:
			x[i] = 1
	x = removeElement(x, 1)
	for num in x:
		print(num, end='')
	print('')


t = int(input())
for _ in range(t):
	s = list(input().strip())
	g = set()
	n = len(s)
	c = 1
	if n == 1:
		print(s[0])
	else:
		for i in range(1, n):
			if s[i] != s[i - 1] and c & 1:
				g.add(s[i - 1])
			else:
				c += 1
			if i == n - 1 and c & 1:
				g.add(s[i])
		print(''.join(sorted(list(g))))


testCases = int(input())
for i in range(testCases):
	listaAlfabetoCondicional = []
	listaAlfabeto = []
	for i in range(26):
		listaAlfabeto.append(0)
		listaAlfabetoCondicional.append(False)
	stringCase = input()
	for i in range(len(stringCase)):
		listaAlfabeto[ord(stringCase[i]) - 97] += 1
	for i in range(len(listaAlfabeto)):
		if listaAlfabeto[i] % 2 != 0:
			listaAlfabetoCondicional[i] = True
	contador = 1
	for i in range(1, len(stringCase)):
		if stringCase[i] != stringCase[i - 1]:
			if contador % 2 != 0:
				listaAlfabetoCondicional[ord(stringCase[i - 1]) - 97] = True
			contador = 1
		else:
			contador += 1
	for i in range(len(listaAlfabetoCondicional)):
		if listaAlfabetoCondicional[i] == True:
			print(chr(i + 97), end='')
	print('')


for _ in range(int(input())):
	s = input()
	n = len(s)
	d = {}
	(z, i) = (0, 0)
	while i <= n:
		if i == 0:
			z = 1
			i += 1
		elif i == n:
			if z % 2 == 1:
				d[s[i - 1]] = True
			i += 1
		elif s[i] == s[i - 1]:
			z += 1
			i += 1
		elif s[i] != s[i - 1]:
			if z % 2 == 1:
				d[s[i - 1]] = True
			z = 1
			i += 1
	r = ''.join(sorted(list(d.keys())))
	print(r)


numberTestCases = int(input())
allWorkingCharactersLists = []
for test in range(numberTestCases):
	guaranteedWorkingCharactersPerCase = []
	testString = input() + ' '
	for i in range(1, len(testString) - 1):
		previousCharacter = testString[i - 1]
		if testString[i] == previousCharacter:
			testStringList = list(testString)
			testStringList[i] = ' '
			testStringList[i - 1] = ' '
			testString = ''.join(testStringList)
	for character in testString:
		if character != ' ' and character not in guaranteedWorkingCharactersPerCase:
			guaranteedWorkingCharactersPerCase.append(character)
	allWorkingCharactersLists.append(guaranteedWorkingCharactersPerCase)
for characterList in allWorkingCharactersLists:
	characterList.sort()
	if characterList == []:
		characterList.append('')
	answer = ''.join(characterList)
	print(answer)


t = int(input())
for _ in range(t):
	s = input()
	isValid = [-1] * 26
	n = len(s)
	i = 0
	while i < n - 1:
		x = ord(s[i]) - 97
		count = 0
		j = i
		while i < n and s[i] == s[j]:
			i += 1
			count += 1
		if count % 2 == 1:
			isValid[x] = 1
	if n == 1 or s[n - 1] != s[n - 2]:
		x = ord(s[n - 1]) - 97
		isValid[x] = 1
	ans = ''
	for i in range(26):
		if isValid[i] == 1:
			l = chr(97 + i)
			ans += l
	print(ans)


from collections import Counter
num_tests = int(input())
for _ in range(num_tests):
	s = input()
	not_broken = set()
	i = 0
	while i < len(s):
		if i == len(s) - 1 or s[i] != s[i + 1]:
			not_broken.add(s[i])
		else:
			i += 1
		i += 1
	not_broken = sorted(not_broken)
	print(''.join(not_broken))


n = int(input())
for g in range(n):
	l = input()
	ans = []
	c = l[0]
	fl = 1
	for i in range(1, len(l)):
		if l[i] == c:
			fl += 1
		else:
			if fl % 2 == 1 and (not c in ans):
				ans.append(c)
			c = l[i]
			fl = 1
	if fl % 2 == 1 and (not c in ans):
		ans.append(c)
	ans.sort()
	for i in ans:
		print(i, end='')
	print()


t = int(input())
for _ in range(t):
	s = input()
	dup = []
	for i in range(0, len(s) - 1):
		if s[i] == s[i + 1] and s[i] not in dup:
			dup.append(s[i])
	res = []
	for i in range(len(dup)):
		sel = ''
		sel = dup[i] + dup[i]
		if s.count(dup[i]) == 2 * s.count(sel):
			res.append(dup[i])
	li = []
	for i in range(len(s)):
		li.append(s[i])
	ans = sorted(set(li) - set(res))
	f = ''
	for i in ans:
		f += i
	print(f)


def fun(arr):
	arr.append(-1)
	check = []
	i = 0
	while i < len(arr) - 1:
		if arr[i] == arr[i + 1]:
			i += 2
		else:
			check.append(arr[i])
			i += 1
	check = list(set(check))
	print(''.join(sorted(check)))
t = int(input())
for _ in range(t):
	text = input('')
	text = list(text)
	fun(text)


t = int(input())
for ts in range(t):
	s = input()
	a = 0
	ar = []
	i = 0
	ls = ''
	while i < len(s):
		k = 1
		while i + k <= len(s):
			p = s[i:i + k]
			if len(set(list(p))) != 1:
				break
			else:
				k += 1
		if k % 2 == 0:
			ar.append(s[i])
		i += k - 1
	for i in sorted(set(ar)):
		ls += i
	print(ls)


n = int(input())
while n > 0:
	s = list(input())
	for i in range(len(s) - 1):
		if s[i] == s[i + 1]:
			s[i] = ''
			s[i + 1] = ''
	s = list(set(s))
	s.sort()
	print(''.join(s))
	n = n - 1


n = int(input())
for i in range(n):
	s = input()
	j = 0
	res = set()
	while j < len(s):
		if j == len(s) - 1 or s[j] != s[j + 1]:
			res.add(s[j])
			j += 1
		else:
			j += 2
	res = sorted(res)
	for x in res:
		print(x, end='')
	print()


def string_checker(s):
	if len(set(s)) == len(s):
		return ''.join(sorted(s))
	else:
		ans = []
		same = 0
		s += '0'
		for x in range(len(s) - 1):
			if same == 0:
				if s[x] != s[x + 1]:
					ans.append(s[x])
				else:
					same = 1
			else:
				same = 0
		return ''.join(sorted(set(ans)))
t = int(input())
q = []
for i in range(t):
	q.append(input())
for x in q:
	print(string_checker(x))


for nt in range(int(input())):
	s = input()
	n = len(s)
	if n == 1:
		print(s[0])
		continue
	g = [[s[0], 1]]
	prev = s[0]
	for i in range(1, n):
		if s[i] == prev:
			g[-1][1] += 1
		else:
			prev = s[i]
			g.append([prev, 1])
	ans = []
	for i in g:
		if i[1] % 2:
			ans.append(i[0])
	ans = list(set(ans))
	ans.sort()
	for i in ans:
		print(i, end='')
	print()


t = int(input())
for i in range(t):
	s = input()
	s = list(s)
	k = ''
	res = []
	if len(s) > 1:
		for j in range(len(s) - 1):
			if s[j] == s[j + 1]:
				k += s[j]
				s[j] = s[j + 1] = '0'
		fin = ''
		s.sort()
		for j in range(len(s)):
			if s[j].isalpha():
				if s[j] not in fin:
					fin += s[j]
		print(fin)
	else:
		print(s[0])


for _ in range(int(input())):
	s = input()
	n = len(s)
	a = []
	if n == 1:
		print(s[0])
		continue
	i = 0
	while i < n:
		if i + 1 >= n:
			break
		if s[i] == s[i + 1]:
			i += 2
			continue
		a.append(s[i])
		i += 1
	i = n - 1
	k = 0
	while i >= 0:
		if i - 1 >= 0:
			if s[i] == s[i - 1]:
				k += 1
			else:
				break
		i -= 1
	if not k & 1:
		a.append(s[n - 1])
	a = list(set(a))
	a.sort()
	for i in range(len(a)):
		print(a[i], end='')
	print()


from collections import defaultdict
for _ in range(int(input())):
	s = list(input())
	j = 0
	while j < len(s):
		if j + 1 < len(s) and s[j] == s[j + 1]:
			s.pop(j)
			s.pop(j)
		else:
			j += 1
	s = list(set(s))
	s.sort()
	print(''.join(s))


t = int(input())
for i in range(t):
	a = input()
	b = [0] * 26
	c = len(a)
	d = []
	e = 1
	for j in range(c - 1):
		if a[j] == a[j + 1]:
			e = e + 1
		else:
			d.append([e, a[j]])
			e = 1
	d.append([e, a[c - 1]])
	e = []
	for j in range(len(d)):
		if d[j][0] % 2 != 0:
			e.append(d[j][1])
	print(''.join(sorted(set(e))))


t = int(input())
while t > 0:
	s = input()
	n = len(s)
	l = list(s)
	for i in range(n - 1):
		if l[i] == l[i + 1] and l[i] != '0':
			l[i] = '0'
			l[i + 1] = '0'
	l = sorted(list(set(l)))
	for i in range(len(l)):
		if l[i] != '0':
			print(l[i], end='')
	print()
	t -= 1


t = int(input())
while t:
	t -= 1
	s = input()
	freq = {}
	for c in s:
		if c in freq:
			freq[c] += 1
		else:
			freq[c] = 1
	ans = ''
	for c in s:
		if freq[c] == 0:
			continue
		if freq[c] % 2:
			ans += c
			freq[c] = 0
		else:
			find = s.count(2 * c)
			if find * 2 != freq[c]:
				ans += c
				freq[c] = 0
	ans = sorted(ans)
	print(''.join(ans))


t = int(input())
for t1 in range(t):
	s = input()
	if len(s) == 1:
		print(s)
	else:
		s1 = set()
		(x, c) = (s[0], 0)
		for i in s:
			if i == x:
				c += 1
			else:
				if c % 2 != 0:
					s1.add(x)
				x = i
				c = 1
		if c % 2 != 0:
			s1.add(x)
		l1 = list(s1)
		l1.sort()
		print(''.join(l1))


t = int(input())

def run_length_compress(string):
	string = string + '@'
	n = len(string)
	begin = 0
	end = 1
	cnt = 1
	ans = []
	while True:
		if end >= n:
			break
		if string[begin] == string[end]:
			end += 1
			cnt += 1
		else:
			ans.append((cnt, string[begin]))
			begin = end
			end = begin + 1
			cnt = 1
	return ans
for _ in range(t):
	s = input()
	r = run_length_compress(s)
	memo = {}
	for (i, char) in r:
		if i % 2 == 1:
			memo[char] = 1
	ans = []
	for i in memo:
		ans.append(i)
	ans = sorted(ans)
	print(''.join(ans))


from sys import stdin
n = int(stdin.readline().strip())
for i in range(n):
	s = stdin.readline().strip()
	can = [False for i in range(26)]
	x = 1
	for i in range(1, len(s)):
		if s[i] != s[i - 1]:
			if x % 2 != 0:
				can[ord(s[i - 1]) - 97] = True
			x = 1
		else:
			x += 1
	if x % 2 != 0:
		can[ord(s[-1]) - 97] = True
	ans = ''
	for i in range(26):
		if can[i] == True:
			ans += chr(97 + i)
	print(ans)


def correct(string):
	ans = ''
	for i in set(string):
		string = string.replace(2 * i, ' ')
		if i in set(string):
			ans += i
	return ''.join(sorted(ans))
t = int(input())
for i in range(t):
	string = input()
	print(correct(string))


a = int(input())
k = 0
while k < a:
	l = input()
	c = l[0]
	p = 1
	out = []
	for i in range(1, len(l)):
		if l[i] == c:
			p = p + 1
		else:
			if not p % 2 == 0:
				out.append(c)
			p = 1
			c = l[i]
	if not p % 2 == 0:
		out.append(c)
	out.sort()
	if len(out) > 0:
		w = out[0]
		print(w, end='')
		for i in range(1, len(out)):
			if not out[i] == out[i - 1]:
				print(out[i], end='')
	print(end='\n')
	k = k + 1


t = int(input())
res = []
for i in range(t):
	s = input()
	dict = {}
	for j in s:
		dict[j] = False
	for k in dict:
		count = 0
		for l in range(len(s)):
			if s[l] == k:
				count += 1
				if len(s) == l + 1 and count % 2 == 1:
					dict[k] = True
			else:
				if count != 0 and count % 2 == 1:
					dict[k] = True
					break
				count = 0
	retorno = []
	for j in dict:
		if dict[j] == True:
			retorno.append(j)
	retorno = sorted(retorno)
	res.append(''.join(retorno))
for i in res:
	print(i)


n = int(input())
while n > 0:
	n -= 1
	s = input()
	ans = set()
	i = 0
	while i < len(s):
		if i == len(s) - 1:
			ans.add(s[i])
		elif s[i] == s[i + 1]:
			i += 1
		else:
			ans.add(s[i])
		i += 1
	print(''.join(map(str, sorted(ans))))


for _ in range(int(input())):
	s = input() + ' '
	ans = []
	i = 0
	while i + 1 < len(s):
		if s[i] != s[i + 1]:
			if s[i] not in ans:
				ans.append(s[i])
		else:
			i += 1
		i += 1
	print(*sorted(ans), sep='')


for k in range(int(input())):
	L = []
	a = []
	ch = input() + '\x00'
	a = [ch[0]]
	for i in range(len(ch) - 1):
		if ch[i] == ch[i + 1]:
			a += [ch[i]]
		else:
			L.append(a)
			a = [ch[i + 1]]
	res = []
	for i in L:
		if len(i) % 2 != 0:
			res += i[0]
	print(''.join(sorted(list(set(res)))))


t = int(input())
for _ in range(t):
	s = input()
	if len(s) == 1:
		print(s)
		continue
	s = s + '0'
	r = s[0]
	p = ''
	for i in range(1, len(s)):
		if s[i] in r:
			r = r + s[i]
		else:
			if len(r) % 2 != 0:
				if r[0] not in p:
					p += r[0]
			r = s[i]
	x = sorted(p)
	c = ''.join(x)
	print(c)


t = int(input())
for i in range(t):
	s = input()
	j = 0
	res = set()
	l = len(s)
	if l == 1:
		print(s)
		continue
	while j < l:
		if j == l - 1:
			res.add(s[j])
			j += 1
			continue
		if s[j] == s[j + 1]:
			j += 1
		else:
			res.add(s[j])
		j += 1
	res = list(res)
	res.sort()
	a = ''
	for x in res:
		a += x
	print(a)


w = 'abcdefghijklmnopqrstuvwxyz'
for i in range(int(input())):
	s = input()
	s1 = ''
	s2 = ''
	if len(s) == 1:
		print(s)
	else:
		q = 0
		for e in range(len(s)):
			if e >= q:
				n = 0
				a = s[e]
				q = e
				while q < len(s) and s[q] == a:
					n = n + 1
					q = q + 1
				if n % 2 != 0 and a not in s1:
					s1 = s1 + a
		for e in w:
			if e in s1:
				s2 = s2 + e
		print(s2)


def main(a):
	index = 0
	a2 = ''
	a3 = ''
	c = 'abcdefghijklmnopqrstuvwxyz'
	while index < len(a):
		if index == len(a) - 1:
			a2 = a2 + a[index]
			break
		if a[index] != a[index + 1]:
			a2 = a2 + a[index]
			index = index + 1
			continue
		index = index + 2
	index = 0
	while index < len(c):
		if c[index] in a2:
			a3 = a3 + c[index]
		index = index + 1
	return a3
t = int(input())
for t_itr in range(t):
	a = input()
	res = main(a)
	print(res)


test = int(input())
for i in range(test):
	s = input()
	ans = set()
	i = 0
	while i != len(s):
		count = 1
		while i + 1 < len(s) and s[i] == s[i + 1]:
			count += 1
			i += 1
		if count % 2 == 1:
			ans.add(s[i])
		i += 1
	print(''.join(sorted(ans)))


t = int(input())
while t:
	t -= 1
	s = input()
	i = 0
	if len(s) == 1:
		print(s)
		continue
	ans = []
	while i < len(s) - 1:
		if s[i] != s[i + 1]:
			ans += [s[i]]
			i += 1
		else:
			i += 2
	if i == len(s) - 1:
		ans += [s[i]]
	print(''.join(sorted(set(ans))))


def getCorrectlyKeys(s):
	i = 0
	res = ''
	while i < len(s):
		if i == len(s) - 1:
			if s[i] not in res:
				res += s[i]
		elif s[i] == s[i + 1]:
			i += 1
		elif s[i] not in res:
			res += s[i]
		i += 1
	return ''.join(sorted(res))
t = int(input())
result = ''
for i in range(t):
	s = input()
	r = getCorrectlyKeys(s)
	result += r + '\n'
print(result)


for _ in range(int(input().strip())):
	s = input().strip()
	p = set()
	i = 0
	pre = s[0]
	pre_c = 0
	while i < len(s):
		if s[i] == pre:
			pre_c += 1
		else:
			if pre_c % 2 == 1:
				p.add(pre)
			pre = s[i]
			pre_c = 1
		i += 1
	if pre_c % 2 == 1:
		p.add(pre)
	print(*sorted(p), sep='')


t = int(input())
for _ in range(t):
	c = [False for i in range(26)]
	s = input()
	n = len(s)
	if n == 1:
		print(s)
	else:
		i = 0
		a = ['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']
		ans = []
		while i < n - 1:
			if s[i] == s[i + 1]:
				i += 2
			else:
				c[ord(s[i]) - ord('a')] = True
				i += 1
		if i == n - 1:
			c[ord(s[i]) - ord('a')] = True
		for i in range(26):
			if c[i] == True:
				ans.append(a[i])
		print(''.join(map(str, ans)))


n = int(input())
while n:
	n -= 1
	m = input()
	i = 0
	if len(m) == 1:
		print(m)
	else:
		s = m
		l = [1]
		for i in range(1, len(s)):
			if s[i] == s[i - 1]:
				l[-1] += 1
			else:
				l.append(1)
		c = []
		ss = 0
		for i in l:
			ss += i
			if i % 2 != 0:
				c.append(s[ss - 1])
		c = list(set(c))
		c = sorted(c)
		print(''.join(c))


def solve(s):
	r = ''
	t = s[0]
	for v in s[1:] + ' ':
		if v != t:
			if len(t) == 1:
				r += t
			t = v
		else:
			t += v
	return ''.join(sorted(set(r)))
for _ in range(int(input())):
	print(solve(input()))


t = int(input())
while t:
	str = input()
	res = set()
	if len(str) == 1:
		print(str)
	else:
		i = 0
		n = len(str)
		while i < n:
			c = 0
			ch = str[i]
			while i < n and str[i] == ch:
				c += 1
				i += 1
			if c % 2 != 0:
				res.add(ch)
		if str[n - 1] != str[n - 2]:
			res.add(str[n - 1])
		res = sorted(res)
		ans = ''.join(res)
		print(ans)
	t -= 1


t = int(input())
for i in range(t):
	y = []
	x = input()
	temp = x[0]
	if len(x) == 1:
		y.append(temp)
	else:
		for i in range(1, len(x)):
			if x[i] == temp[-1]:
				temp = temp + x[i]
				if i == len(x) - 1:
					y.append(temp)
			else:
				y.append(temp)
				temp = x[i]
				if i == len(x) - 1:
					y.append(temp)
	result = {}
	for j in y:
		if len(j) % 2 == 1:
			result[j[0]] = 1
	print(''.join(sorted(list(result.keys()))))


from sys import stdin
from itertools import groupby

def solve(s):
	return ''.join(sorted(set(map(lambda p: str(p[0]), filter(lambda p: len(list(p[1])) & 1, groupby(s))))))
input()
for line in stdin:
	print(solve(line.strip()))


rows = int(input())
for i in range(rows):
	row = input()
	i = 0
	count = 0
	working = set()
	while i < len(row) - 1:
		if row[i] == row[i + 1]:
			count = 2
			i += 1
			while i < len(row) - 1 and row[i] == row[i + 1]:
				count += 1
				i += 1
			if count % 2 != 0:
				working.add(row[i - 1])
			i += 1
		else:
			working.add(row[i])
			i += 1
	if len(row) >= 2:
		if row[-1] != row[-2]:
			working.add(row[-1])
	else:
		working.add(row[0])
	res = sorted(list(working))
	print(''.join(res))


t = int(input())
from collections import defaultdict
for _ in range(t):
	s = input() + 'Q'
	n = len(s) - 1
	dc = defaultdict(int)
	ans = set()
	dc[s[0]] = 1
	for i in range(1, n + 1):
		if s[i - 1] == s[i]:
			dc[s[i]] += 1
		else:
			if dc[s[i - 1]] % 2:
				ans.add(s[i - 1])
			dc[s[i]] = 1
	ans = list(ans)
	ans.sort()
	print(''.join(ans))


for _ in range(int(input())):
	d = {}
	s = input()
	l = list(s)
	i = 0
	while i < len(l):
		try:
			d[l[i]] += 1
		except:
			d[l[i]] = 1
		i += 1
	p = set(d)
	for i in d:
		if d[i] % 2 == 0 and s.count(f'{i * 2}') == d[i] / 2:
			p.remove(i)
	l = list(p)
	l.sort()
	print(*l, sep='')


a = int(input())
for _ in range(a):
	s = input()
	li = ''
	alpha = 'abcdefghijklmnopqrstuvwxyz'
	for i in alpha:
		one = s.count(i)
		two = s.count(i + i)
		if one - two * 2:
			li += i
	print(li)


for _ in range(int(input())):
	s = input()
	res = set()
	i = 1
	curr = s[0]
	curr_cnt = 1
	while i < len(s):
		if s[i] == curr:
			curr_cnt += 1
		else:
			if curr_cnt % 2:
				res.add(curr)
			curr_cnt = 1
			curr = s[i]
		i += 1
	if curr_cnt % 2:
		res.add(curr)
	res = list(res)
	res.sort()
	print(*res, sep='')


n = int(input())
s = ''
for j in range(n):
	s = input()
	for i in range(len(s) - 1):
		if s[i] == s[i + 1]:
			tmp = s[i] + s[i + 1]
			s = s.replace(tmp, '..')
	s = s.replace('..', '')
	l = [str(l) for l in s]
	l = set(l)
	m = [str(m) for m in l]
	m.sort()
	result = ''
	for i in m:
		result += i
	print(result)


t = int(input())
while t > 0:
	s = input()
	n = len(s)
	i = 0
	count = 1
	my = []
	ans = ''
	if n == 1:
		my.append(1)
	else:
		while i < n - 1:
			if s[i] == s[i + 1]:
				count += 1
				if i == n - 2:
					my.append(count)
			else:
				if i == n - 2:
					my.extend([count, 1])
				else:
					my.append(count)
				count = 1
			i += 1
	a = len(my)
	i = 0
	j = 0
	while j < a:
		if my[j] % 2 != 0:
			ans += s[i]
		i += my[j]
		j += 1
	final = []
	for i in range(27):
		final.append('')
	for each in ans:
		final[ord(each) - 97] = each
	new = ''
	for each in final:
		new += each
	print(new)
	t -= 1


t = int(input())
for _ in range(t):
	s = input()
	l = len(s)
	ans = []
	j = 0
	while j < l:
		if j + 1 == l:
			ans.append(s[j])
			break
		if s[j] == s[j + 1]:
			j += 2
			continue
		ans.append(s[j])
		j += 1
	ans = sorted(set(ans))
	print(''.join(ans))


for _ in range(int(input())):
	s = input()
	state = [0] * 26
	i = 0
	count = 1
	f = 0
	while i < len(s) - 1:
		if s[i] == s[i + 1]:
			rec = s[i]
			count += 1
			f = 1
		else:
			if count % 2 == 1:
				state[ord(s[i]) - 97] = 1
			f = 0
			count = 1
		i += 1
	if count % 2 == 1 and i > 0:
		state[ord(s[i]) - 97] = 1
	if f == 0:
		if count % 2 == 1:
			state[ord(s[i]) - 97] = 1
	st = ''
	for (i, val) in enumerate(state):
		if val == 1:
			st += chr(i + 97)
	print(st)


from sys import stdin
from collections import defaultdict
for _ in range(int(stdin.readline())):
	S = stdin.readline().rstrip()
	alpha = defaultdict(lambda : False)
	alpha[S[0]] = False
	cnt = 1
	for i in range(1, len(S)):
		if S[i] == S[i - 1]:
			cnt += 1
		else:
			if cnt % 2 != 0:
				alpha[S[i - 1]] = True
			cnt = 1
	if cnt % 2 != 0:
		alpha[S[-1]] = True
	res = ''
	for ch in sorted(list(alpha.keys())):
		if alpha[ch]:
			res += ch
	print(res)


try:
	t = int(input())
	for ts in range(t):
		s = input()
		if len(s) == 1:
			print(s)
		else:
			i = 0
			j = 1
			res = []
			while 1:
				if s[i] == s[j]:
					if j == len(s) - 1:
						break
					i = j + 1
					if i == len(s) - 1:
						res.append(s[i])
						break
					j = i + 1
				else:
					res.append(s[i])
					i = j
					if i == len(s) - 1:
						res.append(s[i])
						break
					j = i + 1
			res.sort()
			fres = ''
			for lt in res:
				if lt not in fres:
					fres += lt
			print(fres)
except:
	pass


for _ in range(int(input())):
	s = list(input())
	res = []
	c = 0
	i = 0
	while i < len(s) - 1:
		if s[i] == s[i + 1]:
			i += 2
			c += 2
		else:
			res.append(s[i])
			c += 1
			i += 1
	if c == len(s) - 1:
		res.append(s[-1])
	res = list(set(res))
	res.sort()
	print(''.join((i for i in res)))


tc = int(input())
for _ in range(tc):
	s = input()
	res = set()
	i = 0
	while i < len(s):
		j = i + 1
		while j < len(s) and s[i] == s[j]:
			j += 1
		if j - i & 1:
			res.add(s[i])
		i = j
	print(''.join(sorted(res)))


import sys
t = int(sys.stdin.readline())
for _ in range(t):
	s = sys.stdin.readline()[:-1]
	ans = set()
	n = len(s)
	res = ''
	prev = ''
	count = 0
	for i in range(n):
		if s[i] != prev:
			if count % 2 != 0:
				ans.add(prev)
			count = 1
			prev = s[i]
		else:
			count += 1
	if count % 2 != 0:
		ans.add(prev)
	l = list(ans)
	l.sort()
	for i in l:
		res = res + i
	print(res)


t = int(input())
for i in range(t):
	seq = str(input())
	seq += '-'
	ant = seq[0]
	count = 1
	working = []
	length = len(seq)
	for i in range(1, length):
		c = seq[i]
		if c == ant:
			count += 1
		else:
			if count % 2 == 1 and ant not in working:
				working.append(ant)
			count = 1
		ant = c
	working.sort()
	print(''.join(working))


n = int(input())
while n:
	s = list(str(input()))
	ln = len(s)
	c = ''
	if ln == 1:
		print(s[0])
	else:
		k = 0
		while k <= ln - 1:
			if k + 1 != ln and s[k] == s[k + 1]:
				k += 2
			else:
				c += s[k]
				k += 1
		print(''.join(sorted(list(''.join(set(c))))))
	n -= 1


t = int(input())
for i in range(t):
	string = input()
	correct = {}
	if len(string) == 1:
		correct[string[0]] = 1
	else:
		n = len(string)
		count = 1
		for j in range(1, n):
			if string[j] == string[j - 1]:
				count += 1
			else:
				if count % 2 == 1:
					count = 1
					correct[string[j - 1]] = 1
				if count % 2 == 0:
					count = 1
					if string[j - 1] not in correct:
						correct[string[j - 1]] = -1
		if count % 2 == 0 and string[j - 1] not in correct:
			correct[string[j - 1]] = -1
		if count % 2 == 1:
			correct[string[n - 1]] = 1
	results = []
	for i in correct.keys():
		if correct[i] == 1:
			results.append(i)
	results.sort()
	for i in results:
		print(i, end='')
	print()
	del correct, results


t = int(input())
i = 0
while i < t:
	s = input()
	s = list(s)
	s.append(0)
	j = 0
	k = []
	while j < len(s) - 1:
		if s[j] != s[j + 1]:
			k.append(s[j])
			j += 1
		elif s[j] == s[j + 1]:
			j += 2
	k.sort()
	j = []
	for d in k:
		if d not in j:
			j.append(d)
	print(''.join(j))
	i += 1


t = int(input())
for j in range(t):
	s = input()
	s = list(s)
	i = 0
	while i < len(s) - 1:
		if s[i] == s[i + 1]:
			del s[i]
			del s[i]
		else:
			i += 1
	s = set(s)
	s = list(s)
	s = sorted(s)
	s = ''.join(s)
	print(s)


for _ in range(int(input())):
	s = input()
	if len(s) == 1:
		print(s)
	else:
		res = set()
		i = 1
		prev_s = s[0]
		counter = 1
		while i < len(s):
			if prev_s == s[i]:
				counter += 1
				i += 1
			elif prev_s != s[i]:
				if counter % 2 == 0:
					prev_s = s[i]
				else:
					res.add(prev_s)
					prev_s = s[i]
				i += 1
				counter = 1
		if counter % 2 == 1:
			res.add(prev_s)
		print(''.join(sorted(res)))


from collections import defaultdict as dc
from collections import deque as dq
from bisect import bisect_left, bisect_right, insort_left
import sys
import math
mod = 10 ** 9 + 7

def bs(a, x):
	i = bisect_left(a, x)
	if i != len(a):
		return i
	else:
		return len(a)

def inp():
	p = int(input())
	return p

def line():
	p = list(map(int, input().split()))
	return p

def bs(a, b):
	l = a
	r = b + 1
	x = b
	ans = 0
	while l < r:
		mid = (l + r) // 2
		if x | mid > ans:
			ans = x | mid
			l = mid + 1
		else:
			r = mid
	return ans

def bsl(a, b):
	l = a
	r = b + 1
	x = b
	ans = 0
	while l < r:
		mid = (l + r) // 2
		if x | mid > ans:
			ans = x | mid
			r = mid - 1
		else:
			l = mid + 1
	return ans
for _ in range(int(input())):
	s = str(input())
	n = len(s)
	q = dc(str)
	if n == 1:
		print(s)
	else:
		p = ''
		i = 0
		k = 0
		while i < n:
			c = 1
			if i + 1 < n:
				while i + 1 < n and s[i] == s[i + 1]:
					i += 1
					c += 1
				if c % 2 != 0:
					p = p + s[i]
			i += 1
		if c == 1 and s[n - 1] == s[n - 2]:
			c += 1
		if c % 2 != 0:
			p = p + s[n - 1]
		p = sorted(list(set(p)))
		print(''.join(p))


for _ in range(int(input())):
	s = input()
	l = len(s)
	i = 0
	e = []
	while i < l:
		j = i + 1
		c = 1
		while j < l:
			if s[i] == s[j]:
				c += 1
			else:
				break
			j += 1
		if c & 1:
			e.append(s[i])
		i += c
	e = sorted(list(set(e)))
	print(''.join(e))


n = int(input())
for _ in range(n):
	s = input() + ' '
	ans = set()
	cnt = 1
	for idx in range(1, len(s)):
		if s[idx - 1] == s[idx]:
			cnt += 1
		else:
			if cnt % 2 == 1:
				ans.add(s[idx - 1])
			cnt = 1
	print(''.join(sorted(ans)))


t = int(input())
for i in range(t):
	correct = set()
	s = input()
	n = len(s)
	if n == 1:
		print(s)
		continue
	if s[0] != s[1]:
		correct.add(s[0])
	if s[-1] != s[-2]:
		correct.add(s[-1])
	occ = [1] * n
	for j in range(1, n - 1):
		if s[j] != s[j - 1] and s[j] != s[j + 1]:
			correct.add(s[j])
		if s[j] == s[j - 1]:
			occ[j] = occ[j - 1] + 1
	if s[-1] == s[-2]:
		occ[-1] = occ[-2] + 1
	for j in range(n):
		if occ[j] % 2 == 1 and occ[j] != 1 and (j == n - 1 or occ[j + 1] == 1):
			correct.add(s[j])
	correct = list(correct)
	correct.sort()
	result = ''
	for j in correct:
		result += j
	print(result)


tt = int(input())
for _ in range(tt):
	s = input()
	n = len(s)
	s1 = []
	i = 0
	while i <= n - 1:
		if i == n - 1 or s[i] != s[i + 1]:
			s1.append(s[i])
			i += 1
		else:
			i += 2
	s1 = list(set(s1))
	s1.sort()
	for i in s1:
		print(i, end='')
	print()


t = int(input())
for i in range(t):
	s1 = ''
	s = input()
	ch = s[0]
	n = 0
	for i in s:
		if i != ch:
			if n % 2 == 1 and (not ch in s1):
				s1 += ch
			n = 1
			ch = i
		else:
			n += 1
	if n % 2 == 1 and (not ch in s1):
		s1 += ch
	print(''.join(sorted([i for i in s1])))


n = int(input())
for _ in range(n):
	A = [x for x in input()]
	A.append(None)
	B = set()
	for i in A:
		B.add(i)
	D = set()
	for i in B:
		temp = 0
		for j in range(len(A) - 1):
			if A[j] == i:
				if A[j] == i and A[j + 1] == i:
					temp += 1
				elif temp % 2 == 0:
					D.add(i)
					break
			else:
				temp = 0
	res = sorted(list(D))
	for i in res:
		print(i, end='')
	print()


t = int(input())
for i in range(t):
	s = input()
	hash1 = [0 for i in range(26)]
	i = 0
	while i < len(s):
		if i != len(s) - 1 and s[i] == s[i + 1]:
			i += 2
		else:
			hash1[ord(s[i]) - ord('a')] += 1
			i += 1
	for i in range(26):
		if hash1[i] > 0:
			print(chr(i + ord('a')), end='')
	print()


import sys, math
input = sys.stdin.readline
t = int(input())
for i in range(t):
	a = list(input())
	c = 1
	q = []
	for i in range(len(a) - 1):
		if a[i] == a[i + 1]:
			c = c + 1
		elif c % 2 != 0:
			q.append(a[i])
			c = 1
		else:
			c = 1
	q = list(set(q))
	q.sort()
	print(''.join(q))


l = []
for i in range(int(input())):
	x = input().upper()
	ly = ''
	for i in range(65, 91):
		ch = chr(i)
		if x.replace(ch + ch, '').find(ch) != -1:
			ly += ch.lower()
	l.append(ly)
print('\n'.join(l))


n = int(input())
for _ in range(n):
	s = input()
	good_letters = set()
	current_letter = '0'
	counter = 0
	s = s + '0'
	for l in s:
		if l == current_letter:
			counter += 1
		else:
			if counter % 2 != 0:
				good_letters.add(current_letter)
			current_letter = l
			counter = 1
	print(''.join(sorted(good_letters)))


q = int(input())
for re in range(q):
	s = input()
	dob = set()
	n = len(s)
	s = '0' + s + '0'
	i = 1
	while i < n + 2:
		pocz = s[i]
		i += 1
		dupa = 1
		while True:
			if i == n + 2:
				break
			if s[i] == pocz:
				dupa += 1
				i += 1
			else:
				break
		if dupa % 2 == 1:
			dob.add(pocz)
	l = []
	for i in dob:
		if i != '0':
			l.append(i)
	l.sort()
	if len(l) == 0:
		print('')
	else:
		for i in range(len(l)):
			if i < len(l) - 1:
				print(l[i], end='')
			else:
				print(l[i])


import sys, math, queue, collections
MOD = 10 ** 9 + 7
for _ in range(int(input())):
	s = input() + '-'
	dp = [1 for i in range(len(s))]
	ans = set()
	for i in range(1, len(s)):
		if s[i] == s[i - 1]:
			dp[i] += dp[i - 1]
		elif dp[i - 1] % 2 == 1:
			ans.add(s[i - 1])
	print(''.join(sorted(ans)))


t = int(input())
while t != 0:
	s = str(input())
	res = ''
	if len(s) == 1:
		print(s)
		t -= 1
		continue
	ch = s[0]
	cnt = 1
	i = 1
	for i in range(1, len(s)):
		if s[i] != s[i - 1]:
			if cnt % 2 == 1:
				if ch not in res:
					res += ch
			cnt = 1
			ch = s[i]
		else:
			cnt += 1
	if cnt % 2 == 1:
		if ch not in res:
			res += ch
	res = ''.join(sorted(res))
	print(res)
	t -= 1


from itertools import groupby
t = int(input())
for _ in range(t):
	a = list(input())
	x = [(key, len(list(group))) for (key, group) in groupby(a)]
	answer = set()
	for (c, l) in x:
		if l % 2 == 1:
			answer.add(c)
	answer = list(answer)
	answer.sort()
	print(''.join(answer))


for z in range(int(input())):
	d = {'a': 0, 'b': 0, 'c': 0, 'd': 0, 'e': 0, 'f': 0, 'g': 0, 'h': 0, 'i': 0, 'j': 0, 'k': 0, 'l': 0, 'm': 0, 'n': 0, 'o': 0, 'p': 0, 'q': 0, 'r': 0, 's': 0, 't': 0, 'u': 0, 'v': 0, 'w': 0, 'x': 0, 'y': 0, 'z': 0}
	s = input()
	cnt = 1
	for i in range(len(s)):
		if i == len(s) - 1:
			if cnt & 1:
				d[s[i]] = 1
			continue
		if s[i] == s[i + 1]:
			cnt += 1
		else:
			if cnt & 1:
				d[s[i]] = 1
			cnt = 1
	res = ''
	for key in d:
		if d[key] > 0:
			res += key
	print(res)


n = 0
for i in range(n):
	(l, r) = [int(i) for i in input().split()]
	k = 0
	if l == 0:
		l = 1
	for j in range(l + 1, r + 1):
		k += (2 ** bin(j).split('0b')[1].count('0') - l) * 2
	print(k)
n = int(input())
for i in range(n):
	a = input()
	sim = ''
	k = 0
	ans = []
	for j in a:
		if sim == j:
			k += 1
		else:
			if k % 2 == 1:
				ans += sim
			k = 1
			sim = j
	if k % 2 == 1:
		ans += sim
	print(''.join(sorted(list(set(ans)))))


t = int(input())
for i in range(0, t):
	s = input()
	out = []
	j = 0
	while j < len(s):
		if j + 1 == len(s):
			out.append(s[j])
			break
		if s[j + 1] == s[j]:
			j += 2
			continue
		out.append(s[j])
		j += 1
	out = sorted(set(out))
	for k in out:
		print(k, end='')
	print()


t = int(input())
for i in range(t):
	s = str(input())
	ans = []
	dif = set()
	if len(s) == 1:
		print(s)
		continue
	count = 1
	for j in range(len(s) - 1):
		if s[j] != s[j + 1]:
			if count % 2 == 1 and s[j] not in dif:
				ans.append(s[j])
				dif.add(s[j])
			count = 1
		else:
			count += 1
	if count % 2 == 1 and s[len(s) - 1] not in dif:
		ans.append(s[len(s) - 1])
	ans.sort()
	print(''.join(ans))


n = int(input())
for i in range(n):
	m = input()
	m += ' '
	c = ''
	k = 0
	p = []
	for j in m:
		if j == c:
			k += 1
		else:
			if k % 2 != 0:
				if not c in p:
					p.append(c)
			c = j
			k = 1
	print(*sorted(p), sep='')


import sys
tc = int(sys.stdin.readline())
for _ in range(tc):
	arr = list(sys.stdin.readline().rstrip())
	keys = set(arr)
	ans = dict().fromkeys(set(arr))
	for i in ans:
		ans[i] = []
	for i in keys:
		temp = 0
		for j in range(len(arr)):
			if arr[j] == i:
				temp += 1
			else:
				if temp:
					ans[i].append(temp)
				temp = 0
		if temp:
			ans[i].append(temp)
	res = []
	for i in ans:
		for j in ans[i]:
			if j % 2 == 1:
				res.append(i)
				break
	res.sort()
	print(''.join(res))


for _ in range(int(input())):
	st = list(input())
	ans = []
	i = 0
	if len(st) == 1:
		print(*st)
		continue
	while i < len(st) - 1:
		if st[i] == st[i + 1]:
			i += 2
		else:
			ans.append(st[i])
			i += 1
	if i == len(st) - 1:
		ans.append(st[-1])
	ans = list(set(ans))
	ans.sort()
	print(''.join(ans))


n = int(input())
list_of_strings = []

def check_str(string, k, single):
	if k == len(string):
		return single
	if k == 0 and len(string) > 1 and (string[k] == string[k + 1]):
		if len(string) > 2:
			return check_str(string, k + 2, single)
		else:
			return single
	elif k != 0 and k < len(string) - 1 and (string[k] == string[k + 1]):
		if k + 2 == len(string):
			return single
		else:
			return check_str(string, k + 2, single)
	else:
		if string[k] not in single:
			single[string[k]] = 1
		return check_str(string, k + 1, single)
for i in range(n):
	string = str(input())
	list_of_strings.append(string)
for i in range(n):
	k = 0
	single = {}
	output = check_str(list_of_strings[i], k, single)
	output_lst = []
	for k in output:
		output_lst.append(k)
	output_lst = sorted(output_lst)
	output_str = str(output_lst).strip(']').strip('[')
	output_str = output_str.replace("'", '')
	output_str = output_str.replace(', ', '')
	print(output_str)


n = int(input())
for i in range(n):
	entrada = input()
	lista = []
	e = 0
	cont = 0
	ult = entrada[0]
	while e < len(entrada):
		if entrada[e] == ult:
			cont += 1
		elif entrada[e] != ult:
			if cont % 2 != 0 and ult not in lista:
				lista.append(ult)
			ult = entrada[e]
			cont = 1
		e += 1
	if cont % 2 != 0 and ult not in lista:
		lista.append(ult)
	lista.sort()
	print(''.join(lista))


for _ in range(int(input())):
	a = input()
	prev = a[0]
	col = 1
	ans = set()
	for i in a[1:] + ' ':
		if i == prev:
			col += 1
		else:
			if col % 2:
				ans.add(prev)
			col = 1
			prev = i
	print(*sorted(ans), sep='')


import sys
import math
from collections import defaultdict
from itertools import combinations
from itertools import permutations
input = lambda : sys.stdin.readline().rstrip()
read = lambda : map(int, input().split())

def write(*args, sep='\n'):
	for i in args:
		sys.stdout.write('{}'.format(i) + sep)
INF = float('inf')
MOD = int(1000000000.0 + 7)
for _ in range(int(input())):
	s = input()
	ans = ''
	for i in sorted(set(s)):
		if not i + i in s or s.count(i + i) * 2 - s.count(i) < 0:
			ans += i
	print(ans)


from fractions import Fraction
import sys
import bisect
import heapq
from math import *
from collections import Counter as counter
from itertools import combinations as comb
from itertools import permutations as permutate
from bisect import bisect_left as bl
from bisect import bisect_right as br
from bisect import bisect
import statistics
from statistics import mode
from functools import reduce
mod = 1000000007

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

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

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

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

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

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

def graph(vertex):
	return [[] for i in range(0, vertex + 1)]

def zerolist(n):
	return [0] * n

def nextline():
	out('\n')

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

def printlist(a):
	for p in range(0, len(a)):
		out(str(a[p]) + ' ')

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

def power(a, b):
	ans = 1
	while b > 0:
		if b % 2 == 1:
			ans *= a
		a *= a
		b //= 2
	return ans

def most_frequent(List):
	occurence_count = Counter(List)
	return occurence_count.most_common(1)[0][0]

def most_common(List):
	return mode(List)

def chinese_remainder(a, p):
	prod = reduce(op.mul, p, 1)
	x = [prod // pi for pi in p]
	return sum((a[i] * pow(x[i], p[i] - 2, p[i]) * x[i] for i in range(len(a)))) % prod

def createMatrix(rowCount, colCount, dataList):
	mat = []
	for i in range(rowCount):
		rowList = []
		for j in range(colCount):
			if dataList[j] not in mat:
				rowList.append(dataList[j])
		mat.append(rowList)
	return mat

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
import collections

def minimalFilps1(bits):
	n = len(bits)
	flipsFromLeft = [0 for i in range(n)]
	flipsFromRight = [0 for i in range(n)]
	flips = 0
	for i in range(0, n, 1):
		if bits[i] == '1':
			flips = flips + 1
		flipsFromLeft[i] = flips
	flips = 0
	i = n - 1
	while i >= 0:
		if bits[i] == '0':
			flips = flips + 1
		i = i - 1
		flipsFromRight[i] = flips
	minFlips1 = sys.maxsize
	for i in range(1, n, 1):
		if flipsFromLeft[i - 1] + flipsFromRight[i] < minFlips1:
			minFlips1 = flipsFromLeft[i - 1] + flipsFromRight[i]
	return minFlips1

def minimalFilps(bits):
	n = len(bits)
	flipsFromLeft = [0 for i in range(n)]
	flipsFromRight = [0 for i in range(n)]
	flips = 0
	for i in range(0, n, 1):
		if bits[i] == '0':
			flips = flips + 1
		flipsFromLeft[i] = flips
	flips = 0
	i = n - 1
	while i >= 0:
		if bits[i] == '1':
			flips = flips + 1
		i = i - 1
		flipsFromRight[i] = flips
	minFlips = sys.maxsize
	for i in range(1, n, 1):
		if flipsFromLeft[i - 1] + flipsFromRight[i] < minFlips:
			minFlips = flipsFromLeft[i - 1] + flipsFromRight[i]
	return minFlips

def oddn(n):
	for i in range(2, n + 1):
		if i % 2 != 0 and n % i == 0:
			return i
	return 3

def memoized(*args):
	if args in stored_results:
		return stored_results[args]
	else:
		result = stored_results[args] = fn(*args)
		return result
	return memoized
open_list = ['(']
close_list = [')']

def check(myStr):
	stack = []
	e = 0
	for i in myStr:
		if i in open_list:
			stack.append(i)
		elif i in close_list:
			pos = close_list.index(i)
			if len(stack) > 0:
				stack.pop()
				e += 1
	return e
for i in range(int(input())):
	s = input()
	a = list(s)
	b = set(a)
	b = list(b)
	i = 0
	while i < len(a) - 1:
		if a[i] == a[i + 1]:
			a.pop(i)
			if len(a) > 0:
				a.pop(i)
				i = i - 1
			else:
				a.clear()
		i += 1
	a = set(a)
	a = list(a)
	a.sort()
	print(*a, sep='')
import operator
open_list = ['(']
close_list = [')']

def check(myStr):
	stack = []
	e = 0
	for i in myStr:
		if i in open_list:
			stack.append(i)
		elif i in close_list:
			pos = close_list.index(i)
			if len(stack) > 0:
				stack.pop()
				e += 1
	return e


from collections import defaultdict
t = int(input())
for i in range(t):
	s = input()
	d = defaultdict(str)
	count = 1
	for x in s:
		d[x] = 'not working'
	for x in range(len(s) - 1):
		if s[x] == s[x + 1]:
			count += 1
		else:
			if count % 2 == 1:
				d[s[x]] = 'working'
			count = 1
	if count % 2 == 1:
		d[s[len(s) - 1]] = 'working'
	arr = []
	for x in d:
		if d[x] == 'working':
			arr += [x]
	arr.sort()
	ans = ''
	for x in arr:
		ans += x
	print(ans)


def hello(s):
	n = len(s)
	prev = s[0]
	c = 0
	a = dict()
	s += '|'
	for i in range(n + 1):
		if s[i] != prev:
			if a.get(prev, -1) == -1:
				a[prev] = c % 2 == 1
			else:
				a[prev] |= c % 2 == 1
			c = 1
			prev = s[i]
		else:
			c += 1
	ans = []
	for i in a:
		if a[i]:
			ans.append(i)
	return ans
t = int(input())
for _ in range(t):
	print(''.join(sorted(hello(input()))))


for t in range(int(input())):
	s = input()
	l = list(s)
	z = set(s)
	i = 1
	while i < len(s):
		if s[i] == s[i - 1]:
			z.add(i)
			z.add(i - 1)
			i = i + 2
		else:
			i = i + 1
	x = ''
	g = set()
	for i in range(len(s)):
		if i not in z:
			if s[i] not in g:
				x = x + s[i]
				g.add(s[i])
	l = sorted(x)
	for i in l:
		print(i, end='')
	print()


n = int(input())
res = ''
cont = 0
for k in range(0, n):
	s = input()
	if len(s) == 1:
		res += s[0]
	else:
		i = 0
		while i < len(s):
			if i < len(s) - 1:
				if s[i] == s[i + 1]:
					cont = 2
					j = i + 2
					while j < len(s):
						if s[i] == s[j]:
							cont += 1
							j += 1
						else:
							break
					if cont % 2 == 1:
						res += s[i]
					i = j
				else:
					res += s[i]
					i += 1
			else:
				res += s[i]
				break
	print(''.join(sorted(set(res))))
	res = ''


import math
from collections import defaultdict, Counter, deque

def primeFactor(n):
	if n % 2 == 0:
		return 2
	i = 3
	while i ** 2 <= n:
		if n % i == 0:
			return i
		i += 1
	return n

def main():
	s = input()
	if len(s) == 1:
		print(s)
		return
	first = 0
	second = 1
	res = set()
	while second < len(s):
		if s[first] != s[second]:
			res.add(s[first])
			first += 1
			second += 1
		else:
			first += 2
			second += 2
	if second == len(s):
		res.add(s[first])
	res = ''.join(sorted(res))
	print(res)
t = int(input())
for _ in range(t):
	main()


num_tests = int(input())
for _ in range(num_tests):
	s = input()
	not_broken = set()
	i = 0
	while i < len(s):
		if i == len(s) - 1 or s[i] != s[i + 1]:
			not_broken.add(s[i])
		else:
			i += 1
		i += 1
	not_broken = sorted(not_broken)
	print(''.join(not_broken))


t = int(input())
for nt in range(t):
	s = input()
	ans = []
	initial = s[0]
	count = 1
	for i in range(1, len(s)):
		if s[i] != initial:
			if count % 2 == 1:
				ans.append(ord(initial))
				count = 1
				initial = s[i]
			else:
				count = 1
				initial = s[i]
		else:
			count += 1
	if count % 2 == 1:
		ans.append(ord(s[-1]))
	ans = list(set(ans))
	ans.sort()
	for i in ans:
		print(chr(i), end='')
	print()


t = int(input())
for i in range(t):
	s = input()
	c = 0
	ss = set()
	while c < len(s) - 1:
		if s[c] != s[c + 1]:
			ss.add(s[c])
		else:
			c += 1
		c += 1
	if c == len(s) - 1:
		ss.add(s[c])
	ss = sorted(ss)
	print(''.join(ss))


for _ in range(int(input())):
	s = input()
	l = []
	i = 0
	n = len(s)
	while i < n:
		j = i
		cnt = 0
		while j < n and s[i] == s[j]:
			cnt += 1
			j += 1
		if cnt % 2:
			l.append(s[i])
		i = j
	l = list(set(l))
	l.sort()
	print(''.join(l))


for _ in range(int(input())):
	x = input()
	temp = 0
	final = []
	if len(x) == 1:
		print(x)
	else:
		while temp < len(x):
			if temp == len(x) - 1:
				final.append(x[temp])
				break
			if x[temp] == x[temp + 1]:
				temp = temp + 2
			else:
				final.append(x[temp])
				temp = temp + 1
		s = list(sorted(set(final)))
		z = ''
		for i in range(len(s)):
			z = z + str(s[i])
		print(z)


for _ in '0' * int(input()):
	(s, ls) = (input(), [])
	for c in set(s):
		n = s.count(c)
		if n % 2 != 0 or n // 2 != s.count(c * 2):
			ls.append(c)
	print(''.join(sorted(ls)))


n = int(input())
for _ in range(n):
	s = input()
	s += ' '
	correct = set()
	count = 1
	for (i, curr) in enumerate(s):
		if curr == ' ':
			break
		if curr != s[i + 1]:
			if count % 2 == 1:
				correct.add(curr)
			count = 1
		else:
			count += 1
	print(''.join(sorted(correct)))


import sys
from collections import Counter

def main():
	t = int(sys.stdin.readline())
	runLength = 1
	for i in range(t):
		s = sys.stdin.readline().rstrip()
		runLength = 1
		valid = set()
		for (idx, char) in enumerate(s[1:], start=1):
			prev = s[idx - 1]
			if char == prev:
				runLength += 1
			else:
				if runLength % 2 == 1 and prev not in valid:
					valid.add(prev)
				runLength = 1
		if runLength % 2 == 1 and s[-1] not in valid:
			valid.add(s[-1])
		print(''.join(sorted((x for x in valid))))
main()


t = int(input())
for _ in range(t):
	s = input()
	r = set()
	i = 0
	while i < len(s):
		j = i + 1
		while j < len(s) and s[i] == s[j]:
			j += 1
		if (j - i) % 2 == 1:
			r.add(s[i])
		i = j
	print(''.join(sorted(r)))


test_count = int(input())

def check():
	str = input()
	my_list = []
	i = 0
	if len(str) == 1:
		print(str)
	else:
		while i <= len(str) - 1:
			if i != len(str) - 1 and str[i] == str[i + 1]:
				i += 2
			else:
				my_list.append(str[i])
				i += 1
		print(''.join(sorted(set(my_list))))
for i in range(test_count):
	check()


for i in range(int(input())):
	s = input()
	(last, cnt) = ('.', 0)
	ans = set()
	for i in s:
		if i == last:
			cnt += 1
		else:
			if cnt % 2 == 1:
				ans.add(last)
			cnt = 1
			last = i
	if cnt % 2 == 1:
		ans.add(last)
		cnt = 1
		last = i
	s = ''
	for i in ans:
		s += i
	s = sorted(s)
	ans = ''
	for i in s:
		ans += i
	print(ans)


from sys import stdin
from sys import setrecursionlimit as SRL
SRL(10 ** 7)
rd = stdin.readline
rrd = lambda : map(int, rd().strip().split())
q = int(input())
while q:
	s = list(map(str, input().strip()))
	s += ['0']
	pre = s[0]
	cnt = 1
	ans = set()
	for i in s[1:]:
		if i != pre:
			if cnt % 2:
				ans.add(pre)
			cnt = 0
		cnt += 1
		pre = i
	aa = []
	for i in ans:
		aa.append(i)
	aa = sorted(aa)
	ans = ''.join(aa)
	print(ans)
	q -= 1


from itertools import groupby
for k in range(int(input())):
	res = []
	for (num, group) in groupby(input()):
		if len(list(group)) % 2 == 1:
			res += [num]
	res = sorted(list(set(res)))
	print(*res, sep='')


T = int(input())
while T > 0:
	s = input()
	n = len(s)
	if n == 1:
		print(s[0])
	else:
		string = set()
		k = 1
		l = s[0]
		for i in range(1, n):
			if s[i] == l:
				k += 1
			else:
				if k % 2 == 1:
					string.add(l)
				l = s[i]
				k = 1
			if i == n - 1:
				if k % 2 == 1:
					string.add(l)
		val = ''
		for i in range(len(string)):
			val += string.pop()
		print(''.join(sorted(val)))
	T -= 1


k = input
for i in range(int(k())):
	s = k()
	b = {}
	for i in sorted(s):
		if b.get(i):
			pass
		else:
			b[i] = 1
	for i in b:
		s = s.replace(i * 2, '#')
		if s.find(i) != -1:
			print(i, end='')
	print()


t = int(input())
for j in range(t):
	s = input()
	a = []
	i = 0
	while i < len(s) - 1:
		if s[i] == s[i + 1]:
			i += 2
		else:
			a.append(s[i])
			i += 1
	if i == len(s) - 1:
		a.append(s[i])
	a1 = list(set(a))
	a1.sort()
	a2 = ''.join(a1)
	print(a2)


n = int(input())
for z in range(n):
	s = input()
	c = [False for x in range(26)]
	i = 0
	j = s[0]
	count = 0
	while i < len(s):
		if s[i] != j:
			if count % 2 == 1:
				c[ord(j) - ord('a')] = True
			count = 0
			j = s[i]
		count += 1
		i += 1
	i = 0
	if count % 2 == 1:
		c[ord(j) - ord('a')] = True
	while i < 26:
		if c[i]:
			print(chr(i + ord('a')), end='')
		i += 1
	print()


import sys
input = sys.stdin.readline
t = int(input())
for test in range(t):
	S = input().strip() + '0'
	NOW = S[0]
	count = 1
	ANS = []
	for i in range(1, len(S)):
		if S[i] == S[i - 1]:
			count += 1
		else:
			if count % 2 == 1:
				ANS.append(S[i - 1])
			count = 1
	ANS = sorted(set(ANS))
	print(''.join(ANS))


for i in range(int(input())):
	s = input()
	i = 0
	res = ''
	n = len(s)
	while i < n - 1:
		if s[i] == s[i + 1]:
			i += 2
		else:
			i += 1
			res += s[i - 1]
	if i == n - 1:
		res += s[i]
	print(''.join(sorted(list(set(res)))))


from sys import stdin
from collections import defaultdict
for _ in range(int(stdin.readline())):
	s = input()
	fin = ''
	if len(s) == 1:
		print(s)
		continue
	j = 0
	while j < len(s) - 1:
		if s[j] != s[j + 1]:
			fin += s[j]
			j += 1
		else:
			j += 2
	if j == len(s) - 1:
		fin += s[len(s) - 1]
	print(''.join(sorted(set(fin))))


from math import *
from collections import *
from itertools import *
from bisect import *
from heapq import *
from operator import *
from sys import *
setrecursionlimit(100000000)
import os
import sys
from sys import *
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')

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()
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
z = lambda : sys.stdin.readline().rstrip('\r\n')

def op():
	return list(map(int, z().split()))

def o():
	return int(z())

def r(x):
	if type(x) == int:
		return range(x)
	else:
		return range(len(x))

def kl(con, x=0):
	if x == 0:
		print('Yes') if con else print('No')
	elif x == 1:
		print('yes') if con else print('no')
	elif x == 2:
		print('YES') if con else print('NO')
MOD = 1000000007
MAX = float('inf')
MIN = -float('inf')
for _ in range(o()):
	s = z()
	f = 0
	c = 1
	d = {}
	for i in range(97, 123):
		d[i] = 0
	for i in r(len(s) - 1):
		if s[i] == s[i + 1]:
			f = 1
			c += 1
		else:
			f = 0
			if c & 1:
				d[ord(s[i])] = 1
			c = 1
	if c & 1:
		d[ord(s[-1])] = 1
	ans = ''
	for i in range(97, 123):
		if d[i] == 1:
			ans += chr(i)
	print(ans)


import sys
import math
read = sys.stdin.buffer.read
readlines = sys.stdin.buffer.readlines
t = int(input())
for case in range(t):
	s = input()
	ok = [0] * 26
	consequence_len = 1
	consequence_char = s[0]
	for i in range(len(s)):
		if i < len(s) - 1:
			if s[i] == s[i + 1]:
				consequence_len += 1
			else:
				if consequence_len % 2:
					ok[ord(consequence_char) - ord('a')] = 1
				consequence_len = 1
				consequence_char = s[i + 1]
	if consequence_len % 2:
		ok[ord(consequence_char) - ord('a')] = 1
	for i in range(26):
		if ok[i]:
			print(chr(97 + i), end='')
	print()


queries = int(input())
for x in range(queries):
	string = input()
	lists = []
	flag = True
	result = ''
	if string == '':
		print('')
	for x in string:
		lists.append(x)
	for x in range(len(lists) - 1):
		if lists[x] == lists[x + 1]:
			lists[x] = ''
			lists[x + 1] = ''
	for x in set(lists):
		result += x
	result = ''.join(sorted(result))
	print(result)


TC = int(input())
for tc in range(TC):
	grps = []
	for c in input():
		if not grps or grps[-1][0] != c:
			grps.append([c, 1])
		else:
			grps[-1][1] += 1
	works = [False] * 26
	for (c, p) in grps:
		if p % 2 == 1:
			works[ord(c) - ord('a')] = True
	res = ''.join((chr(x + ord('a')) for x in range(26) if works[x]))
	print(res)


n = int(input())
for i in range(n):
	st = list(input())
	for i in range(len(st) - 1):
		if st[i] == st[i + 1]:
			st[i] = ''
			st[i + 1] = ''
	st = list(set(st))
	st.sort()
	z = ''.join(st)
	print(z)


t = int(input())
for i1 in range(t):
	s = input() + '0'
	itr = iter(range(len(s) - 1))
	funcionando = []
	for i2 in itr:
		letra = s[i2]
		if letra not in funcionando:
			if letra != s[i2 + 1]:
				funcionando.append(letra)
			else:
				next(itr)
	funcionando.sort()
	for letra in funcionando:
		print(letra, end='')
	if i1 != t - 1:
		print('')


import string
a = list(string.ascii_lowercase)
q = int(input())
for i in range(q):
	saida = ''
	string = list(input())
	tamanho = len(string)
	arvore = [0] * 26
	cnt = 0
	parar = 0
	string.append(' ')
	for j in range(tamanho):
		if parar == 1:
			parar = 0
		elif string[j] == string[j + 1]:
			parar = 1
		else:
			index = a.index(string[j])
			arvore[index] = arvore[index] + 1
	for l in range(26):
		if arvore[l] > 0:
			saida = saida + a[l]
	print(saida)


import sys
read = sys.stdin.readline

def solution():
	f = set()
	if len(st) == 1:
		f.add(st[0])
	else:
		if st[0] != st[1]:
			f.add(st[0])
		if st[-2] != st[-1]:
			f.add(st[-1])
	prev = st[0]
	i = 1
	cnt = 1
	while i < len(st):
		curr = st[i]
		if prev != curr:
			if cnt % 2 == 1:
				f.add(prev)
			else:
				prev = curr
			cnt = 1
		else:
			cnt += 1
			if i == len(st) - 1 and cnt % 2 == 1:
				f.add(prev)
		prev = curr
		i += 1
	return sorted(f)
q = int(read().strip())
for i in range(q):
	st = read().strip()
	sol = solution()
	for s in sol:
		print(s, end='')
	print()


t = int(input())
for i in range(t):
	s = input()
	size = len(s)
	mF = {}
	for c in s:
		mF[c] = []
	count = 1
	for k in range(1, size):
		if s[k] == s[k - 1]:
			count += 1
		else:
			mF[s[k - 1]].append(count)
			count = 1
	mF[s[size - 1]].append(count)

	def isOdd(x):
		return x % 2 != 0
	for c in sorted(mF):
		ok = True
		for o in mF[c]:
			if o % 2 != 0:
				ok = False
				break
		if ok == False:
			print(c, end='')
	print()


from sys import stdin

def iinput():
	return int(stdin.readline())

def minput():
	return map(int, stdin.readline().split())

def linput():
	return list(map(int, stdin.readline().split()))
t = iinput()
while t:
	t -= 1
	s = input()
	i = 0
	res = set()
	while i <= len(s) - 1:
		if i == len(s) - 1:
			res.add(s[i])
			i += 1
		elif s[i] != s[i + 1]:
			res.add(s[i])
			i += 1
		else:
			i += 2
	print(''.join(sorted(res)))


for q in range(int(input())):
	a = []
	d = {}
	res = ''
	o = ''
	s = input()
	a += s
	i = 0
	if len(a) == 1:
		o = a[0]
	else:
		while i < len(a) - 1:
			if a[i] == a[i + 1]:
				i += 2
			else:
				o += a[i]
				i += 1
		z = len(a) - 1
		c = 0
		while a[z] == a[len(a) - 1] and z >= 0:
			z = z - 1
			c += 1
		if c % 2 != 0:
			o += a[len(a) - 1]
	o = list(set(o))
	o.sort()
	o = ''.join(o)
	print(o)


from itertools import groupby
for _ in range(int(input())):
	s = input()
	k = len(s)
	l = []
	for (i, j) in groupby(s):
		if len(list(j)) % 2 != 0:
			l.append(i)
	l = list(set(l))
	l.sort()
	print(''.join(l))


proibidos = ['aa', 'bb', 'cc', 'dd', 'ee', 'ff', 'gg', 'hh', 'ii', 'jj', 'kk', 'll', 'mm', 'nn', 'oo', 'pp', 'qq', 'rr', 'ss', 'tt', 'uu', 'vv', 'ww', 'xx', 'yy', 'zz']

def solve(res, string, pointer):
	if pointer == 0:
		res = res + string[0]
		return res
	elif pointer == 1 and string[0:2] in proibidos:
		return res
	elif pointer == 1 and string[0:2] not in proibidos:
		res = res + string[0:2]
		return res
	else:
		ultima = string[pointer]
		meio = string[pointer - 1]
		primeira = string[pointer - 2]
		if ultima != meio:
			res = res + ultima
			pointer -= 1
			return solve(res, string, pointer)
		else:
			pointer -= 2
			return solve(res, string, pointer)
q = int(input())
queries_list = []
for i in range(1, q + 1):
	queries_list.append(input())
for query in queries_list:
	aux = ''
	res = ''.join(sorted(set(solve(aux, query, len(query) - 1))))
	print(res)


t = int(input())
for _ in range(t):
	x = [i for i in input()]
	n = len(x)
	if n == 1:
		print(x[0])
		continue
	o = ''
	if x[0] == x[1]:
		x[0] = None
		x[1] = None
	i = 1
	while i < n:
		if x[i - 1] == x[i]:
			x[i] = None
			x[i - 1] = None
		i += 1
	print(''.join(sorted(list(set([i for i in x if i is not None])))))


test_cases = int(input())
for i in range(test_cases):
	policarp_string = input()
	non_dup = set(policarp_string)
	res = ''
	for element in sorted(non_dup):
		double_character = element + element
		if 2 * policarp_string.count(double_character) < policarp_string.count(element):
			res = res + element
	print(res)


n = int(input())
a = []
for i in range(0, n):
	strings = []
	dict_str = {}
	string = input()
	for s in range(0, len(string)):
		strings.append(string[s])
	for s in range(0, len(string) - 1):
		if string[s] == string[s + 1] and (not strings[s] == ''):
			strings[s] = ''
			strings[s + 1] = ''
	for s in range(0, len(strings)):
		if strings[s] in dict_str:
			strings[s] = ''
		else:
			dict_str[strings[s]] = s
	res = ''
	for x in sorted(strings):
		res += x
	a.append(res)
for st in a:
	print(st)


for _ in range(int(input())):
	s = input()
	l = len(s)
	if l == 1:
		print(s)
	else:
		res = list()
		for i in range(l):
			cd = s.count(s[i] * 2)
			c = s.count(s[i])
			if cd * 2 != c:
				res.append(s[i])
		res = set(res)
		res = list(res)
		res.sort()
		print(''.join(res))


def f(s):
	i = 0
	ans = ''
	while i < len(s):
		x = i
		a = s[i]
		c = 1
		if a not in ans:
			for j in range(x + 1, len(s)):
				if s[j] == a:
					c += 1
					i = j
				else:
					break
			if c % 2 == 1:
				ans = ans + s[i]
		i += 1
	ans = sorted(ans)
	final = ''
	for i in range(0, len(ans)):
		final = final + ans[i]
	return final
t = int(input())
for i in range(0, t):
	s = input()
	print(f(s))


n = int(input())
for i in range(n):
	str = list(input())
	strLen = len(str)
	checkList = []
	resultList = []
	for k in range(1, strLen):
		currentWord = str[k]
		if currentWord == str[k - 1]:
			str[k] = '-'
			str[k - 1] = '-'
	result = list(set([x for x in str if x != '-']))
	result.sort()
	print(''.join(result))


t = int(input())
for _ in range(t):
	s = input()
	l = []
	n = len(s)
	i = 0
	d = 0
	while i < n:
		a = []
		a.append(s[i])
		z = s[i]
		i += 1
		c = 0
		while i < n:
			if z == s[i]:
				c += 1
			else:
				d += c + 1
				a.append(c + 1)
				l.append(a)
				break
			i += 1
		if i == n:
			a.append(c + 1)
			l.append(a)
	f = [0] * 26
	for (i, j) in l:
		if j % 2 != 0:
			f[ord(i) - 97] = 1
	for i in range(26):
		if f[i] == 1:
			print(chr(i + 97), end='')
	print()


for _ in range(int(input())):
	str = input()
	final = ''
	i = 0
	while i < len(str):
		j = i
		while j < len(str) - 1 and str[i] == str[j + 1]:
			j += 1
		if (j - i) % 2 == 0 and str[i] not in final:
			final += str[i]
		i = j + 1
	print(''.join(sorted(final)))


for j in range(int(input())):
	t = input()
	s = ''
	for i in t:
		l = t.count(i)
		p = i + i
		k = t.count(p)
		if l != 2 * k or l == 0:
			if i not in s:
				s = s + i
	a = sorted(s)
	print(''.join(a))


import sys
from math import ceil
cin = sys.stdin.buffer.readline
for _ in range(int(cin())):
	s = input()
	ct = 1
	ans = set()
	for i in range(1, len(s)):
		if s[i] == s[i - 1]:
			ct += 1
		else:
			if ct % 2 != 0:
				ans.add(s[i - 1])
			ct = 1
	if ct % 2 != 0:
		ans.add(s[-1])
	ans = list(ans)
	ans.sort()
	for el in ans:
		print(el, end='')
	print()


a = int(input())
i = 0
while i < a:
	b = input()
	r = 0
	ans = ''
	while r < len(b):
		if r + 1 < len(b) and b[r] == b[r + 1]:
			r = r + 1
		else:
			ans = ans + b[r]
		r = r + 1
	set(ans)
	ans = list(dict.fromkeys(ans))
	print(''.join(sorted(ans)))
	i = i + 1


t = int(input())
for i in range(t):
	res = set()
	inp = input()
	c = ' '
	length = 0
	for char in inp:
		if char != c:
			if length % 2 == 1:
				res.add(c)
			c = char
			length = 1
		else:
			length += 1
	if length % 2 == 1:
		res.add(c)
	for char in sorted(res):
		print(char, end='')
	print()


def func1(s):
	temp = ''
	tempdict = {}
	count = 1
	if len(s) == 1:
		return s
	for i in range(len(s)):
		if i == len(s) - 1:
			if count % 2 != 0:
				tempdict[s[i]] = 1
			continue
		if s[i] == s[i + 1]:
			count += 1
		elif count % 2 != 0:
			count = 1
			tempdict[s[i]] = 1
		else:
			count = 1
	for i in tempdict.keys():
		temp += i
	temp2 = sorted(temp)
	temp3 = ''
	for i in range(len(temp2)):
		temp3 += temp2[i]
	return temp3
n = int(input())
for i in range(n):
	t = input()
	print(func1(t))


t = int(input())
for _ in range(t):
	ans = {}
	s = input()
	i = 0
	while i < len(s):
		j = i + 1
		while j < len(s) and s[j] == s[i]:
			j += 1
		if (j - i) % 2 == 1:
			ans[s[i]] = True
		i = j
	keys = []
	for i in ans:
		keys.append(i)
	if len(keys) == 0:
		print()
		continue
	keys.sort()
	print(''.join(keys))


def triguil(l):
	i = 0
	while i < len(l) - 1:
		if l[i] == l[i + 1]:
			l.remove(l[i])
			l.remove(l[i])
			i = i - 1
		i = i + 1
	j = 0
	l1 = []
	for i in range(len(l)):
		if not l[i] in l1:
			l1.append(l[i])
			j = j + 1
	return l1
a = int(input())
l2 = []
l3 = []
for i in range(a):
	l2.append(input())
for j in range(a):
	l = [i for i in l2[j]]
	l3 = triguil(l)
	l3.sort()
	ch = ''.join(l3)
	print(ch)


for test in range(int(input())):
	ans = []
	s = input()
	n = len(s)
	i = 0
	while i < n:
		j = i + 1
		while j < n and s[j] == s[i]:
			j += 1
		if (j - i) % 2 != 0:
			ans.append(s[i])
		i = j
	ans = list(set(ans))
	ans.sort()
	print(''.join(ans))


t = int(input())
for i in range(t):
	s = input()
	res = []
	tmp = 1
	for j in range(1, len(s)):
		if s[j] == s[j - 1]:
			tmp += 1
		else:
			if tmp % 2 == 1 and s[j - 1] not in res:
				res.append(s[j - 1])
			tmp = 1
	if tmp % 2 == 1 and s[-1] not in res:
		res.append(s[-1])
	res.sort()
	print(*res, sep='')


import sys

def solve():
	s = sys.stdin.readline().rstrip()
	n = len(s)
	(l, r) = (0, 0)
	res = set()
	while l < n:
		while r < n and s[l] == s[r]:
			r += 1
		if (r - l) % 2 != 0:
			res.add(s[l])
		l = r
	print(''.join(sorted(res)))
(t,) = map(int, sys.stdin.readline().split())
for _ in range(t):
	solve()


x = int(input())
s = []
for _ in range(x):
	s.append(input())
for i in s:
	d = set()
	pred = i[0]
	k = 0
	for j in i:
		if j == pred:
			k += 1
		else:
			if k % 2 != 0:
				d.add(pred)
			k = 1
			pred = j
	else:
		if k % 2 != 0:
			d.add(pred)
	d = list(d)
	d.sort()
	print(''.join(d))


for _ in range(int(input())):
	s = input()
	stack = []
	ans = set()
	for i in s:
		if not stack:
			stack.append(i)
			continue
		if stack[-1] == i:
			stack.append(i)
		else:
			if len(stack) % 2 != 0:
				ans.add(stack[-1])
			stack = [i]
	if len(stack) % 2 != 0:
		ans.add(stack[-1])
	ans = list(ans)
	print(''.join(sorted(ans)))


from sys import stdin, stdout
import math
get = stdin.readline
put = stdout.write
t = 0
for _ in range(int(get())):
	x = input() + '00'
	p = ''
	for i in range(len(x)):
		if t:
			t -= 1
			continue
		if x[i] != x[i + 1]:
			p = p + x[i]
		else:
			t += 1
		if i == len(x) - 3:
			break
	print(''.join(sorted(list(set(p)))))


from collections import defaultdict
t = int(input().strip())
while t > 0:
	s = input().strip()
	mp = defaultdict(lambda : False)
	i = 0
	n = len(s)
	while i < n:
		if i == n - 1:
			mp[s[i]] = True
			i += 1
			continue
		if s[i] == s[i + 1]:
			i += 2
		else:
			mp[s[i]] = True
			i += 1
	mp = sorted(mp)
	for el in mp:
		print(el, end='')
	print()
	t -= 1


t = int(input())
while t:
	s = str(input())
	l = len(s)
	if l == 1:
		print(s)
	else:
		sl = []
		i = 0
		while i < l:
			if i == l - 1:
				if s[i] not in sl:
					sl.append(s[i])
				break
			elif s[i] != s[i + 1]:
				if s[i] not in sl:
					sl.append(s[i])
				i += 1
			else:
				i += 2
		print(''.join(sorted(sl)))
	t -= 1


n = int(input())
for _ in range(n):
	s = list(input())
	r = []
	i = 0
	while i < len(s):
		j = 1
		while i < len(s) - 1 and s[i] == s[i + 1]:
			j += 1
			i += 1
		if j % 2 == 1:
			if s[i] not in r:
				r.append(s[i])
		i += 1
	r = sorted(r)
	print(''.join(r))


t = int(input())
s = 'abcdefghijklmnopqrstuvwxyz'
for i in range(t):
	ss = input()
	ss = ' ' + ss + ' '
	l = len(ss)
	a = 0
	for k in range(0, 26):
		for j in range(1, l):
			if s[k] == ss[j]:
				a = a + 1
			elif a % 2 == 1:
				print(s[k], end='')
				a = 0
				break
	print()


t = int(input())
i = 0
while i < t:
	s = input()
	l = []
	j = 0
	while j < len(s) - 1:
		if s[j] != s[j + 1]:
			l.append(s[j])
			j = j + 1
		else:
			j = j + 2
	if j == len(s) - 1:
		l.append(s[j])
	l = list(set(l))
	l.sort()
	p = str(l)
	print(p.translate(p.maketrans('', '', "[]', ")))
	i = i + 1


from sys import stdin
for _ in range(int(stdin.readline())):
	s = stdin.readline()
	d = {}
	prev = 1
	for (idx, val) in enumerate(s[1:], start=1):
		if val != s[idx - 1]:
			if prev % 2 == 1:
				d[s[idx - 1]] = True
			prev = 1
		else:
			prev += 1
	print(''.join(sorted(d.keys())))


n = int(input())
for i in range(n):
	s = input()
	if len(s) > 1:
		l = []
		j = 0
		while j <= len(s) - 1:
			if j == len(s) - 1:
				if s[j] not in l:
					l.append(s[j])
				break
			elif s[j] != s[j + 1]:
				if s[j] not in l:
					l.append(s[j])
				j += 1
			else:
				j += 2
		l = sorted(l)
		for _ in l:
			print(_, end='')
		print()
	else:
		print(s[0])


from sys import stdin
from math import *
for i in range(int(input())):
	s = input()
	ans = ''
	i = 0
	j = 0
	while i < len(s) and j < len(s):
		while j < len(s):
			if s[i] != s[j]:
				if (j - i) % 2 != 0:
					if s[i] not in ans:
						ans += s[i]
				i = j
				j += 1
			else:
				j += 1
	if (j - i) % 2 == 1:
		if s[i] not in ans:
			ans += s[i]
	ans = list(ans)
	ans.sort()
	print(''.join(ans))


t = int(input())
for i in range(t):
	a = list(input())
	x = len(a)
	j = 0
	op = [0] * 26
	while j < x:
		c = 1
		while j < x - 1 and a[j] == a[j + 1]:
			j += 1
			c += 1
		if c % 2:
			op[ord(a[j]) - ord('a')] = 1
		j += 1
	ans = []
	for j in range(26):
		if op[j]:
			ans.append(chr(j + ord('a')))
	print(''.join(ans))


q = int(input())
for t in range(q):
	s = input()
	ans = []
	i = 1
	p = 1
	while i < len(s):
		if s[i] == s[i - 1]:
			p += 1
		else:
			if p % 2 == 1:
				ans.append(s[i - 1])
			p = 1
		i += 1
	if p % 2 == 1:
		ans.append(s[-1])
	ans = list(set(ans))
	ans.sort()
	for i in range(len(ans)):
		print(ans[i], end='')
	print()


q = int(input())
for i in range(q):
	s = input()
	ls = len(s)
	s += '0'
	j = 0
	res = ''
	while j < ls:
		if s[j] != s[j + 1]:
			res += s[j]
			j += 1
		else:
			j += 2
	print(''.join(sorted(list(set(res)))))


for testes in range(int(input())):
	s = input()
	ult = s[0]
	cont = 1
	res = []
	for c in s[1:]:
		if c != ult:
			if cont % 2 == 1 and ult not in res:
				res.append(ult)
			ult = c
			cont = 1
		else:
			cont += 1
	if cont % 2 == 1 and ult not in res:
		res.append(ult)
	for c in sorted(res):
		print(c, end='')
	print()


import string
num_inputs = int(input())
for _ in range(num_inputs):
	this_input = input()
	working_letters = []
	for s in string.ascii_lowercase:
		this_input = this_input.replace(s * 2, s.upper())
		if s in this_input:
			working_letters.append(s)
	print(''.join(sorted(working_letters)))


from math import ceil, sqrt
for _ in range(int(input())):
	l = input() + '>.'
	l = '>' + l[:]
	n = len(l)
	res = ''
	if n == 1:
		print(l)
		continue
	px = []
	for i in range(1, n - 2):
		if l[i - 1] != l[i] != l[i + 1] or l.count(l[i]) - l.count(l[i] + l[i]) * 2:
			res += l[i]
	res = sorted(set(res))
	print(''.join((str(i) for i in res)))


t = int(input())
for _ in range(t):
	s = input()
	cnt = 1
	s += '1'
	l = []
	for i in range(len(s) - 1):
		if s[i] != s[i + 1]:
			l.append((s[i], cnt))
			cnt = 1
		else:
			cnt += 1
	ans_s = set()
	for (alpha, c) in l:
		if c % 2 == 1:
			ans_s.add(alpha)
	ans_l = list(ans_s)
	ans_l.sort()
	print(''.join(ans_l))


for i in range(int(input())):
	s = input()
	d = list(s)
	v = len(s)
	j = []
	i = 0
	while i < v - 1:
		k = i + 1
		if d[i] != d[k]:
			j.append(d[i])
			i += 1
		else:
			i += 2
	if i == v - 1:
		j.append(d[i])
		i += 1
	m = list(set(j))
	m.sort()
	for i in m:
		print(i, end='')
	print()


t = int(input())
for _ in range(t):
	st = input()
	l = []
	i = 0
	while i < len(st):
		if st[i] not in l:
			if i == len(st) - 1 or st[i] != st[i + 1]:
				l.append(st[i])
				i += 1
			else:
				i += 2
		else:
			i += 1
	l.sort()
	print(''.join(map(str, l)))


t = input()
for _ in range(int(t)):
	correct = []
	s = input()
	if len(s) == 1:
		correct.append(s[0])
	else:
		combo = 1
		for i in range(len(s)):
			c = s[i]
			left = None
			right = None
			if i > 0:
				left = s[i - 1]
				if c == left:
					combo += 1
				else:
					if combo > 2 and combo % 2 == 1:
						correct.append(left)
					combo = 1
			if i < len(s) - 1:
				right = s[i + 1]
			if left != c and right != c:
				correct.append(c)
			elif right == None and combo % 2 == 1:
				correct.append(left)
	print(''.join(sorted(set(correct))))


from sys import stdin

def main():
	case = int(stdin.readline().strip())
	for k in range(case):
		s = stdin.readline().strip()
		arr = [0 for _ in range(26)]
		i = 0
		while i < len(s):
			var = ord(s[i]) - 97
			if i + 1 < len(s) and s[i] == s[i + 1]:
				if arr[var] != 1:
					arr[var] = 2
				i += 2
			else:
				arr[var] = 1
				i += 1
		for i in range(26):
			if arr[i] == 1:
				print(chr(i + 97), end='')
		if k + 1 != case:
			print()
main()


test_cases = int(input())
for i in range(test_cases):
	word = list(input())
	for i in range(len(word) - 1):
		if word[i] == word[i + 1]:
			(word[i], word[i + 1]) = ('', '')
	good_keys = list(set(word))
	good_keys.sort()
	print(''.join(good_keys))


n = int(input())
for _ in range(n):
	string = str(input())
	result = set()
	acc = 0
	value = ''
	for i in range(len(string)):
		if string[i] == value or value == '':
			value = string[i]
			acc += 1
		else:
			if acc % 2 != 0:
				result.add(value)
			value = string[i]
			acc = 1
	if acc % 2 != 0:
		result.add(value)
	print(''.join(sorted(result)))


n = int(input())
for a0 in range(n):
	s = input()
	i = 0
	l = []
	while i < len(s):
		if i < len(s) - 1 and s[i] == s[i + 1]:
			i += 2
		else:
			l.append(s[i])
			i += 1
	print(*sorted(set(l)), sep='', end='')
	print()


t = int(input())
for _ in range(t):
	s = input()
	i = 0
	res = []
	s += '0'
	while i < len(s) - 1:
		if s[i] == s[i + 1]:
			i += 2
		else:
			res.append(s[i])
			i += 1
	res = list(dict.fromkeys(res))
	print(''.join(sorted(res)))


import sys
from itertools import groupby
reader = (line.rstrip() for line in sys.stdin)
input = reader.__next__
t = int(input())
for _ in range(t):
	s = input()
	good = set()
	for (k, g) in groupby(s):
		if len(list(g)) & 1:
			good.add(k)
	print(''.join(sorted(good)))


def insert(list, s):
	if len(list) == 0:
		list.append(s)
		return list
	i = 0
	while i < len(list):
		if s == list[i]:
			return list
		if s < list[i]:
			list.insert(i, s)
			return list
		i += 1
	list.append(s)
	return list

def main_function(S):
	button_work_correctly = []
	S = S + '0'
	i = 0
	while i < len(S) - 1 or S[i] != '0':
		if S[i + 1] == '0':
			button_work_correctly = insert(button_work_correctly, S[i])
			break
		elif S[i + 1] != S[i]:
			button_work_correctly = insert(button_work_correctly, S[i])
			i += 1
		else:
			i += 2
	return ''.join(button_work_correctly)
for _ in range(int(input())):
	s = str(input())
	result = main_function(s)
	print(result)


def solve():
	s = input()
	prev = s[0]
	cnt = 0
	d = {}
	for c in s:
		if prev == c:
			cnt += 1
		else:
			d[prev] = max(d.get(prev, 0), cnt % 2)
			cnt = 1
			prev = c
	d[prev] = max(d.get(prev, 0), cnt % 2)
	ans = []
	for (c, i) in d.items():
		if i:
			ans.append(c)
	ans.sort()
	ans = ''.join(ans)
	print(ans)
t = int(input())
for i in range(t):
	solve()


t = int(input())
while t:
	s = input()
	n = len(s)
	ans = set()
	i = j = 0
	while i < n:
		while j < n and s[j] == s[i]:
			j += 1
		if j - i & 1:
			ans.add(s[i])
		i = j
	ans = sorted(ans)
	for i in ans:
		print(i, end='')
	print()
	t -= 1


t = int(input())
for tc in range(t):
	s = input()
	prev = s[0]
	curr_streak = 1
	unique = set()
	for i in range(1, len(s)):
		if s[i] != prev:
			if curr_streak % 2 != 0:
				unique.add(prev)
			prev = s[i]
			curr_streak = 1
		else:
			curr_streak += 1
	if curr_streak % 2 != 0:
		unique.add(prev)
	print(''.join(sorted(unique)))


n = int(input())
for i in range(n):
	st = input()
	ans = []
	c = 1
	for j in range(1, len(st)):
		if st[j] == st[j - 1]:
			c += 1
		else:
			if c % 2 == 1:
				if not st[j - 1] in ans:
					ans.append(st[j - 1])
			c = 1
	if c % 2 == 1:
		if not st[len(st) - 1] in ans:
			ans.append(st[len(st) - 1])
	ans.sort()
	for f in ans:
		print(f, end='')
	print()


for _ in range(int(input())):
	st = input()
	se = set(st)
	ra = ''
	for i in se:
		if st.count(i) - st.count(i * 2) * 2 > 0:
			ra += i
	print(''.join(sorted(ra)))


from sys import stdin

def input():
	return stdin.readline()[:-1]

def intput():
	return int(input())

def sinput():
	return input().split()

def intsput():
	return map(int, sinput())
t = intput()
for _ in range(t):
	s = input()
	prev = s[0]
	cnt = 1
	res = []
	for i in range(1, len(s)):
		if s[i] != prev:
			if cnt % 2:
				res.append(prev)
			prev = s[i]
			cnt = 1
		else:
			cnt += 1
	if cnt % 2:
		res.append(prev)
	res = list(set(res))
	print(''.join(sorted(res)))


t = int(input())
out = []
for _ in range(t):
	a = list(input())
	res = ''
	x = a[0]
	y = 0
	for i in range(len(a)):
		if a[i] == x:
			y += 1
		else:
			if y % 2 == 1:
				res += a[i - 1]
			y = 1
			x = a[i]
	if y % 2 == 1 or len(a) == 1:
		res += a[-1]
	out.append(''.join(sorted(set(res))))
print('\n'.join(out))


n = int(input())
for i in range(n):
	a = []
	s = input()
	for j in range(len(s)):
		c = s[j]
		cnt = 0
		bl = True
		for u in range(len(s)):
			if c == s[u] and cnt == 0:
				cnt += 1
			elif c == s[u] and cnt != 0:
				cnt += 1
			elif cnt != 0 and c != s[u]:
				if cnt % 2 != 0:
					if not c in a:
						a.append(c)
					break
				cnt = 0
				if u == len(s) - 1:
					bl = False
			if u == len(s) - 1 and cnt % 2 != 0 and bl and (cnt != 0):
				if not c in a:
					a.append(c)
	a.sort()
	for j in range(len(a)):
		print(a[j], end='')
	print()


for _ in range(int(input())):
	s = input()
	ans = list()
	for i in range(ord('a'), ord('z') + 1):
		b = 0
		c = 0
		for k in s:
			if ord(k) == i:
				c += 1
			elif c % 2:
				b = 1
				break
		if c % 2:
			b = 1
		if b:
			ans.append(chr(i))
	print(''.join(ans))


def solve():
	s = input()
	myset = set()
	i = 0
	while i < len(s):
		j = i
		while j + 1 < len(s) and s[j + 1] == s[i]:
			j += 1
		if (j - i + 1) % 2 == 1:
			myset.add(s[i])
		i = j + 1
	print(''.join(sorted(list(myset))))
n = int(input())
for _ in range(n):
	solve()


N = int(input())
counts = []
for _ in range(N):
	s = input()
	last_c = None
	last_count = 0
	ans = set()
	for c in s:
		if last_c == None:
			last_c = c
			last_count = 1
		elif c == last_c:
			last_count += 1
		else:
			if last_count % 2 == 1:
				ans.add(last_c)
			last_c = c
			last_count = 1
	if last_count % 2 == 1:
		ans.add(c)
	print(''.join(sorted(list(ans))))


t = int(input())
for ti in range(t):
	entrada = input()
	res = []
	tamanho = len(entrada)
	index = 0
	count = 1
	while index < tamanho:
		if index + 1 < tamanho:
			if entrada[index] == entrada[index + 1]:
				count = count + 1
			else:
				if count % 2 != 0:
					res.append(entrada[index])
				count = 1
		else:
			if count % 2 != 0:
				res.append(entrada[index])
			count = 1
		index = index + 1
	res = sorted(set(res))
	print(''.join(res))


x = int(input())
for __ in range(x):
	n = input()
	lol = set()
	i = 0
	while i < len(n):
		if i < len(n) - 1:
			if n[i] == n[i + 1]:
				i += 2
			else:
				lol.add(n[i])
				i += 1
		else:
			lol.add(n[i])
			i += 1
	lol = list(lol)
	lol.sort()
	print(''.join(lol))


t = int(input())
for j in range(t):
	q = set()
	count = 1
	dude = []
	s = input()
	s = ' ' + s + ' '
	m = s[0]
	for i in range(len(s)):
		if i == 0:
			continue
		if m == s[i]:
			count += 1
		else:
			if count % 2 == 1:
				q.add(m)
			m = s[i]
			count = 1
	for ii in q:
		if ii == ' ':
			continue
		dude.append(ii)
	dude.sort()
	print(''.join(map(str, dude)))


case = input()
for i in range(int(case)):
	data = input()
	if len(data) == 1:
		print(data[0])
		continue
	record = [0] * 26
	i = 0
	while True:
		if i == len(data) - 1:
			record[ord(data[i]) - ord('a')] = data[i]
			break
		elif data[i] == data[i + 1]:
			i += 2
			if i == len(data):
				break
			continue
		else:
			record[ord(data[i]) - ord('a')] = data[i]
			i += 1
			continue
	for i in record:
		if i != 0:
			print(i, end='')
	print()


import sys
input = lambda : sys.stdin.readline().strip()
t = int(input())
for i in range(t):
	s = input()
	ls = []
	check = 0
	i = 0
	while i < len(s):
		cnt = 0
		while i < len(s) and s[i] == s[check]:
			i += 1
			cnt += 1
		if cnt % 2 != 0:
			ls.append(s[check])
		check = i
	ls = sorted(list(set(ls)))
	print(''.join(ls))


for _ in range(int(input())):
	abc = [0 for i in range(26)]
	s = input()
	last = s[0]
	odd = 1
	for i in s[1:] + '0':
		if i == last:
			odd ^= 1
		else:
			abc[ord(last) - ord('a')] += odd
			last = i
			odd = 1
	for (i, e) in enumerate(abc):
		if e:
			print(chr(i + ord('a')), end='')
	print()


for i in range(int(input())):
	s = input()
	x = sorted(set(s))
	ans = ''
	for c in x:
		if s.count(c) > 2 * s.count(c + c):
			ans = ans + c
	print(ans)


test_count = int(input())
test_inputs = list()

def result(a):
	pointer = 0
	ans = set()
	while pointer < len(a):
		if pointer + 1 == len(a):
			ans.add(a[pointer])
			pointer += 1
		elif a[pointer] != a[pointer + 1]:
			ans.add(a[pointer])
			pointer += 1
		else:
			pointer += 2
	ans = sorted(list(ans))
	s = str()
	for i in ans:
		s += i
	print(s)
for i in range(test_count):
	a = input()
	result(a)


T = int(input())
for t in range(T):
	string = str(input())
	i = 0
	correct_keys = ''
	used = {}
	for x in string:
		used[x] = False
	while i < len(string):
		element_repetitions = 1
		current_element = string[i]
		while i < len(string) - 1 and string[i + 1] == string[i]:
			element_repetitions += 1
			i += 1
		if element_repetitions % 2 != 0 and used[current_element] == False:
			used[current_element] = True
			correct_keys = correct_keys + current_element
		i += 1
	print(''.join(sorted(correct_keys)))


t = int(input())
for i in range(t):
	arr = str(input())
	count = 0
	c = 0
	temp = arr[0]
	s = [0] * len(arr)
	for j in range(len(arr)):
		if temp == arr[j]:
			if c >= 2:
				c = 0
				count = count + 1
			s[j] = count
			c = c + 1
		else:
			count = count + 1
			s[j] = count
			temp = arr[j]
			c = 1
	b = []
	for i in range(count + 1):
		if s.count(i) == 1:
			ind = s.index(i)
			b.append(arr[ind])
	c = list(set(b))
	c.sort()
	for i in range(len(c)):
		print(c[i], end='')
	print()


t = int(input())
while t:
	t -= 1
	s = input()
	res = []
	ch = 0
	c = 1
	for i in range(0, len(s) - 1):
		if s[i] == s[i + 1]:
			c += 1
		else:
			if c % 2:
				res.append(s[i])
			c = 1
	if c % 2:
		res.append(s[len(s) - 1])
	res = list(set(res))
	res.sort()
	for i in res:
		print(i, end='')
	print()


vezes = int(input())
for __ in range(vezes):
	letras = []
	string = input()
	tamanho = 1
	if len(string) == 1:
		print(string[0])
	else:
		for i in range(len(string) - 1):
			if string[i] == string[i + 1]:
				tamanho += 1
				if i == len(string) - 2:
					if tamanho % 2 != 0 and string[i] not in letras:
						letras.append(string[i])
			else:
				if tamanho % 2 != 0 and string[i] not in letras:
					letras.append(string[i])
				tamanho = 1
		if string[len(string) - 1] != string[len(string) - 2]:
			if string[len(string) - 1] not in letras:
				letras.append(string[len(string) - 1])
		letras.sort()
		print(*letras, sep='')


def run():
	import sys
	sys.stdin = open('/home/punit/Documents/Cpp Programs/input.txt', 'r')
	sys.stdout = open('/home/punit/Documents/Cpp Programs/output.txt', 'w')
	from math import ceil, sqrt, floor
for _ in range(int(input())):
	s = input()
	d = dict()
	for i in range(len(s)):
		if s[i] not in d.keys():
			d[s[i]] = [i]
		else:
			d[s[i]].append(i)
	p = ''
	for (k, v) in d.items():
		if len(v) % 2 == 1:
			p += k
		else:
			flag = 1
			for j in range(0, len(v) - 1, 2):
				if v[j + 1] - v[j] > 1:
					flag = 0
					break
			if flag == 0:
				p += k
	p = sorted(p)
	for i in p:
		print(i, end='')
	print()


n = int(input())
lst = []
for _ in range(n):
	lst.append(input().strip())
for i in range(n):
	ans = set()
	s = lst[i]
	l = len(s)
	idx = 0
	while idx < l - 1:
		if s[idx] != s[idx + 1]:
			ans.add(s[idx])
		else:
			idx += 1
		idx += 1
	if idx == l - 1:
		ans.add(s[l - 1])
	print(''.join(sorted(ans)), end='\n')


for _ in range(int(input())):
	s = input()
	n = len(s)
	if n == 1:
		print(s)
	else:
		a = set()
		i = 0
		while i < n - 1:
			if s[i] == s[i + 1]:
				j = i + 1
				while j < n and s[j] == s[i]:
					j += 1
				if (j - i) % 2 != 0:
					a.add(s[i])
				i = j
			else:
				a.add(s[i])
				i += 1
		if s[n - 1] != s[n - 2]:
			a.add(s[n - 1])
		arr = list(sorted(a))
		print(''.join((str(x) for x in arr)))


import sys
sys.setrecursionlimit(10 ** 8)
n = int(input())
for i in range(n):
	ok = set()
	s = input().rstrip() + '#'
	prev = s[0]
	cnt = 1
	for ch in s[1:]:
		if ch != prev:
			if cnt % 2 == 1:
				ok.add(prev)
			prev = ch
			cnt = 1
		else:
			cnt += 1
	ans = list(ok)
	ans.sort()
	print(''.join([str(item) for item in ans]))


import sys
input = sys.stdin.readline

def main():
	t = int(input())
	for _ in range(t):
		S = input().strip()
		ans = set()
		i = 0
		while i < len(S):
			if i == len(S) - 1:
				ans.add(S[i])
				break
			if S[i] != S[i + 1]:
				ans.add(S[i])
				i += 1
				continue
			else:
				i += 2
				continue
		ans2 = sorted(list(ans))
		print(''.join(ans2))
main()


import string
x = string.ascii_lowercase
t = int(input())
for case in range(t):
	s = input()
	n = len(s)
	for char in x:
		s = s.replace(char * 2, '*')
	s = s.replace('*', '')
	s = ''.join(sorted(list(set(list(s)))))
	print(s)


for i in range(int(input())):
	s = input()
	ans = ''
	for j in range(97, 123):
		if s.count(chr(j) + chr(j)) * 2 < s.count(chr(j)):
			ans += chr(j)
	print(ans)


from itertools import zip_longest
t = int(input())
for _ in range(t):
	result = set()
	line = input()
	count = 0
	for (sym1, sym2) in zip_longest(line, line[1:]):
		count += 1
		if sym1 == sym2:
			continue
		else:
			if count % 2:
				result.add(sym1)
			count = 0
	print(''.join(sorted(result)))


T = int(input())
for _ in range(T):
	s = input()
	workings = set()
	last_char = s[0]
	last_char_cnt = 0
	for i in range(len(s)):
		if s[i] == last_char:
			last_char_cnt += 1
		else:
			if last_char_cnt % 2 == 1:
				workings.add(last_char)
			last_char = s[i]
			last_char_cnt = 1
	if last_char_cnt % 2 == 1:
		workings.add(last_char)
	workings = sorted(list(workings))
	print(''.join(workings))


import sys

def minp():
	return sys.stdin.readline().strip()

def mint():
	return int(minp())

def mints():
	return map(int, minp().split())

def solve():
	s = [ord(i) - ord('a') for i in minp()]
	c = [False] * 26
	i = 0
	while i < len(s):
		j = i + 1
		while j < len(s) and s[j] == s[i]:
			j += 1
		if (j - i) % 2 == 1:
			c[s[i]] = True
		i = j
	for i in range(26):
		if c[i]:
			print(chr(i + ord('a')), end='')
	print()
for i in range(mint()):
	solve()


t = int(input())
for _ in range(t):
	s = input()
	letras = []
	tamanho = 1
	if len(s) == 1:
		letras.append(s)
	else:
		for i in range(len(s) - 1):
			if s[i] == s[i + 1]:
				tamanho += 1
				if i == len(s) - 2:
					if tamanho % 2 != 0 and s[i] not in letras:
						letras.append(s[i])
			else:
				if tamanho % 2 != 0 and s[i] not in letras:
					letras.append(s[i])
				tamanho = 1
	if s[len(s) - 1] not in letras and s[len(s) - 1] != s[len(s) - 2]:
		letras.append(s[len(s) - 1])
	letras.sort()
	print(''.join(letras))


n = int(input())
while n:
	S = input()
	S += '_'
	lastChar = ''
	cur = 0
	x = set()
	for s in S:
		if s != lastChar:
			if cur % 2:
				x.add(lastChar)
			lastChar = s
			cur = 1
		else:
			cur += 1
	x = list(x)
	x.sort()
	for c in x:
		print(c, end='')
	print()
	n -= 1


import math
t = int(input())
while t:
	l = input()
	m = []
	n = len(l)
	if n == 1:
		m.append(ord(l[0]))
	else:
		i = 0
		while i < n:
			cnt = 1
			for j in range(i + 1, n):
				if l[i] == l[j]:
					cnt += 1
				else:
					break
			if cnt % 2 != 0:
				m.append(ord(l[i]))
			i = i + cnt - 1
			i += 1
	m = list(set(m))
	m.sort()
	for i in range(len(m)):
		print(chr(m[i]), end='')
	print()
	t -= 1


t = int(input())
from itertools import groupby
for _ in range(t):
	works = []
	for (i, grp) in groupby(input()):
		x = list(grp)
		if len(x) % 2:
			works.append(x[0])
	print(''.join(sorted(set(works))))


n = int(input())
for _ in range(n):
	s = input()
	d = []
	cnt = 1
	for i in range(len(s) - 1):
		if s[i] == s[i + 1]:
			cnt += 1
		else:
			d.append((s[i], cnt))
			cnt = 1
	d.append((s[-1], cnt))
	ans = []
	for (x, y) in d:
		if y % 2 == 1 and x not in ans:
			ans.append(x)
	ans.sort()
	print(''.join(ans))


import math
t = int(input())
for _ in range(t):
	l = list()
	d = dict()
	s = input()
	i = 0
	l1 = list()
	while i < len(s):
		val = s[i]
		j = i
		count = 0
		while s[j] == val and j < len(s):
			count += 1
			j += 1
			if j >= len(s):
				break
		if count % 2 != 0:
			l.append(s[i])
		i = j
	l.sort()
	for i in range(len(l)):
		if l[i] not in d:
			d[l[i]] = 1
			l1.append(l[i])
	print(''.join(l1))


for _ in range(int(input())):
	a = input()
	c = str(a[0])
	cnt = 0
	ans = []
	for i in a:
		if c == i:
			cnt += 1
		else:
			if cnt % 2 != 0:
				ans.append(c)
			cnt = 1
			c = str(i)
	if cnt % 2 != 0:
		ans.append(a[-1])
	ans = set(ans)
	ans = list(ans)
	ans.sort()
	for i in ans:
		print(i, end='')
	print()


num_tests = int(input())
answers = []
for i in range(num_tests):
	string_test = input()
	functional_letters = []
	if len(string_test) < 2:
		answers.append(string_test)
		continue
	while True:
		if len(string_test) == 1:
			functional_letters.append(string_test[0])
			break
		elif len(string_test) == 0:
			break
		if string_test[0] == string_test[1]:
			string_test = string_test[2:]
		else:
			functional_letters.append(string_test[0])
			string_test = string_test[1:]
	answers.append(''.join(sorted(list(set(functional_letters)))))
for a in answers:
	print(a)


n = int(input())
for _ in range(n):
	s = input()
	groupings = []
	current = s[0]
	for i in range(1, len(s)):
		if current[-1] == s[i]:
			current += s[i]
		else:
			groupings.append(current)
			current = s[i]
	groupings.append(current)
	groupings = [u[0] for u in groupings if len(u) % 2 == 1]
	print(''.join(sorted(list(set(groupings)))))


for _ in range(int(input())):
	s = input()
	n = len(s)
	start = s[0]
	count = 1
	ans = set()
	for i in range(1, n):
		if start == s[i]:
			count += 1
		else:
			if count % 2 == 1:
				ans.add(start)
			start = s[i]
			count = 1
	if count % 2 == 1:
		ans.add(start)
	prt = []
	for val in ans:
		prt.append(val)
	prt.sort()
	x = ''
	for i in prt:
		x += i
	print(x)


n = int(input())
while n > 0:
	n -= 1
	x = input()
	arr = []
	for i in range(len(x)):
		arr.append(x[i])
	look = set(arr)
	str = []
	ans = ''
	for item in look:
		if x.count(item) > x.count(item * 2) * 2:
			str.append(item)
	str.sort()
	for item in str:
		ans += item
	print(ans)


n1 = int(input())
for x in range(n1):
	s = input()
	b = sorted(set(s))
	ans = ''
	for i in b:
		if 2 * s.count(2 * i) != s.count(i):
			ans = ans + i
	print(ans)


def separator(b):
	r = 1
	sa = [None] * 500
	sa[0] = b[0]
	s = 0
	while r < len(b):
		if b[r] == b[r - 1]:
			sa[s] = sa[s] + b[r]
		else:
			s = s + 1
			sa[s] = b[r]
		r = r + 1
	return sa
a = int(input())
b = list()
r = 0
while r < a:
	c = [char for char in input()]
	c = separator(c)
	s = 0
	d = list()
	while s < len(c) and c[s] != None:
		if len(c[s]) % 2 != 0 and c[s][0] not in d:
			d.append(c[s][0])
			s = s + 1
		else:
			s = s + 1
	b.append(d)
	r = r + 1
r = 0
while r < len(b):
	b[r].sort()
	print(''.join((char for char in b[r])))
	r = r + 1


for _ in range(int(input())):
	s = list(input())
	s.append('1')
	(r, x) = ([], -1)
	for i in range(len(s) - 1):
		if i > x:
			if s[i] != s[i + 1]:
				r.append(s[i])
			else:
				x = i + 1
	print(''.join(sorted(set(r))))


tc = int(input())
for _ in range(tc):
	s = input()
	nd = set()
	i = 0
	while i < len(s):
		if i == len(s) - 1:
			nd.add(s[-1])
			i += 1
		elif s[i] == s[i + 1]:
			i += 2
		else:
			nd.add(s[i])
			i += 1
	nd = sorted(list(nd))
	print(*nd, sep='')


n = int(input())
ss = []
for i in range(n):
	ss.append(input())
als = [chr(i) for i in range(97, 97 + 26)]
for i in range(n):
	ok = []
	ng = []
	tar = ss[i]
	le = len(tar)
	k = 0
	naga = 1
	con = 0
	while k < le - 1:
		if tar[k] != tar[k + 1] and con == 0:
			ok.append(tar[k])
		elif tar[k] != tar[k + 1] and con == 1:
			if naga % 2 == 1:
				ok.append(tar[k])
				con = 0
				naga = 1
			else:
				con = 0
				naga = 1
		else:
			con = 1
			naga = naga + 1
		k = k + 1
	if le == 1:
		ok.append(tar[0])
	if k == le - 1:
		if tar[k] != tar[k - 1]:
			ok.append(tar[k])
		elif con == 1:
			if naga % 2 == 1:
				ok.append(tar[k])
	print(''.join(sorted(set(ok))))


t = int(input())
D = dict()
B = dict()
for i in range(t):
	s = input()
	for j in range(len(s)):
		if s[j] not in D:
			B[s[j]] = False
	k = 0
	while k < len(s) - 1:
		if s[k] == s[k + 1]:
			k += 2
		else:
			B[s[k]] = True
			k += 1
	if k == len(s) - 1:
		B[s[k]] = True
	for j in range(26):
		if chr(j + 97) in B:
			if B[chr(j + 97)]:
				print(chr(j + 97), end='')
	print()
	D.clear()
	B.clear()


def keyboard(s):
	if len(s) == 1:
		return s
	stack = []
	ans = ''
	for i in s:
		if not stack:
			stack.append(i)
		elif i == stack[-1]:
			stack.clear()
			continue
		else:
			val = stack.pop()
			if val not in ans:
				ans += val
			stack.append(i)
	vals = ''.join(stack)
	ans += vals
	fin = ''
	for i in sorted(set(ans)):
		fin += i
	return fin
t = int(input())
for i in range(t):
	s = input()
	print(keyboard(s))


from itertools import groupby
t = int(input())
while t > 0:
	l = []
	t -= 1
	s = input()
	groups = [''.join(g) for (_, g) in groupby(s)]
	for x in groups:
		if len(x) % 2 == 1:
			l.append(x[0])
	ans = ''
	l = sorted(set(l))
	for i in l:
		ans += i
	print(ans)


t = int(input())
for _ in range(t):
	a = input()
	s = set()
	i = 0
	n = len(a)
	flag = 0
	while i < n:
		count = 1
		for j in range(i + 1, n):
			if a[i] != a[j]:
				break
			count += 1
		if count % 2 == 1:
			s.add(a[i])
		i = i + count
		count = 1
	if len(a) == 1:
		print(a)
	else:
		s = list(s)
		s.sort()
		for i in s:
			print(i, end='')
		print()


t = int(input())
for j in range(t):
	s = input()
	ans = set()
	c = 1
	for i in range(1, len(s)):
		if s[i] == s[i - 1]:
			c += 1
		else:
			if c % 2:
				ans.add(s[i - 1])
			c = 1
	if c % 2:
		ans.add(s[len(s) - 1])
	for x in sorted(ans):
		print(x, end='')
	print()


cases = int(input())
for i in range(cases):
	s = input() + '.'
	count = 1
	funciona = []
	j = 0
	while j + 1 < len(s):
		if s[j] == s[j + 1]:
			count += 1
		else:
			if count % 2 == 1 and s[j] not in funciona:
				funciona.append(s[j])
			count = 1
		j += 1
	funciona.sort()
	print(*funciona, sep='')


n = int(input())
for _ in range(n):
	s = input()
	i = 0
	a = set()
	while i < len(s):
		if i == len(s) - 1 or s[i] != s[i + 1]:
			a.add(s[i])
			i += 1
		else:
			i += 2
	l = [c for c in a]
	l.sort()
	print(''.join(l))


import sys
import math
import itertools
import collections

def getdict(n):
	d = {}
	if type(n) is list or type(n) is str:
		for i in n:
			if i in d:
				d[i] += 1
			else:
				d[i] = 1
	else:
		for i in range(n):
			t = ii()
			if t in d:
				d[t] += 1
			else:
				d[t] = 1
	return d

def divs(n, start=1):
	r = []
	for i in range(start, int(math.sqrt(n) + 1)):
		if n % i == 0:
			if n / i == i:
				r.append(i)
			else:
				r.extend([i, n // i])
	return r

def cdiv(n, k):
	return n // k + (n % k != 0)

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

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

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

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

def wr(arr):
	return ''.join(map(str, arr))

def revn(n):
	return int(str(n)[::-1])

def prime(n):
	if n == 2:
		return True
	if n % 2 == 0 or n <= 1:
		return False
	sqr = int(math.sqrt(n)) + 1
	for d in range(3, sqr, 2):
		if n % d == 0:
			return False
	return True

def nconv(number, base=3):
	newnumber = ''
	while number > 0:
		newnumber = str(number % base) + newnumber
		number //= base
	return newnumber
t = ii()
for _ in range(t):
	s = input()
	ans = set()
	i = 0
	while i < len(s):
		if i != len(s) - 1 and s[i] == s[i + 1]:
			i += 2
		else:
			ans.update(s[i])
			i += 1
	print(wr(sorted(list(ans))))


n = int(input())
lista = []
saida = []
for i in range(n):
	entrada = input()
	lista.append(entrada)
for j in lista:
	k = 0
	s = ''
	while k < len(j) - 1:
		if j[k] == j[k + 1]:
			k += 2
		else:
			if not j[k] in s:
				s += j[k]
			k += 1
	if k == len(j) - 1:
		if not j[k] in s:
			s += j[k]
	s2 = sorted(s)
	s3 = ''
	for l in s2:
		s3 += l
	saida.append(s3)
for l in saida:
	print(l)


t = int(input())
while t:
	s = input()
	a = []
	count = 0
	for i in range(len(s)):
		if i == 0:
			count += 1
			if i == len(s) - 1:
				if count % 2 == 1:
					a.append(s[i])
		elif s[i] == s[i - 1]:
			count += 1
			if i == len(s) - 1:
				if count % 2 == 1:
					a.append(s[i])
		else:
			if count % 2 == 1:
				a.append(s[i - 1])
			count = 1
			if i == len(s) - 1:
				if count % 2 == 1:
					a.append(s[i])
	a = list(set(a))
	a.sort()
	print(''.join((str(x) for x in a)))
	t -= 1


i = int
cin = input

def solve(s):
	a = set(s)
	fin = ''
	for (idx, char) in enumerate(a):
		res = s.count(char) - s.count(char * 2) * 2
		if res > 0:
			fin += char
	fin = ''.join(map(str, sorted(fin)))
	return fin
for _ in range(int(cin())):
	print(solve(cin()))


n = int(input())
for i in range(n):
	s = input()
	d = {}
	val = s[0]
	count = 0
	res = []
	for j in s:
		if j != val:
			if count % 2 == 1:
				res.append(val)
			val = j
			count = 0
		count = count + 1
	if count % 2 == 1:
		res.append(val)
	res = list(set(res))
	res.sort()
	for j in res:
		print(j, end='')
	print()


n = int(input())

def non_mal(w):
	if len(w) == 1:
		return w
	i = 0
	d = {chr(ord('a') + i): False for i in range(26)}
	while i < len(w):
		j = i
		while j + 1 < len(w) and w[j + 1] == w[i]:
			j += 1
		if (j - i) % 2 == 0:
			d[w[i]] = True
		i = j + 1
	res = ''
	for k in d:
		if d[k]:
			res += k
	return res
for _ in range(n):
	print(non_mal(input()))


from sys import stdin, stdout
for i in stdin:
	t = i
	break
for i in stdin:
	i = list(i.strip())
	x = 'abcdefghijklmnopqrstuvwxyz'
	for j in range(len(i) - 1):
		if i[j] == i[j + 1] and i[j] in x:
			(i[j], i[j + 1]) = (1, 1)
	y = [j if j in i else '' for j in x]
	stdout.write(''.join(y) + '\n')


import sys
import itertools
t = int(input())
for _ in range(t):
	s = str(input())
	counter = [[k, len(list(g))] for (k, g) in itertools.groupby(s)]
	result = [char[0] for char in counter if char[1] % 2 != 0]
	res = ''.join(sorted(list(set(result))))
	print(res)


t = int(input())
for _ in range(t):
	s = input()
	if len(s) == 1:
		print(s[0])
	elif len(s) == 2:
		if s[0] != s[1]:
			print(''.join(sorted(s)))
		else:
			print('')
	else:
		d = ''
		i = 0
		while i < len(s):
			if i == len(s) - 1:
				d += s[i]
				break
			elif s[i] == s[i + 1]:
				i = i + 2
			else:
				d += s[i]
				i += 1
		d = sorted(set(d))
		print(''.join(d))


n = int(input())
for i in range(n):
	p = input()
	if len(p) == 1:
		print(p[0])
	else:
		curr = 0
		ans = list()
		for j in range(len(p) - 1):
			if p[j] == p[j + 1]:
				curr += 1
			else:
				break
		if curr % 2 == 0:
			ans.append(p[j])
		curr = 1
		last = -1
		for j in range(1, len(p)):
			if p[j] == p[j - 1]:
				curr += 1
			else:
				if curr % 2 == 1 and p[j - 1] not in ans:
					ans.append(p[j - 1])
				curr = 1
		curr = 0
		for j in range(len(p) - 1, 0, -1):
			if p[j] == p[j - 1]:
				curr += 1
			else:
				break
		if curr % 2 == 0 and p[j] not in ans:
			ans.append(p[j])
		ans.sort()
		for j in range(len(ans)):
			print(ans[j], end='')
		print()


for _ in range(int(input())):
	s = input()
	ans = ''
	for t in s:
		l = s.count(t)
		p = t + t
		k = s.count(p)
		if l != 2 * k or l == 0:
			if t not in ans:
				ans = ans + t
	ans = sorted(ans)
	print(''.join(ans))


t = int(input())
for i in range(t):
	s = str(input())
	is_working = {}
	if len(s) == 1:
		print(s)
	else:
		i = 0
		while i < len(s):
			if i < len(s) - 1:
				if s[i] != s[i + 1]:
					is_working[s[i]] = True
					i += 1
				else:
					if is_working.get(s[i]) is None:
						is_working[s[i]] = False
					i += 2
			else:
				if s[i] != s[i - 1]:
					is_working[s[i]] = True
				elif len(s) > 2:
					if s[i - 2] == s[i - 1] and s[i - 1] == s[i]:
						is_working[s[i]] = True
				i += 1
		result = ''
		for key in is_working:
			if is_working[key]:
				result += key
		print(''.join(sorted(result)))


for _ in range(int(input())):
	a = input()
	n = len(a)
	i = 0
	dic = dict()
	if n == 1:
		print(a)
	else:
		while i < n:
			j = i
			c = 0
			while j < n and a[j] == a[i]:
				j += 1
				c += 1
			if c % 2 != 0:
				dic[a[i]] = True
			i = j
		for i in 'abcdefghijklmnopqrstuvwxyz':
			if i in dic:
				print(i, sep='', end='')
		print()


n = int(input())
for _ in range(n):
	strok = input()
	len_strok = len(strok)
	i = 0
	dict_bukv = {}
	while i < len_strok:
		if strok[i] not in dict_bukv:
			dict_bukv.update({strok[i]: False})
		if i != len_strok - 1 and strok[i] != strok[i + 1]:
			dict_bukv.update({strok[i]: True})
			i += 1
		elif i == len_strok - 1:
			dict_bukv.update({strok[i]: True})
			i += 1
		else:
			i += 2
	print(''.join(sorted([i for i in dict_bukv if dict_bukv[i]])))


for _ in range(int(input())):
	s = input()
	a = [3] * 26
	i = 0
	while i < len(s):
		j = i
		t = 0
		while j < len(s) and s[j] == s[i]:
			j += 1
			t += 1
		if t & 1:
			a[ord(s[i]) - ord('a')] = min(0, a[ord(s[i]) - ord('a')])
		else:
			a[ord(s[i]) - ord('a')] = min(1, a[ord(s[i]) - ord('a')])
		i = j
	s = ''
	for i in range(26):
		if a[i] == 0:
			s += chr(97 + i)
	print(s)


def judge(s):
	d = {x: False for x in set(list(s))}
	c = s[0]
	t = 0
	for i in range(len(s)):
		if c == s[i]:
			t += 1
		else:
			d[c] |= t % 2
			c = s[i]
			t = 1
	d[c] |= t % 2
	ans = [x for x in d if d[x]]
	ans.sort()
	return ''.join(ans)
n = int(input())
for _ in range(n):
	print(judge(input()))


n = int(input())
otv = []
for i in range(n):
	r = ''
	a = input()
	b = ''.join(set(a))
	for i in range(len(b)):
		a = a.replace(b[i] + b[i], ' ')
	a = a.replace(' ', '')
	a = ''.join(set(a))
	otv.append(sorted(a))
for i in range(n):
	print(''.join(map(str, otv[i])))


k = int(input())
for _ in range(k):
	s = input()
	res = [0] * 26
	i = 0
	n = len(s)
	if len(s) == 1:
		print(s)
		continue
	while i < n - 1:
		if s[i] == s[i + 1]:
			i += 2
		else:
			res[ord(s[i]) - ord('a')] += 1
			i += 1
	if i == n - 1:
		res[ord(s[i]) - ord('a')] += 1
	c = ''
	for i in range(len(res)):
		if res[i] != 0:
			c += chr(ord('a') + i)
	print(c)


t = int(input())
lst = list()
for p in range(t):
	a = list()
	i = 0
	arr = input()
	index = 0
	count = 1
	for l in arr:
		if l == arr[index + 1:index + 2]:
			count += 1
		else:
			if count % 2 != 0:
				a.append(l)
				i += 1
			count = 1
		index += 1
		if index == len(arr):
			break
	lst.append(''.join(sorted(set(a))))
for i in lst:
	print(i)


n = int(input())
for i in range(n):
	s = input()
	a = [False] * 26
	curr = '?'
	ct = 0
	for c in s:
		if c == curr:
			ct += 1
		else:
			if ct % 2 == 1:
				a[ord(curr) - ord('a')] = True
			curr = c
			ct = 1
	if ct % 2 == 1:
		a[ord(curr) - ord('a')] = True
	for j in range(26):
		if a[j] == True:
			print(chr(j + ord('a')), end='')
	print()


t = int(input())
for __ in [0] * t:
	s = list(input())
	n = len(s)
	res = []
	cnt = 1
	for i in range(1, n):
		if s[i] == s[i - 1]:
			cnt += 1
		else:
			if cnt % 2 == 1:
				res.append(s[i - 1])
			cnt = 1
	if cnt % 2 == 1:
		res.append(s[-1])
	res = list(set(res))
	res.sort()
	print(''.join(res))


for _ in range(int(input())):
	n = input()
	p = []
	if len(n) == 1:
		print(n)
		continue
	n += ' '
	i = 0
	while i < len(n) - 1:
		if n[i] != n[i + 1]:
			p.append(n[i])
		else:
			i += 1
		i += 1
	print(*sorted(set(p)), sep='')


def funcao(string):
	mapa = {}
	tam = len(string)
	if tam == 1:
		mapa[string] = 1
		return mapa
	i = 0
	while i < tam:
		if i == tam - 1:
			mapa[string[i]] = 1
			return mapa
		if string[i] == string[i + 1]:
			i += 2
		else:
			mapa[string[i]] = 1
			i += 1
	return mapa
t = int(input())
lista = []
for i in range(t):
	lista.append(input())
for e in lista:
	res = sorted(funcao(e).keys())
	print(''.join(res))


for t in range(int(input())):
	a = input()
	i = 0
	ans = ''
	while i < len(a):
		cnt = 1
		j = i + 1
		while j < len(a) and a[i] == a[j]:
			j += 1
			cnt += 1
		if cnt & 1 == 1:
			ans += a[i]
		i = j
	s = set(ans)
	print(''.join((c for c in sorted(s))))


n = int(input())
for i in range(0, n):
	ln = input()
	ct = 1
	nb = [False] * 26
	for j in range(1, len(ln)):
		if ln[j] == ln[j - 1]:
			ct += 1
		else:
			if ct % 2 == 1:
				nb[ord(ln[j - 1]) - 97] = True
			ct = 1
	if ct % 2 == 1:
		nb[ord(ln[len(ln) - 1]) - 97] = True
	st = ''
	for j in range(0, len(nb)):
		if nb[j]:
			st += chr(j + 97)
	print(st)


t = int(input())
for _ in range(t):
	l = input()
	s = list(sorted(list(set(l))))
	a = ''
	for i in s:
		if 2 * l.count(i * 2) != l.count(i):
			a += i
	print(a)


from collections import defaultdict
for _ in range(int(input())):
	s = list(input())
	rec = {}
	rec = defaultdict(lambda : -1)
	ans = []
	i = 0
	n = len(s)
	while i < n:
		j = i
		temp = 0
		while j < n and s[j] == s[i]:
			temp += 1
			j += 1
		if temp % 2 == 0 and rec.get(s[i], 0) != 1:
			rec[s[i]] = -1
		elif rec.get(s[i], 0) != 1:
			ans.append(s[i])
			rec[s[i]] = 1
		i = j
	ans.sort()
	for i in ans:
		print(i, end='')
	print('')


t = int(input())
for i in range(t):
	s = input()
	lst = []
	n = len(s)
	if n == 1:
		print(s)
	else:
		f = 0
		j = 0
		while True:
			if j > n - 1:
				break
			c = 0
			k = j
			while True:
				if k <= n - 1 and s[j] == s[k]:
					c += 1
					k += 1
				else:
					break
			if c % 2 != 0:
				lst.append(s[j])
			j = k
		lst = list(dict.fromkeys(lst))
		lst.sort()
		for j in range(len(lst)):
			print(lst[j], end='')
		print()


t = int(input())
for i in range(t):
	s = input()
	i = 0
	ans = ''
	l = 0
	while l < len(s):
		r = l
		cur = 0
		while r < len(s) and s[l] == s[r]:
			cur += 1
			r += 1
		ans += s[l] * (cur % 2)
		l = r
	ans = list(set(ans))
	ans.sort()
	print(''.join(ans))


t = int(input())
for j in range(0, t):
	s = input()
	res = ''
	i = 0
	while i < len(s):
		k = i + 1
		count = 1
		if k < len(s):
			while s[k] == s[i]:
				count = count + 1
				k = k + 1
				if k >= len(s):
					break
		if count % 2 != 0:
			if s[i] not in res:
				res = res + s[i]
		if count > 1:
			i = k
		else:
			i = i + 1
	a = ''.join(sorted(res))
	print(a)


q = int(input())
for i in range(q):
	a = input()
	if len(a) != 1:
		a = list(a)
	s1 = set()
	s2 = set()
	j = 0
	while j < len(a):
		res = 1
		while j + 1 < len(a) and a[j + 1] == a[j]:
			res += 1
			j += 1
		if res % 2 == 0:
			if a[j] not in s1:
				s1.add(a[j])
		else:
			s2.add(a[j])
		j += 1
	l = list()
	for j in s2:
		l.append(j)
	l.sort()
	print(*l, sep='')


t = int(input())
for _ in range(t):
	s = input()
	n = len(s)
	count = 1
	res = ''
	if len(s) == 1:
		res += s[0]
	else:
		for i in range(1, n):
			if s[i - 1] == s[i]:
				count += 1
			else:
				if count & 1:
					res += s[i - 1]
				count = 1
		if count & 1:
			res += s[i]
	st = sorted(set(res))
	res = ''
	for i in st:
		res += i
	print(res)


import sys, math

def input():
	return sys.stdin.readline()[:-1]

def main():
	q = int(input())
	for _ in range(q):
		s = input()
		if len(s) == 1:
			print(s)
		else:
			s = [str(x) for x in s]
			s += ['_']
			for k in range(len(s) - 1):
				if s[k] == s[k + 1]:
					s[k] = '_'
					s[k + 1] = '_'
			s = set(s)
			s.discard('_')
			print(''.join(sorted(list(s))))
main()


import re
for _ in range(int(input())):
	s = input()
	st = set(s)
	d = {}
	ans = ''
	for i in st:
		patt = '' + i + '+'
		d[i] = [len(j) for j in re.findall(patt, s)]
		for v in d[i]:
			if v % 2 == 1:
				if i not in ans:
					ans += i
	ans = sorted(ans)
	print(''.join(ans))


T = int(input())
for something in range(T):
	s = input()
	res = ''
	i = 0
	while True:
		count = 1
		if i >= len(s):
			break
		try:
			while s[i] == s[i + 1]:
				count += 1
				i += 1
		except:
			IndexError
		if count % 2 == 1:
			if s[i] not in res:
				res += s[i]
		i += 1
	print(''.join(sorted(res)))


import itertools as it
answer = []
for _ in range(int(input())):
	s = input()
	correct = set()
	groups = [list(g) for (k, g) in it.groupby(s)]
	for gr in groups:
		if len(gr) % 2 == 1:
			correct.add(gr[0])
	answer.append(''.join(sorted(correct)))
for ans in answer:
	print(ans)


for _ in range(int(input())):
	s = str(input())
	f = set()
	i = 0
	while i < len(s):
		if i == len(s) - 1:
			f.add(s[-1])
			i += 1
		elif s[i] == s[i + 1]:
			i += 2
		else:
			f.add(s[i])
			i += 1
	fin = sorted(f)
	fLiss = list(fin)
	print(*fLiss, sep='')


from sys import stdin
t = int(stdin.readline().rstrip())
while t > 0:
	s = stdin.readline().rstrip()
	st = s[0]
	c = 1
	for i in range(1, len(s)):
		if s[i] == s[i - 1]:
			c += 1
			if c % 2 == 0:
				st = st[:len(st) - 1]
			else:
				st += s[i]
		else:
			st += s[i]
			c = 1
	l = list(st)
	l.sort()
	d = dict()
	for i in l:
		if i not in d:
			d[i] = 1
		else:
			d[i] += 1
	for i in d.keys():
		print(str(i), end='')
	print()
	t -= 1


for _ in range(int(input())):
	s = input()
	a = set()
	s1 = 1
	s2 = ''
	if len(s) <= 1:
		print(s)
		continue
	for i in range(1, len(s)):
		c = s[i]
		if c == s[i - 1]:
			s1 += 1
		if c != s[i - 1]:
			if s1 % 2 != 0:
				a.add(s[i - 1])
			s1 = 1
	if s1 % 2 != 0:
		a.add(s[len(s) - 1])
	a = sorted(a)
	for i in a:
		s2 += i
	print(s2)


def keyboard(letters):
	saida = []
	res = ''
	indices = []
	for e in range(len(letters) - 1):
		if letters[e] == letters[e + 1] and e not in indices:
			indices.append(e)
			indices.append(e + 1)
	for a in range(len(letters)):
		if a not in indices and letters[a] not in saida:
			saida += letters[a]
	saida.sort()
	for c in range(len(saida)):
		res += saida[c]
	return res
t = int(input())
for a in range(t):
	letters = input()
	print(keyboard(letters))


for i in range(int(input())):
	s = input()
	s2 = set(s)
	for i in s2:
		i = str(i)
		s = s.replace(i * 2, '1')
	s = s.replace('1', '')
	s = sorted(set(s))
	print(''.join(map(str, s)))


t = int(input())
for tt in range(t):
	s = input()
	l = set()
	n = len(s)
	if n == 1:
		print(s, end='')
	else:
		left = 0
		right = 1
		while left < n and right < n:
			if s[left] == s[right]:
				left += 2
				right += 2
			else:
				l.add(s[left])
				left += 1
				right += 1
		if left == n - 1:
			l.add(s[left])
	li = list(l)
	li.sort()
	for i in li:
		print(i, end='')
	print('')


t = int(input())
a = []
for i in range(t):
	a.append(input())
for i in a:
	b = []
	j = 0
	while j < len(i) - 1:
		if i[j] != i[j + 1] and i[j] not in b:
			b.append(i[j])
			j += 1
		elif i[j] == i[j + 1]:
			j += 2
		else:
			j += 1
	if i[-1] not in b and j == len(i) - 1:
		b.append(i[-1])
	b.sort()
	s = ''
	for j in b:
		s += j
	print(s)


for _ in range(int(input())):
	a = [k for k in input()]
	f = []
	if len(a) == len(set(a)):
		print(''.join(map(str, sorted(list(set(a))))))
		continue
	i = 0
	while i < len(a):
		if i + 1 < len(a) and a[i] == a[i + 1]:
			i += 2
		else:
			f.append(a[i])
			i += 1
	print(''.join(map(str, sorted(list(set(f))))))


n = int(input())
for i in range(n):
	x = input()
	y = set(x)
	s = ''
	for j in y:
		t = 0
		tt = []
		for k in x:
			if j == k:
				t += 1
			else:
				tt.append(t)
				t = 0
		tt.append(t)
		val = 0
		for vv in tt:
			if vv % 2 == 1:
				val += 1
		if val > 0:
			s += str(j)
	ss = [iii for iii in s]
	ss.sort()
	fff = ''
	for kkk in ss:
		fff += kkk
	print(fff)


t = int(input())
for i in range(t):
	key = str(input()) + ' '
	i = 0
	used = []
	while i < len(key) - 1:
		if key[i] not in used:
			if key[i] == key[i + 1]:
				i += 1
			else:
				used.append(key[i])
		i += 1
	used.sort()
	print(''.join(used))


n = int(input())
while n:
	n = n - 1
	str = input()
	sz = len(str)
	p = []
	for i in range(sz):
		p.append(0)
	l = 0
	r = 0
	while True:
		if l >= sz:
			break
		while r < sz and str[r] == str[l]:
			r = r + 1
		if (r - l) % 2 != 0:
			p[l] = 1
		l = r
	ans = []
	for i in range(sz):
		if p[i] == 1:
			ans.append(str[i])
	ans.sort()
	lenth = len(ans)
	for i in range(lenth):
		if i > 0 and ans[i] == ans[i - 1]:
			continue
		print(ans[i], end='')
	print()


n = int(input())
cont = 1
answers = []
for i in range(n):
	entrada = input()
	letters = list(entrada)
	letters.append('0')
	for j in range(len(letters)):
		if letters[j] == '0' or letters[j] in answers:
			continue
		elif letters[j] == letters[j + 1]:
			cont += 1
		elif j == 0 or cont % 2 != 0:
			answers.append(letters[j])
			cont = 1
		else:
			cont = 1
	answers.sort()
	ans = ''.join(answers)
	print(ans)
	answers = []


from itertools import groupby
n = int(input())
for i in range(n):
	ans = set()
	s = list(input())
	s = groupby(s)
	for (key, group) in s:
		if len(list(group)) % 2 == 1:
			ans.add(key)
	ans = list(ans)
	ans.sort()
	print(''.join(map(str, ans)))


for _ in range(int(input())):
	alpha = [0 for i in range(26)]
	s = input()
	l = len(s)
	i = 0
	f = 0
	while i < l:
		if i == l - 1:
			f = 1
			alpha[ord(s[i]) - 97] = 1
			break
		if s[i] == s[i + 1]:
			i += 2
		else:
			f = 1
			alpha[ord(s[i]) - 97] = 1
			i += 1
	if f == 1:
		for i in range(26):
			if alpha[i]:
				print(chr(i + 97), end='')
	else:
		pass
	print()


import string
t = int(input())
for _ in range(t):
	x = input()
	d = {}
	c = 1
	pr = x[0]
	for i in range(1, len(x)):
		if x[i] == x[i - 1]:
			c += 1
		else:
			if pr in d:
				if c % 2 == 1:
					d[pr] = c
			else:
				d[pr] = c
			c = 1
			pr = x[i]
	if pr in d:
		if c % 2 == 1:
			d[pr] = c
	else:
		d[pr] = c
	st = ''
	for i in string.ascii_lowercase:
		if i not in d:
			continue
		if d[i] % 2 == 1:
			st += i
	print(st)


t = int(input())
for w in range(t):
	s = list(input())
	for i in range(len(s) - 1):
		if s[i] == s[i + 1]:
			s[i] = ''
			s[i + 1] = ''
	s = list(set(s))
	s.sort()
	print(''.join(s))


q = int(input())
for i in range(q):
	ans = []
	s = input()
	j = 0
	while 1:
		if j >= len(s):
			break
		elif j + 1 >= len(s):
			ans.append(s[j])
			break
		elif s[j] == s[j + 1]:
			j = j + 2
		else:
			ans.append(s[j])
			j = j + 1
	ans.sort()
	S = ''
	for c in ans:
		if len(S) == 0 or c != S[-1]:
			S = S + c
	print(S)


t = int(input())
for i in range(t):
	s = input() + '$'
	res = set()
	prev = '#'
	count = 0
	for c in s:
		if c == prev:
			count += 1
		else:
			if prev != '#' and count % 2 == 1:
				res.add(prev)
				count = 1
			else:
				count += 1
			prev = c
	print(''.join(sorted(res)))


T = int(input())
for t in range(T):
	s = set({})
	line = input()
	cnt_prev = 0
	prev = 'A'
	for c in line:
		if c == prev:
			cnt_prev += 1
		else:
			if cnt_prev & 1 == 1:
				s.add(prev)
			prev = c
			cnt_prev = 1
	if cnt_prev & 1 == 1:
		s.add(prev)
	res = list(s)
	res.sort()
	res = ''.join(res)
	print(res)


n = int(input())
for _ in range(n):
	s = input()
	l = []
	a = b = 0
	for c in s:
		if c == a:
			b += 1
		else:
			if b % 2 > 0 and (not a in l):
				l += [a]
			a = c
			b = 1
	if b % 2 > 0 and (not a in l):
		l += [a]
	print(*sorted(l), sep='')


q = int(input())
for i in range(q):
	a = '0'
	string = input()
	a += string
	a += '0'
	alphabets = 'abcdefghijklmnopqrstuvwxyz'
	good = []
	for letter in alphabets:
		repeated = []
		first = 0
		for i in range(len(string)):
			if string[i] == letter:
				repeated.append(i)
		if len(repeated) == 0:
			continue
		elif len(repeated) % 2 != 0 and len(repeated) > 0:
			good.append(letter)
		elif len(repeated) % 2 == 0 and len(repeated) > 0:
			isconsecutive = False
			for i in range(0, len(repeated), 2):
				if repeated[i + 1] - repeated[i] == 1:
					isconsecutive = True
				elif repeated[i + 1] - repeated[i] != 1:
					isconsecutive = False
					break
			if isconsecutive == False:
				good.append(letter)
	final = ''
	for item in good:
		final += item
	print(final)


entries = int(input())
for i in range(entries):
	s = list(input())
	aux = 0
	output = set()
	if len(s) > 1:
		while aux < len(s) - 1:
			if s[aux] == s[aux + 1]:
				aux += 2
			else:
				output.add(s[aux])
				aux += 1
		if aux == len(s) - 1:
			output.add(s[aux])
	else:
		output.add(s[0])
	output = sorted(output)
	answer = ''
	for c in output:
		answer += c
	print(answer)


for _ in range(int(input())):
	s = input()
	k = [0 for i in range(26)]
	i = 0
	while i < len(s):
		if i != len(s) - 1 and s[i] == s[i + 1]:
			i += 2
		else:
			k[ord(s[i]) - ord('a')] += 1
			i += 1
	for i in range(26):
		if k[i] > 0:
			print(chr(i + ord('a')), end='')
	print()


T = int(input())
for _ in range(T):
	e = input()
	lm = []
	if len(e) == 1:
		print(e)
		continue
	a = 1
	e = e + '\n'
	m = 0
	for i in range(len(e) - 1):
		if e[i] != e[i + 1]:
			d = {}
			for char in e[m:i + 1]:
				if char in d:
					d[char] += 1
				else:
					d[char] = 1
			m = i + 1
			for n in d.keys():
				if d[n] % 2 == 1 and n not in lm:
					lm.append(n)
	print(''.join(sorted(lm)))


from itertools import *
for _ in [0] * int(input()):
	s = set()
	for (k, g) in groupby(input()):
		if len([*g]) % 2:
			s |= {k}
	print(''.join(sorted(s)))


for i in range(int(input())):
	res = []
	st = input()
	s = list(set(list(st)))
	for j in s:
		if st.count(j) - st.count(j * 2) * 2 > 0:
			res += [j]
	print(''.join(sorted(res)))


import sys
readline = sys.stdin.readline
read = sys.stdin.read
ns = lambda : readline().rstrip()
ni = lambda : int(readline().rstrip())
nm = lambda : map(int, readline().split())
nl = lambda : list(map(int, readline().split()))
prn = lambda x: print(*x, sep='\n')

def solve():
	s = ns() + '$'
	l = set()
	t = s[0]
	c = 0
	for x in s:
		if x == t:
			c += 1
		else:
			if c % 2:
				l.add(t)
			t = x
			c = 1
	print(''.join(sorted(list(l))))
	return
T = ni()
for _ in range(T):
	solve()


from sys import stdout
for t in range(int(input())):
	cl = list(input())
	for i in range(1, len(cl)):
		if cl[i] == cl[i - 1]:
			cl[i] = 0
			cl[i - 1] = 0
	cs = set(cl)
	cs.discard(0)
	for c in sorted(cs):
		stdout.write(c)
	print()


t = int(input())
for _ in range(t):
	a = input().strip()
	n = len(a)
	a += '0'
	ans = set()
	lo = 0
	hi = 0
	while lo < n:
		while a[hi] == a[lo]:
			hi += 1
		count = hi - lo
		if count % 2 == 1:
			ans.add(a[lo])
		lo = hi
	print(*sorted(ans), sep='')


def indexes(string, ch):
	return [i for (i, c) in enumerate(string) if c == ch]

def keyboard(string):
	imprimir = []
	letras = set(string)
	for i in letras:
		conteo = string.count(i)
		if not conteo % 2:
			y = indexes(string, i)
			for j in range(0, len(y), 2):
				resta = y[j + 1] - y[j]
				if resta > 1:
					imprimir.append(i)
					break
		else:
			imprimir.append(i)
	return imprimir
tests = int(input())
for i in range(tests):
	string = input()
	y = keyboard(string)
	y.sort()
	x = ''.join(y)
	print(x)


t = int(input())
for x in range(t):
	s = input()
	d = {}
	i = 0
	while i < len(s):
		if d.get(s[i]) == None:
			d[s[i]] = False
		if i < len(s) - 1:
			if s[i] != s[i + 1]:
				d[s[i]] = True
			if s[i] == s[i + 1]:
				i += 1
		else:
			d[s[i]] = True
		i += 1
	ans = ''
	for (keys, val) in d.items():
		if val:
			ans += keys
	ans = list(ans)
	ans.sort()
	print(''.join(ans))


t = int(input())
for _ in range(t):
	input_str = input()
	s = set(list(input_str))
	response = []
	for char in s:
		str = char + char
		if input_str.count(str) * 2 != input_str.count(char):
			response.append(char)
	response.sort()
	for char in response:
		print(char, end='')
	print('')