PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN

#BS0000399. Phân số nguyên tố nhỏ thứ k (K-th Smallest Prime Fraction)

HỌC THEO LỘ TRÌNH

Bài tập thuộc lộ trình

1 lộ trình

Phân số nguyên tố nhỏ thứ k (K-th Smallest Prime Fraction)

K-th Smallest Prime Fraction

Source: LeetCode

Version: Phuoc Hung OJ Extended

Problem Statement

Given a strictly increasing integer sequence a1,…,ana_1,\ldots,a_n with a1=1a_1=1 and every other element prime, form one fraction ai/aja_i/a_j for each pair 1≤i<j≤n1\le i<j\le n. Order these fractions by increasing value. Determine the numerator and denominator of the fraction at rank kk (starting at 1).

Input

The first line contains integers n,kn,k. The second line contains nn integers a1,…,ana_1,\ldots,a_n.

Output

Print two space-separated integers: the numerator followed by the denominator.

Subtasks

  • Subtask 1 (20 points): 2≤n≤302\le n\le 30; 1≤k≤n(n−1)/21\le k\le n(n-1)/2; 1=a1<a2<⋯<an≤300001=a_1<a_2<\cdots<a_n\le30000; aia_i is prime for every 2≤i≤n2\le i\le n.
  • Subtask 2 (30 points): 2≤n≤10002\le n\le 1000; 1≤k≤n(n−1)/21\le k\le n(n-1)/2; k≤1000k\le1000; 1=a1<a2<⋯<an≤300001=a_1<a_2<\cdots<a_n\le30000; aia_i is prime for every 2≤i≤n2\le i\le n.
  • Subtask 3 (50 points): 2≤n≤10002\le n\le 1000; 1≤k≤n(n−1)/21\le k\le n(n-1)/2; 1=a1<a2<⋯<an≤300001=a_1<a_2<\cdots<a_n\le30000; aia_i is prime for every 2≤i≤n2\le i\le n.

Examples

Input

4 3
1 2 3 5

Output

2 5

Explanation

The increasing sequence is 1/5,1/3,2/5,1/2,3/5,2/31/5,1/3,2/5,1/2,3/5,2/3. Rank 3 is 2/52/5, giving 2 5.

Input

2 1
1 7

Output

1 7

Explanation

The sole pair forms 1/71/7, which is the first fraction.