Всем привет!

Имеет интересная задачка.

У мужчины довольно странная семейная структура. У каждого мужчины в его семье вначале рождается мальчик, а затем дочка. У каждой женщины — наоборот, вначале девочка, а затем мальчик. Мужчины хочет научиться предсказывать пол K ребенка в N поколении. Напишите соответствующий код

Утилита должна работать с условиями 1 <= K <= min(10^15, 2^(n-1)) and 1 <= N <= 10000

Написал часть кода, но хотел бы попросить о помощи с продолжением

#Asking to enter desired number of child in desired generation
child_number = input(“Please, enter desired number of child:”)
generation = input(“Please, enter desired generation”)
#Checking whether the input of desired number of child and desired generation is numeric
try :
child_number = int(child_number)
generation = int(generation)
except :
print(“Error, please enter numeric input”)
quit()
if 1 <= child_number <= min(10**15, 2**(generation - 1)) :
#There should be the body of the code
else :
print(“Please, enter the diffent number of the child”)
if 1 <= generation <= 10000 :
#There should be the body of code
else :
print(“Please, enter the generation number between 1 and 10 000”)