Input: n = 3, K = 7, arr[] = {3, 1, 2}
Output: [3, 1]
Explanation: [3, 1, 2] * [3, 1, 2] = [ [3, 3], [ 3, 1], [3, 2], [1, 3], [1, 1], [1, 2], [2, 3], [2, 1], [2, 2] ], now sort this cross product array to get the lexicographically increasing order. [[1, 1], [1, 2], [1, 3], [2, 1], [2, 2], [2, 3], [3, 1], [3, 2], [3, 3]] (in sorted order), so 7th is [3, 1]
Input: n = 4, K = 13, arr = {1, 7, 3, 1}
Output: [7, 1]
Explanation: [1, 7, 3, 1] * [1, 7, 3, 1] = [ [1, 1], [1, 7], [1, 3], [1, 1], [7, 1], [7, 7], [7, 3], [7, 1], [3, 1], [3, 7], [3, 3], [3, 1], [1, 1], [ 1, 7], [1, 3], [1, 1] ], now sort this cross product array to get the lexicographically increasing order. [[1, 1], [1, 1], [1, 1], [1, 1], [1, 3], [1, 3], [1, 7], [1, 7], [3, 1], [3, 1], [3, 3], [3, 7], [7, 1], [7, 1], [7, 3], [7, 7]] (in sorted order) so 13th element is [7, 1].