Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- chars = ['a','b','c']
- inp = int(input())
- for x in range(inp):
- used = False
- output = []
- array = [a for a in input()]
- for pointer in range(len(array)-1):
- if array[pointer] == array[pointer+1] and array[pointer] != '?':
- print(-1)
- used = True
- break
- if array[pointer] != '?':
- output.append(array[pointer])
- continue
- for char in chars:
- if pointer == 0:
- if array[pointer+1] != char:
- output.append(char)
- break
- else:
- if output[pointer-1] != char and array[pointer+1] != char:
- output.append(char)
- break
- if used == False:
- if len(array) != len(output):
- if output[-1] == 'a' and array[-1] == '?':
- output.append('b')
- elif output[-1] == 'b' and array[-1] == '?':
- output.append('a')
- elif output[-1] == 'c' and array[-1] == '?':
- output.append('a')
- else:
- output.append(array[-1])
- print(''.join(output))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement