This page is still under construction.

Parts of this page are still being built. What you see may change.

Hongjun's matrix

Time limit2sMemory limit512 MB

Summary
Given sequences A and B of length N, find the K-th smallest value among all N^2 products A_i * B_j.
Level

Medium7 of 10

Topics
Binary search, Sorting, Math, Two pointers
Solved
No attempts yet

Problem

Hongjun has two sequences AA and BB, each of length NN. He builds an N×NN \times N matrix whose entry in row ii and column jj is Ai×BjA_i \times B_j.

Hongjun sorts all N2N^2 entries in non-decreasing order and wants to know the value that lands in position KK. Positions are counted from 1, and a value that appears several times is counted once for each entry that produces it. Write the program that finds the KK-th value for him, since sorting is slow for Hongjun.

Input

The first line contains NN and KK, separated by a space. (1≤N≤300001 \le N \le 30000, 1≤K≤N21 \le K \le N^2)

The second line contains the NN elements of the sequence AA, separated by spaces.

The third line contains the NN elements of the sequence BB, separated by spaces.

Every element of both sequences is an integer between 11 and 10910^9.

Output

Print the KK-th smallest entry of the matrix.

Examples2

  1. Example 1

    Input
    2 3
    2 3
    3 5
    
    Expected output
    10
    
  2. Example 2

    Input
    3 5
    2 2 2
    3 3 3
    
    Expected output
    6