public int getMedianOfTwoArrays(int[] a1, int[] a2, int start1, int end1, int start2, int end2) {
		int length = end1 - start1 + 1;
		if (length == 0)
			return -1;
		if (length == 1)
			return (a1[0] + a2[0]) / 2;
		if (length == 2)
			return (Math.max(a1[start1 + 0], a2[start2 + 0]) + Math.min(a1[start1 + 1], a2[start2 + 1])) / 2;
		int m1 = getMedian(a1, start1, end1);
		int m2 = getMedian(a2, start2, end2);

		if (m1 == m2)
			return m1;
		else if (m1 > m2) {
			if (length % 2 == 0) {
				return getMedianOfTwoArrays(a1, a2, start1 + 0, start1 + (length / 2), start2 + (length / 2) - 1, start2 + length - 1);
			} else {
				return getMedianOfTwoArrays(a1, a2, start1 + 0, start1 + ((length - 1) / 2), start2 + ((length - 1) / 2), start2 + length - 1);
			}
		} else {
			if (length % 2 == 0) {
				return getMedianOfTwoArrays(a1, a2, start1 + (length / 2) - 1, start1 + length - 1, start2 + 0, start2 + (length / 2));
			} else {
				return getMedianOfTwoArrays(a1, a2, start1 + ((length - 1) / 2), start1 + length - 1, start2 + 0, start2 + ((length - 1) / 2));
			}
		}
	}