This page is still under construction.

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

Round Number

Time limit2sMemory limit256 MB

Summary
For each query, decide whether removing exactly k digits from x can leave a number with no leading zeros that is divisible by 100, and if so print one such result.
Level

Medium5 of 10

Topics
Greedy, Implementation, String, Math
Solved
No attempts yet

Problem

Everyone likes round numbers. There are many reasons for this, the main one being that a number divisible by, say, 100 is much easier to remember. Unfortunately, round numbers are far rarer in our lives than all the others. First-grader Petya is very upset about this. So he came up with his own definition of a round number.

By Petya's definition, a number is round only if exactly kk digits can be removed from it so that the resulting number has no leading zeros but is divisible by 100. For example, with k=2k = 2, the number 10304 is round, but the number 1000 is not.

Now Petya wants to know which numbers are round for which kk and which are not. Help him.

Input

The first line contains an integer nn, the number of pairs of numbers kk and xx that Petya wants to know about. The next nn lines each contain two positive integers kk and xx. Every kk is strictly less than the number of digits in the corresponding xx. Every xx has no leading zeros. The total number of digits across all xx does not exceed 10510^5.

Output

For each pair kk and xx from the input, print -1 if the number xx is not round for the given kk. If the number xx is round for the given kk, print the number xx with exactly kk digits crossed out, after which it became divisible by 100. The number you print must not contain leading zeros, but it may be equal to zero.

Examples1

  1. Example 1

    Input
    3
    2 10304
    2 1000
    3 1023
    
    Expected output
    100
    -1
    0