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.*;

public class D
{
   public static void main(String[] args)
   {
      new D(new Scanner(System.in));
   }

   int[][] next;
   int[][] memo;

   String s1;
   String s2;

   int oo = 987654321;

   int go(int i, int j)
   {
      if ((i == s1.length())&&(j == s2.length()))
         return 0;
      if (memo[i][j] != -1) return memo[i][j];

      int best = oo;
      int dir = 0;

      // Match
      if ((i < s1.length())&&(j < s2.length()))
      {
         int cc = 1;
         int cur = go(i+1, j+1);
         
         if (s1.charAt(i) != s2.charAt(j))
         {
            cc = 4;
            cur++;
         }

         if (cur < best)
         {
            best = cur;
            dir = cc;
         }
      }

      // DELETE
      if (i < s1.length())
      {
         int cur = 1+go(i+1, j);
         if (cur < best)
         {
            best = cur;
            dir = 2;
         }
      }

      // INSERT
      if (j < s2.length())
      {
         int cur = 1+go(i, j+1);
         if (cur < best)
         {
            best = cur;
            dir = 3;
         }
      }

      memo[i][j] = best;
      next[i][j] = dir;
      return best;
   }

   public D(Scanner in)
   {
      s1 = in.next();
      s2 = in.next();

      memo = new int[s1.length()+1][s2.length()+1];
      next = new int[s1.length()+1][s2.length()+1];

      for (int[] mem : memo)
         Arrays.fill(mem, -1);

      int res = go(0, 0);
      System.out.printf("%d%n", res);
  
      int i = 0;
      int j = 0;

      int ipos = 0;
      while (next[i][j] > 0)
      {
         switch (next[i][j])
         {
            case 2:
               System.out.printf("DELETE %d%n", ipos+1);
               i++;
               break;
            case 3:
               System.out.printf("INSERT %d %c%n", j+1, s2.charAt(j));
               j++;
               ipos++;
               break;
            case 4:
               System.out.printf("REPLACE %d %c%n", j+1, s2.charAt(j));
            case 1:
               i++;
               j++;
               ipos++;
               break;
         }
      }
   }
}