Krishnakant is standing at $(0,0)$ in the Cartesian plane. He wants to go to the point $(x,y)$ in the same plane using only horizontal and vertical moves of $1$ unit. There are many ways of doing this, and he is writing down all such ways. Each way comprises of few ${H}$ moves and few $V}$ moves. i.e. moves in horizontal and vertical direction respectively. For example, if Krishnakant wants to go to point $(2,2)$ from point $(0,0)$, ${HVHV}$ is one of the possible ways.   

Given the value of ${K}$, he wants to know lexicographically $K^{{th}}$ smallest way of going to $(x,y)$ from $(0,0)$.   

Input Format 

The first line contains an integer ${T}$ , i.e., number of test cases. 

Next ${T}$ lines will contain integers ${x}$,$y$ and ${K}$.  

Output Format 

For each test case, print lexicographically $K^{{th}}$ smallest path.  

Constraints 

$1\leq T\leq1000000$ 

$1\leq x\leq10$ 

$1\leq y\leq10$ 

$0\leq K<\text{number of paths}$ 

Sample Input  

2
2 2 2
2 2 3

Sample Output  

HVVH
VHHV

Explanation

All the paths of going to $(2,2)$ from $(0,0)$ in lexicographically increasing order:

$0.HHVV$

$1.HVHV$

$2.HVVH$

$3.VHHV$

$4.VHVH$

$5.VVHH$

Difficulty: MEDIUM
Tags: Combinatorics

Starter code:

Solutions:
import math

def paths(n, m):
	if min(n, m) < 0:
		return 0
	return math.factorial(n + m) / math.factorial(n) / math.factorial(m)
T = int(input())
for cs in range(T):
	res = []
	(N, M, K) = [int(x) for x in input().split()]
	(x, y) = (0, 0)
	while (x, y) != (N, M):
		n = paths(N - x - 1, M - y)
		if x + 1 <= N and K < n:
			res.append('H')
			x += 1
		else:
			K -= n
			res.append('V')
			y += 1
	print(''.join(res))


import collections
answer = collections.defaultdict(list)
for i in range(1, 1047552 + 1):
	b_str = bin(i)[2:]
	b_str = b_str.replace('1', 'H').replace('0', 'V')
	v_ct = b_str.count('V')
	h_ct = b_str.count('H')
	answer[h_ct, v_ct].append(b_str)
	for j in range(v_ct + 1, 11):
		answer[h_ct, j].append('V' * (j - v_ct) + b_str)
for k in answer:
	answer[k].sort()
t = int(input())
for i in range(t):
	(n, m, k) = [int(x) for x in input().split()]
	print(answer[n, m][k])


Nmax = 10
Mmax = 10
NbPath = [[0 for m in range(Mmax)] for n in range(Nmax)]
for m in range(Mmax):
	NbPath[0][m] = 1
for n in range(Nmax):
	NbPath[n][0] = 1
for n in range(1, Nmax):
	for m in range(1, Mmax):
		NbPath[n][m] = NbPath[n - 1][m] + NbPath[n][m - 1]

def getKPath(n, m, k):
	if n == 0:
		return 'V' * m
	if m == 0:
		return 'H' * n
	if k < NbPath[n - 1][m]:
		return 'H' + getKPath(n - 1, m, k)
	else:
		return 'V' + getKPath(n, m - 1, k - NbPath[n - 1][m])
T = int(input())
for _ in range(T):
	(n, m, k) = [int(_) for _ in input().split()]
	print(getKPath(n, m, k))


from sys import stdin
T = int(stdin.readline())

def numpaths(n, m):
	a = 1
	for i in range(n + 1, n + m + 1):
		a *= i
	for i in range(1, m + 1):
		a //= i
	return a

