Under construction

Still being built. Things may change

Kth Lex Min Min Min Subpalindromes

Time limit3sMemory limit1024 MB

Summary
Find the k-th lexicographically smallest length-n array over 1 to m that has the fewest palindromic subarrays, or print -1 if there are fewer than k such arrays.
Level

Medium6 of 10

Topics
Greedy, Combinatorics, Math
Solved
No attempts yet

Problem

Consider all arrays of length nn whose elements are integers from 11 to mm. Let PP be the minimum number of contiguous subarrays that are palindromic that such an array can have. An array is palindromic if it is equal to its own reverse.

From all arrays of length nn with integers from 11 to mm, keep only those that have the minimum number of palindromic contiguous subarrays, and sort them lexicographically. Find the kk-th array in this order.

Input

The only line contains three integers nn, mm, and kk (1≤n≤1061 \le n \le 10^6, 1≤m≤1061 \le m \le 10^6, 1≤k≤10181 \le k \le 10^{18}).

Output

If there are fewer than kk valid arrays, print -1. Otherwise, print the kk-th lexicographically smallest of them.

Hint

Did we put the minimum number of min in the title? Min.

Examples5

  1. Example 1

    Input
    1 1 1
    
    Expected output
    1
    
  2. Example 2

    Input
    2 2 2
    
    Expected output
    2 1
    
  3. Example 3

    Input
    3 3 3
    
    Expected output
    2 1 3
    
  4. Example 4

    Input
    9 9 8244353
    
    Expected output
    2 4 1 2 6 8 1 2 7
    
  5. Example 5

    Input
    10 7 998244353
    
    Expected output
    -1