Under construction

Still being built. Things may change

Edit Distance Yet Again

Time limit20sMemory limit512 MB

Summary
Decide whether the edit distance between two strings is at most k, and if so, output a minimum-length sequence of insert, delete, and replace operations.
Level

Hard8 of 10

Topics
String, Dynamic programming, String matching
Solved
No attempts yet

Problem

Have you ever heard of the edit distance problem? Given two strings of lowercase English letters, you must determine the minimum number of operations needed to transform the first one into the second one. A single operation can be one of the following:

  • inserting a character into the sequence at any position,
  • deleting any character from the sequence,
  • substituting a character with another one.

Everyone at our university loves this problem, maybe a little too much, so we decided to create an easier one! You are given two strings s=s1…sns = s_1 \ldots s_n and t=t1…tmt = t_1 \ldots t_m, and an integer kk. Find out whether the edit distance between the strings is at most kk. If so, you must also output any sequence of the minimum possible number of operations that transforms the first string into the second one.

Input

The first line contains the number of test cases zz (1≤z≤1001 \leq z \leq 100). The descriptions of the test cases follow.

The first line of each test case contains three integers n,m,kn, m, k (1≤n,m≤1 000 0001 \leq n, m \leq 1\,000\,000, 0≤k≤10000 \leq k \leq 1000), the lengths of the strings and the parameter from the problem. The second line contains a string of length nn consisting of lowercase English letters, the string ss. The third line contains a string of length mm consisting of lowercase English letters, the string tt.

The total length of all strings in all test cases does not exceed 10710^7.

Output

For each test case, if the edit distance is greater than kk, print a single line containing NO. Otherwise, print YES on the first line. On the second line, print the minimum number rr of operations needed to transform ss into tt. Then print the rr operations, one per line.

  • To insert a lowercase English letter cc into a sequence of size ww at position pp (1≤p≤w+11 \leq p \leq w + 1), print INSERT p c.
  • To delete the character at position pp of a sequence of size ww (1≤p≤w1 \leq p \leq w), print DELETE p.
  • To substitute the character at position pp of a sequence of size ww (1≤p≤w1 \leq p \leq w) with a lowercase English letter cc, print REPLACE p c.

Examples1

  1. Example 1

    Input
    2
    3 4 3
    kot
    plot
    5 7 3
    zycie
    porazka
    
    Expected output
    YES
    2
    REPLACE 1 l
    INSERT 1 p
    NO