Under construction

Still being built. Things may change

Password

Time limit4sMemory limit512 MB

Summary
Given a length-N string, collect all distinct substrings meeting four counts (length, digits, specials, uppercase), sort them lexicographically, and print the middle one.
Level

Hard8 of 10

Topics
String, Sorting, String matching, Two pointers
Solved
No attempts yet

Problem

Jihun forgot the password of a site he rarely visits. The site keeps passwords as hashes, so it cannot tell him the old one and asks him to create a new password instead. The security policy is strict, so a password has to meet all four of these conditions.

  • Its length is at least AA.
  • It contains at least BB digits.
  • It contains at least CC special characters. A special character is a character that is neither a digit nor a letter.
  • It contains at least DD uppercase letters.

Jihun picks the new password this way.

  1. He writes one string of length NN, choosing each character freely from lowercase letters, uppercase letters, digits, and the special characters !@#$%^&*()_-.
  2. He inspects the contiguous substrings of that string one by one and puts into a candidate list only the ones that meet all four conditions. If the same string occurs more than once, it enters the list only once. For example, in abab the substring ab enters the list exactly once.
  3. He sorts the candidate list in lexicographic order. Characters compare by their ASCII values, and when one string equals the beginning of another, the shorter one comes first.
  4. If the sorted list holds MM candidates candidate[1], candidate[2], ..., candidate[M], he adopts the ⌊(M+1)/2⌋\lfloor (M+1)/2 \rfloor-th one as the final password.

You are given the string of length NN that Jihun wrote. Find the password he finally adopts.

Input

The first line contains the integers NN, AA, BB, CC, DD in this order, separated by spaces.

The second line contains the string of length NN that Jihun wrote. It consists only of lowercase letters, uppercase letters, digits, and the special characters !@#$%^&*()_-.

Output

Print on the first line the password Jihun finally adopts. Every given input has at least one candidate.

Constraints

  • 1≤N≤5000001 \le N \le 500000
  • 1≤A≤N1 \le A \le N
  • 0≤B,C,D≤N0 \le B, C, D \le N

Examples3

  1. Example 1

    Input
    10 9 1 0 1
    h4llowOrld
    
    Expected output
    h4llowOrl
    
  2. Example 2

    Input
    1 1 0 0 0
    a
    
    Expected output
    a
    
  3. Example 3

    Input
    5 2 0 0 0
    aaaaa
    
    Expected output
    aaa