#include<bits/stdc++.h>
using namespace std;
int main()
{
string s1, s2;
getline(cin, s1);
getline(cin, s2);
int m = s1.size();
int n = s2.size();
int EDIT[n+1][m+1];
for(int i = 0; i < m+1; i++)
{
EDIT[0][i] = i;
}
for(int i = 0; i< n+1; i++)
{
EDIT[i][0] = i;
}
for(int i = 1; i < n+1; i++)
{
for(int j = 1; j < m+1; j++)
{
if(s1[j-1] == s2[i-1])
{
EDIT[i][j] = EDIT[i-1][j-1];
}
else
{
EDIT[i][j] = 1+ min({EDIT[i-1][j], EDIT[i][j-1], EDIT[i-1][j-1]});
}
}
}
for(int i = 0; i < n+1; i++)
{
for(int j = 0; j < m+1; j++)
{
cout<<EDIT[i][j]<<" ";
}
cout<<endl;
}
int i = n, j = m;
while(i > 0)
{
//cout<<i<<" "<<j<<endl;
if(s1[j-1] == s2[i-1])
{
i = i-1;
j = j-1;
}
else
{
if(EDIT[i][j] == 1 + EDIT[i-1][j-1])
{
cout<<s1[j-1]<<" is replaced by "<<s2[i-1]<<endl;
i = i-1;
j = j-1;
}
else if(EDIT[i][j] == 1 + EDIT[i-1][j])
{
cout<<s1[j-1]<<" is inserted"<<endl;
i = i-1;
}
else
{
cout<<s1[j-1]<<" is deleted"<<endl;
j = j-1;
}
}
}
}
I2luY2x1ZGU8Yml0cy9zdGRjKysuaD4KdXNpbmcgbmFtZXNwYWNlIHN0ZDsKCmludCBtYWluKCkKewogICAgc3RyaW5nIHMxLCBzMjsKICAgIGdldGxpbmUoY2luLCBzMSk7CiAgICBnZXRsaW5lKGNpbiwgczIpOwogICAgaW50IG0gPSBzMS5zaXplKCk7CiAgICBpbnQgbiA9IHMyLnNpemUoKTsKCiAgICBpbnQgRURJVFtuKzFdW20rMV07CgogICAgZm9yKGludCBpID0gMDsgaSA8IG0rMTsgaSsrKQogICAgewogICAgICAgIEVESVRbMF1baV0gPSBpOwogICAgfQogICAgZm9yKGludCBpID0gMDsgaTwgbisxOyBpKyspCiAgICB7CiAgICAgICAgRURJVFtpXVswXSA9IGk7CiAgICB9CgogICAgZm9yKGludCBpID0gMTsgaSA8IG4rMTsgaSsrKQogICAgewogICAgICAgIGZvcihpbnQgaiA9IDE7IGogPCBtKzE7IGorKykKICAgICAgICB7CiAgICAgICAgICAgIGlmKHMxW2otMV0gPT0gczJbaS0xXSkKICAgICAgICAgICAgewogICAgICAgICAgICAgICAgRURJVFtpXVtqXSA9IEVESVRbaS0xXVtqLTFdOwogICAgICAgICAgICB9CiAgICAgICAgICAgIGVsc2UKICAgICAgICAgICAgewogICAgICAgICAgICAgICAgRURJVFtpXVtqXSA9IDErIG1pbih7RURJVFtpLTFdW2pdLCBFRElUW2ldW2otMV0sIEVESVRbaS0xXVtqLTFdfSk7CiAgICAgICAgICAgIH0KICAgICAgICB9CiAgICB9CgogICAgZm9yKGludCBpID0gMDsgaSA8IG4rMTsgaSsrKQogICAgewogICAgICAgIGZvcihpbnQgaiA9IDA7IGogPCBtKzE7IGorKykKICAgICAgICB7CiAgICAgICAgICAgIGNvdXQ8PEVESVRbaV1bal08PCIgIjsKICAgICAgICB9CiAgICAgICAgY291dDw8ZW5kbDsKICAgIH0KCiAgICBpbnQgaSA9IG4sIGogPSBtOwogICAgd2hpbGUoaSA+IDApCiAgICB7CiAgICAgICAgLy9jb3V0PDxpPDwiICI8PGo8PGVuZGw7CiAgICAgICAgaWYoczFbai0xXSA9PSBzMltpLTFdKQogICAgICAgIHsKICAgICAgICAgICAgaSA9IGktMTsKICAgICAgICAgICAgaiA9IGotMTsKICAgICAgICB9CiAgICAgICAgZWxzZQogICAgICAgIHsKICAgICAgICAgICAgaWYoRURJVFtpXVtqXSA9PSAxICsgRURJVFtpLTFdW2otMV0pCiAgICAgICAgICAgIHsKICAgICAgICAgICAgICAgIGNvdXQ8PHMxW2otMV08PCIgaXMgcmVwbGFjZWQgYnkgIjw8czJbaS0xXTw8ZW5kbDsKICAgICAgICAgICAgICAgIGkgPSBpLTE7CiAgICAgICAgICAgICAgICBqID0gai0xOwogICAgICAgICAgICB9CiAgICAgICAgICAgIGVsc2UgaWYoRURJVFtpXVtqXSA9PSAxICsgRURJVFtpLTFdW2pdKQogICAgICAgICAgICB7CiAgICAgICAgICAgICAgICBjb3V0PDxzMVtqLTFdPDwiIGlzIGluc2VydGVkIjw8ZW5kbDsKICAgICAgICAgICAgICAgIGkgPSBpLTE7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgZWxzZQogICAgICAgICAgICB7CiAgICAgICAgICAgICAgICBjb3V0PDxzMVtqLTFdPDwiIGlzIGRlbGV0ZWQiPDxlbmRsOwogICAgICAgICAgICAgICAgaiA9IGotMTsKICAgICAgICAgICAgfQogICAgICAgIH0KICAgIH0KCgoKCgoKCgp9Cg==