difficult-characters
Source: hackerearth
Difficulty: EASY

Yesterday while Omar was trying to learn English, he saw that there are letters repeated many times in words while some other letters repeated only few times or not repeated at all!  

Of course anyone can memorize the letters (repeated many times) better than the letters repeated few times, so Omar will concatenate all the words in the context he has, and try to know the difficulty of each letter according to the number of repetitions of each letter.  

So Omar has now the whole context and wants to arrange the letters from the most difficult letter (repeated few times) to the less difficult letter (repeated many times).  

If there are 2 letters with the same level of difficulty, the letter with higher value of ASCII code will be more difficult.  

Input Format:
Given an integer (T), 1 ≤ T ≤ 10 (number of test cases).
For each test case:
Given a string of (lower English characters), 1 ≤ size\; of\; string ≤ 10 ^ 6.
(each string in a new line).  

Output Format:
Output the English lower case characters from the most difficult letter to the less difficult letter. (leave a space between 2 successive letters)
(Output each test case in a separate line).

SAMPLE INPUT
1
oomar

SAMPLE OUTPUT
z y x w v u t s q p n l k j i h g f e d c b r m a o


import string
tc=int(input())
while tc:
	tc=tc-1
	N=input()
	sett=sorted(set(N))
	#print sett
	d={}
	for i in sett:
		countt=N.count(i)
		#print countt
		if d.get(countt,'not found')=='not found':
			d[countt]=[i]
			#print 'if',d[countt]
		else:
			d[countt].append(i)
			#print 'else',d[countt]
	ans=[]
	all_keys=sorted(list(d.keys()),reverse=True)
	for i in all_keys:
		ans.extend(d[i])
	#print ans
	all_letters=string.ascii_lowercase

	ANS=ans
	for i in all_letters:
		if i in ANS:
			pass
		else:
			ANS.append(i)
	ANS.reverse()
	for i in ANS:
		print(i, end=' ')
	print() 
			


import string


t = eval(input())

while t:
	t -=1
	d = {}
	s= input().strip()
	for each in s:
		if each in d:
			d[each] += 1
		else:
			d[each] = 1
	i = 25
	letters = string.ascii_lowercase
	output = ""
	while i >= 0:
		if letters[i] not in d:
			output += letters[i] + " "
		i -= 1


	o = {}

	for each in list(d.keys()):
		if d[each] in o:
			o[d[each]].append(each)
		else:
			o[d[each]] = [each]
	d = {}
	o = sorted(list(o.items()), key=lambda x: x[0])

	for each in o:
		l = each[1]
		l.sort(reverse=True)

		for temp in l:
			output += temp + " "

	print(output)



T = int(eval(input()))
alpha_number_mapping = {}
while T > 0 :
	input_str = input()
	alpha_counts = [0]*26
	for alpha in input_str :
		alpha_counts[ord(alpha)-97] += 1
	
	count_with_alpha = []
	index = 40
	for alpha_count in alpha_counts[::-1] :
		count_with_alpha.append(index + alpha_count*100)
		index += 1
	
	ans = ''
	#print (count_with_alpha)
	count_with_alpha.sort()
	for each_alpha_with_count in count_with_alpha :
                
		ascii_val = chr(-int(str(each_alpha_with_count)[len(str(each_alpha_with_count))-2:])+162)
	#	value = int(str(each_alpha_with_count)[2:])
		ans += ascii_val+' '
	print (ans)
	T -= 1


from collections import OrderedDict

def get_alphabet_dict():
	alphabet_chars = "abcdefghijklmnopqrstuvwxyz"
	reverse_alphabet = alphabet_chars[::-1]
	dict=OrderedDict()
	for k in reverse_alphabet:
		dict[k] = 0
	return dict

def get_difficult_char_sequence(str_input):
	english_alphabet_dict = get_alphabet_dict()
	for char in str_input:
		english_alphabet_dict[char] = english_alphabet_dict[char] + 1

	max_val_key = max(english_alphabet_dict, key=lambda k: english_alphabet_dict[k])
	max_count_val = english_alphabet_dict[max_val_key]

	count = 0
	output_response = ""
	while(count <= max_count_val):
		for key, val in list(english_alphabet_dict.items()):
			if val == count:
				output_response = output_response + key + " "
				del english_alphabet_dict[key]
		count += 1
	return output_response[:-1]

test_case = input()
total_test_case = int(test_case)
outputs = []

# getting the output
for i in range(0, total_test_case):
	input_str = input()
	outputs.append(get_difficult_char_sequence(input_str))

# print the output
for i in range(0, total_test_case):
	print((outputs[i]))


from collections import Counter

kases = int(input())

