#include<bits/stdc++.h>
using namespace std;
stack<int>a;
vector<string>ans;
int main(){
int n;
string op,ed;
while(cin>>n>>op>>ed){
while(!a.empty())a.pop();
ans.clear();
int count=0;
for(int i=0;i<n;++i){
a.push(op[i]);
ans.push_back("in");
while(!a.empty()&&a.top()==ed[count]){
a.pop();
count++;
ans.push_back("out");
}
}
if(!a.empty())cout<<"No."<<endl;
else{
cout<<"Yes."<<endl;
for(string i:ans)cout<<i<<endl;//定义了一个新的字符串i,收集ans集合(数组)中的元素
}
cout<<"FINISH"<<endl;
}
return 0;
}