import java.util.*;

public class Solution {
    public boolean solve (String A, String B) {
        // 拼接两个A后再判断
        return A.length() == B.length() && (A+A).contains(B);
    }
}