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 <typename T>
using maxHeap = priority_queue<T, vector<T>, less<T>>;
template <typename T>
using minHeap = priority_queue<T, vector<T>, greater<T>>;
template <typename Iter>
ostream& _out(ostream& s, Iter b, Iter e) {
  s << "[";
  for (auto it = b; it != e; it++) s << (it == b ? "" : " ") << *it;
  s << "]";
  return s;
}
template <typename A, typename B>
ostream& operator<<(ostream& s, const pair<A, B>& p) {
  return s << "(" << p.first << "," << p.second << ")";
}
template <typename T>
ostream& operator<<(ostream& s, const vector<T>& c) {
  return _out(s, begin(c), end(c));
}
bool debug = 0;
template <typename T>
void DEBUG(const T& x) {
  if (debug) cerr << x;
}
template <typename T, typename... Args>
void DEBUG(const T& head, const Args&... tail) {
  if (debug) {
    cerr << head;
    DEBUG(tail...);
  }
}
const int N = 1000 + 5;
enum { SAME, REP, ADD, DEL };
int dp[N][N], how[N][N];
int main(int argc, char* argv[]) {
  if (argc > 1 and string(argv[1]) == "-D") debug = 1;
  if (!debug) {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
  }
  string s1, s2;
  cin >> s1 >> s2;
  int n = (int)(s1.size()), m = (int)(s2.size());
  for (int i = 0; i <= n; i++) {
    dp[i][0] = i;
    how[i][0] = DEL;
  }
  for (int i = 0; i <= m; i++) {
    dp[0][i] = i;
    how[0][i] = ADD;
  }
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= m; j++) {
      if (s1[i - 1] == s2[j - 1]) {
        dp[i][j] = dp[i - 1][j - 1];
        how[i][j] = SAME;
      } else {
        dp[i][j] = n * m + 100;
        if (dp[i - 1][j - 1] + 1 < dp[i][j]) {
          dp[i][j] = dp[i - 1][j - 1] + 1;
          how[i][j] = REP;
        }
        if (dp[i - 1][j] + 1 < dp[i][j]) {
          dp[i][j] = dp[i - 1][j] + 1;
          how[i][j] = DEL;
        }
        if (dp[i][j - 1] + 1 < dp[i][j]) {
          dp[i][j] = dp[i][j - 1] + 1;
          how[i][j] = ADD;
        }
      }
    }
  cout << dp[n][m] << '\n';
  pair<int, int> cur = {n, m};
  while (cur.first != 0 or cur.second != 0) {
    int i = cur.first, j = cur.second;
    switch (how[i][j]) {
      case SAME:
        i--, j--;
        break;
      case REP:
        cout << "REPLACE " << i << ' ' << s2[j - 1] << '\n';
        i--, j--;
        break;
      case DEL:
        cout << "DELETE " << i << '\n';
        i--;
        break;
      case ADD:
        cout << "INSERT " << i + 1 << ' ' << s2[j - 1] << '\n';
        j--;
        break;
    }
    cur = {i, j};
  }
  return 0;
}