#K64512. Replace Question Marks

    ID: 31992 Type: Default 1000ms 256MiB

Replace Question Marks

Replace Question Marks

You are given a string s consisting of lowercase English letters and question mark characters '?'. Your task is to replace each question mark with a lowercase letter such that no two adjacent characters in the resulting string are the same.

More formally, for the resulting string r of length n, it must satisfy \[ r_i \neq r_{i+1} \quad \text{for } 1 \leq i \leq n-1. \]

If there are multiple valid solutions, output the lexicographically smallest one based on the replacement algorithm provided. If it is impossible to obtain such a string (which will not occur with the given constraints), output "Impossible".

Example Explanation:

  • For s = "a?c", replacing ? with 'b' leads to "abc".
  • For s = "?????", one possible valid replacement is "ababa".
  • For s = "ab??ba", the valid replacement is "abacba".

inputFormat

The input consists of a single line containing a non-empty string s composed of lowercase letters and the character '?'.

outputFormat

Output a single line — the resulting string after replacing all question marks such that no two adjacent characters are the same.

If it is impossible to form such a string, output Impossible.

## sample
a?c
abc

</p>