import java.awt.Point;
import java.util.*;

public class A {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		String l1 = sc.nextLine();
		String l2 = sc.nextLine();
		
		char[] ca1 = (" " + l1).toCharArray();
		char[] ca2 = (" " + l2).toCharArray();
		List<Point> ret = editDistance(ca1, ca2);
		Collections.reverse(ret);
		
		for(int i = 0; i < ret.size() - 1; i++) {
			Point p1 = ret.get(i);
			Point p2 = ret.get(i + 1);
			
			if(p1.x + 1 == p2.x && p1.y + 1 == p2.y) {
				if(ca1[p2.y] == ca2[p2.x]) {
					System.out.println("c " + ca1[p2.y]);
				}
				else {
					System.out.println("m " + ca2[p2.x]);
				}
			}
			else if(p1.x + 1 == p2.x) {
				System.out.println("a " + ca2[p2.x]);
			}
			else {
				System.out.println("d " + ca1[p2.y]);
			}
		}
//		System.out.println(ret);

	}
	
	
    public static List<Point> editDistance(char[] ca1, char[] ca2) {
        int[][] dp = new int[ca1.length][ca2.length];
        for(int i = 0; i < ca1.length; i++) {
            for(int j = 0; j < ca2.length; j++) {
                if(i == 0 || j == 0) dp[i][j] = Math.max(i, j);
                else dp[i][j] = Math.min(Math.min(dp[i-1][j] + 1, dp[i][j-1] + 1), dp[i-1][j-1] + (ca1[i] == ca2[j] ? 0 : 1));
            }
        }
        
//        System.out.println(dp[ca1.length-1][ca2.length-1]);
        List<Point> ret = new ArrayList<Point>();
        Point curr = new Point(ca2.length - 1, ca1.length - 1);
        ret.add(curr);
        
        while(curr.x != 0 && curr.y != 0) {
        	if(ca1[curr.y] == ca2[curr.x]) curr = new Point(curr.x - 1, curr.y - 1);
        	else {
        		int i = curr.y;
        		int j = curr.x;
        		
        		int a = dp[i-1][j] + 1;
        		int b = dp[i][j-1] + 1;
        		int c = dp[i-1][j-1] + 1;
        		
        		int aaa = dp[i][j];
        		if(a == aaa) curr = new Point(j, i-1);
        		else if(b == aaa) curr = new Point(j-1, i);
        		else if(c == aaa) curr = new Point(j-1, i-1);
        	}
        		
        	ret.add(curr);
        }
        
        while(curr.x > 0) {
        	curr = new Point(curr.x - 1, curr.y);
        	ret.add(curr);
        }
        
        while(curr.y > 0) {
        	curr = new Point(curr.x, curr.y - 1);
        	ret.add(curr);
        }
        
        return ret;
    } 
	

}