栈模拟
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <math.h>
using namespace std;
#define sf scanf
#define pf printf
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define dbg(x) cerr << "Line:" << __LINE__ << " : " << #x << " = " << (x) << endl
#define nMax 1000
#define ll long long
int n;
string s1,s2;
int in[nMax];
int ans[nMax];
char st[nMax];
int top;
void go() {
top = 0;
int i,j,m=0;
i = 0;j = 0;
int l = s1.length();
//st[++top] = i;in[i]=1;i++;
while(j < l) {
if(top && s2[j]==s1[st[top]]) {
ans[m++]=-1;
top --;
j++;
}else {
if(i==l) break;
ans[m++]=1;
st[++top]=i;
in[i]=1;
i++;
}
}
if(j!=l) {
pf("No.\n");
pf("FINISH\n");
}else {
pf("Yes.\n");
rep(i,m) {
pf("%s\n",ans[i]==1?"in":"out");
}
pf("FINISH\n");
}
return ;
}
int main() {
#ifndef ONLINE_JUDGE
freopen("in.txt","r",stdin);
#endif
while(cin >> n >> s1 >> s2) {
go();
}
return 0;
}