{"problem":{"name":"Replace Digits","description":{"content":"You are given a string $S$ of length $N$ and a string $T$ of length $M$, both consisting of digits from `1` to `9`. You will perform the following operation for $k=1,2,\\ldots,M$ in order: *   Choose ","description_type":"Markdown"},"platform":"AtCoder","limit":{"time_limit":2000,"memory_limit":262144},"difficulty":"None","is_remote":true,"is_sync":true,"sync_url":null,"sign":"arc191_a"},"statements":[{"statement_type":"Markdown","content":"You are given a string $S$ of length $N$ and a string $T$ of length $M$, both consisting of digits from `1` to `9`.\nYou will perform the following operation for $k=1,2,\\ldots,M$ in order:\n\n*   Choose an integer $i$ such that $1 \\le i \\le N$. Then, replace the $i$\\-th character of $S$ with the $k$\\-th character of $T$.\n\nFind the maximum possible value of the resulting string $S$ interpreted as an integer after performing the $M$ operations.\n\n## Constraints\n\n*   $1 \\le N,M \\le 10^6$\n*   $N$ and $M$ are integers.\n*   $S$ is a string of length $N$ consisting of digits from `1` through `9`.\n*   $T$ is a string of length $M$ consisting of digits from `1` through `9`.\n\n## Input\n\nThe input is given from Standard Input in the following format:\n\n$N$ $M$\n$S$\n$T$\n\n[samples]","is_translate":false,"language":"English"}],"meta":{"iden":"arc191_a","tags":[],"sample_group":[["3 3\n191\n325","593\n\nThe following sequence of operations is optimal:\n\n*   For $k=1$: Choose $i=3$. Then, $S =$ `193`.\n*   For $k=2$: Choose $i=1$. Then, $S =$ `293`.\n*   For $k=3$: Choose $i=1$. Then, $S =$ `593`.\n\nIn this case, the value of $S$ interpreted as an integer is $593$, which is the maximum."],["3 9\n191\n998244353","993"],["11 13\n31415926535\n2718281828459","98888976555"]],"created_at":"2026-03-03 11:01:13"}}