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>
int main(int argc, char *argv[]) {
  std::vector<std::string> p;
  std::string s, t;
  std::ios_base::sync_with_stdio(false);
  std::cin >> s >> t;
  struct edit {
    size_t c;
    char o;
  };
  struct plan {
    size_t rows, cols;
    std::vector<edit> m;
    plan(const size_t rows, const size_t cols)
        : rows(rows), cols(cols), m(rows * cols) {}
    edit &operator()(const size_t r, const size_t c) { return m[c + r * cols]; }
  } w(s.length() + 1, t.length() + 1);
  w(0, 0) = {0, '_'};
  for (size_t r = 1; r <= s.length(); r++) w(r, 0) = {r, 'D'};
  for (size_t c = 1; c <= t.length(); c++) w(0, c) = {c, 'I'};
  for (size_t r = 1; r <= s.length(); r++)
    for (size_t c = 1; c <= t.length(); c++) {
      const edit del = {1 + w(r - 1, c).c, 'D'};
      const edit ins = {1 + w(r, c - 1).c, 'I'};
      const edit sub = {(s[r - 1] != t[c - 1]) + w(r - 1, c - 1).c,
                        s[r - 1] != t[c - 1] ? 'S' : 'K'};
      w(r, c) = del.c <= ins.c && del.c <= sub.c   ? del
                : ins.c <= del.c && ins.c <= sub.c ? ins
                                                   : sub;
    }
  printf("%" PRId64 "\n", static_cast<int64_t>(w(s.length(), t.length()).c));
  for (ssize_t r = s.length(), c = t.length(); r >= 0 && c >= 0;
       w(r, c).o == 'D'   ? r--
       : w(r, c).o == 'I' ? c--
                          : (r--, c--)) {
    char b[32] = "";
    if (w(r, c).o == 'I')
      sprintf(b, "INSERT %" PRId64 " %c", static_cast<int64_t>(c), t[c - 1]);
    else if (w(r, c).o == 'D')
      sprintf(b, "DELETE %" PRId64, static_cast<int64_t>(c + 1));
    else if (w(r, c).o == 'S')
      sprintf(b, "REPLACE %" PRId64 " %c", static_cast<int64_t>(c), t[c - 1]);
    if (b[0] != '\0') p.push_back(b);
  }
  for (std::vector<std::string>::const_reverse_iterator i = p.crbegin();
       i != p.crend(); ++i)
    printf("%s\n", i->c_str());
  return EXIT_SUCCESS;
}