import Foundation
let S:[String]=readLine()!
let T:[String]=readLine()!
var a=0
for_i;for i 0..<S.characters.count{
  a=0
  if S[0]==T[i] {
    for_j;for j 1..<S.characters.count{
      if S[j]==T[(i+j)%5]{
        a=a+1
      }else {
        break for_j
      }
    }
  }
  if a==S.characters.count{
    print("Yes")
    break for_i
  }
}
if a!=S.characters.count{
  print("No")
}
        