def solve(n, m, k):
	if n == 0:
		return 'V' * m
	elif m == 0:
		return 'H' * n
	elif k < numpaths(n, m) * n // (n + m):
		return 'H' + solve(n - 1, m, k)
	else:
		return 'V' + solve(n, m - 1, k - numpaths(n, m) * n // (n + m))
for _ in range(T):
	(N, M, K) = [int(s) for s in stdin.readline().strip().split()]
	print(solve(N, M, K))


_C = [[1], [1, 1]]

def comb(n, r):

	def _newC():
		_C.append([1] + [cl + cr for (cl, cr) in zip(_C[-1][:-1], _C[-1][1:])] + [1])
	if len(_C) <= n:
		for _ in range(len(_C), n + 1):
			_newC()
	return _C[n][r]

def lexi_step(h, v, k):
	(th, tv, tk) = (h, v, k)
	result = ''
	while th:
		c = comb(th + tv - 1, tv)
		if tk >= c:
			tv -= 1
			tk -= c
			result += 'V'
		else:
			th -= 1
			result += 'H'
	while tv:
		tv -= 1
		result += 'V'
	return result
T = int(input())
for _ in range(T):
	(N, M, K) = map(int, input().split())
	print(lexi_step(N, M, K))


import itertools
l = []
for i in range(20):
	l.append(pow(2, i))
m = []
for i in range(1, 11):
	for j in range(1, 11):
		n = []
		c = l[:i + j - 1]
		c.reverse()
		for k in itertools.combinations(c, i):
			t = 0
			for h in k:
				t = t + int(h)
			n.append(t)
		m.append(n)
r = int(input())
for i in range(r):
	u = input().split(' ')
	u[0] = int(u[0])
	u[1] = int(u[1])
	w = u[0] + u[1]
	u[2] = int(u[2])
	y = bin(m[(u[0] - 1) * 10 + u[1]][u[2]])[1:]
	e = ''
	for u in y:
		if u == '0':
			e = e + 'V'
		elif u == '1':
			e = e + 'H'
	if len(e) < w:
		e = (w - len(e)) * 'V' + e
	print(e)


class unique_element:

	def __init__(self, value, occurrences):
		self.value = value
		self.occurrences = occurrences

def perm_unique(elements):
	eset = set(elements)
	listunique = [unique_element(i, elements.count(i)) for i in eset]
	u = len(elements)
	return perm_unique_helper(listunique, [0] * u, u - 1)

def perm_unique_helper(listunique, result_list, d):
	if d < 0:
		yield tuple(result_list)
	else:
		for i in listunique:
			if i.occurrences > 0:
				result_list[d] = i.value
				i.occurrences -= 1
				for g in perm_unique_helper(listunique, result_list, d - 1):
					yield g
				i.occurrences += 1

def do(a, b):
	perms = [''.join(p) for p in perm_unique(['H'] * a + ['V'] * b)]
	perms.sort()
	return perms
sa = [[0] * 11 for i in range(11)]
for i in range(1, 11):
	for j in range(1, 11):
		sa[i][j] = do(i, j)
tcs = int(input())
for i in range(tcs):
	(a, b, c) = map(int, input().split(' '))
	print(sa[a][b][c])


from math import factorial
facs = [factorial(x) for x in range(21)]

def a_0(N, M, K):
	if N == 0 and M == 0:
		return
	L = N + M
	nr_paths = facs[L] / (facs[N] * facs[M])
	nr_N_perColumn = nr_paths * N / L
	if K < nr_N_perColumn:
		print('H', end='')
		a_0(N - 1, M, K)
	else:
		print('V', end='')
		a_0(N, M - 1, K - nr_N_perColumn)
T = int(input())
for i in range(T):
	(N, M, K) = map(int, input().split())
	a_0(N, M, K)
	print()


import math

def nck(n, k):
	f = math.factorial
	return f(n) / f(k) / f(n - k)
T = int(input())
for i in range(T):
	s = input()
	(n, m, k) = s.split()
	n = int(n)
	m = int(m)
	k = int(k)
	k = k + 1
	res = ''
	while n + m > 0:
		if n == 0:
			for i in range(m):
				res = res + 'V'
			m = 0
		elif m == 0:
			for i in range(n):
				res = res + 'H'
			n = 0
		else:
			top = nck(n + m - 1, n - 1)
			if top < k:
				k = k - top
				res = res + 'V'
				m = m - 1
			else:
				res = res + 'H'
				n = n - 1
	print(res)


class Paths:

	def __init__(self):
		self.paths = []
SIZE = 11
board = []
for x in range(0, SIZE):
	line = []
	for y in range(0, SIZE):
		line.append(Paths())
	board.append(line)
board[0][0].paths = ['']
for x in range(0, SIZE):
	for y in range(0, SIZE):
		if x == 0 and y == 0:
			continue
		combined_paths = []
		if x > 0:
			for path in board[x - 1][y].paths:
				combined_paths.append(path + 'H')
		if y > 0:
			for path in board[x][y - 1].paths:
				combined_paths.append(path + 'V')
		combined_paths.sort()
		board[x][y].paths = combined_paths
test_count = int(input())
for i in range(0, test_count):
	test_input = list(map(int, input().split()))
	print(board[test_input[0]][test_input[1]].paths[test_input[2]])


C = [[-1] * 25 for _ in range(25)]

def choose(n, k):
	if k == 0 or n == k:
		return 1
	if C[n][k] != -1:
		return C[n][k]
	C[n][k] = choose(n - 1, k - 1) + choose(n - 1, k)
	return C[n][k]
t = int(input())
for _ in range(t):
	(x, y, k) = list(map(int, input().split()))
	ways = choose(x + y, x)
	res = []
	while k > 0 and x > 0 and (y > 0):
		ways = choose(x + y, x) * x // (x + y)
		if ways <= k:
			k = k - ways
			res.append('V')
			y -= 1
		else:
			res.append('H')
			x -= 1
	for _ in range(x):
		res.append('H')
	for _ in range(y):
		res.append('V')
	print(''.join(list(map(str, res))))


table = [[1] * 11 for _ in range(11)]
for i in range(1, 11):
	for j in range(1, 11):
		table[i][j] = table[i - 1][j] + table[i][j - 1]
for _ in range(int(input())):
	(h, v, k) = map(int, input().split())
	string = ''
	while h or v:
		if h and k < table[h - 1][v]:
			string += 'H'
			h -= 1
		else:
			k -= table[h - 1][v]
			string += 'V'
			v -= 1
	print(string)


def fact(n):
	if n <= 1:
		return 1
	return n * fact(n - 1)

def cm(a, b):
	return fact(a + b) / (fact(a) * fact(b))

def f(x, y, k, s):
	if x == 0 and y == 0:
		return s
	elif x == 0:
		return f(x, y - 1, k, s + 'V')
	elif y == 0:
		return f(x - 1, y, k, s + 'H')
	else:
		h = cm(x - 1, y)
		if h > k:
			return f(x - 1, y, k, s + 'H')
		else:
			return f(x, y - 1, k - h, s + 'V')
for t in range(int(input())):
	(x, y, k) = map(int, input().split())
	print(f(x, y, k, ''))


nCr = [[0 for x in range(25)] for x in range(25)]

def Preprocess():
	nCr[0][0] = 0
	for i in range(22):
		nCr[i][0] = 1
		nCr[i][i] = 1
		for j in range(i):
			nCr[i][j] = nCr[i - 1][j] + nCr[i - 1][j - 1]

def solve():
	s = input()
	(x, y, K) = s.strip().split(' ')
	x = int(x)
	y = int(y)
	K = int(K)
	ans = ''
	cur = int(0)
	while cur < K:
		temp = nCr[y + x - 1][y]
		if cur + temp > K:
			ans += 'H'
			x -= 1
		else:
			ans += 'V'
			y -= 1
			cur += temp
	while x > 0:
		ans += 'H'
		x -= 1
	while y > 0:
		ans += 'V'
		y -= 1
	print(ans)

def main():
	t = int(input())
	Preprocess()
	while t > 0:
		solve()
		t -= 1
main()


def findpath(x, y):
	if (x, y) not in cache:
		cache[x, y] = ([], [])
		x_less_node = ([], [])
		y_less_node = ([], [])
		if x != 0:
			x_less_node = findpath(x - 1, y)
		if y != 0:
			y_less_node = findpath(x, y - 1)
		if x == 0 and y == 0:
			cache[x, y] = ([''], [''])
			return cache[x, y]
		H = []
		V = []
		if x != 0:
			H += [i + 'V' for i in y_less_node[0]]
			H += [i + 'H' for i in x_less_node[0]]
			H = sorted(H)
		if y != 0:
			V += [i + 'V' for i in y_less_node[1]]
			V += [i + 'H' for i in x_less_node[1]]
			V = sorted(V)
		cache[x, y] = (H, V)
	return cache[x, y]
cache = dict()
n = int(input())
for i in range(n):
	(x, y, k) = input().strip().split()
	results = findpath(int(x), int(y))
	paths = results[0] + results[1]
	print(paths[int(k)])


def findpath(x2, y2):
	if (x2, y2) not in cachetable:
		cachetable[x2, y2] = []
		if x2 != 0:
			temppath = findpath(x2 - 1, y2)
			if not temppath:
				cachetable[x2, y2] = ['H']
			else:
				cachetable[x2, y2] += [i + 'H' for i in findpath(x2 - 1, y2)]
				cachetable[x2, y2] = sorted(cachetable[x2, y2])
		if y2 != 0:
			temppath = findpath(x2, y2 - 1)
			if not temppath:
				cachetable[x2, y2] = ['V']
			else:
				cachetable[x2, y2] += [i + 'V' for i in findpath(x2, y2 - 1)]
				cachetable[x2, y2] = sorted(cachetable[x2, y2])
	return cachetable[x2, y2]
cachetable = dict()
n = int(input())
for i in range(n):
	(x, y, k) = input().strip().split()
	paths = findpath(int(x), int(y))
	print(paths[int(k)])


def findpath(x2, y2):
	if (x2, y2) not in cachetable:
		cachetable[x2, y2] = []
		if 0 != x2:
			temppath = findpath(x2 - 1, y2)
			if not temppath:
				cachetable[x2, y2] = ['H']
			else:
				cachetable[x2, y2] += [i + 'H' for i in findpath(x2 - 1, y2)]
				cachetable[x2, y2] = sorted(cachetable[x2, y2])
		if 0 != y2:
			temppath = findpath(x2, y2 - 1)
			if not temppath:
				cachetable[x2, y2] = ['V']
			else:
				cachetable[x2, y2] += [i + 'V' for i in findpath(x2, y2 - 1)]
				cachetable[x2, y2] = sorted(cachetable[x2, y2])
	return cachetable[x2, y2]
cachetable = dict()
n = int(input())
for i in range(n):
	(x, y, k) = input().strip().split()
	paths = findpath(int(x), int(y))
	print(paths[int(k)])


from sys import stdin
from itertools import accumulate as acc, count, combinations_with_replacement as cmbrep, takewhile as tkw, repeat as rp, dropwhile as dpw, combinations as comb
from functools import reduce
from random import randint
from collections import Counter
from math import sqrt, log, factorial
from fractions import gcd
from heapq import merge
from array import array
filou = None

def cb1(N):
	return sum((int(i) for i in bin(N)[2:]))

def toLit(N, bits):
	return bin(N)[2:].zfill(bits).replace('0', 'H').replace('1', 'V')

def lessStup(x, y, K):
	return toLit(tab[x][K], x + y)

def prep(MaxBits):
	cnb = [0] * (MaxBits + 1)
	(parCbAll, sz) = ([], 1)
	for bi in range(MaxBits + 1):
		parCbAll += [array('i', [0] * sz)]
		sz = sz * (MaxBits - bi) // (bi + 1)
	for v in range(1, 2 ** MaxBits):
		nb1 = cb1(v)
		if nb1 <= 10:
			parCbAll[nb1][cnb[nb1]] = v
			cnb[nb1] += 1
	return parCbAll
tab = prep(20)
rd = open(filou) if filou else stdin
for _ in range(int(rd.readline().strip())):
	(x, y, K) = map(int, rd.readline().strip().split())
	print(lessStup(y, x, K))


import math

def getOrder(x, y, k):
	if x + y == 0:
		return ''
	elif x == 0:
		return 'V' + getOrder(x, y - 1, k)
	elif y == 0:
		return 'H' + getOrder(x - 1, y, k)
	else:
		cutoff = math.factorial(x + y - 1) // math.factorial(x - 1) // math.factorial(y)
		if k < cutoff:
			return 'H' + getOrder(x - 1, y, k)
		else:
			return 'V' + getOrder(x, y - 1, k - cutoff)
t = int(input().strip())
for _ in range(t):
	(x, y, k) = [int(temp) for temp in input().strip().split(' ')]
	print(getOrder(x, y, k))


from math import factorial as f
T = int(input())
for i in range(T):
	(H, V, K) = (int(j) for j in input().split())
	st = ''
	while H + V > 0:
		total = f(H + V) // f(H) // f(V)
		h_part = H * total // (H + V)
		if K < h_part:
			st += 'H'
			H -= 1
		else:
			st += 'V'
			V -= 1
			K -= h_part
	print(st)


F = {}

def f(n, l):
	if n == 3:
		return (l + 1) * (l + 2) // 2
	if n == 2:
		return l + 1
	if n == 1:
		return 1
	if (n, l) in F:
		return F[n, l]
	s = 1
	for i in range(1, l + 1):
		s += f(n - 1, i)
	F[n, l] = s
	return s

def solve3(H, V, K):
	A = [0] * V
	i = 0
	r = 0
	while True:
		s = 0
		while s + r < K:
			A[i] += 1
			s = f(A[i], V - i)
		if s + r == K:
			break
		A[i] -= 1
		s = f(A[i], V - i)
		i += 1
		r += s
	s = []
	B = [A[i] - A[i + 1] for i in range(len(A) - 1)] + [A[-1]]
	for b in reversed(B):
		for h in range(b):
			s.append('H')
			H -= 1
		s.append('V')
	for h in range(H):
		s.append('H')
	p = ''
	for k in reversed(s):
		p += k
	return p
T = int(input())
for t0 in range(T):
	(H, V, K) = (int(a) for a in input().split())
	print(solve3(H, V, K))


T = int(input())
for run in range(T):
	(x, y, k) = [int(i) for i in input().split()]
	n = x + y
	s = ''
	(p, q) = (1, 1)
	for i in range(x - 1):
		p *= n - 1 - i
		q *= i + 1
	ch = p // q
	for i in range(n):
		if ch > k:
			s += 'H'
			x -= 1
			if i + 1 < n:
				ch = ch * x // (n - i - 1)
		else:
			s += 'V'
			k -= ch
			if i + 1 < n:
				ch = ch * (n - i - x) // (n - i - 1)
	print(s)


from itertools import permutations
from math import factorial as f
t = int(input())
while t:
	t -= 1
	(x, y, k) = map(int, input().split())
	s = ''
	while x != 0 and y != 0:
		b = f(x + y - 1) // (f(x - 1) * f(y))
		if k < b:
			s += 'H'
			x -= 1
		else:
			s += 'V'
			y -= 1
			k -= b
	if x == 0:
		s += 'V' * y
	else:
		s += 'H' * x
	print(s)


def build_dp(x, y):
	dp = [[[]] * (y + 1) for _ in range(x + 1)]
	for j in range(y + 1):
		for i in range(x + 1):
			if i or j:
				if j == 0:
					dp[i][j] = [i * 'H']
				elif i == 0:
					dp[i][j] = [j * 'V']
				else:
					below = [e + 'V' for e in dp[i][j - 1]]
					left = [e + 'H' for e in dp[i - 1][j]]
					dp[i][j] = below + left
					dp[i][j].sort()
	return dp

def solve(x, y, k):
	return dp[x][y][k]
dp = build_dp(10, 10)
t = int(input().strip())
for _ in range(t):
	(x, y, k) = [int(i) for i in input().strip().split()]
	print(solve(x, y, k))


nchoosek = [[1]]
for i in range(1, 18 + 1):
	nchoosek.append([])
	nchoosek[i].append(1)
	for j in range(1, i):
		nchoosek[i].append(nchoosek[i - 1][j - 1] + nchoosek[i - 1][j])
	nchoosek[i].append(1)

def compute_kth_path(x, y, k, s=''):
	if x == 0:
		return s + 'V' * y
	elif y == 0:
		return s + 'H' * x
	elif k < nchoosek[x + y - 1][y]:
		s = compute_kth_path(x - 1, y, k, s + 'H')
	else:
		s = compute_kth_path(x, y - 1, k - nchoosek[x + y - 1][y], s + 'V')
	return s
T = int(input())
for _ in range(0, T):
	(x, y, k) = [int(a) for a in input().split()]
	print(compute_kth_path(x, y, k))


def getProduct(start, end):
	product = 1
	for i in range(start, end + 1):
		product *= i
	return product

def addCheck(h, v, count, path):
	if not count:
		return path + 'H' * h + 'V' * v
	else:
		top = getProduct(v + 1, h + v - 1)
		bottom = getProduct(1, h - 1)
		temp = int(top / bottom)
		if count - temp >= 0:
			count -= temp
			path += 'V'
			return addCheck(h, v - 1, count, path)
		else:
			path += 'H'
			return addCheck(h - 1, v, count, path)
T = int(input().strip())
for i in range(T):
	values = input().strip().split(' ')
	(x, y, k) = (int(values[0]), int(values[1]), int(values[2]))
	print(addCheck(x, y, k, ''))


import time
fact = [1]
for i in range(1, 30):
	fact.append(fact[-1] * i)
cache = {}

def choose(n, k):
	if n < 0 or k < 0 or k > n:
		return 0
	return fact[n] // fact[k] // fact[n - k]

def solve(x, y, k):
	if x == 0 and y == 0 and (k == 0):
		return ''
	if k < 0 or x < 0 or y < 0 or (choose(x + y, x) < k):
		return None
	if (x, y, k) in cache:
		return cache[x, y, k]
	a = solve(x - 1, y, k)
	if a is not None:
		a = 'H' + a
	b = solve(x, y - 1, k - choose(x - 1 + y, x - 1))
	if b is not None:
		b = 'V' + b
	result = a or b
	cache[x, y, k] = result
	return result
t = int(input())
for _ in range(t):
	(x, y, k) = [int(s) for s in input().split(' ')]
	start = time.time()
	print(solve(x, y, k))


def precomp_binom(M):
	M += 1
	B = [[0] * M for _ in range(M)]
	B[0][0] = 1
	for n in range(1, M):
		B[n][0] = 1
		for p in range(1, n + 1):
			B[n][p] = B[n - 1][p - 1] + B[n - 1][p]
	return B
B = precomp_binom(20)

def kth_path(X, Y, K):
	P = []
	k = 0
	while X or Y:
		if X and k + B[X + Y - 1][X - 1] > K:
			X -= 1
			P.append('H')
		else:
			k += B[X + Y - 1][X - 1]
			Y -= 1
			P.append('V')
	return ''.join(P)

def main():
	T = int(input())
	for _ in range(T):
		(X, Y, K) = map(int, input().split())
		print(kth_path(X, Y, K))
main()


hist = {}

def binom(n, k):
	if k == 0 or k == n:
		return 1
	q = (n, k)
	if q in hist:
		return hist[q]
	rv = binom(n - 1, k) + binom(n - 1, k - 1)
	hist[q] = rv
	return rv
hist2 = {}

def path_str(x, y, k):
	if x == 0:
		return 'V' * y
	if y == 0:
		return 'H' * x
	q = (x, y, k)
	if q in hist2:
		return hist2[q]
	a = binom(x + y - 1, x - 1)
	if k < a:
		rv = 'H' + path_str(x - 1, y, k)
	else:
		rv = 'V' + path_str(x, y - 1, k - a)
	hist2[q] = rv
	return rv
num_q = int(input())
for _ in range(num_q):
	(x, y, k) = (int(x) for x in input().split())
	print(path_str(x, y, k))


import sys
from time import time

def rdigit_gen(n, base):
	if n == 0:
		yield 0
	else:
		while n:
			yield (n % base)
			n //= base

def rbin_gen(n, k):
	stack = [(list(range(k)), [], n)]
	while stack:
		(prefix, suffix, ix) = stack.pop()
		yield (prefix + suffix)
		if prefix:
			for i in range(ix - 1, prefix[-1], -1):
				stack.append((list(prefix[:-1]), [i] + suffix, i))

def convert(rii, n):
	dd = [0] * n
	for ix in rii:
		dd[ix] = 1
	return dd[::-1]

def solve_bf(x, y, k):
	print('x=%d y=%d k=%d' % (x, y, k), file=sys.stderr)
	for (i, rii) in enumerate(rbin_gen(x + y, y)):
		print('\ti=%d rii=%s dd=%s' % (i, rii, convert(rii, x + y)), file=sys.stderr)
		if i == k:
			bb = convert(rii, x + y)
			return ''.join(('HV'[b] for b in bb))
	return ''

def pascal_gen():
	line = [1]
	while True:
		yield line
		new_line = [1]
		for i in range(1, len(line)):
			new_line.append(line[i - 1] + line[i])
		new_line.append(1)
		line = new_line

def binomial_cache(n):
	cache = []
	for (i, line) in enumerate(pascal_gen()):
		cache.append(line)
		if i == n:
			break
	return cache

def solve(x, y, k, bcache):

	def calc(n, m, k):
		print('\t\tn=%d m=%d k=%d' % (n, m, k), file=sys.stderr)
		if k >= bcache[n][m]:
			raise Exception('n=%d m=%d k=%d' % (n, m, k))
		if n == 0:
			return ''
		if n == m:
			return 'V' * n
		(c1, c2) = (bcache[n][m], bcache[n - 1][m])
		print('\t\t\tc1=%d c2=%d' % (c1, c2), file=sys.stderr)
		if k < c2:
			return 'H' + calc(n - 1, m, k)
		return 'V' + calc(n - 1, m - 1, k - c2)
	print('\tx=%d y=%d k=%d' % (x, y, k), file=sys.stderr)
	return calc(x + y, y, k)
tm = time()
bcache = binomial_cache(20)
print('bcache generated', file=sys.stderr)
t = int(input())
for _ in range(t):
	(x, y, k) = map(int, input().split())
	print(solve(x, y, k, bcache))
print('time elapsed: %s' % (time() - tm,), file=sys.stderr)


fact = [1] * 21
for i in range(1, len(fact)):
	fact[i] = fact[i - 1] * i
T = int(input())
for t in range(T):
	(x, y, k) = map(int, input().split())
	out = []
	while x or y:
		n = fact[x + y - 1] // (fact[y] * fact[x - 1]) if x else 0
		if k < n:
			out.append('H')
			x -= 1
		else:
			out.append('V')
			y -= 1
			k -= n
	print(''.join(out))


from math import factorial

def binom(n, k):
	return factorial(n) // factorial(k) // factorial(n - k)
for _ in range(int(input())):
	(first, second, index) = map(int, input().split())
	result = ''
	while first > 0 and second > 0:
		coeff = binom(first + second - 1, second)
		if index < coeff:
			result += 'H'
			first -= 1
		else:
			result += 'V'
			second -= 1
			index -= coeff
	print(result + 'H' * first + 'V' * second)


from math import *
mod = 1000000007

def binpow(a, b):
	global mod
	if b == 1:
		return a % mod
	u = binpow(a, b // 2)
	if b % 2 == 0:
		return u * u % mod
	else:
		return u * u * a % mod
dic = {}

def ncr(n, r):
	if r > n - r:
		r = n - r
	if r == 0 and n == 0:
		return 1
	if r > n:
		return 0
	if n == r or r == 0:
		return 1
	if r == 1:
		return n
	key = str(n) + '|' + str(r)
	if key not in dic:
		dic[key] = ncr(n - 1, r - 1) + ncr(n - 1, r)
	return dic[key]
glob = []
l = [[]]
for i in range(1, 11):
	l.append(['H' * i])
glob.append(l)
for j in range(1, 11):
	m = [['V' * j]]
	for r in range(1, 11):
		x = []
		for a in m[-1]:
			x.append('H' + a)
		for a in glob[-1][r]:
			x.append('V' + a)
		m.append(x)
	glob.append(m)
for _ in range(int(input())):
	s = [int(i) for i in input().split()]
	print(glob[s[1]][s[0]][s[2]])


import os
import sys
from math import factorial as f
t = int(input())
for t_itr in range(t):
	nmk = input().split()
	n = int(nmk[0])
	m = int(nmk[1])
	k = int(nmk[2])
	s = ''
	while k > 0:
		if k < f(n + m - 1) // (f(m) * f(n - 1)):
			s += 'H'
			n -= 1
		else:
			s += 'V'
			k -= f(n + m - 1) // (f(m) * f(n - 1))
			m -= 1
	s += n * 'H'
	s += m * 'V'
	print(s)


from math import factorial

def C(n, r):
	ans = factorial(n) / (factorial(r) * factorial(n - r))
	return ans

def solve(x, y, k):
	ans = ''
	while k > 0:
		if k < C(x + y - 1, y):
			ans += 'H'
			x -= 1
		else:
			ans += 'V'
			k -= C(x + y - 1, y)
			y -= 1
	ans += x * 'H'
	ans += y * 'V'
	return ans
for _ in range(int(input())):
	(x, y, k) = map(int, input().split())
	print(solve(x, y, k))


import math

def paths(n, m):
	if min(n, m) < 0:
		return 0
	return math.factorial(n + m) / math.factorial(n) / math.factorial(m)
T = int(input())
for cs in range(T):
	res = []
	(N, M, K) = [int(x) for x in input().split()]
	(x, y) = (0, 0)
	while (x, y) != (N, M):
		n = paths(N - x - 1, M - y)
		if x + 1 <= N and K < n:
			res.append('H')
			x += 1
		else:
			K -= n
			res.append('V')
			y += 1
	print(''.join(res))


import math

def paths(n, m):
	if min(n, m) < 0:
		return 0
	return math.factorial(n + m) / math.factorial(n) / math.factorial(m)
T = int(input())
for cs in range(T):
	res = []
	(N, M, K) = [int(x) for x in input().split()]
	(x, y) = (0, 0)
	while (x, y) != (N, M):
		n = paths(N - x - 1, M - y)
		if x + 1 <= N and K < n:
			res.append('H')
			x += 1
		else:
			K -= n
			res.append('V')
			y += 1
	print(''.join(res))


import math

def paths(n, m):
	if min(n, m) < 0:
		return 0
	return math.factorial(n + m) / math.factorial(n) / math.factorial(m)
T = int(input())
for cs in range(T):
	res = []
	(N, M, K) = [int(x) for x in input().split()]
	(x, y) = (0, 0)
	while (x, y) != (N, M):
		n = paths(N - x - 1, M - y)
		if x + 1 <= N and K < n:
			res.append('H')
			x += 1
		else:
			K -= n
			res.append('V')
			y += 1
	print(''.join(res))


import math

def paths(n, m):
	if min(n, m) < 0:
		return 0
	return math.factorial(n + m) / math.factorial(n) / math.factorial(m)
T = int(input())
for cs in range(T):
	res = []
	(N, M, K) = [int(x) for x in input().split()]
	(x, y) = (0, 0)
	while (x, y) != (N, M):
		n = paths(N - x - 1, M - y)
		if x + 1 <= N and K < n:
			res.append('H')
			x += 1
		else:
			K -= n
			res.append('V')
			y += 1
	print(''.join(res))


import math

def paths(n, m):
	if min(n, m) < 0:
		return 0
	return math.factorial(n + m) / math.factorial(n) / math.factorial(m)
T = int(input())
for cs in range(T):
	res = []
	(N, M, K) = [int(x) for x in input().split()]
	(x, y) = (0, 0)
	while (x, y) != (N, M):
		n = paths(N - x - 1, M - y)
		if x + 1 <= N and K < n:
			res.append('H')
			x += 1
		else:
			K -= n
			res.append('V')
			y += 1
	print(''.join(res))


dp = [[1 for i in range(11)] for j in range(11)]
for i in range(1, 11):
	for j in range(1, 11):
		dp[i][j] = dp[i - 1][j] + dp[i][j - 1]
for _ in range(int(input())):
	(x, y, k) = [int(p) for p in input().split()]
	k += 1
	result = ''
	while x > 0 and y > 0:
		if dp[x - 1][y] >= k:
			result += 'H'
			x -= 1
		else:
			result += 'V'
			k -= dp[x - 1][y]
			y -= 1
	while y > 0:
		result += 'V'
		y -= 1
	while x > 0:
		result += 'H'
		x -= 1
	print(result)