n | first = input() | n | x = input() |
| second = input() | | y = input() |
| isit = False | | z = False |
| | | |
n | if len(second) > len(first): | n | if len(y) > len(x): |
| print("NO") | | print("NO") |
n | elif len(second) == 0: | n | elif len(y) == 0: |
| print("YES") | | print("YES") |
n | elif len(second) == 1: | n | elif len(y) == 1: |
| if second in first: | | if y in x: |
| print("YES") | | print("YES") |
| else: | | else: |
| print("NO") | | print("NO") |
| else: | | else: |
n | for i in range(len(first)): | n | for i in range(len(x)): |
| if isit: | | if z: |
| break | | break |
n | #if first[i]==second[0]: print(first[i], second[0]) | n | |
| if first[i] == second[0]: | | if x[i] == y[0]: |
| for j in range(i+1, len(first)): | | for k in range(i+1, len(x)): |
| # print(j) | | |
| if isit: | | if z: |
| break | | break |
n | if first[j] == second[1]: | n | if x[k] == y[1]: |
| # print("AAA") | | |
| k = j-i | | j = k-i |
| | | |
| third = first[i:i+k*(len(second)):k] | | p = x[i:i+j*(len(y)):j] |
| | | |
| if third == second: | | if p == y: |
| isit = True | | z = True |
| | | |
| if isit: | | if z: |
| print("YES") | | print('YES') |
| else: | | else: |
t | print("NO") | t | print('NO') |
| | | |