Let's consider one interesting word game. In this game you should transform one word into another through special operations. Let's say we have word w, let's split this word into two non-empty parts x and y so, that w = xy. A split operation is transforming word w = xy into word u = yx. For example, a split operation can transform word "wordcut" into word "cutword".You are given two words start and end. Count in how many ways we can transform word start into word end, if we apply exactly k split operations consecutively to word start. Two ways are considered different if the sequences of applied operations differ. Two operation sequences are different if exists such number i (1 ≤ i ≤ k), that in the i-th operation of the first sequence the word splits into parts x and y, in the i-th operation of the second sequence the word splits into parts a and b, and additionally x ≠ a holds.

The first line contains a non-empty word start, the second line contains a non-empty word end. The words consist of lowercase Latin letters. The number of letters in word start equals the number of letters in word end and is at least 2 and doesn't exceed 1000 letters. The third line contains integer k (0 ≤ k ≤ 105) — the required number of operations.

Print a single number — the answer to the problem. As this number can be rather large, print it modulo 1000000007 (109 + 7).

NoteThe sought way in the first sample is:ab  →  a|b  →  ba  →  b|a  →  abIn the second sample the two sought ways are: ababab  →  abab|ab  →  ababab  ababab  →  ab|abab  →  ababab

start = raw_input().strip()
end = raw_input().strip()
k = int(raw_input())
if k == 0:
    if start == end:
       print 1
    else:
       print 0
    exit(0)
L = len(start)
ans = tmp = 0
mod = 10 ** 9 + 7
for i in xrange(1, L):
    if start[i:] + start[:i] == end:
        tmp += 1
if start == end:
    p = [1, 0]
    for i in xrange(k):
        p = [p[1], (p[0] * (L-1) + p[1] * (L-2)) % mod]
    ans += p[0]
if tmp > 0:
    p = [0, 1]
    for i in xrange(k):
        p = [p[1], (p[0] * (L-1) + p[1] * (L-2)) % mod]
    ans += p[0] * tmp % mod
print ans % mod

'''
Created on Apr 20, 2012

@author: Tobias Flach
'''

def solve():
    prime = 1000000007

    str_a = raw_input()
    str_b = raw_input()
    k = int(raw_input())

    good_shifts = 0
    bad_shifts  = 0

    for i in range(0, len(str_a)):
        shifted = str_a[i:] + str_a[:i]
        if shifted == str_b:
            good_shifts += 1
        else:
            bad_shifts += 1

    good_sols = 0
    bad_sols  = 0
    if str_a == str_b:
        good_sols = 1
    else:
        bad_sols  = 1

    for i in range(0, k):
        t_good_sols = good_sols * (good_shifts - 1) + bad_sols * good_shifts
        t_bad_sols  = good_sols * bad_shifts + bad_sols * (bad_shifts - 1)
        good_sols = t_good_sols % prime
        bad_sols  = t_bad_sols % prime

    print "%d" % (good_sols)

if __name__ == '__main__':
    solve()

import sys

start = raw_input()
end = raw_input()
k = int(raw_input())

dpA = [-1 for i in xrange(k+1)]
dpB = [-1 for i in xrange(k+1)]

def calculaA(n):
    global dpA, dpB
    if n == 0:
        return 0
    if dpA[n-1] == -1:
        calculaA(n-1)

    dpA[n] = dpA[n-1]*(A-1) + dpB[n-1]*A
    dpB[n] = dpA[n-1]*B     + dpB[n-1]*(B-1)

    return dpA[n]

if start == end and k == 0:
    print 1
    exit(0)

A = B = 0

if start != end:
    dpA[0] = 0
    dpB[0] = 1
else:
    dpA[0] = 1
    dpB[0] = 0

for i in xrange(len(start)):
    now = start[i:]+start[:i]

    if now == end:
        A += 1
    else:
        B += 1

for n in xrange(1, k+1):
    dpA[n] = (dpA[n-1]*(A-1) + dpB[n-1]*A)%1000000007
    dpB[n] = (dpA[n-1]*B     + dpB[n-1]*(B-1))%1000000007

print dpA[k]

class Solution():
	def number_or_ways(start, end, moves):
		p = 10**9+7
		num_rots = 0
		for i in range(len(start)):
			rot = start[i:]+start[0:i]
			if rot == end:
				num_rots += 1

		dp = [[0 for i in range(2)] for j in range(moves+1)]

		dp[0][0], dp[0][1] = 1, 0

		for i in range(1, moves+1):
			dp[i][0] = (((num_rots-1)*dp[i-1][0])%p + ((len(start)-num_rots)*dp[i-1][1])%p)%p
			dp[i][1] = ((num_rots*dp[i-1][0])%p + ((len(start)-1-num_rots)*dp[i-1][1])%p)%p

		if start == end:
			return dp[moves][0]
		else:
			return dp[moves][1]

start = input().strip()
end = input().strip()

moves = int(input())

print(Solution.number_or_ways(start, end, moves))

def WordCut():
    start = input()
    end = input()
    k = int(input())
    n=len(start)
    dpA,dpB = (start==end),(start!=end)
    end+=end
    A=sum(start==end[i:i+n] for i in range(n))
    B = n- A
    M = 10**9+7
    for _ in range(k):
        dpA,dpB=(dpA*(A-1)+dpB*A)%M,(dpA*B+dpB*(B-1))%M
    return int(dpA)

print(WordCut())

from collections import deque

start = deque(input())
end = deque(input())
k = int(input())

n = len(start)

deu = 0
naoDeu = 0
for i in range(0, n):

	if (start == end):
		deu += 1
	else:
		naoDeu += 1

	start.rotate(1)

dpDeu = [0] * (k + 1)
dpNaoDeu = [0] * (k + 1)

if (start == end):
	dpDeu[0] = 1
	dpNaoDeu[0] = 0

else:
	dpDeu[0] = 0
	dpNaoDeu[0] = 1

for i in range(1, k + 1):
	dpDeu[i] = (dpDeu[i - 1] * (deu - 1) + dpNaoDeu[i - 1] * deu) % 1000000007
	dpNaoDeu[i] = (dpDeu[i - 1] * naoDeu + dpNaoDeu[i - 1] * (naoDeu - 1)) % 1000000007

print(dpDeu[k])

M = 1000000007
a = raw_input()
b = raw_input()
k = input()

r = [i for i in xrange(0,len(a)) if a[i:] + a[:i] == b]

x,y = 1, 0
l = len(a)
for _ in xrange(k):
    x, y = y*(l-1)%M, (x+y*(l-2))%M

if 0 in r: print (x + y * (len(r) - 1))%M
else: print y * len(r) % M

def main():
    inicio = raw_input()
    fim = raw_input()
    k = int(raw_input())

    vA = [-1]*(k+1)
    vB = [-1]*(k+1)

    if inicio == fim and k == 0:
        return 1
    else:
        A = B = 0

        if inicio != fim:
            vA[0] = 0
            vB[0] = 1
        else:
            vA[0] = 1
            vB[0] = 0

        for i in xrange(len(inicio)):
            atual = inicio[i:]+inicio[:i]
            if atual == fim:
                A += 1
            else:
                B += 1

        for n in xrange(1, k+1):
            vA[n] = (vA[n-1]*(A-1) + vB[n-1]*A)%1000000007
            vB[n] = (vA[n-1]*B     + vB[n-1]*(B-1))%1000000007

        return vA[k]

if __name__ == '__main__':
    print main()

a,b,k=raw_input(),raw_input(),input()
n=len(a)
x,y=(a==b),(a!=b)
b+=b
z=sum(a==b[i:i+n] for i in range(n))
t=n-z
M=10**9+7
for _ in xrange(k):x,y=(x*(z-1)+y*z)%M,(x*t+y*(t-1))%M
print int(x)

# Made By Mostafa_Khaled

MOD = 1000000007

start = raw_input()
end = raw_input()
k = input()

