def min_pre(s):
i, j, k, n = 0, 1, 0, len(s)
while i < n and j < n and k < n:
if s[(i + k) % n] == s[(j + k) % n]:
k += 1
elif s[(i + k) % n] > s[(j + k) % n]:
i = i + k + 1
k = 0
else:
j = j + k + 1
k = 0
if i == j:
i += 1
if i > j:
i, j = j, i
return s[i:] + s[:i]
s1, s2 = input(), input()
m1, m2 = min_pre(s1), min_pre(s2)
if m1 == m2:
print("Yes\n%s" % m1)
else:
print("No")