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;
template <class T1, class T2>
ostream& operator<<(ostream& os, const pair<T1, T2>& p) {
  os << "{" << p.first << " " << p.second << "}";
  return os;
}
string act[4] = {"REPLACE", "INSERT", "DELETE", "NOTHING"};
int main() {
  string s, t;
  cin >> s >> t;
  int n = t.size();
  int m = s.size();
  vector<vector<int> > a(n + 1, vector<int>(m + 1, 0));
  vector<vector<int> > action(n + 1, vector<int>(m + 1, -1));
  for (int i = 0; i <= n; ++i)
    for (int j = 0; j <= m; ++j) {
      if (i + j == 0) continue;
      a[i][j] = numeric_limits<int>::max();
      if (i - 1 >= 0 && j - 1 >= 0 && t[i - 1] == s[j - 1]) {
        a[i][j] = a[i - 1][j - 1];
        action[i][j] = 3;
      }
      if (i - 1 >= 0 && a[i][j] > 1 + a[i - 1][j]) {
        a[i][j] = 1 + a[i - 1][j];
        action[i][j] = 1;
      }
      if (j - 1 >= 0 && a[i][j] > 1 + a[i][j - 1]) {
        a[i][j] = 1 + a[i][j - 1];
        action[i][j] = 2;
      }
      if (i - 1 >= 0 && j - 1 >= 0 && t[i - 1] != s[j - 1] &&
          a[i][j] > 1 + a[i - 1][j - 1]) {
        a[i][j] = 1 + a[i - 1][j - 1];
        action[i][j] = 0;
      }
    }
  if (0)
    for (int i = 0; i <= n; ++i, cout << endl)
      for (int j = 0; j <= m; ++j) {
        cout << setw(4) << a[i][j] << act[action[i][j]][0];
      }
  vector<string> path;
  int nn = n, mm = m;
  while (nn + mm != 0) {
    stringstream ss;
    if (action[nn][mm] == 3) {
      nn--, mm--;
    } else {
      ss << act[action[nn][mm]] << " ";
      if (action[nn][mm] == 1) {
        ss << nn << " " << t[nn - 1];
        nn--;
      } else if (action[nn][mm] == 2) {
        ss << nn + 1;
        mm--;
      } else if (action[nn][mm] == 0) {
        ss << nn << " " << t[nn - 1];
        nn--;
        mm--;
      } else
        abort();
      path.push_back(ss.str());
    }
  }
  cout << path.size() << endl;
  for (int i = 0; i < path.size(); ++i)
    cout << path[path.size() - 1 - i] << endl;
  if (1) {
    string tmp = s;
    for (int i = 0; i < path.size(); ++i) {
      stringstream ss;
      ss << path[path.size() - 1 - i];
      string a;
      int pos;
      char c;
      ss >> a >> pos >> c;
      if (a == "REPLACE") {
        tmp[pos - 1] = c;
      } else if (a == "INSERT") {
        string tmp2 = "";
        for (int j = 0; j < tmp.size(); ++j) {
          if (j == pos - 1) tmp2 += c;
          tmp2 += tmp[j];
        }
        if (pos - 1 == tmp.size()) tmp2 += c;
        tmp = tmp2;
      } else if (a == "DELETE") {
        string tmp2 = "";
        for (int j = 0; j < tmp.size(); ++j) {
          if (j != pos - 1) tmp2 += tmp[j];
        }
        tmp = tmp2;
      }
    }
    assert(tmp == t);
  }
  assert(path.size() == a[n][m]);
  return 0;
}