A = 0
B = 0
for i in range(len(start)):
    if start[i:] + start[:i] == end:
        A += 1
    else:
        B += 1

f0, g0 = 0, 0
if start == end:
    f0 = 1
else:
    g0 = 1

den = pow(A + B, MOD - 2, MOD)
c1 = A * (f0 + g0) * den % MOD
c2 = (B * f0 - A * g0) * den % MOD
fn = c1 * pow(A + B - 1, k, MOD)
if k % 2:
    fn -= c2
else:
    fn += c2
fn %= MOD

print(fn)

MOD = 1000000007
start = raw_input()
end = raw_input()
k = input()

A = 0
B = 0
for i in range(len(start)):
    if start[i:] + start[:i] == end:
        A += 1
    else:
        B += 1

dpA = [0] * (k + 1)
dpB = [0] * (k + 1)

if start == end:
    dpA[0] = 1
else:
    dpB[0] = 1

for i in range(1, k + 1):
    dpA[i] = (dpA[i - 1] * (A - 1) + dpB[i - 1] * A) % MOD
    dpB[i] = (dpA[i - 1] * B + dpB[i - 1] * (B - 1)) % MOD

print(dpA[k])

MOD = 1000000007

def kmp(s, p):
    pi = [0 for _ in range(len(p))]
    k = 0
    for i in range(1, len(p)):
        while k > 0 and p[k] != p[i]:
            k = pi[k - 1]
        if p[k] == p[i]:
            k += 1
        pi[i] = k

    k = 0
    resp = []
    for i in range(len(s)):
        while k > 0 and p[k] != s[i]:
            k = pi[k - 1]
        if p[k] == s[i]:
            k += 1
        if k == len(p):
            resp.append(i - len(p) + 1)
            k = pi[k - 1]
    return resp

start = raw_input()
end = raw_input()
k = input()

A = len(kmp(start + start, end))
B = len(start) - A

f0, g0 = 0, 0
if start == end:
    f0 = 1
    A -= 1
    B += 1
else:
    g0 = 1

den = pow(A + B, MOD - 2, MOD)
c1 = A * (f0 + g0) * den % MOD
c2 = (B * f0 - A * g0) * den % MOD
fn = c1 * pow(A + B - 1, k, MOD)
if k % 2:
    fn -= c2
else:
    fn += c2
fn %= MOD

print(fn)

MOD = 1000000007

def mult(a, b):
    c = [[0, 0], [0, 0]]
    for i in range(2):
        for j in range(2):
            for k in range(2):
                c[i][j] += a[i][k] * b[k][j]
            c[i][j] %= MOD
    return c

def modpow(a, n):
    b = [[1, 0], [0, 1]]
    while n:
        if n % 2:
            b = mult(a, b)
        a = mult(a, a)
        n /= 2
    return b

start = raw_input()
end = raw_input()
k = input()

A = 0
B = 0
for i in range(len(start)):
    if start[i:] + start[:i] == end:
        A += 1
    else:
        B += 1

f0, g0 = 0, 0
if start == end:
    f0 = 1
else:
    g0 = 1

F = [[A - 1, A], [B, B - 1]]
F = modpow(F, k)
ans = (F[0][0] * f0 + F[0][1] * g0) % MOD

print(ans)

MOD = 1000000007

def mult(a, b):
    c = [[0, 0], [0, 0]]
    for i in range(2):
        for j in range(2):
            for k in range(2):
                c[i][j] += a[i][k] * b[k][j]
            c[i][j] %= MOD
    return c

def modpow(a, n):
    b = [[1, 0], [0, 1]]
    while n:
        if n % 2:
            b = mult(a, b)
        a = mult(a, a)
        n /= 2
    return b

def kmp(s, p):
    pi = [0 for _ in range(len(p))]
    k = 0
    for i in range(1, len(p)):
        while k > 0 and p[k] != p[i]:
            k = pi[k - 1]
        if p[k] == p[i]:
            k += 1
        pi[i] = k

    k = 0
    resp = []
    for i in range(len(s)):
        while k > 0 and p[k] != s[i]:
            k = pi[k - 1]
        if p[k] == s[i]:
            k += 1
        if k == len(p):
            resp.append(i - len(p) + 1)
            k = pi[k - 1]
    return resp

start = raw_input()
end = raw_input()
k = input()

A = len(kmp(start + start, end))
B = len(start) - A

f0, g0 = 0, 0
if start == end:
    f0 = 1
    A -= 1
    B += 1
else:
    g0 = 1

F = [[A - 1, A], [B, B - 1]]
F = modpow(F, k)
ans = (F[0][0] * f0 + F[0][1] * g0) % MOD

print(ans)

MOD = 1000000007

if __name__ == '__main__':
    a, b, k = raw_input(), raw_input(), int(raw_input())

    str_len = len(a)
    cut_pos = [i for i in xrange(str_len) if a[i:] + a[:i] == b]
    cut_pos_len= len(cut_pos)
    sum = 1
    unit = 0
    for x in xrange(1, k+1):
        unit = sum - unit
        sum *= str_len-1
        sum %= MOD
    ans = unit*cut_pos_len%MOD
    if cut_pos_len > 0 and cut_pos[0] == 0:
        ans += (-1 if k % 2 else 1)
        if ans < 0: ans += MOD
        ans %= MOD
    print ans

MOD = 1000000007

if __name__ == '__main__':
    a, b, k = raw_input(), raw_input(), int(raw_input())

    str_len = len(a)
    cut_pos = [i for i in xrange(str_len) if a[i:] + a[:i] == b]
    cut_pos_len = len(cut_pos)
    sum = 1
    x, y = 1, 0
    for _ in xrange(k):
        x = sum - x
        y = sum - y
        sum *= str_len-1
        sum %= MOD
    print (x+y*(cut_pos_len-1))%MOD if 0 in cut_pos else y*cut_pos_len%MOD

from sys import stdin
from collections import *

def count():
    g = 0
    for i in range(len(s1)):
        s1.rotate(-1)
        g += (s1 == s2)

    return g, len(s1) - g

def dp():
    mem = [[0, 0] for _ in range(k + 1)]
    mem[0][0] = (s1 == s2) & 1
    mem[0][1] = 1 - mem[0][0]

    for i in range(1, k + 1):
        mem[i][0] = add(mult(mem[i - 1][0], max(good - 1, 0)), mult(mem[i - 1][1], good))
        mem[i][1] = add(mult(mem[i - 1][1], max(bad - 1, 0)), mult(mem[i - 1][0], bad))

    print(mem[-1][0] % mod)

rstr = lambda: stdin.readline().strip()
add = lambda a, b: (a % mod + b % mod) % mod
mult = lambda a, b: ((a % mod) * (b % mod)) % mod
mod = 10 ** 9 + 7

s1, s2, k = deque(rstr()), deque(rstr()), int(input())
good, bad = count()
dp()

MOD = int(1e9) + 7
if __name__ == "__main__":
    a, b, k = input(), input(), int(input())
    x, y = (1, 0) if a == b else (0, 1)
    n = len(b)
    b += b
    same = sum(a == b[i: i + n] for i in range(n))
    diff = n - same
    for _ in range(k):
        x, y = ((x * (same - 1)) % MOD + (y * same) % MOD) % MOD, ((x * (diff)) % MOD + (y * (diff - 1)) % MOD) % MOD
    print(x)

MOD = int(1e9) + 7
if __name__ == "__main__":
    a = input()
    b = input()
    k = int(input())
    if(len(a) != len(b)):
        print(0)
        exit()
    a = a + a
    x = 0
    y = 0
    for i in range(len(a) // 2):
        flag = 1
        for j in range(len(b)):
            if(a[j + i] != b[j]):
                flag = 0
                break
        if(flag == 1):
            x += 1
        else:
            y += 1
    flag = 0
    for i in range(len(b)):
        if(a[i] != b[i]):
            flag = 1
    u = 1
    v = 0
    if(flag == 1):
        v = 1
        u = 0
    for i in range(k):
        uu = (u * (x - 1)) % MOD + (v * (x)) % MOD
        vv = (u * (y)) % MOD + (v * (y - 1)) % MOD
        u = uu % MOD
        v = vv % MOD
    print(u)

# ------------------- fast io --------------------
import os
import sys
from io import BytesIO, IOBase

BUFSIZE = 8192

class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None

    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)

