def find_kth(nums1, nums2, index1, index2, k):
    if (index1 >= len(nums1)):
        return nums2[((index2 + k) - 1)]
    if (index2 >= len(nums2)):
        return nums1[((index1 + k) - 1)]
    if (k == 1):
        return (nums1[index1] if (nums1[index1] < nums2[index2]) else nums2[index2])
    do_discard_nums1 = True
    mid = ((k // 2) - 1)
    if (((index1 + mid) >= len(nums1)) or (((index2 + mid) < len(nums2)) and (nums1[(index1 + mid)] > nums2[(index2 + mid)]))):
        do_discard_nums1 = False
    mid += 1
    if do_discard_nums1:
        return find_kth(nums1, nums2, (index1 + mid), index2, (k - mid))
    else:
        return find_kth(nums1, nums2, index1, (index2 + mid), (k - mid))
def find_kth(nums1, nums2, index1, index2, k):
    if (index1 >= len(nums1)):
        return nums2[((index2 + k) - 1)]
    if (index2 >= len(nums2)):
        return nums1[((index1 + k) - 1)]
    if (k == 1):
        return (nums1[index1] if (nums1[index1] < nums2[index2]) else nums2[index2])
    do_discard_nums1 = True
    mid = ((k // 2) - 1)
    if (((index1 + mid) >= len(nums1)) or (((index2 + mid) < len(nums2)) and (nums1[(index1 + mid)] > nums2[(index2 + mid)]))):
        do_discard_nums1 = False
    mid += 1
    if do_discard_nums1:
        return find_kth(nums1, nums2, (index1 + mid), index2, (k - mid))
    else:
        return find_kth(nums1, nums2, index1, (index2 + mid), (k - mid))