Under construction

Still being built. Things may change

Repetitive Palindrome

Time limit1sMemory limit1024 MB

Summary
Given a lowercase string s and integer k, decide if t formed by concatenating k copies of s is a palindrome.
Level

Medium4 of 10

Topics
String, Math, Implementation
Solved
No attempts yet

Problem

You are given a string ss of lowercase alphabets and an integer kk.

Form a new string tt by concatenating kk copies of ss. Determine whether tt is a palindrome, that is, whether it reads the same forward and backward.

Input

The first line contains a string ss of lowercase alphabets. (1≤∣s∣≤250,0001 \le |s| \le 250,000)

The second line contains an integer kk. (1≤k≤10181 \le k \le 10^{18})

Output

If tt is a palindrome, print YES. Otherwise, print NO.

Examples2

  1. Example 1

    Input
    abc
    3
    
    Expected output
    NO
    
  2. Example 2

    Input
    abba
    1
    
    Expected output
    YES