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 long long MOD = 1e9 + 7;
const long long MAX = 1e14 + 8;
const long long MAXN = 1e5 + 8;
long long dp[1001][1001], res, n1, n2;
string s1, s2;
long long DP(long long x, long long y) {
  if (x > n1 || y > n2) return MAX;
  if (x == n1 && y == n2) return 0;
  long long &ret = dp[x][y];
  if (ret != -1) return ret;
  ret = MAX;
  if (s1[x] == s2[y]) ret = DP(x + 1, y + 1);
  ret = min(ret, DP(x + 1, y) + 1);
  ret = min(ret, DP(x, y + 1) + 1);
  ret = min(ret, DP(x + 1, y + 1) + 1);
  return ret;
}
long long M = 0;
void fs(long long x, long long y, long long p) {
  if (x == n1 && y == n2) {
    return;
  }
  if (s2[y] == s1[x]) {
    fs(x + 1, y + 1, p + 1);
    return;
  }
  if ((M + dp[x + 1][y] + 1) == res && (x < n1)) {
    cout << "DELETE " << p << endl;
    M++;
    fs(x + 1, y, p);
    return;
  }
  if ((M + dp[x + 1][y + 1] + 1) == res && (x < n1 && y < n2)) {
    cout << "REPLACE " << p << " " << s2[y] << endl;
    M++;
    fs(x + 1, y + 1, p + 1);
    return;
  }
  if ((M + dp[x][y + 1] + 1) == res && (y < n2)) {
    cout << "INSERT " << p << " " << s2[y] << endl;
    M++;
    fs(x, y + 1, p + 1);
    return;
  }
}
int main() {
  memset(dp, -1, sizeof(dp));
  cin >> s1 >> s2;
  n1 = s1.size(), n2 = s2.size();
  res = DP(0, 0);
  dp[n1][n2] = 0;
  cout << res << endl;
  fs(0, 0, 1);
  return 0;
}