#K77257. String Transformation with Exact Levenshtein Distance

    ID: 34824 Type: Default 1000ms 256MiB

String Transformation with Exact Levenshtein Distance

String Transformation with Exact Levenshtein Distance

You are given a string s of length n and an integer k. Your task is to construct another string t such that the Levenshtein distance between s and t is exactly k.

The Levenshtein distance between two strings is defined as the minimum number of single-character edits (insertions, deletions or substitutions) required to change one string into the other. Mathematically, it can be denoted as:

\( d(s,t) = k \)

If such a string t exists, output any valid string t; otherwise, output IMPOSSIBLE.

Note: In this problem, a simple valid strategy is to append k characters (for example, the character 'a') to s if k is less than or equal to the length of s. However, if k is greater than the length of s, it is considered impossible to form such a string using the approach required by this problem.

inputFormat

The input is given via standard input and consists of two lines:

  • The first line contains the string s.
  • The second line contains two space-separated integers n and k, where n is the length of s and k is the desired Levenshtein distance.

outputFormat

Output a single line via standard output. If there exists a string t whose Levenshtein distance from s is exactly k, output that string. Otherwise, output IMPOSSIBLE.

## sample
abc
3 2
abcaa