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;
long long int mod = 1e9 + 7;
template <typename T, typename... Args>
void debug(T t, Args... args) {
  return;
}
long long int power(long long int x, long long int y) {
  long long int ans = 1;
  while (y > 0) {
    if (y & 1) ans = (ans * x) % mod;
    y = y >> 1;
    x = (x * x) % mod;
  }
  return ans;
}
const int N = 1005;
long long int dp[N][N];
string s, t;
pair<int, char> dp2[N][N];
long long int h(int i, int j) {
  if (i == s.size() && j == t.size()) return 0;
  if (i > s.size() || j > t.size()) return 3 * N;
  int ans = 3 * N;
  pair<int, char> op = {0, '0'};
  if (dp[i][j] != -1) return dp[i][j];
  if (i < s.size() && j < t.size() && s[i] == t[j]) {
    ans = h(i + 1, j + 1);
  } else {
    if (i < s.size() && 1 + h(i + 1, j) < ans) {
      ans = 1 + h(i + 1, j);
      op = {1, s[i]};
    }
    if (j < t.size() && 1 + h(i, j + 1) < ans) {
      ans = 1 + h(i, j + 1);
      op = {2, t[j]};
    }
    if (i < s.size() && j < t.size() && 1 + h(i + 1, j + 1) < ans) {
      ans = 1 + h(i + 1, j + 1);
      op = {3, t[j]};
    }
  }
  dp2[i][j] = op;
  return dp[i][j] = ans;
}
void h2(int i, int j, int ind) {
  if (i == s.size() && j == t.size()) return;
  if (dp2[i][j].first == 0)
    h2(i + 1, j + 1, ind + 1);
  else if (dp2[i][j].first == 1) {
    cout << "DELETE"
         << " " << ind << endl;
    h2(i + 1, j, ind);
  } else if (dp2[i][j].first == 2) {
    cout << "INSERT"
         << " " << ind << " " << t[j] << endl;
    h2(i, j + 1, ind + 1);
  } else {
    cout << "REPLACE"
         << " " << ind << " " << t[j] << endl;
    h2(i + 1, j + 1, ind + 1);
  }
}
void solve(int T) {
  cin >> s >> t;
  memset(dp, -1, sizeof(dp));
  cout << h(0, 0) << endl;
  h2(0, 0, 1);
};
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int t = 1;
  for (int i = 1; i <= t; i++) solve(i);
  return 0;
}