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.util.*;
import java.io.*;
 
public class Main {
	
	public static void main(String[] args) throws IOException,InterruptedException{
		Scanner sc=new Scanner(System.in);
		char[] s1=sc.next().toCharArray();
		char[] s2=sc.next().toCharArray();
		int[][] arr=new int[s1.length+1][s2.length+1];
		Stack<String> ans=new Stack<>();
		for (int i = 0; i < s1.length+1; i++) {
			for (int j = 0; j < s2.length+1; j++) {
				if(i==0) arr[i][j]=j;
				else if(j==0) arr[i][j]=i;
				else if(s1[i-1]==s2[j-1]) arr[i][j]=arr[i-1][j-1];
				else arr[i][j]=Math.min(Math.min(arr[i][j-1],arr[i-1][j-1]),arr[i-1][j])+1;
			}
		}
		pw.println(arr[s1.length][s2.length]);
		int p1=s1.length,p2=s2.length,c=0;
		while(p1>=0&&p2>=0) {
			if (p1>=1&&p2>=1&&arr[p1][p2]==arr[p1-1][p2-1]+1) {
				p1--;
				p2--;
			}else if (p2>=1&&arr[p1][p2]==arr[p1][p2-1]+1) {
				p2--;
				c++;
			}else if (p1>=1&&arr[p1][p2]==arr[p1-1][p2]+1) {
				p1--;
				c--;
			}else if (p1>=1&&p2>=1&&arr[p1][p2]==arr[p1-1][p2-1]) {
				p1--;
				p2--;
			}else break;
		}
		p1=s1.length;
		p2=s2.length;
		while(p1>=0&&p2>=0) {
			if (p1>=1&&p2>=1&&arr[p1][p2]==arr[p1-1][p2-1]+1) {
				ans.add("REPLACE "+(p1+c)+" "+s2[p2-1]);
				p1--;
				p2--;
			}else if (p2>=1&&arr[p1][p2]==arr[p1][p2-1]+1) {
				ans.add("INSERT "+(p1+c)+" "+s2[p2-1]);
				p2--;
				c--;
			}else if (p1>=1&&arr[p1][p2]==arr[p1-1][p2]+1) {
				ans.add("DELETE "+(p1+1+c));
				p1--;
				c++;
			}else if (p1>=1&&p2>=1&&arr[p1][p2]==arr[p1-1][p2-1]) {
				p1--;
				p2--;
			}else break;
		}
//		pw.println(c);
//		for (int i = 0; i < arr.length; i++) {
//			for (int j = 0; j < arr[i].length; j++) {
//				pw.print(arr[i][j]+" ");
//			}
//			pw.println();
//		}
//		pw.println(ans);

		while (!ans.isEmpty()) {
			pw.println(ans.pop());
		}
		pw.close();
    }
	
	static PrintWriter pw=new PrintWriter(System.out);
	static class pair implements Comparable<pair> {
		int x;
		int y;
 
		public pair(int x, int y) {
			this.x = x;
			this.y = y;
		}
 
		public String toString() {
			return x + " " + y;
		}
		public boolean equals(Object o) {
            if (o instanceof pair) {
                pair p = (pair)o;
                return p.x == x && p.y == y;
            }
            return false;
        }
        public int hashCode() {
            return new Double(x).hashCode() * 31 + new Double(y).hashCode();
        }
        public int compareTo(pair other) {
        	if(this.x==other.x) {
        		return Long.compare(this.y, other.y);
        	}
			return Long.compare(this.x, other.x);
		}
	}
	static class tuble implements Comparable<tuble> {
		int x;
		int y;
		int z;
 
		public tuble(int x, int y, int z) {
			this.x = x;
			this.y = y;
			this.z = z;
		}
 
		public String toString() {
			return x + " " + y + " " + z;
		}
 
		public int compareTo(tuble other) {
			if (this.x == other.x) {
				if(this.y==other.y) return this.z - other.z;
				else return this.y - other.y;
			} else {
				return this.x - other.x;
			}
		}
	}
	static class Scanner {
		StringTokenizer st;
		BufferedReader br;
 
		public Scanner(InputStream s) {
			br = new BufferedReader(new InputStreamReader(s));
		}
 
		public boolean hasNext() {
			// TODO Auto-generated method stub
			return false;
		}
 
		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 {
			String x = next();
			StringBuilder sb = new StringBuilder("0");
			double res = 0, f = 1;
			boolean dec = false, neg = false;
			int start = 0;
			if (x.charAt(0) == '-') {
				neg = true;
				start++;
			}
			for (int i = start; i < x.length(); i++)
				if (x.charAt(i) == '.') {
					res = Long.parseLong(sb.toString());
					sb = new StringBuilder("0");
					dec = true;
				} else {
					sb.append(x.charAt(i));
					if (dec)
						f *= 10;
				}
			res += Long.parseLong(sb.toString()) / f;
			return res * (neg ? -1 : 1);
		}
 
		public boolean ready() throws IOException {
			return br.ready();
		}
 
	}
}