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 JAVA):

Solution:
function main(a, b) {
  // define variables
  var config = {
    sources: {
      insert: 0,
      remove: 1,
      matching: 2,
    },
    scores: {
      match: 0,
      replace: -1,
      insert: -1,
      remove: -1
    },
  };
  function create() {
    var table = [];
    for (var i = 0; i < a.length + 1; i++) {
      var row = [];
      for (var j = 0; j < b.length + 1; j++) {
        row.push(null);
      }
      table.push(row);
    }
    return table;
  }
  var scores = create();
  var sources = create();
  var letters = create();

  // compute first row and first column
  scores[0][0] = 0;
  for (var i = 0; i < a.length; i++) {
    scores[i + 1][0] = (i + 1) * config.scores.remove;
    sources[i + 1][0] = config.sources.remove;
    letters[i + 1][0] = a[i];
  }
  for (var i = 0; i < b.length; i++) {
    scores[0][i + 1] = (i + 1) * config.scores.insert;
    sources[0][i + 1] = config.sources.insert;
    letters[0][i + 1] = b[i];
  }

  // compute the whole table
  for (var i = 1; i < scores.length; i++) {
    for (var j = 1; j < scores[i].length; j++) {
      var match = a[i - 1] === b[j - 1];
      var insertScore = scores[i][j - 1] + config.scores.insert;
      var removeScore = scores[i - 1][j] + config.scores.remove;
      var matchingScore = scores[i - 1][j - 1] + config.scores[match ? 'match' : 'replace'];

      if (insertScore >= removeScore && insertScore >= matchingScore) {
        scores[i][j] = insertScore;
        sources[i][j] = config.sources.insert;
        letters[i][j] = b[j - 1];
      } else if (removeScore >= insertScore && removeScore >= matchingScore) {
        scores[i][j] = removeScore;
        sources[i][j] = config.sources.remove;
        letters[i][j] = a[i - 1];
      } else if (matchingScore >= removeScore && matchingScore >= insertScore) {
        scores[i][j] = matchingScore;
        sources[i][j] = config.sources.matching;
        letters[i][j] = match ? ' ' : b[j - 1];
      }
    }
  }

  // return the editing operation list
  var path = [];
  var j = b.length;
  var i = a.length;
  var current = a.slice();
  while (i > 0 || j > 0) {
    if (sources[i][j] === config.sources.matching) {
      if (scores[i][j] < scores[i - 1][j - 1]) {
        current[i - 1] = letters[i][j];
        path.push({
          current: current.slice(),
          type: 'replace',
          position: i,
          item: letters[i][j],
        });
      }
      i--;
      j--;
    } else if (sources[i][j] === config.sources.remove) {
      current.splice(i - 1, 1);
      path.push({
        current: current.slice(),
        type: 'delete',
        position: i,
        item: letters[i][j],
      });
      i--;
    } else if (sources[i][j] === config.sources.insert) {
      current.splice(i, 0, letters[i][j]);
      path.push({
        current: current.slice(),
        type: 'insert',
        position: i + 1,
        item: letters[i][j],
      });
      j--;
    }
  }
  return path;
}

var a = readline().trim();
var b = readline().trim();
var changes = main(a.split(''), b.split(''));

print(changes.length);
changes.forEach(function (change) {
  print(change.type.toUpperCase() + ' ' + change.position + (change.type === 'delete' ? '' : (' ' + change.item)));
});