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:
t=int(raw_input())
while(t):
	t-=1	
	str=""
	temp=0
	b=raw_input().split(' ')	
	a=list(b[0])
	c=[]
	'''for i in a:
		s=ord(i)
		print s		
		if not s in range(65, 91):
			print "tt"'''
			
	for i in a:
		s=ord(i)		
		if s in range(65, 91):
			c.append(i)
	a=c
	c=[]
			
	if len(a) is 0:
		print 'NULL'
	else:
		a.sort()
		if(int(b[1])%2==1):
			a.reverse()
		for i in a:
			str+=i
		print str