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;
enum { ins, del, rep };
const int MAXN = 1e3 + 10;
int dp[MAXN][MAXN];
struct node {
  int op, pos;
  char c;
  node(int _op, int _pos, char _c) { op = _op, pos = _pos, c = _c; }
};
int main() {
  string a, b;
  vector<node> v;
  cin >> a >> b;
  for (int i = 0; i <= a.size(); i++) {
    for (int j = 0; j <= b.size(); j++) {
      if (i && j) {
        if (a[i - 1] == b[j - 1])
          dp[i][j] = dp[i - 1][j - 1];
        else
          dp[i][j] = min(dp[i - 1][j - 1] + 1,
                         min(dp[i][j - 1] + 1, dp[i - 1][j] + 1));
      } else if (i)
        dp[i][j] = dp[i - 1][j] + 1;
      else if (j)
        dp[i][j] = dp[i][j - 1] + 1;
    }
  }
  int x = a.size(), y = b.size(), last;
  while (x + y) {
    if (x && y)
      last = min(dp[x - 1][y - 1], min(dp[x][y - 1], dp[x - 1][y]));
    else if (x) {
      v.emplace_back(node(del, x, '\0'));
      x--;
      continue;
    } else {
      v.emplace_back(node(ins, x + 1, b[y - 1]));
      y--;
      continue;
    }
    if (dp[x][y] == last)
      x--, y--;
    else if (last == dp[x - 1][y - 1]) {
      v.emplace_back(node(rep, x, b[y - 1]));
      x--, y--;
    } else if (last == dp[x][y - 1]) {
      v.emplace_back(node(ins, x + 1, b[y - 1]));
      y--;
    } else {
      v.emplace_back(node(del, x, '\0'));
      x--;
    }
  }
  cout << v.size() << '\n';
  int cnt1 = 0, cnt2 = 0;
  for (int i = v.size() - 1; i >= 0; i--) {
    if (v[i].op == ins) {
      cout << "INSERT " << v[i].pos + cnt1 - cnt2 << ' ' << v[i].c << '\n';
      cnt1++;
    } else if (v[i].op == rep)
      cout << "REPLACE " << v[i].pos + cnt1 - cnt2 << ' ' << v[i].c << '\n';
    else {
      cout << "DELETE " << v[i].pos + cnt1 - cnt2 << '\n';
      cnt2++;
    }
  }
  return 0;
}