human
Lexicographically Kth smallest way to reach given coordinate from origin | Return ( a + b ) ! / a ! b !.
finding ( a + b ) !.
finding ( a + b ) ! / a !.
finding ( a + b ) ! / b !.
Return the Kth smallest way to reach given coordinate from origin.
if at origin.
if on y - axis.
decrement y ..
Move vertical.
recursive call to take next step ..
If on x - axis.
decrement x ..
Move horizontal ..
recursive call to take next step ..
If x + y C x is greater than K.
Move Horizontal.
recursive call to take next step ..
Move vertical.
recursive call to take next step ..
Driver Code"
How can the above be solved in Python?

=====
Write me a code to lexicographically Kth smallest way to reach given coordinate from origin and the other steps required?
assistant
#Here is code to lexicographically Kth smallest way to reach given coordinate from origin and the other steps required.
 def factorial ( a , b ) :
	res = 1
	for i in range ( 1 , a + b + 1 ) :
		res = res * i
	for i in range ( 1 , a + 1 ) :
		res = res // i
	for i in range ( 1 , b + 1 ) :
		res = res // i
	return res
def Ksmallest ( x , y , k ) :
	if x == 0 and y == 0 :
		return
	elif x == 0 :
		y -= 1
		print ( " V " , end = " " )
		Ksmallest ( x , y , k )
	elif y == 0 :
		x -= 1
		print ( " H " , end = " " )
		Ksmallest ( x , y , k )
	else :
		if factorial ( x - 1 , y ) > k :
			print ( " H " , end = " " )
			Ksmallest ( x - 1 , y , k )
		else :
			print ( " V " , end = " " )
			Ksmallest ( x , y - 1 , k - factorial ( x - 1 , y ) )
if __name__ == " _ _ main _ _ " :
	x , y , k = 2 , 2 , 2
	Ksmallest ( x , y , k )