class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")

sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
input = lambda: sys.stdin.readline().rstrip("\r\n")

# ------------------- fast io --------------------
from math import gcd, ceil

def prod(a, mod=10**9+7):
    ans = 1
    for each in a:
        ans = (ans * each) % mod
    return ans

def lcm(a, b): return a * b // gcd(a, b)

def binary(x, length=16):
    y = bin(x)[2:]
    return y if len(y) >= length else "0" * (length - len(y)) + y

from collections import deque

for _ in range(int(input()) if not True else 1):
    #n = int(input())
    #n, k = map(int, input().split())
    #a, b = map(int, input().split())
    #c, d = map(int, input().split())
    #a = list(map(int, input().split()))
    #b = list(map(int, input().split()))
    s1 = deque(k for k in input())
    s2 = deque(k for k in input())
    n = len(s1)
    k = int(input())
    if k == 0:
        print(int(s1==s2))
        quit()
    mod = 10**9 + 7
    n1pow = [1]
    for i in range(696969):
        n1pow += [(n1pow[-1]*(n-1)) % mod]
    ans0 = 0
    for i in range(1, k):
        ans0 = (n1pow[i] - ans0) % mod
    ans1 = 1
    for i in range(1, k):
        ans1 = (n1pow[i] - ans1) % mod
    #print(ans0, ans1)
    total = 0
    for t in range(n):
        if s1 == s2:
            total += ans1 if t else ans0
        s1.appendleft(s1.pop())
    print(total % mod)

start, end, k = input(), input(), int(input())
dp = [[start == end for _ in range(k + 1)], [start != end for _ in range(k + 1)]]
mod = int(1e9 + 7)
same = sum(end == (start[i: len(start)] + start[0: i]) for i in range(len(start)))
diff = len(start) - same
for i in range(1, k + 1):
    dp[0][i] = (dp[0][i - 1] * (same - 1) + dp[1][i - 1] * same) % mod
    dp[1][i] = (dp[0][i - 1] * diff + dp[1][i - 1] * (diff - 1)) % mod
print(int(dp[0][k]))

start = raw_input()
end = raw_input()
k = int(raw_input())

dpA = [-1 for i in xrange(k+1)]
dpB = [-1 for i in xrange(k+1)]

def calculaA(n):
    global dpA, dpB
    if n == 0:
        return 0
    if dpA[n-1] == -1:
        calculaA(n-1)

    dpA[n] = dpA[n-1]*(A-1) + dpB[n-1]*A
    dpB[n] = dpA[n-1]*B     + dpB[n-1]*(B-1)

    return dpA[n]

A = B = 0

if start != end:
    dpA[0] = 0
    dpB[0] = 1
else:
    dpA[0] = 1
    dpB[0] = 0

for i in xrange(len(start)):
    now = start[i:]+start[:i]

    if now == end:
        A += 1
    else:
        B += 1

print calculaA(k)

class Solution():
	def number_or_ways(start, end, moves):
		p = 10**9+7
		num_rots = 1
		for i in range(1, len(start)-1):
			rot = start[i:]+start[0:i]
			if rot == end:
				num_rots += 1

		dp = [[0 for i in range(2)] for j in range(moves+1)]

		dp[0][0], dp[0][1] = 1, 0

		for i in range(1, moves+1):
			dp[i][0] = (((num_rots-1)*dp[i-1][0])%p + ((len(start)-num_rots)*dp[i-1][1])%p)%p
			dp[i][1] = ((num_rots*dp[i-1][0])%p + ((len(start)-1-num_rots)*dp[i-1][1])%p)%p

		if start == end:
			return dp[moves][0]
		else:
			return dp[moves][1]

start = input().strip()
end = input().strip()

moves = int(input())

print(Solution.number_or_ways(start, end, moves))

def WordCut():
    start = input()
    end = input()
    k = int(input())
    n=len(start)
    dpA,dpB = (start==end),(start!=end)
    end+=end
    A=sum(start==end[i:i+n] for i in range(n))
    B = n- A
    M = 10**9+7
    for _ in range(k):dpA,dpB=(dpA*(A-1)+dpB*A)%M,(dpA*B+dpB*(B-1))%M
    return dpA

print(WordCut())

a,b,k=raw_input(),raw_input(),input()
n=len(a)
x,y=(a==b),(a!=b)
b+=b
z=sum(a==b[i:i+n] for i in range(n))
t=n-z
M=10**9+7
for _ in xrange(k):x,y=(x*(z-1)+y*z)%M,(x*t+y*(t-1))%M
print x

M = 1000000007
a = raw_input()
b = raw_input()
k = input()

r = [i for i in xrange(1,len(a)) if a[i:] + a[:i] == b]

x,y = 0, 1
l = len(a)
for _ in xrange(k):
    x, y = y*(l-1)%M, (x+y*(l-2))%M

if 0 in r: print (x + y * (len(r) - 1))%M
else: print y * len(r) % M

MOD = 1000000007

start = raw_input()
end = raw_input()
k = input()

A = 0
B = 0
for i in range(len(start)):
    if start[i:] + start[:i] == end:
        A += 1
    else:
        B += 1

f0, g0 = 0, 0
if start == end:
    f0 = 1
    A -= 1
    B += 1
else:
    g0 = 1

den = pow(A + B, MOD - 2, MOD)
c1 = A * (f0 + g0) * den % MOD
c2 = (B * f0 - A * g0) * den % MOD
fn = c1 * pow(A + B - 1, k, MOD)
if k % 2:
    fn -= c2
else:
    fn += c2
fn %= MOD

print(fn)

MOD = 1000000007

if __name__ == '__main__':
    a, b, k = raw_input(), raw_input(), int(raw_input())

    str_len = len(a)
    cut_pos = [i for i in xrange(str_len) if a[i:] + a[:i] == b]
    cut_pos_len= len(cut_pos)
    sum = 1
    x, y = 1, 0
    for _ in xrange(k):
        x = sum - x
        y = sum - y
        sum *= str_len-1
        sum %= MOD
    print (x+y*(str_len-1))%MOD if 0 in cut_pos else y*str_len%MOD

MOD = 1000000007

def mat_mul(a, b, n):
    c = [[0]*n]*n
    for k in xrange(n):
        for i in xrange(n):
            if a[i][k]:
                for j in xrange(n):
                    c[i][j] += a[i][k] * b[k][j]
                    c[i][j] %= MOD
    return c

def mat_pow(a, n, k):
    if k == 0: return [[int(i==j) for j in xrange(n)] for i in xrange(n)]
    if k == 1: return a
    b = mat_pow(a, n, k//2)
    b = mat_mul(b, b, n)
    if n % 2: b = mat_mul(b, a, n)
    return b

if __name__ == '__main__':

    start, end = raw_input(), raw_input()
    k = int(raw_input())

    str_len = len(start)

    dp = [0] * str_len
    dp[0] = 1
    p = [[int(i!=j) for j in xrange(str_len)] for i in xrange(str_len)]
    p = mat_pow(p, str_len, k)

    ans = 0
    for j in xrange(str_len):
        if start[j:] + start[:j] == start:
            for i in xrange(str_len):
                ans += dp[i]*p[i][j]
                ans %= MOD
    print ans

from sys import stdin
from collections import *

def count():
    g = 0
    for i in range(len(s1) - 1):
        s1.rotate(-1)
        g += (s1 == s2)

    s1.rotate(-1)
    return g, len(s1) - g - 1

def dp():
    mem = [[0, 0] for _ in range(k + 1)]
    mem[0][0] = (s1 == s2) & 1
    mem[0][1] = 1 - mem[0][0]

    for i in range(1, k + 1):
        mem[i][0] = add(mult(mem[i - 1][0], max(good - 1, 0)), mult(mem[i - 1][1], good))
        mem[i][1] = add(mult(mem[i - 1][1], max(bad - 1, 0)), mult(mem[i - 1][0], bad))

    print(mem[-1][0] % mod)

rstr = lambda: stdin.readline().strip()
add = lambda a, b: (a + b) % mod
mult = lambda a, b: ((a % mod) * (b % mod)) % mod
mod = 10 ** 9 + 7

s1, s2, k = deque(rstr()), deque(rstr()), int(input())
good, bad = count()
# print(good,bad)
dp()

# ------------------- fast io --------------------
import os
import sys
from io import BytesIO, IOBase

BUFSIZE = 8192

class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None

    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)

