/***************
Problem from :ds
Problem describe :
队列模拟进站出站过程
栈存储信息
data:
****************/
#include<iostream>
#include<cstdlib>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<map>
#include<stack>
#include<queue>
#include<ctime>
#include<cstring>
#include<vector>
#include<string>
#define ll __int64
#define inf 0x3f3f3f3f3f
using namespace std;
int num[20]={0};
queue<int>in;
queue<int>out;
stack<int>s;
queue<string>q;
int main()
{
int i, n;
char c;
scanf("%d ", &n);
for(i=0; i<n; i++)
{
scanf("%c", &c);
in.push(c-'0');
}
getchar();
for(i=0;i<n; i++)
{
scanf("%c", &c);
out.push(c-'0');
}
bool flag=true;
while( !out.empty() )
{
int k=out.front();
out.pop();
if(num[k]==1)
{
if(s.top()!=k) flag=false;
else
{
s.pop();
q.push("out");
num[k]=2;
}
}
else
{
bool t=false;
while(!in.empty())
{
int k1=in.front();
in.pop();
if(k1==k)
{
t=true;
q.push("in");
q.push("out");
num[k]=2;
break;
}
else
{
s.push(k1);
q.push("in");
num[k1]=1;
}
}
if(!t) flag=false;
}
if(!flag) break;
}
if(flag)
{
printf("Yes\n");
while(!q.empty())
{
cout<<q.front()<<endl;
q.pop();
}
}
else
{
printf("No\n");
}
return 0;
}