Problem: After learning basics of arrays and strings, Dark started wondering that if we can sort the numbers then why not STRINGS?

Deeply thinking and looking the various strings lying in the string pool, he decided to ascend or descend the string according to his wish.

Ascending means strings having all the characters in a string in a order like A,B,C,D,...,Z  while descending means string having all characters in a reverse order that is first all Z,Y,X,...,A and so on....

Note: String may contain all the characters available on the normal keyboard.
Thus Dark want you to help him design a code to sort the strings according to his wish the code has to sort either ascending or descending...

To make it easy, Dark wants to print only the characters which are Upper Case Alphabets present in the string in sorted form and don't display the other characters of the string.

Note: String will be only one word with mixture of any key present in the normal keyboard.

Input:

The first line contains T, the number of test cases.
Followed by T lines each contains space separated  a single string 'S' and a number 'N'.

N is even--> Ascending 

N is odd--> Descending

Output:

For every test case print the sorted form of the string.
Print "NULL" if their is no UPPER CASE ALPHABETS present in the string.

Constraints:

1 ≤ T ≤ 500
1 ≤ |S| ≤ 100000
0 ≤ N ≤ 100

Author : Darshak Mehta

SAMPLE INPUT
4
AABAHD 0
AABGHAD 1
AXBCD 0
AXBCD 1

SAMPLE OUTPUT
AAABDH
HGDBAAA
ABCDX
XDCBA

Solution (in PYTHON):

Solution:
testcases = int(raw_input())

for i in range(0,testcases):
	line = raw_input().split()
	while not line:
		line = raw_input().split()
			#else:
	string = line[0]
	order =int(line[1])
	finalstring=""
	flag=0
	#print "Printing Final String"
	for j in string:
		
		if j.isalpha() and j.isupper():
			finalstring+=j
	#	print finalstring
	
		if not string.isupper():
			flag=1
	if order%2==0:
	#sorting is even
		b = sorted(finalstring)
	else:
	#sorting is odd
		b = sorted(finalstring, reverse=True)
	
	if flag==1:
		print "NULL"
	else:
		print ''.join(b)