import java.io.*;

public class problem4 {

public static void main (String args[]) throws java.io.IOException {

	// for easier input
	BufferedReader br = new BufferedReader (new InputStreamReader(System.in)); 

	// ask for the patter
	System.out.println("Pattern String:");
	String pattern = br.readLine();
	
	// ask for the targer
	System.out.println("\nTarget String:");
	String target = br.readLine();
	
	// we make sure that the pattern isn't empty
	if (pattern.length() == 0) {  
		System.out.println("\nPattern is empty.\n");
	} else {
		System.out.println("\nResult of the parse:");
		
		// the indexes that will help us track how far we
		// are in our reading of the strings. We start with
		// the first character.
		int current_pattern = 0;
		int current_target  = 0;
		
		// as long as we haven't read all the target string
		while (current_target < target.length( )) {
			// read the current pattern character
			switch(pattern.charAt(current_pattern%pattern.length())) {
			case '-': // display the current target character
				System.out.print(target.charAt(current_target));
				// since we read that target character, the next becomes current
				current_target += 1;
				break;
			case '?':
				// move to next pattern character
				current_pattern += 1;
				// compare with target
				if (pattern.charAt(current_pattern%pattern.length()) == target.charAt(current_target)) {
					// they are identical so look into 'B' for ?ABC
					current_pattern += 1;
					if (pattern.charAt(current_pattern%pattern.length()) == '-') {
						// display the target character from the comparison
						System.out.print(target.charAt(current_target));
						// move out of the ? condition after the C
						current_pattern += 1;
					} else if (pattern.charAt(current_pattern%pattern.length()) == '?') {
						System.out.println("\n\n*** Forbidden use of ? ***\n");
						System.exit(0);
					} else {
						// display the pattern character
						System.out.print(pattern.charAt(current_pattern%pattern.length()));
						// move after the C
						current_pattern += 1;
					}
				} else { // the comparison is false
					// they are different so look into 'C' for ?ABC
					current_pattern += 2;
					if (pattern.charAt(current_pattern%pattern.length()) == '-') {
						// display the target character from the comparison
						System.out.print(target.charAt(current_target));
					} else if (pattern.charAt(current_pattern%pattern.length()) == '?') {
						System.out.println("\n\n*** Forbidden use of ? ***\n");
						System.exit(0);
					} else {
						// display the pattern character
						System.out.print(pattern.charAt(current_pattern%pattern.length()));
					}
				}
				// we are done with that target character, we move to next
				current_target += 1;
				break;
			default: // neither ? or - so display current pattern character
				System.out.print(pattern.charAt(current_pattern%pattern.length()));
			}
			// we are done with that character of pattern, let's move to next
			current_pattern += 1;
		}
	} // end of the 'if (pattern.length() == 0) ... else ...'
	// to be nice to command line systems
	System.out.println("\n");
}
}
