Problem: There is a string s, consisting of capital Latin letters. Let's denote its current length as |s|. During one move it is allowed to apply one of the following operations to it: 

  * INSERT pos ch — insert a letter ch in the string s in the position pos (1 ≤ pos ≤ |s| + 1, A ≤ ch ≤ Z). The letter ch becomes the pos-th symbol of the string s, at that the letters shift aside and the length of the string increases by 1. 
  * DELETE pos — delete a character number pos (1 ≤ pos ≤ |s|) from the string s. At that the letters shift together and the length of the string decreases by 1. 
  * REPLACE pos ch — the letter in the position pos of the line s is replaced by ch (1 ≤ pos ≤ |s|, A ≤ ch ≤ Z). At that the length of the string does not change. 



Your task is to find in which minimal number of moves one can get a t string from an s string. You should also find the sequence of actions leading to the required results.

Input

The first line contains s, the second line contains t. The lines consist only of capital Latin letters, their lengths are positive numbers from 1 to 1000.

Output

In the first line print the number of moves k in the given sequence of operations. The number should be the minimal possible one. Then print k lines containing one operation each. Print the operations in the format, described above. If there are several solutions, print any of them.

Examples

Input

ABA
ABBBA


Output

2
INSERT 3 B
INSERT 4 B


Input

ACCEPTED
WRONGANSWER


Output

10
REPLACE 1 W
REPLACE 2 R
REPLACE 3 O
REPLACE 4 N
REPLACE 5 G
REPLACE 6 A
INSERT 7 N
INSERT 8 S
INSERT 9 W
REPLACE 11 R

Solution (in JAVA):

Solution:
import java.io.*;
 
import java.util.*;
 
 
 
public class Main {
 
static PrintWriter pw = new PrintWriter(System.out);
 
	public static void main(String[] args) throws Exception {
 
		Scanner sc = new Scanner(System.in);
 
		
 
		StringBuilder sb=new StringBuilder(sc.nextLine());
		StringBuilder sb1=new StringBuilder(sc.nextLine());
		dp=new int[sb.length()+1][sb1.length()+1];
		for(int[] i:dp)Arrays.fill(i,-1);
        pw.println(solve(0,0,sb,sb1));
        trac(0,0,sb,sb1);
		pw.close();
 
	}static int[][] dp;
	public static int solve(int i,int j,StringBuilder x,StringBuilder y){
	    if(i==x.length())
	        return(y.length()-j);
	    if(j==y.length())return (x.length()-i);
	    if(dp[i][j]!=-1){
	        return dp[i][j];
	    }
	    if(x.charAt(i)==y.charAt(j))return(dp[i][j]=solve(i+1,j+1,x,y));
	    else return dp[i][j]=Math.min(solve(i+1,j+1,x,y),Math.min(solve(i,j+1,x,y),solve(i+1,j,x,y)))+1;
	    
	}
	public static void trac(int i,int j,StringBuilder x,StringBuilder y){
	    while(i<x.length()&&j<y.length()){
	    if(x.charAt(i)!=y.charAt(j)){
	        int temp=solve(i,j,x,y);
	        if(temp==solve(i+1,j+1,x,y)+1){
	            pw.println("REPLACE "+(j+1)+" "+y.charAt(j));
	            i++;j++;
	        }
	        else if(temp==solve(i,j+1,x,y)+1){
	            pw.println("INSERT "+(j+1)+" "+y.charAt(j));
	            j++;
	        }
	        else{pw.println("DELETE "+(j+1));i++;}
	       }else {i++;j++;}
	    }
	        while(j<y.length()){
	            pw.println("INSERT "+(j+1)+" "+y.charAt(j++));
	        }
	        while(i<x.length()){
	            pw.println("DELETE "+(j+1));i++;
	    }
	    
	}
public static boolean prime(int x){
	    int[] arr=new int[10000000];
	    int index=0;
	    int num=3;
	    int i=0;
	    arr[0]=2;
	    while(num<=x){
	      for(i=0;i<=index;i++){
	          if(num%arr[i]==0){
	              break;
	          }
	      }
	      if(i==index+1){
	          arr[++index]=num;
	      }
	      num++;
	    }
	    if(arr[index]==x)return true;
	    return false;
	      
	}
public static void conquer(int[] arr,int b,int m,int e){
	    int len1=m-b+1;
	    int len2=e-m;
	    int[] l=new int[len1];
	    int[] r=new int[len2];
	    for(int i=0;i<len1;i++){
	        l[i]=arr[b+i];
	    }
	   for(int j=0;j<len2;j++){
	            r[j]=arr[m+1+j];
	   }
	    int i=0,j=0,k=b;
	    while((i<len1)&&(j<len2)){
	        if(r[j]>=l[i]){
	            arr[k]=l[i];
	            k++;
	            i++;
	        }
	        else{
	           arr[k]=r[j];
	           k++;
	           j++;
	        }
	    }
	    while(i<len1){
	        arr[k++]=l[i++];
	    }
	    while(j<len2){
	        arr[k++]=r[j++];
	    }
	}
	static int mid;
	public static void sort(int[] arr,int b,int e){
	    if(b<e){
	        int mid =(e+b)/2;
	        sort(arr,b,mid);
	        sort(arr,mid+1,e);
	        conquer(arr,b,mid,e);
	    }
	}
    public static void Sort(int[] arr){
        sort(arr,0,arr.length-1);
    }
 
	static class Scanner {
 
		StringTokenizer st;
 
		BufferedReader br;
 
 
 
		public Scanner(InputStream s) {
 
			br = new BufferedReader(new InputStreamReader(s));
 
		}
 
 
 
		public Scanner(String file) throws FileNotFoundException {
 
			br = new BufferedReader(new FileReader(file));
 
		}
 
 
 
		public String next() throws IOException {
 
			while (st == null || !st.hasMoreTokens())
 
				st = new StringTokenizer(br.readLine());
 
			return st.nextToken();
 
		}
 
 
 
		public int nextInt() throws IOException {
 
			return Integer.parseInt(next());
 
		}
 
 
 
		public long nextLong() throws IOException {
 
			return Long.parseLong(next());
 
		}
 
 
 
		public String nextLine() throws IOException {
 
			return br.readLine();
 
		}
 
 
 
		public double nextDouble() throws IOException {
 
			return Double.parseDouble(next());
 
		}
 
 
 
		public boolean ready() throws IOException {
 
			return br.ready();
 
		}
 
 
 
	}
 
}