double find_kth(int[] A, int m, int[] B, int n, int k){
		if(m > n){
			return find_kth(B, n, A, m, k);
		}
		if(m == 0){
			return B[k-1];
		}
		if(k == 1){
			return Math.min(A[0], B[0]);
		}
		
		int pa = Math.min(k/2, m);
		int pb = k -pa;
		if(A[pa-1] < B[pb-1]){
			return find_kth(Arrays.copyOfRange(A, pa, A.length), m-pa, B, n, k-pa);
		}else if(A[pa-1] > B[pb-1]){
			return find_kth(A,m,Arrays.copyOfRange(B, pb, B.length), n-pb, k-pb);
		}else{
			return A[pa-1];
		}
		
		
	}