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 CPP):

Solution:
#include <bits/stdc++.h>
using namespace std;
const int oo = 1e8;
int N, M;
char A[1100], B[1100];
int dp[1100][1100], op[1100][1100];
int NO = 4;
int CH = 1;
int EL = 2;
int IN = 3;
void print(int n, int m) {
  assert(n >= 0 && m >= 0);
  if (n == 0 && m == 0) return;
  if (op[n][m] == NO) {
    print(n - 1, m - 1);
    return;
  }
  if (op[n][m] == CH) {
    print(n - 1, m - 1);
    cout << "REPLACE " << m << " " << B[m] << endl;
  } else if (op[n][m] == IN) {
    print(n, m - 1);
    cout << "INSERT " << m << " " << B[m] << endl;
  } else if (op[n][m] == EL) {
    print(n - 1, m);
    cout << "DELETE " << m + 1 << endl;
  } else {
    assert(false);
  }
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cin >> A + 1 >> B + 1;
  N = strlen(A + 1);
  M = strlen(B + 1);
  for (int I = 1; I <= N; I++) dp[I][0] = I, op[I][0] = EL;
  for (int K = 1; K <= M; K++) dp[0][K] = K, op[0][K] = IN;
  dp[0][0] = 0;
  for (int I = 1; I <= N; I++)
    for (int K = 1; K <= M; K++) {
      dp[I][K] = oo;
      if (A[I] == B[K]) {
        dp[I][K] = dp[I - 1][K - 1];
        op[I][K] = NO;
      }
      if (A[I] != B[K]) {
        dp[I][K] = dp[I - 1][K - 1] + 1;
        op[I][K] = CH;
      }
      if (dp[I][K - 1] + 1 < dp[I][K]) {
        dp[I][K] = dp[I][K - 1] + 1;
        op[I][K] = IN;
      }
      if (dp[I - 1][K] + 1 < dp[I][K]) {
        dp[I][K] = dp[I - 1][K] + 1;
        op[I][K] = EL;
      }
    }
  cout << dp[N][M] << endl;
  print(N, M);
}