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 inf = 1000000000;
int f[1010][1010];
pair<int, pair<int, int> > pre[1010][1010];
string s, t;
char a[1010], b[1010];
vector<int> del;
void print(int x, int y) {
  if (x == 0 && y == 0) return;
  if (pre[x][y].first == 1) {
    cout << "REPLACE " << y << " " << a[x] << endl;
    b[y] = a[x];
  }
  if (pre[x][y].first == 3) del.push_back(y);
  print(x + pre[x][y].second.first, y + pre[x][y].second.second);
}
int main() {
  getline(cin, t);
  getline(cin, s);
  int n = s.size(), m = t.size();
  for (int i = 1; i <= n; i++) a[i] = s[i - 1];
  for (int i = 1; i <= m; i++) b[i] = t[i - 1];
  for (int i = 0; i <= n; i++)
    for (int j = 0; j <= m; j++) f[i][j] = inf;
  f[0][0] = 0;
  for (int i = 0; i <= n; i++)
    for (int j = 0; j <= m; j++) {
      if (j && i && a[i] == b[j]) {
        f[i][j] = f[i - 1][j - 1];
        pre[i][j] = make_pair(0, make_pair(-1, -1));
      }
      if (j && i)
        if (f[i - 1][j - 1] + 1 < f[i][j]) {
          f[i][j] = f[i - 1][j - 1] + 1;
          pre[i][j] = make_pair(1, make_pair(-1, -1));
        }
      if (i)
        if (f[i - 1][j] + 1 < f[i][j]) {
          f[i][j] = f[i - 1][j] + 1;
          pre[i][j] = make_pair(2, make_pair(-1, 0));
        }
      if (j)
        if (f[i][j - 1] + 1 < f[i][j]) {
          f[i][j] = f[i][j - 1] + 1;
          pre[i][j] = make_pair(3, make_pair(0, -1));
        }
    }
  cout << f[n][m] << endl;
  del.clear();
  print(n, m);
  sort(del.begin(), del.end());
  t = "";
  for (int i = 1; i <= m; i++) t += b[i];
  for (int i = del.size() - 1; i >= 0; i--) {
    cout << "DELETE " << del[i] << endl;
    t.erase(del[i] - 1, 1);
  }
  for (int i = 0; i < n; i++)
    if (i > t.size() - 1 || s[i] != t[i]) {
      cout << "INSERT " << i + 1 << " " << s[i] << endl;
      string tmp = t.substr(i);
      t.erase(i);
      t += s[i];
      t += tmp;
    }
  return 0;
}