Convert a number string to the largest possible value by changing at most one digit according to the allowed currency digit mapping.
You are given a number written in a special currency system where each digit can be converted to another digit according to a fixed mapping. Your task is to make the resulting number as large as possible by applying the conversion rules to at most one digit, or to all digits if that is required by the exact rule set of the problem.
Read the digits of the number, apply the allowed transformation carefully, and output the resulting number in the same order. The key is to follow the digit-mapping rule exactly and choose the best position to improve the value when multiple choices are possible.
If there are multiple valid answers, print any one that satisfies the rules.
Example 1
Input
5 12345
Output
52345
Explanation
If the rules allow changing one digit to a larger one, the best choice is to improve the earliest possible digit, since that has the biggest impact on the final value.
Premium problem context
Premium adds guided hints, editorial links, similar variants, discussion resources, and concept maps so you can understand why a problem matters, not just solve it once.