#include<bits/stdc++.h>
using namespace std;
const int N=1e6+7;
int m;
struct str
{
char a[N];
} s1,s2;
int len;
void get_min(str &x)
{
int i=0,j=1,k=0;
while (i<len&&j<len&&k<len)
{
int t=x.a[(i+k)%len]-x.a[(j+k)%len];
if (!t) k++;
else
{
if (t>0) i+=k+1;
else j+=k+1;
if (i==j) j++;
k=0;
}
}
i=(i<j)?i:j;str cc;
for (int p=0;p<len;p++) cc.a[p]=x.a[(i+p)%len];
x=cc;
}
int main()
{
freopen("necklacee.in","r",stdin);
freopen("necklacee.out","w",stdout);
scanf("%s",s1.a);
scanf("%s",s2.a);
len=strlen(s1.a);
if (len!=strlen(s2.a)) {printf("No");return 0;}
get_min(s1);
get_min(s2);
for (int i=0;i<len;i++)
if (s1.a[i]!=s2.a[i]) {printf("No");return 0;}
printf("Yes\n");
for (int i=0;i<len;i++) printf("%c",s1.a[i]);
return 0;
}