for _k in range(kases):
	d = Counter('abcdefghijklmnopqrstuvwxyz')
	d.update(input())
	sort_list = sorted(list(d.items()), key=lambda k_v: (k_v[1], k_v[0]), reverse=True)
	d.clear()
	temp = sort_list[1][1]
	outstr = tempstr = ''

	for ele in sort_list:
		if ele[1] != temp:
			outstr = tempstr + outstr
			temp = ele[1]
			tempstr = ''
		tempstr += ele[0] + ' '
	outstr = tempstr + outstr

	print(outstr)


from string import ascii_lowercase
from collections import OrderedDict
import operator
num_test_cases = int(input())

for word in range((num_test_cases)):
	word= str(input())
	

	dic={}
	for c in ascii_lowercase:
		dic[c]=0
	
	for index in range(len(word)):
		letter=word[index]
		dic[letter]=dic[letter]+1
		
	dic= sorted(list(dic.items()), key=lambda key: key[0],reverse=True)
	#dic=sorted(dic.values(), key=operator.itemgetter(0), reverse=False)
	dic.sort(key=lambda x: x[1])
	result=''
	for i,j in dic:
		result=result+ i +' '
		
	print(result)



from string import ascii_lowercase
from collections import OrderedDict
import operator
num_test_cases = int(input())

for word in range((num_test_cases)):
	word= str(input())
	
	

	count=0
	dic={}
	for c in ascii_lowercase:
		dic[c]=[count,0]
		count=count+1
	
	for index in range(len(word)):
		letter=word[index]
		dic[letter]=[dic[letter][0],dic[letter][1]+1]
		
	dic= sorted(list(dic.items()), key=lambda key: key[0],reverse=True)
	#dic=sorted(dic.values(), key=operator.itemgetter(0), reverse=False)
	dic.sort(key=lambda x: x[1][1])
	result=''
	for i,j in dic:
		result=result+ i +' '
		
	print(result)



from string import ascii_lowercase
from collections import OrderedDict
import operator
num_test_cases = int(input())

for word in range((num_test_cases)):
	word= str(input())
	
	

	count=0
	dic={}
	for c in ascii_lowercase:
		dic[c]=[count,0]
		count=count+1
	
	for letter in word:
		dic[letter]=[dic[letter][0],dic[letter][1]+1]
		
	dic= sorted(list(dic.items()), key=lambda key: key[0],reverse=True)
	#dic=sorted(dic.values(), key=operator.itemgetter(0), reverse=False)
	dic.sort(key=lambda x: x[1][1])
	result=''
	for i,j in dic:
		result=result+ i +' '
		
	print(result)



'''
# Read input from stdin and provide input before running code

name = raw_input('What is your name?\n')
print 'Hi, %s.' % name
'''
def solution(ip):
	#ip = raw_input()
	ascii_for_z = int(ord('z'))
	ascii_for_a = int(ord('a'))
	result = []
	ip = list(ip)
	count = {}
	alphabet_ascii = ascii_for_z
	while alphabet_ascii >= ascii_for_a:
		if chr(alphabet_ascii) in ip:
			if chr(alphabet_ascii) not in list(count.keys()):
				count[chr(alphabet_ascii)] = ip.count(chr(alphabet_ascii))
		else:
			result.append(chr(alphabet_ascii))
		alphabet_ascii = alphabet_ascii - 1
	count_values = list(count.values())
	count_values = list(set(count_values))
	count_values = sorted(count_values)
	while count_values:
		minimum_count = count_values.pop(0)
		keys = find_keys(minimum_count, count)
		keys = sorted(keys, reverse=True)
		for key in keys:
			result.append(key)
	op = ""
	for i in result:
		op = op + str(i) + " "
	print(op)
	
	
def find_keys(value, d):
	res = []
	for key in list(d.keys()):
		if d[key] == value:
			res.append(key)
	return res
	
	
t = int(input())

input_now = []

for i in range(0,t):
	input_now.append(input())

for i in input_now:
	solution(i)



J = 0;
J = int(input());
while (J > 0):

	istr = input();

	def GetFreq(istr):
		freqs = [0]*26;
	
		for x in istr:
			freqs[ord(x) - ord('a')] = freqs[ord(x) - ord('a')] + 1;

		afreqs = [];
		for i in range(len(freqs)):
			afreqs.append( ((-1)*freqs[i],i) );
		afreqs.sort();
		afreqs.reverse();
		return afreqs;



	freq = GetFreq(istr);	

	for T in freq:
		print(chr(T[1]+ord('a')), end=' ')
			
	print() 
	J = J-1;


from collections import  Counter
from string import ascii_lowercase as al
n = int(input())
for i in range(n):
	D = Counter(input().strip())
	print(" ".join(sorted(al[::-1], key=lambda p:D[p])))