class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")

sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
input = lambda: sys.stdin.readline().rstrip("\r\n")

# ------------------- fast io --------------------
from math import gcd, ceil

def prod(a, mod=10**9+7):
    ans = 1
    for each in a:
        ans = (ans * each) % mod
    return ans

def lcm(a, b): return a * b // gcd(a, b)

def binary(x, length=16):
    y = bin(x)[2:]
    return y if len(y) >= length else "0" * (length - len(y)) + y

from collections import deque

for _ in range(int(input()) if not True else 1):
    #n = int(input())
    #n, k = map(int, input().split())
    #a, b = map(int, input().split())
    #c, d = map(int, input().split())
    #a = list(map(int, input().split()))
    #b = list(map(int, input().split()))
    s1 = deque(k for k in input())
    s2 = deque(k for k in input())
    n = len(s1)
    k = int(input())
    if k == 0:
        print(int(s1==s2))
        quit()
    mod = 10**9 + 7
    n1pow = [1]
    for i in range(696969):
        n1pow += [(n1pow[-1]*(n-1)) % mod]
    ans0 = 0
    for i in range(2, k+1):
        ans0 = (n1pow[i] - ans0) % mod
    ans1 = 1
    for i in range(2, k+1):
        ans1 = (n1pow[i] - ans1) % mod
    #print(ans0, ans1)
    total = 0
    for t in range(n):
        if s1 == s2:
            total += ans1 if t else ans0
        s1.appendleft(s1.pop())
    print(total % mod)

# ------------------- fast io --------------------
import os
import sys
from io import BytesIO, IOBase

BUFSIZE = 8192

class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None

    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)

class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")

sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
input = lambda: sys.stdin.readline().rstrip("\r\n")

# ------------------- fast io --------------------
from math import gcd, ceil

def prod(a, mod=10**9+7):
    ans = 1
    for each in a:
        ans = (ans * each) % mod
    return ans

def lcm(a, b): return a * b // gcd(a, b)

def binary(x, length=16):
    y = bin(x)[2:]
    return y if len(y) >= length else "0" * (length - len(y)) + y

from collections import deque

for _ in range(int(input()) if not True else 1):
    #n = int(input())
    #n, k = map(int, input().split())
    #a, b = map(int, input().split())
    #c, d = map(int, input().split())
    #a = list(map(int, input().split()))
    #b = list(map(int, input().split()))
    s1 = deque(k for k in input())
    s2 = deque(k for k in input())
    n = len(s1)
    k = int(input())
    if k == 0:
        print(int(s1==s2))
        quit()
    mod = 10**9 + 7
    n1pow = [1]
    for i in range(696969):
        n1pow += [(n1pow[-1]*(n-1)) % mod]
    ans0 = 0
    for i in range(2, k+1):
        ans0 = (n1pow[i] - ans0) % mod
    ans1 = 1
    for i in range(1, k):
        ans1 = (n1pow[i] - ans1) % mod
    #print(ans0, ans1)
    total = 0
    for t in range(n):
        if s1 == s2:
            total += ans1 if t else ans0
        s1.appendleft(s1.pop())
    print(total % mod)

# ------------------- fast io --------------------
import os
import sys
from io import BytesIO, IOBase

BUFSIZE = 8192

class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None

    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)

class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")

sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
input = lambda: sys.stdin.readline().rstrip("\r\n")

# ------------------- fast io --------------------
from math import gcd, ceil

def prod(a, mod=10**9+7):
    ans = 1
    for each in a:
        ans = (ans * each) % mod
    return ans

def lcm(a, b): return a * b // gcd(a, b)

def binary(x, length=16):
    y = bin(x)[2:]
    return y if len(y) >= length else "0" * (length - len(y)) + y

from collections import deque

for _ in range(int(input()) if not True else 1):
    #n = int(input())
    #n, k = map(int, input().split())
    #a, b = map(int, input().split())
    #c, d = map(int, input().split())
    #a = list(map(int, input().split()))
    #b = list(map(int, input().split()))
    s1 = deque(k for k in input())
    s2 = deque(k for k in input())
    n = len(s1)
    k = int(input())
    mod = 10**9 + 7
    n1pow = [1]
    for i in range(6969):
        n1pow += [(n1pow[-1]*(n-1)) % mod]
    ans0 = 0
    for i in range(1, k):
        ans0 = (n1pow[i] - ans0) % mod
    ans1 = 1
    for i in range(1, k):
        ans1 = (n1pow[i] - ans1) % mod
    #print(ans0, ans1)
    total = 0
    for t in range(n):
        if s1 == s2:
            total += ans1 if t else ans0
        s1.appendleft(s1.pop())
    print(total % mod)

start, end, k = input(), input(), int(input())
dp = [[start == end for _ in range(k + 1)], [start != end for _ in range(k + 1)]]
mod = int(1e9 + 7)
same = sum(end == (start[i: len(start)] + start[0: i]) for i in range(len(start)))
diff = len(start) - same
for i in range(1, k + 1):
    dp[0][i] = (dp[0][i - 1] * (same - 1) + dp[1][i - 1] * same) % mod
    dp[1][i] = (dp[0][i - 1] * diff + dp[1][i - 1] * (diff - 1)) % mod
print(dp[0][k])


Little Petya loves playing with squares. Mum bought him a square 2n × 2n in size. Petya marked a cell inside the square and now he is solving the following task.The task is to draw a broken line that would go along the grid lines and that would cut the square into two equal parts. The cutting line should not have any common points with the marked cell and the resulting two parts should be equal up to rotation.Petya wants to determine whether it is possible to cut the square in the required manner given the sizes of the square side and the coordinates of the marked cell. Help him.

The first line contains three space-separated integers 2n, x and y (2 ≤ 2n ≤ 100, 1 ≤ x, y ≤ 2n), representing the length of a square's side and the coordinates of the marked cell. It is guaranteed that 2n is even. The coordinates of the marked cell are represented by a pair of numbers x y, where x represents the number of the row and y represents the number of the column. The rows and columns are numbered by consecutive integers from 1 to 2n. The rows are numbered from top to bottom and the columns are numbered from the left to the right.

If the square is possible to cut, print "YES", otherwise print "NO" (without the quotes).

NoteA sample test from the statement and one of the possible ways of cutting the square are shown in the picture:

n,x,y= map(int,input().split())
n//=2
if(x==n or x==n+1) and (y==n or y==n+1):
    print('NO')
else:
    print("YES")

n, x, y = map(int, raw_input().split())
f = lambda x : x in (n / 2, n / 2 + 1)
print 'NO' if f(x) and f(y) else 'YES'

n,x,y=[int(x) for x in input().split()]
flag=0
if x == n//2 or x == n//2+1:
    flag += 1
if y == n//2 or y == n//2+1:
    flag += 1
if flag == 2:
    print('NO')
else:
    print('YES')

n,x,y=map(int,input().split())
n//=2
print("NO" if (x==n or x==n+1) and (y==n or y==n+1) else "YES")

n,x,y=map(int,raw_input().split())
n/=2
print"NO"if (x==n or x==n+1)and(y==n or y==n+1)else"YES"

