#include<iostream>
#include<string.h>
#include<stdlib.h>
using namespace std;
#define stack_int_size 100
#define stackcintsize 10
#define ok 1
#define error 0
#define overflow -1
typedef struct
{
int *base;
int *top;
int stacksize;
}sqstack;
int init(sqstack &l)
{
l.base=(int *)malloc(stack_int_size*sizeof(int));
if(!l.base)exit(error);
l.top=l.base;
l.stacksize=stack_int_size;
return ok;
}
int push(sqstack &l,int e)
{
if(l.top-l.base>=l.stacksize)
{
l.base=(int *)realloc(l.base,(stack_int_size+stackcintsize)*sizeof(int));
if(!l.base)exit(error);
l.top=l.base+l.stacksize;
l.stacksize+=stackcintsize;
}
*l.top++=e;
return ok;
}
int pop(sqstack &l,char &e)
{
if(l.top==l.base)return error;
e=*--l.top;
return ok;
}
int empty(sqstack &l)
{
if(l.top==l.base)return 1;
else return 0;
}
int main()
{
sqstack l1,l2;
init(l1);
init(l2);
int n;
char a[10],b[10],c,d;
while(cin>>n)
{
int N=n;
cin>>a>>b;
for(int k=0,int i=0;k<strlen(a);k++)
{
int h=k;
push(l1,a[k]);
while(!empty(l1)){
if(a[h--]==b[i]){pop(l1,b[i]);if(k!=strlen(a)-1)i++;if(h!=0)h--;}
else break;}
}
if(!empty(l1))cout<<"No."<<endl<<"FINISH"<<endl;
else
{
cout<<"Yes."<<endl;
for(int k=0,int i=0;k<strlen(a);k++)
{
int h=k;
push(l2,a[k]);
cout<<"in"<<endl;
while(!empty(l2)){
if(a[h--]==b[i]){pop(l2,b[i]);cout<<"out"<<endl;if(k!=strlen(a)-1)i++;if(h!=0)h--;}
else break;}
}
cout<<"FINISH"<<endl;
}
}
return 0;
}