Problem:
Score : 300 points

Problem Statement

E869120 found a chest which is likely to contain treasure.

However, the chest is locked. In order to open it, he needs to enter a string S consisting of lowercase English letters.

He also found a string S', which turns out to be the string S with some of its letters (possibly all or none) replaced with ?.

One more thing he found is a sheet of paper with the following facts written on it:

Condition 1: The string S contains a string T as a contiguous substring.

Condition 2: S is the lexicographically smallest string among the ones that satisfy Condition 1.

Print the string S.

If such a string does not exist, print UNRESTORABLE.

Constraints

1 \leq |S'|, |T| \leq 50

S' consists of lowercase English letters and ?.

T consists of lowercase English letters.

Input

Input is given from Standard Input in the following format:

S
T'

Output

Print the string S.

If such a string does not exist, print UNRESTORABLE instead.

Sample Input 1

?tc????
coder

Sample Output 1

atcoder

There are 26 strings that satisfy Condition 1: atcoder, btcoder, ctcoder,..., ztcoder.
Among them, the lexicographically smallest is atcoder, so we can say S = atcoder.

Sample Input 2

??p??d??
abc

Sample Output 2

UNRESTORABLE

There is no string that satisfies Condition 1, so the string S does not exist.

Solution in Rust (1.15.1) (judge verdict: Accepted)

use std::fmt;
use std::io::stdin;
use std::io::BufRead;
use std::str;
use std::str::FromStr;
use std::vec::Vec;

fn main() {
    let stdin = stdin();
    let mut scan = InputScanner::new(stdin.lock(),256);

    let mut s:Vec<char> = scan.next::<String>().chars().collect::<Vec<char>>();
    let t:Vec<char> = scan.next::<String>().chars().collect::<Vec<char>>();

    let mut found = false;

    let mut p:i64 = (s.len() - t.len()) as i64;

    while p >= 0 {
        if cmp(&s[(p as usize)..(p as usize)+t.len()],&t[0..]) {
            found = true;

            let mut p = p;

            for &c in &t {
                s[p as usize] = c;
                p += 1;
            }
        } else {
            if s[p as usize + t.len() - 1] == '?' {
                s[p as usize + t.len() - 1] = 'a';
            }
        }

        if found {
            p = p - 1;

            while p >= 0 {
                if s[p as usize] == '?' {
                    s[p as usize] = 'a';
                }
                p = p - 1;
            }
        }

        p -= 1;
    }

    if found {
        println!("{}", s.into_iter().collect::<String>());
    } else {
        println!("UNRESTORABLE");
    }
}
fn cmp(a:&[char],b:&[char]) -> bool {
    if a.len() != b.len() {
        false
    } else {
        for i in 0..a.len() {
            if a[i] != '?' && a[i] != b[i] {
                return false;
            }
        }

        true
    }
}
struct InputScanner<R: BufRead> {
	reader: R,
	buf: Vec<u8>, // Should never be empty
	pos: usize,   // Should never be out of bounds as long as the input ends with '\n'
}
impl<R: BufRead> InputScanner<R> {
	fn new(reader: R, capacity: usize) -> Self {
		InputScanner {
			reader: reader,
			buf: Vec::with_capacity(capacity),
			pos: 0,
		}
	}

	#[inline]
	fn next<T: FromStr>(&mut self) -> T
	where
		T::Err: fmt::Debug,
	{
		if self.buf.is_empty() {
			self._read_next_line();
		}
		let mut start = None;
		loop {
			match (self.buf[self.pos], start.is_some()) {
				(b' ', true) | (b'\n', true) | (b'\r', true) => break,
				(_, true) | (b' ', false) => self.pos += 1,
				(b'\n', false) | (b'\r', false) => self._read_next_line(),
				(_, false) => start = Some(self.pos),
			}
		}
		let target = &self.buf[start.unwrap()..self.pos];
		unsafe { str::from_utf8_unchecked(target) }.parse().unwrap()
	}

	#[inline]
	fn _read_next_line(&mut self) {
		self.pos = 0;
		self.buf.clear();
		if self.reader.read_until(b'\n', &mut self.buf).unwrap() == 0 {
			panic!("Reached EOF");
		}
	}
}