from collections import Counter
from string import ascii_lowercase as al
for _ in range(int(input())):
	c = Counter(input().strip())
	print(" ".join(sorted(al[::-1], key=lambda x:c[x])))



import string
import operator


t = eval(input())

while t:
	t -=1
	d = {}
	s= input().strip()
	for each in s:
		if each in d:
			d[each] += 1
		else:
			d[each] = 1
	i = 25
	letters = string.ascii_lowercase
	output = ""
	while i >= 0:
		if letters[i] not in d:
			output += letters[i] + " "
		i -= 1

	d = sorted(list(d.items()), key=operator.itemgetter(1))
	o = {}

	for each in d:
		if each[1] in o:
			o[each[1]].append(each[0])
		else:
			o[each[1]] = [each[0]]
	o = sorted(list(o.items()), key=lambda x: x[0])

	for each in o:
		l = each[1]
		l.sort(reverse=True)

		for temp in l:
			output += temp + " "

	print(output)



import string
testcases = int(input())
alphabet_dict=dict()
while(testcases>0):
	name = input()
	alphabet_dict = dict.fromkeys(string.ascii_lowercase, 0)
	for c in name:
		alphabet_dict[c] = alphabet_dict[c] + 1
	#print([(k,v) for v,k in sorted([(v,k) for k,v in alphabet_dict.items()])])
	#print(sorted(alphabet_dict,key=f))
	x = sorted(alphabet_dict, key=lambda k: (-alphabet_dict[k], k),reverse=True )
	print(' '.join(str(p) for p in x)) 
	testcases = testcases - 1 

	


'''
# Read input from stdin and provide input before running code

name = raw_input('What is your name?\n')
print 'Hi, %s.' % name
'''
#print 'Hello World!'
from collections import OrderedDict
tc = int(input())
for i in range(tc):
	letter={'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}

	letter = OrderedDict(sorted(list(letter.items()), key=lambda t: t[0], reverse=True))

	name = str(input())

	for c in name:
		letter[c] += 1
	letter = OrderedDict(sorted(list(letter.items()), key = lambda t: t[1]))
	print(' '.join(list(letter.keys())))


from collections import OrderedDict

n = eval(input())

for i in range(0, n):
	dic = OrderedDict()
	for j in range(122, 96, -1):
		dic[chr(j)] = 0
	sent = list(input())

	for val in sent:
		dic[val] += 1
	temp = sorted(dic, key=dic.get)
	for val2 in temp:
		print(val2, end=' ')
	print("")


'''
# Read input from stdin and provide input before running code

name = raw_input('What is your name?\n')
print 'Hi, %s.' % name
'''
from collections import  Counter
from string import ascii_lowercase as al
n = int(input())
for i in range(n):
	D = Counter(input().strip())
	print(" ".join(sorted(al[::-1], key=lambda p:D[p])))



tc = int(input())
for z in range(0,tc):
	alpha = ['z', 'y', 'x', 'w', 'v', 'u', 't', 's', 'r', 'q', 'p', 'o', 'n', 'm', 'l', 'k', 'j', 'i', 'h', 'g', 'f',
			 'e', 'd', 'c', 'b', 'a']
	count = [0 for i in range(26)]
	str_arr = input()
	for letter in list(str_arr):
		count[alpha.index(letter)] += 1
	dict_arr = {}
	for x in range(26):
		for y in range(26):
			if count[x] < count[y]:
				count[x],count[y] = count[y],count[x]
				alpha[x],alpha[y] = alpha[y],alpha[x]
			if count[x] == count[y] and ord(alpha[x]) > ord(alpha[y]):
				count[x], count[y] = count[y], count[x]
				alpha[x], alpha[y] = alpha[y], alpha[x]
	print(" ".join(alpha))

		


import string

t = int(input())
for i in range(t):
	arr = list(input())
	dic = {}
	out = ""
	for item in arr:
		if item in dic:
			dic[item]+=1
		else:
			dic[item] = 1
	alp = list(string.ascii_lowercase)
	alp.reverse()
	for x in alp:
		if x not in list(dic.keys()):
			out+=x+" "
	temp = 1
	arr1 = []
	while len(dic)!=0:
		if temp in list(dic.values()):
			for key,value in list(dic.items()):
				if temp==value:
					arr1.append(key)
					del dic[key]
		else:
			arr1.sort()
			arr1.reverse()
			for y in range(len(arr1)):
				out+=arr1[y]+" "
			while len(arr1)!=0:
				arr1.pop()
			temp+=1
	arr1.sort()
	arr1.reverse()
	for y in range(len(arr1)):
		out+=arr1[y]+" "
			
	print(out)