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;
    static Scanner sc;
    static HashMap<Pair, Integer> map;
    static String end;
    static String st;
    static int inf=(int)1e9;
    static HashMap<Pair, Pair> next;
    static long ceildiv(long x, long y){ return (x+y-1)/y;}
    public static void main(String[] args) throws Exception {
        sc= new Scanner(System.in);
        pw=new PrintWriter(System.out);
        st=sc.nextLine();
        end=sc.nextLine();
        next=new HashMap<Pair, Pair>();
        map= new HashMap<Pair, Integer>();
        map.put(new Pair(st.length(), end.length()), 0);
        int ans=solve(new Pair(0, 0));
        pw.println(ans);
        Triple[] arr=new Triple[ans];
        int diff=0;
        Pair prev=new Pair(0,0);
        for(int i=0; i<ans;){
            if(i==ans)
                break;
            Pair p=next.get(prev);
            if(p.x==prev.x){
                arr[i]=new Triple(1, prev.x+diff, end.charAt(prev.y));
                diff++;
                i++;
            }else if(p.y==prev.y){
                arr[i]=new Triple(-1, prev.x+diff, ' ');
                diff--;
                i++;
            }else{
                arr[i]= new Triple(0, prev.x+diff, end.charAt(prev.y));
                i+=st.charAt(prev.x)==end.charAt(prev.y)?0:1;
            }
            prev=new Pair(p.x, p.y);
        }
        Arrays.sort(arr);
        for(Triple t: arr)
            pw.println(t);
        pw.close();
    }
//    static int[][] dp;
//    static int combin(int a, int b, int last){
//        if(dp[a][b]==-1){
//
//        }
//    }
    static ArrayList<Integer> ans;
    static int solve(Pair p){
        if(!map.containsKey(p)){
            if(p.x<st.length()){
                if(p.y<end.length()){
                    int ans, ans2, ans3;
                    ans= solve(new Pair(p.x+1, p.y+1));
                    if(st.charAt(p.x)!=end.charAt(p.y))
                        ans++;
                    ans2=solve(new Pair(p.x+1, p.y))+1;
                    ans3=solve(new Pair(p.x, p.y+1))+1;
                    int min=Math.min(ans, Math.min(ans2, ans3));
                    map.put(p, min);
                    if(min==ans)
                        next.put(p, new Pair(p.x+1, p.y+1));
                    else if(min==ans2)
                        next.put(p, new Pair(p.x+1, p.y));
                    else
                        next.put(p, new Pair(p.x, p.y+1));
                }else{
                    map.put(p, solve(new Pair(p.x+1, p.y))+1);
                    next.put(p, new Pair(p.x+1, p.y));
                }
            }else{
                map.put(p, solve(new Pair(p.x, p.y+1))+1);
                next.put(p, new Pair(p.x, p.y+1));
            }
        }
        return map.get(p);
    }
    static void printArr(int[] arr){
        for(int i=0; i<arr.length-1; i++)
            pw.print(arr[i]+" ");
        pw.println(arr[arr.length-1]);
    }
    static void printArr(long[] arr){
        for(int i=0; i<arr.length-1; i++)
            pw.print(arr[i]+" ");
        pw.println(arr[arr.length-1]);
    }
    static void printArr(Integer[] arr){
        for(int i=0; i<arr.length-1; i++)
            pw.print(arr[i]+" ");
        pw.println(arr[arr.length-1]);
    }
    static class Scanner {
        StringTokenizer st;
        BufferedReader br;
        public Scanner(InputStream s) {
            br = new BufferedReader(new InputStreamReader(s));
        }

        public Scanner(FileReader r) {
            br = new BufferedReader(r);
        }

        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 int[] nextArr(int n) throws IOException {
            int[] arr = new int[n];
            for (int i = 0; i < arr.length; i++)
                arr[i] = nextInt();
            return arr;
        }
        public Integer[] nextsort(int n) throws IOException{
            Integer[] arr=new Integer[n];
            for(int i=0; i<n; i++)
                arr[i]=nextInt();
            return arr;
        }
        public Pair nextPair() throws IOException{
            return new Pair(nextInt(), nextInt());
        }
        public Pair[] nextPairArr(int n, int l) throws IOException{
            Pair[] arr=new Pair[n];
            if(l==2){
                int[] a=nextArr(n), b=nextArr(n);
                for(int i=0; i<n; i++)
                    arr[i]=new Pair(a[i], b[i]);
                return arr;
            }
            for(int i=0; i<n; i++)
                arr[i]=new Pair(nextInt(), nextInt());
            return arr;
        }
        public boolean ready() throws IOException {
            return br.ready();
        }
    }
    static class Pair implements Comparable<Pair>{
        int x;
        int y;
        public Pair(int x, int y) {
            this.x=x;
            this.y=y;
        }
        public int hashCode() {
            return this.x*2000+this.y;
        }
        public int compareTo(Pair other) {
            if(this.y!=other.y)
                return this.y-other.y;
            return this.x-other.x;
        }
        public boolean equals(Object obj) {
            if (obj == null) {
                return false;
            }
            if (this.getClass() != obj.getClass()) {
                return false;
            }
            Pair p = (Pair) obj;
            return this.x==p.x && this.y==p.y;
        }
        public boolean equal(Pair p){
            if(this.x==p.x)
                return this.y==p.y;
            if(this.x==p.y)
                return this.y==p.x;
            else
                return false;
        }
        public String toString(){
            return this.x+" "+this.y;
        }
    }
    static class Triple implements Comparable<Triple>{
        int x;
        int y;
        char c;
        public Triple(int x, int y, char c){
            this.x=x;
            this.y=y;
            this.c=c;
        }
        public int compareTo(Triple t){
            return this.y-t.y;
        }
        public String toString(){
            if(this.x==1)
                return "INSERT "+(this.y+1)+" "+this.c;
            else if(this.x==0)
                return "REPLACE "+(this.y+1)+" "+this.c;
            else
                return "DELETE "+(this.y+1);
        }
    }
}