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;
void solutionD();
int main() {
  ios_base::sync_with_stdio(false);
  solutionD();
  return EXIT_SUCCESS;
}
string a, b;
long long dp[1024][1024];
struct command {
  long long x, y, z;
  command(long long x = 0, long long y = 0, long long z = 0)
      : x(x), y(y), z(z) {}
};
pair<pair<long long, long long>, command> p[1024][1024];
void solve() {
  long long n = a.size(), m = b.size();
  for (long long i = 0; i <= n; ++i)
    for (long long j = 0; j <= m; ++j) dp[i][j] = 1000000000;
  dp[0][0] = 0;
  for (long long i = 0; i <= n; ++i)
    for (long long j = 0; j <= m; ++j) {
      if (a[i] == b[j]) {
        if (dp[i][j] < dp[i + 1][j + 1]) {
          dp[i + 1][j + 1] = dp[i][j];
          p[i + 1][j + 1] = make_pair(make_pair(i, j), command(0, -1, -1));
        }
      } else {
        if (dp[i][j] + 1 < dp[i + 1][j + 1]) {
          dp[i + 1][j + 1] = dp[i][j] + 1;
          p[i + 1][j + 1] = make_pair(make_pair(i, j), command(3, j, b[j]));
        }
        if (dp[i][j] + 1 < dp[i][j + 1]) {
          dp[i][j + 1] = dp[i][j] + 1;
          p[i][j + 1] = make_pair(make_pair(i, j), command(1, j, b[j]));
        }
        if (dp[i][j] + 1 < dp[i + 1][j]) {
          dp[i + 1][j] = dp[i][j] + 1;
          p[i + 1][j] = make_pair(make_pair(i, j), command(2, j, -1));
        }
      }
    }
  assert(dp[n][m] != 1000000000);
  pair<long long, long long> v(n, m);
  vector<command> ans;
  while (v.first != 0 || v.second != 0) {
    command it = p[v.first][v.second].second;
    if (it.x != 0) ans.push_back(it);
    v = p[v.first][v.second].first;
  }
  reverse(ans.begin(), ans.end());
  cout << dp[n][m] << endl;
  for (command it : ans) {
    if (it.x == 1) {
      cout << "INSERT " << it.y + 1 << " " << char(it.z) << '\n';
    } else if (it.x == 2) {
      cout << "DELETE " << it.y + 1 << '\n';
    } else if (it.x == 3) {
      cout << "REPLACE " << it.y + 1 << " " << char(it.z) << '\n';
    }
  }
}
void solutionD() {
  for (; cin >> a >> b;) {
    solve();
    cerr << endl;
  }
}