n, x, y = map(int, raw_input().split())
print ['YES', 'NO'][{x, y} <= {n / 2, n / 2 + 1}]

n, x, y = map(int, input().split());
if((x == n // 2 or x == n // 2 + 1) and (y == n // 2 or y == n // 2 + 1)):
    print('NO')
else:
    print('YES')

import sys
L=raw_input()
L=L.split()
n=int(L[0])
x=int(L[1])
y=int(L[2])
n/=2
if (x>=n)&(x<=n+1)&(y>=n)&(y<=n+1):
    print "NO"
else:
    print "YES"

s=raw_input().split()
n=int(s[0])/2
x=int(s[1])
y=int(s[2])

if (x==n or x==n+1) and (y==n or y==n+1):
	print 'NO'
else:
	print 'YES'

n, x, y = map(int, raw_input().split())
print "NO" if n / 2 <= min(x, y) and max(x, y) <= n / 2 + 1 else "YES"

input = raw_input().split(' ')

n = int(input[0])/2
x = int(input[1])
y = int(input[2])

if  (x,y) == (n, n)     or \
    (x,y) == (n+1, n)   or \
    (x,y) == (n, n+1)   or \
    (x,y) == (n+1, n+1):
    print 'NO'
else:
    print 'YES'

n2, x, y = [int(i) for i in input().split()]

middle = n2//2

if (x == middle+1 or x == middle) and (y == middle+1 or y == middle):
    print("NO")
else:
    print("YES")

n,x,y=map(int,raw_input().split())
f=lambda x: x in [n/2,n/2+1]
print ['YES','NO'][f(x) and f(y)]

k=input().split(" ")
n=int(k[0])
x=int(k[1])
y=int(k[2])
n/=2
if (x==n or x==n+1)and(y==n or y==n+1):
    print("NO")
else:
    print("YES")

#def gcd(a,b):
#   while b > 0: a,b = b, a%b
#   return a
#def lcm(a, b):
#   return a*b/gcd(a,b)

#T = input()
n, x, y = map(int, raw_input().split())
n = n/2
if (x == n or x == n+1) and (y == n or y == n+1):
    print "NO"
else:
    print "YES"

#data = map(int, raw_input().split())
#data2 = [ map(int, raw_input().split()) for i in xrange(T)]

n,x,y=map(int,raw_input().split())
mid=n/2
a=[[mid,mid],[mid+1,mid],[mid,mid+1],[mid+1,mid+1]]
if [x,y] in a:
	print "NO"
else:
	print "YES"

import sys
def read_values():
  return map(int,raw_input().split())

n,x,y=read_values() ; n/=2
if n<=x<=n+1 and n<=y<=n+1:
  print 'NO'
else:
  print 'YES'

n,x,y=map(int, raw_input().split())
n/=2
s=[n,n+1]
print "YNEOS"[x in s and y in s::2]

s = raw_input().split(" ")
n = int(s[0])/2
x = int(s[1])
y = int(s[2])

if n<=x<=n+1 and n<=y<=n+1:
  print "NO"
else:
  print "YES"

n, x, y = tuple(int(x) for x in raw_input().strip().split(" "))

nn = n/2

if (x==nn and y==nn) or (x==nn and y==nn+1) or (x==nn+1 and y==nn) or (x==nn+1
        and y==nn+1):
    print "NO"
else:
    print "YES"

n,x,y = map(int,raw_input().split())
n /= 2;
if (x != n and x != n+1) or (y != n and y != n+1):
    print "YES"
else:
    print "NO"

(tn,tx,ty) = raw_input().split()
n,x,y = int(tn),int(tx),int(ty)

mid = n / 2
if (x,y) in [(mid,mid+1),(mid,mid),(mid+1,mid),(mid+1,mid+1)]:
    print 'NO'
else:
    print 'YES'

input_data = raw_input()

n,x,y = input_data.split()
n = int(n)
x = int(x)
y = int(y)

flag = False
if x == n/2 and y == n/2:
    flag = True
if x == (n/2  +1 ) and y == n/2:
    flag = True
if x == (n/2  +1 ) and y == (n/2+1):
    flag = True
if x == (n/2 ) and y == (n/2+1):
    flag = True
if flag:
    print "NO"
else:
    print "YES"

n,x,y=map(int,input().split())
if ((x==n/2 or  x==n/2+1) and (y==((n/2)) or y==((n/2)+1))):
    print("NO")
else:
    print("YES")

n,x,y = map(int,input().split())

if x in (n//2, n//2+1) and y in (n//2, n//2+1):
    print('NO')
else:
    print('YES')

In=raw_input().split(" ")
(n,x,y)=[int(c) for c in In]
n/=2
if ( (x==n) or (x==n+1) ) and ( (y==n) or (y==n+1) ) :
    print "NO"
else:
    print "YES"

n, x, y = map(int, raw_input().split())
if (n / 2 <= x <= n / 2 + 1) and (n / 2 <= y <= n / 2 + 1):
    print "NO"
else:
    print "YES"

n , x, y = [int(x) for x in raw_input().split()]
if (x == n/2 or x == n/2 + 1) and (y == n/2 or y == n/2 + 1):
    print "NO"
else:
    print "YES"

n,x,y=[int(i) for i in input().split()]
if y!=n/2 and y!=n/2+1: print("YES")
else:
    if x!=n/2 and x!=n/2+1: print("YES")
    else: print("NO")

x,y,z = [int(x) for x in input("").split()]

n= x/2

if ((y == n or y == n + 1) and (z == n or z == n + 1)):
    print("NO")
else:
    print("YES")

args = raw_input().split()
_2n = int(args[0])
x = int(args[1])
y = int(args[2])

pair = (_2n/2, _2n/2 + 1)
yes = x not in pair or y not in pair
if yes:
    print "YES"
else:
    print "NO"

n,x,y=map(int,input().split())
if min(x,y)>=n//2 and max(x,y)<=n//2 + 1:
    print('NO')
else:
    print('YES')

_2n,x,y=list(map(int,input().split()))
n=_2n/2
if (x==n or x==n+1) and (y==n or y==n+1): print('NO')
else: print('YES')

s=input().split();n,x,y=int(s[0])//2,int(s[1]),int(s[2])
if x==n and y==n:
    print('NO')
elif x==n+1 and y==n:
    print('NO')
elif x==n+1 and y==n+1:
    print('NO')
elif x==n and y==n+1:
    print('NO')
else:
    print('YES')

n,x,y = map(int, input().split());
n /= 2;
print(['YES','NO'][(x == n or x == n + 1) and (y == n or y == n + 1)]);

n,x,y=map(int,input().split())
p=int(n/2)+2
if n==2:
    print('NO')
elif n%2==0 and y in range(int(n/2),p) and x not in range(int(n/2),p):
    print('YES')
elif n%2==0 and x in range(int(n/2),p) and y not in range(int(n/2),p):
    print('YES')
elif n%2==0 and (x not in range(int(n/2),p) or y not in range(int(n/2),p)):
    print('YES')
else:
    print('NO')

from sys import stdin, stdout

(n2, x, y) = [int(x) for x in stdin.readline().strip().split()]

print('YES' if x != n2//2 and x != n2//2+1 or y != n2//2 and y != n2//2+1 else 'NO' )

n, x, y = map(int, raw_input().split())

if (n/2 == x or n/2+1 == x) and (n/2 == y or n/2+1 == y) :
    print "NO"
else:
    print "YES"

#-*- coding: utf-8 -*-

import sys
import re

write = sys.stdout.write

nab = sys.stdin.readline()
nab = nab.replace('\n','').split(" ")
n,a,b = int(nab[0]), int(nab[1]), int(nab[2])

n = n/2

if n==1:
    write("NO")
elif a!=n and a!=n+1:
    write("YES")
elif b>1 and b<2*n and n>=3 and b!=n and b!=n+1:
    write("YES")
elif (b==1 or b==2*n) and n>=2:
    write("YES")
else:
    write("NO")

if __name__ == "__main__":
    A = map(int,raw_input().split(" "))
    N = A[0]/2
    x = A[1]
    y = A[2]
    if (x == N or x == N + 1) and (y == N or y == N + 1):
        print "NO"
    else:
        print "YES"

n, x, y = map(int, raw_input().split())
print "NO" if n / 2 <= min(x, y) and max(x, y) <= n / 2 + 1 else "YES"

line=raw_input().split()
n=int(line[0])
x=int(line[1])
y=int(line[2])
if (x==n/2 or x==n/2+1) and (y==n/2 or y==n/2+1):
    print 'NO'
else:
    print 'YES'

from sys import setrecursionlimit
setrecursionlimit(1000000000)

def main():
    a, b, c=[int(i) for i in input().split()]
    if ((a//2==b) and (a//2==c)) or ((a//2==b-1) and (a//2==c)) or ((a//2==b) and (a//2==c-1)) or ((a//2==b-1) and (a//2==c-1)):
        print("NO")
        return 0
    print("YES")

main()

n, x, y = map(int, raw_input().split())
n /= 2

if (n == x or n + 1 == x) and (n == y or n + 1 == y):
    print 'NO'
else:
    print 'YES'

n,x,y=map(int, raw_input().split())
n/=2
s=[n,n+1]
print "YNEOS"[x in s and y in s::2]

n,x,y = map(int,raw_input().strip().split())
n /= 2
if (x,y) in ((n,n),(n+1,n),(n,n+1),(n+1,n+1)):
    print 'NO'
else:
    print 'YES'

def main(n, x, y):
    if (x == n and y == n):
        return "NO"
    if (x == n and y == n+1):
        return "NO"
    if (x == n+1 and y == n):
        return "NO"
    if (x == n+1 and y == n+1):
        return "NO"
    else:
        return "YES"

line = raw_input()
lst = line.split(" ")
n = int(lst[0])/2
x = int(lst[1])
y = int(lst[2])
print main(n, x, y)

k=input().split(" ")
n=int(k[0])
x=int(k[1])
y=int(k[2])
n/=2
if (x==n or x==n+1)and(y==n or y==n+1):
    print("NO")
else:
    print("YES")

n, x, y = map(int, raw_input().split())
n /= 2
if (x, y) in [(a, b) for a in (n, n+1) for b in (n, n+1)]:
    print 'NO'
else:
    print 'YES'

n,x,y = map(int, raw_input().split())
print "NO" if n/2 <= x <= n/2+1 and n/2 <= y <= n/2+1 else "YES"

a,b,c=map(int,input().split(' '))
if (b==a//2 or b==a//2+1 )and( c==a//2 or c==a//2+1):
    print("NO")
else:
    print("YES")

n,x,y=map(int,raw_input().split())
f=lambda x: x in [n/2,n/2+1]
print ['YES','NO'][f(x) and f(y)]

n,x,y=[int(i) for i in input().split()]
if y!=n/2 and y!=n/2+1: print("YES")
else:
    if x!=n/2 and x!=n/2+1: print("YES")
    else: print("NO")

n, x, y = map(int, raw_input().split(' '))

print not (x in (n/2,n/2+1) and y in (n/2,n/2+1)) and 'YES' or 'NO'

n, x, y = map(int, input().split())
p = [n // 2, n // 2 + 1]
if x in p and y in p:
    print('NO')
else:
    print('YES')

n,x,y=map(int,input().split())
if min(x,y)>=n//2 and max(x,y)<=n//2 + 1:
    exit(print('NO'))
else:
    exit(print('YES'))

n,x,y=map(int,input().split())
a=[(n//2),(n//2)+1]
print(['YES','NO'][x in a and y in a])

n,x,y=map(int,raw_input().split())
hor=[]
ver=[]
for i in range(1,n+1):
	hor.append([n/2,i])
	hor.append([n/2+1,i])
for i in range(1,n+1):
	ver.append([i,n/2])
	ver.append([i,n/2+1])
if [x,y] in hor and [x,y] in ver:
	print "NO"
else:
	print "YES"

n, x, y = map(int, raw_input().split())
n /= 2
if (x, y) in ((n, n), (n+1, n), (n, n+1), (n+1, n+1)):
    print 'NO'
else:
    print 'YES'

import sys
import itertools
import math

if __name__ == '__main__':
  splited = raw_input().rstrip().split(" ")
  n = int(splited[0])
  x = int(splited[1])
  y = int(splited[2])

  p = [(n / 2, n / 2), (n / 2 + 1, n / 2), (n / 2, n / 2 + 1), (n / 2 + 1, n / 2 + 1)]
  if (x, y) in p:
    print "NO"
  else:
    print "YES"

n, a, b = map(int,input().split())
t1, t2 = n//2, (n//2)+1
if (a==t1 and b==t1) or (a==t1 and b==t2) or (a==t2 and b==t1) or (a==t2 and b==t2):
        print('NO')
else:
    print('YES')

L = map(int, raw_input().strip().split())
n = L[0]
x = L[1]
y = L[2]

if (x == n/2 or x == n/2 + 1) and (y == n/2 or y == n/2 + 1):
    print "NO"
else:
    print "YES"

n, x, y = map(int, input().split())
n //= 2
print('NO' if n <= x <= n + 1 and n <= y <= n + 1 else 'YES')

n, x, y = map(int, raw_input().split())
if x == n / 2 and y == n / 2 or x == n / 2 and y == n / 2 + 1 or x == n / 2 + 1 and y == n / 2 or x == n / 2 + 1 and y == n / 2 + 1:
    print 'NO'
else:
    print 'YES'

s = raw_input().split(" ")
n = int(s[0])/2
x = int(s[1])
y = int(s[2])

if n<=x<=n+1 and n<=y<=n+1:
  print "NO"
else:
  print "YES"

n, x, y = map(int, raw_input().split())
if (n / 2 <= x <= n / 2 + 1) and (n / 2 <= y <= n / 2 + 1):
    print "NO"
else:
    print "YES"

n,x,y=map(int,input().split())
n//=2
if (n==x or n==x-1) and (n==y or n==y-1):
    print("NO")
else:
    print("YES")

n,x,y = map(int,raw_input().strip().split())
n /= 2
if (x,y) in ((n,n),(n+1,n),(n,n+1),(n+1,n+1)):
    print 'NO'
else:
    print 'YES'

n,x,y=map(int, raw_input().split())
m=n/2
print "YNEOS"[x in [m,m+1] and y in [m,m+1]::2]

n,x,y=map(int,input().split())
n=n//2
if (x==n and y==n) or (x==n+1 and y==n) or (x==n and y==n+1) or (x==n+1 and y==n+1):
	print('NO')
else:
	print('YES')

n, x, y = map(int, input().split())
if y == n // 2 or y == n // 2 + 1:
    if x == n // 2 or x == n // 2 + 1:
        print("NO")
    else:
        print("YES")
else:
    print("YES")

n, x, y = map(int, raw_input().split())
print 'NO' if ((x == n / 2 or x == n / 2 + 1) and (y == n / 2 or y == n / 2 + 1)) else 'YES'

n,x,y=map(int,raw_input().split())
n/=2
print"NO"if abs(x-n)<2 and abs(y-n)<2 else"YES"

n, a, b = map(int,input().split())
t1, t2 = n//2, (n//2)+1
if (a==t1 and b==t1) or (a==t1 and b==t2) or (a==t2 and b==t1) or (a==t2 and b==t2):
        print('NO')
else:
    print('Yes')

n,x,y=map(int,input().split())
n=n//2
if n==x or n==x-1 and n==y or n==y-1:
    print("NO")
else:
    print("YES")

n,x,y=map(int,input().split())

if n==2:
    print('NO')
elif n%2==0 and (x not in range(int(n/2),n) or y not in range(int(n/2),n)):
        print('YES')
else:
    print('NO')

n,x,y=map(int,input().split())
p=int(n/2)+2
if n==2:
    print('NO')
elif n%2==0 and y in range(int(n/2),p) and x not in range(int(n/2),p):
    print('YES')
elif n%2==0 and x in range(int(n/2),p) and y not in range(int(n/2),p):
    print('YES')
else:
    print('NO')

n,x,y=map(int,input().split())
if n==2:
    print('NO')
elif n%2==0 and (x and y) not in range(int(n/2),n):
    print('YES')
else:
    print('NO')

n, x, y = map(int, input().split())

s = n//2

print('YES' if (x < s  or x > s + 1) and (y < s or y > s + 1) else 'NO')

#from  sys import stdin
#input=stdin.readline
#a = sorted([(n, i) for i, n in enumerate(map(int, input().split()))])
# from collections import Counter
# import sys
#s="abcdefghijklmnopqrstuvwxyz"
#n=int(input())
#n,k=map(int,input().split())
#arr=list(map(int,input().split()))
#arr=list(map(int,input().split()))
n,x,y=map(int,input().split())
if (x==n//2 or x==(n//2)+1) and (y==n or y==((n//2)+1)):
    print("NO")
else:
    print("YES")

#from  sys import stdin
#input=stdin.readline
#a = sorted([(n, i) for i, n in enumerate(map(int, input().split()))])
# from collections import Counter
# import sys
#s="abcdefghijklmnopqrstuvwxyz"
#n=int(input())
#n,k=map(int,input().split())
#arr=list(map(int,input().split()))
#arr=list(map(int,input().split()))
n,x,y=map(int,input().split())
if x==n//2 or x==(n//2)+1:
    if n>2:
        if y>1 and y<n:
            print("NO")

        else:
            print("YES")
    else:
        print("NO")
else:
    print("YES")

#from  sys import stdin
#input=stdin.readline
#a = sorted([(n, i) for i, n in enumerate(map(int, input().split()))])
# from collections import Counter
# import sys
#s="abcdefghijklmnopqrstuvwxyz"
#n=int(input())
#n,k=map(int,input().split())
#arr=list(map(int,input().split()))
#arr=list(map(int,input().split()))
n,x,y=map(int,input().split())
if x==n//2 or x==(n//2)+1 and y==n or y==(n//2)+1:
    print("NO")
else:
    print("YES")

#from  sys import stdin
#input=stdin.readline
#a = sorted([(n, i) for i, n in enumerate(map(int, input().split()))])
# from collections import Counter
# import sys
#s="abcdefghijklmnopqrstuvwxyz"
#n=int(input())
#n,k=map(int,input().split())
#arr=list(map(int,input().split()))
#arr=list(map(int,input().split()))
n,x,y=map(int,input().split())
if x==n//2 or x==(n//2)+1:
    if n>2:
        if y>1 and y<n:
            print("NO")
    else:
        print("NO")
else:
    print("YES")

#from  sys import stdin
#input=stdin.readline
#a = sorted([(n, i) for i, n in enumerate(map(int, input().split()))])
# from collections import Counter
# import sys
#s="abcdefghijklmnopqrstuvwxyz"
#n=int(input())
#n,k=map(int,input().split())
#arr=list(map(int,input().split()))
#arr=list(map(int,input().split()))
n,x,y=map(int,input().split())
if x==n//2 or x==n//2+1 and y>1 and y<2*n:
    print("NO")
else:
    print("YES")

#!/usr/bin/python2

if __name__ == "__main__":
    s = raw_input()
    l = s.split(' ')
    n, x, y = int(l[0]), int(l[1]), int(l[2])
    if n > 4: print "YES"
    elif n == 2: print "NO"
    elif n == 4:
        if 2 <= x <= 3 and 2 <= y <=3:
            print "NO"
        else : print "YES"

#!/usr/bin/python2

if __name__ == "__main__":
    s = raw_input()
    l = s.split(' ')
    n, x, y = int(l[0]), int(l[1]), int(l[2])
    if n > 4: print "YES1"
    elif n == 2: print "NO"
    elif n == 4:
        if 2 <= x <= 3 and 2 <= y <=3:
            print "NO"
        else : print "YES"

l=[int(x) for x in raw_input().split()]
print 'YES' if l[0]%(4*l[2])==0 and l[0]>=(2*l[1]) else 'NO'

n,x,y = map(int, raw_input().split())
if x>=n/2 and x<=n/2+1 and y>=n/2 and y<=n/2+1:
    print "YES"
else:
    print "NO"

n, x, y = map(int, raw_input().split())
print ['YES', 'NO'][{x, y} <= {n, n + 1}]

import sys
L=raw_input()
L=L.split()
n=int(L[0])
x=int(L[1])
y=int(L[2])

if ((x>=n)&(x<=n+1))|((y>=n)&(y<=n+1)):
    print "NO"
else:
    print "YES"

import sys
L=raw_input()
L=L.split()
n=int(L[0])
x=int(L[1])
y=int(L[2])

if (x>=n)&(x<=n+1)&(y>=n)&(y<=n+1):
    print "NO"
else:
    print "YES"

#-*- coding: utf-8 -*-

import sys
import re

write = sys.stdout.write

nab = sys.stdin.readline()
nab = nab.replace('\n','').split(" ")
n,a,b = int(nab[0]), int(nab[1]), int(nab[2])

n = n/2

if a!=n and a!=n+1:
    write("YES")
elif n==1:
    write("NO")
elif b>1 and b<2*n and 2*n>=6:
    write("YES")
else:
    write("NO")

#-*- coding: utf-8 -*-

import sys
import re

write = sys.stdout.write

nab = sys.stdin.readline()
nab = nab.replace('\n','').split(" ")
n,a,b = int(nab[0]), int(nab[1]), int(nab[2])

n = n/2

if n==1:
    write("NO")
elif a!=n and a!=n+1:
    write("YES")
elif b>1 and b<2*n and 2*n>=6:
    write("YES")
elif (b==1 or b==2*n) and 2*n>=4:
    write("YES")
else:
    write("NO")

n,x,y=map(int,raw_input().split())
f=lambda x: x in [n,n+1]
print ['YES','NO'][f(x) and f(y)]

n,a,b = map(int,raw_input().split())
n /= 2
if n==1 or ((a==n or a==n+1) and (b==n or b==n+1)):
    print 'YES'
else:
    print 'NO'

def main():
    n, x, y = map(int, raw_input().split())
    if n <= x <= n + 1 and n <= y <= n + 1:
        print "NO"
    else:
        print "YES"

main()

def main():
    n, x, y = map(int, raw_input().split())
    if n == 1:
        print "NO"
    elif n == 2:
        if not (2 <= x <= 3 or 2 <= y <= 3):
            print "YES"
        else:
            print "NO"
    elif n <= x <= n + 1 and n <= y <= n + 1:
        print "NO"
    else:
        print "YES"

main()

input_data = raw_input()

n,x,y = input_data.split()
n = int(n)
x = int(x)
y = int(y)

number_of_fields = 0
if x-1 >= 1 and y-1>=1:
    number_of_fields += 1
if y-1 >= 1:
    number_of_fields +=1
if y+1 <=n:
    number_of_fields +=1
if x-1 >=1:
    number_of_fields +=1
if x+1 <= n:
    number_of_fields +=1

if y-1 >=1 and x+1 <=n:
    number_of_fields +=1
if y+1 <=n and x+1 <=n:
    number_of_fields +=1
if y+1 <=n and x-1 >=1:
    number_of_fields +=1
number_of_fields +=1

if number_of_fields < (n*n)/2:
    print "YES"
else:
    print "NO"

input_data = raw_input()

n,x,y = input_data.split()
n = int(n)
x = int(x)
y = int(y)

number_of_fields = 0
if x-1 >= 1 and y-1>=1:
    number_of_fields += 1
if y-1 >= 1:
    number_of_fields +=1
if y+1 <=n:
    number_of_fields +=1
if x-1 >=1:
    number_of_fields +=1
if x+1 <= n:
    number_of_fields +=1

if y-1 >=1 and x+1 <=n:
    number_of_fields +=1
if y+1 <=n and x+1 <=n:
    number_of_fields +=1
if y+1 <=n and x-1 >=1:
    number_of_fields +=1
number_of_fields +=1

if number_of_fields <= (n*n)/2:
    print "YES"
else:
    print "NO"

import sys

if __name__ == "__main__":
	l=raw_input()
	l=int(l[0])
	if(l>2): print "YES"
	else: print "NO"

(n, x, y) = [int(i) for i in raw_input().split()]
if x == n / 2 and y == n / 2 or x == n / 2 and y + 1== n / 2 or x + 1 == n / 2 and y == n / 2 or x + 1 == n / 2 and y + 1 == n / 2:
	print "YES"
else:
	print "NO"

(n, x, y) = [int(i) for i in raw_input().split()]
if x == n / 2 or y == n / 2 or x + 1 == n / 2 or y + 1 == n / 2:
	print "YES"
else:
	print "NO"

line = raw_input()
(n, x, y) = map(int, line.split(' '))
n /= 2
if(-1 <= x - n <= 0 and -1 <= y - n <= 0):
    print 'YES'
else:
    print 'NO'

import sys

n2, x, y = map(int, raw_input().split())
D = [-1, 0, 1]
Sq = {}
for dx, dy in [(a, b) for a in D for b in D if (a, b) != (0, 0)]:
   print dx, dy
   i, j = x + dx, y + dy
   if (i < 1 or i > n2) or (j < 1 or j > n2):
      continue
   if (i, j) in Sq:
      if Sq[(i, j)] == -1:
         print "NO"
         sys.exit(0)
   else:
      Sq[(i, j)] = 1
      Sq[(n2 - i + 1, n2 - j + 1)] = -1

print "YES"

input = [int(x) for x in raw_input().split(' ')]
size = input[0]
x = input[1]
y = input[2]

sizeA = size / 2
sizeB = sizeA + 1

can_be_split = True

if sizeA == x:
    can_be_split = False
elif sizeB == y:
    can_be_split = False
elif sizeA == x:
    can_be_split = False
elif sizeA == y:
    can_be_split = False

if can_be_split == False:
    print "NO"
else:
    print "YES"

n,x,y=map(int,input().split())

if x==1:
	if y==1:
		if n>x:
			if (n**2)//2>=4:
				print("YES")
			else:
				print("NO")
		else:
			print("NO")
	elif y==n:
		if n>1:
			if (n**2)//2>=4:
				print("YES")
			else:
				print("NO")
		else:
			print("NO")
	else:
		if (n**2)//2>=6:
			print("YES")
		else:
			print("NO")
elif x==n:
	if y==1 or y==n:
		if n>1:
			if (n**2)//2>=4:
				print("YES")
			else:
				print("NO")
		else:
			print("NO")
	else:
		if (n**2)//2>=6:
			print("YES")
		else:
			print("NO")
else:
	if y==1 or y==n:
		if (n**2)//2>=6:
			print("YES")
		else:
			print("NO")
	else:
		if (n**2)//2>=9:
			print("YES")
		else:
			print("NO")

n,x,y=map(int,input().split())
if ((y==n/2 and x==n/2) or (y==((n/2)+1) and x==((n/2)+1))):
    print("NO")
else:
    print("YES")

n,x,y=map(int,input().split())
if (y==n/2 or y==((n/2)+1)):
    print("NO")
else:
    print("YES")

x,y,z = [int(x) for x in input("").split()]

n= x/2

s= x*x
t=y*z

if(s!=t):
    if(y==n or z==n):
        print("NO")
    else:
        print("YES")
else:
    print("NO")

x,y,z = [int(x) for x in input("").split()]

n= x/2

if(y>=n or z>=n):
    print("NO")
else:
    print("YES")

def main():
  n, x, y = [int(i) / 2 for i in raw_input().split()]
  if n == x and n == y:
    print 'NO'
  else:
    print 'YES'

if __name__ == '__main__':
  main()

import math
from fractions import gcd
def inp():
    return int(raw_input())
def linp():
    return map(int, raw_input().split())
n, x, y = linp()
if n==2:
    print "NO"
else:
    print "YES"

#!/usr/bin/env python

n,x,y=[int(i) for i in raw_input().split(" ")]

if x>=n/2 and x<=n/2+1:
    if y>=n/2 and y<=n/2+1: print "NO"
else: print "YES"

def main(n, x, y):
    if (x == n and y == n):
        return "YES"
    if (x == n and y == n+1):
        return "YES"
    if (x == n+1 and y == n):
        return "YES"
    if (x == n+1 and y == n+1):
        return "YES"
    else:
        return "NO"

line = raw_input()
lst = line.split(" ")
n = int(lst[0])/2
x = int(lst[1])
y = int(lst[2])
print main(n, x, y)

n2, x, y = [int(_) for _ in raw_input().split(" ")]
n = n2/2
if n == 1:
  print "NO"
else:
  if x == n and y == n:
    print "NO"
  else:
    print "YES"

def rd():
	return raw_input()
def nums():
	return map(int, rd().split())
n, x, y = nums()
p = x,y
if p == (n,n) or p == (n+1,n) or p == (n+1,n+1) or p == (n,n+1):
	print 'NO'
else:
	print 'YES'

n, x, y = map(int, raw_input().split())
if (x, y) in ((n, n), (n+1, n), (n, n+1), (n+1, n+1)):
    print 'NO'
else:
    print 'YES'

s=raw_input().split()
n=int(s[0])
x=int(s[1])
y=int(s[2])

if (x==n or x==n+1) and (y==n or y==n+1):
	print 'NO'
else:
	print 'YES'

n,x,y = map(int,raw_input().split( ' ' ) )
if n >= 4:
    print 'YES'
else:
    print 'NO'

s = raw_input().split(" ")
n2 = int(s[0])
x = int(s[1])
y = int(s[2])

if n2<=2:
  print "NO"
elif n2<=4 and (2<=x<=3 and 2<=y<=3):
  print "NO"
else:
  print "YES"

n, x ,y = map(int, raw_input().split(' '))
msg = "NO"
if n / 2 != x and n / 2 + 1 != x:
    if n / 2 != y and n / 2 + 1 != y:
        msg = "YES"
print msg

(n, x, y) = map(int, raw_input().split(" "))
m = n // 2
if x == m - 1 and y == m - 1:
    print "NO"
elif x == m - 1 and y == m + 1:
    print "NO"
elif x == m + 1 and y == m + 1:
    print "NO"
elif x == m + 1 and y == m - 1:
    print "NO"
else:
    print "YES"

n,x,y=map(int,raw_input().split())

n/=2

if (x==n or x==n+1) and (y==n or y==n+1):  #midden dus niet spiegelbaar
    print 'N0'
else:
    print 'YES'

n,x,y= map(int,input().split())
n//=2
if(x>=n) and (y>=n):
    print('NO')
else:
    print("YES")

n,x,y=map(int,input().split())
if x==int(n/2) or x==int(n/2)+1 or y==int(n/2) or y==int(n/2)+1:
    print('NO')
else:
    print('YES')

a,b,c=map(int,input().split(' '))
if b==a//2 or b==a//2+1 or c==a//2 or c==a//2+1:
    print("NO")
else:
    print("YES")

n,x,y=map(int,input().split())

if(n==2):
    print("NO")
else:
    print("YES")

n,x,y=map(int,input().split())
print(['NO',"YES"][x!=n/2 and x!=n/2+1 and y!=n/2 and y!=n/2+1])

s=input().split();n,x,y=int(s[0]),int(s[1]),int(s[2])
if x!=n and x!=n+1 and y!=n and y!=n+1:
    print('YES')
else:
    print('NO')

n,x,y=map(int,input().split())

d = { n//2, n//2+1 }

if x in d or y in d:
	print("NO")
else:
	print("YES")