Harryxun/stf_run huggingface dataset:
n, m = map(int, input().split())

mod = 10 ** 9 + 7


def Fib(n, memo={}):
    if n == 1:
        return 0
    elif n == 2:
        return 1
    elif n in memo:
        return memo[n] % mod
    else:
        memo[n] = Fib(n - 1, memo) + Fib(n - 2, memo)
        return memo[n] % mod


A = list(int(input()) for i in range(m))


if m > 0:
    ans = Fib(A[0] + 1) % mod
    for i in range(m - 1):
        ans *= Fib(A[i + 1] - A[i])
        ans %= mod
        if A[i] + 1 == A[i + 1]:
            print(0)
            exit()
    ans *= Fib(n - A[-1] + 1)
    ans %= mod
else:
    ans = Fib(n + 2) % mod
print(ans)

### FIXED CODE ###

n, m = map(int, input().split())
A = list(int(input()) for i in range(m))

mod = 10 ** 9 + 7

def Fib(n):
    a, b = 0, 1
    if n == 1:
        return a
    elif n == 2:
        return b
    else:
        for i in range(n-2):
            a, b = b, a + b
        return b


if m > 0:
    ans = Fib(A[0] + 1) % mod
    for i in range(m - 1):
        if A[i] == A[i + 1]:
            continue
        ans *= Fib(A[i + 1] - A[i])
        ans %= mod
    ans *= Fib(n - A[-1] + 1)
    ans %= mod
else:
    ans = Fib(n + 2) % mod
print(ans)
x = input()
y = input()

a = int(x)
b = int(y)

c = a * b

if c % 2 == 0:
  print("Even")
else:
  print("Odd")

### FIXED CODE ###

A,B = map(int,input().split(" "))
print(['Even','Odd'][(A*B)%2])
a, b = input().split()
print(["<>"[a > b], "="][a = b])

### FIXED CODE ###

a, b = input().split()
print(["<>"[a > b], "="][a == b])
k, n = map(int, input().split())
a = list(map(int, input().split()))
dmax = k - (a[n - 1] - a[0])
for i in range(n - 1):
    if (a[i + 1] - a[i]) > dmax:
        dmax = a[i + 1] - a[i]
print(k - dmax)

### FIXED CODE ###

s = input()
if (s[2] == s[3]) & (s[4] == s[5]):
    print('Yes')
else:
    print('No')
import sys
input = sys.stdin.readline
import numpy as np
base_list = np.array(['A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'])
dict_list = []
dict_list.append(base_list)
for i in range(25):
    tmp_char = dict_list[i][0]
    tmp_list = dict_list[i][1:]
    tmp_list = np.append(tmp_list,tmp_char)
    dict_list.append(tmp_list)

def print_ans(N, sr):
    """Test Case
    >>> print_ans(2, ['A', 'B', 'C', 'X', 'Y', 'Z'])
    CDEZAB
    >>> print_ans(0, ['A', 'B', 'C','X', 'Y', 'Z'])
    ABCXYZ
    """
    idx_list = []
    for s in sr:
        tmp = np.where(base_list == s)[0]
        idx_list.append(int(tmp))
    ans = ''.join(dict_list[N][idx_list])
    print(ans)

if __name__ == '__main__':
    N = int(input().rstrip())
    tmp_s= input().rstrip()
    sr = []
    for s in tmp_s:
        sr.append(s)
    print_ans(N, sr)




### FIXED CODE ###

import sys
input = sys.stdin.readline
import numpy as np
base_list = np.array(['A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'])
dict_list = []
dict_list.append(base_list)
for i in range(26):
    tmp_char = dict_list[i][0]
    tmp_list = dict_list[i][1:]
    tmp_list = np.append(tmp_list,tmp_char)
    dict_list.append(tmp_list)

def print_ans(N, sr):
    """Test Case
    >>> print_ans(2, ['A', 'B', 'C', 'X', 'Y', 'Z'])
    CDEZAB
    >>> print_ans(0, ['A', 'B', 'C','X', 'Y', 'Z'])
    ABCXYZ
    """
    idx_list = []
    for s in sr:
        tmp = np.where(base_list == s)[0]
        idx_list.append(int(tmp))
    ans = ''.join(dict_list[N][idx_list])
    print(ans)

if __name__ == '__main__':
    N = int(input().rstrip())
    tmp_s= input().rstrip()
    sr = []
    for s in tmp_s:
        sr.append(s)
    print_ans(N, sr)
while True:
    try:
        a = int(input())
        b = int(input())
        print(len(str(a + b)))
    except EOFError:
        break


### FIXED CODE ###

while True:
    try:
        a, b = map(int, input().split(" "))
        print(len(str(a + b)))
    except:
        break
n = int(input())
a = list(map(int, input().split()))
ans = 0
for i in range(n - 1):
    if a[i] == i + 1:
        a[i], a[i + 1] = a[i + 1], a[i]
        ans += 1
    if a[n] == n + 1:
        ans += 1
print(ans)

### FIXED CODE ###

n = int(input())
a = list(map(int, input().split()))
ans = 0
for i in range(n - 1):
    if a[i] == i + 1:
        a[i], a[i + 1] = a[i + 1], a[i]
        ans += 1
        
if a[n - 1] == n:
    ans += 1
print(ans)
# -*- coding: utf-8 -*-

import sys
from collections import defaultdict


n, q = [int(x) for x in sys.stdin.readline().rstrip().split(" ")]

tree = defaultdict(list)
data = defaultdict(int)


def add(p, x):
    data[p] += x
    for p2 in tree[p]:
        add(p2, x)


for _ in range(n - 1):
    a, b = [int(x) for x in sys.stdin.readline().rstrip().split(" ")]
    tree[a].append(b)

for _ in range(q):
    p, x = [int(x) for x in sys.stdin.readline().rstrip().split(" ")]
    add(p, x)

print(" ".join([str(data[i + 1]) for i in range(n)]))


### FIXED CODE ###

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

import sys


sys.setrecursionlimit(10**6)


def main():
    n, q = map(int, sys.stdin.readline().split())

    tree = [[] for x in range(n + 1)]
    data = [0 for x in range(n + 1)]

    for _ in range(n - 1):
        a, b = map(int, sys.stdin.readline().split())
        tree[a].append(b)
        tree[b].append(a)

    for _ in range(q):
        p, x = map(int, sys.stdin.readline().split())
        data[p] += x

    def dfs(p, p2, x):
        data[p] += x
        for p3 in tree[p]:
            if p3 == p2:
                continue
            dfs(p3, p, data[p])

    dfs(1, 0, 0)

    print(" ".join([str(x) for x in data[1:]]))


if __name__ == "__main__":
    main()
N = int(input())
A = list(map(int,input().split()))
j = True
count = 0
while j :
     for i in range(N):
             if A[i] % 2 == 0 or A[i] == 0:
                     A[i] =/ 2
             else:
                     j = False
     if j == True:             
     	count += 1
print(count)

### FIXED CODE ###

N = int(input())
A = list(map(int,input().split()))
j = True
count = 0
while j :
     for i in A:
             if i % 2 == 0 or i == 0:
                     A[A.index(i)] = i / 2
             else:
                     j = False
     if j == True:             
     	count += 1
print(count)
s = input()

n1 = s[0:2]
n2 = s[2:4]

if int(n1) > 12 and int(n2) > 12:
    out_print = 'NA'

elif int(n1) <= 12 and int(n2) <= 12:
    out_print = 'AMBIGUOUS'
    if int(n1) == 0:
        out_print = 'YYMM'
    elif int(n2) == 0:
        out_print = 'MMYY'
    elif int(n1)==0 and int(n2)==0
        out_print = 'NA'
elif int(n1) <= 12 and int(n2) >12:
    out_print = 'MMYY'
    if int(n1) == 0:
        out_print = 'NA'

elif int(n1) > 12 and int(n2) <= 12:
    out_print = 'YYMM'
    if int(n2) == 0:
        out_print = 'NA'

print(out_print)

### FIXED CODE ###

s = input()

n1 = s[0:2]
n2 = s[2:4]

if int(n1) > 12 and int(n2) > 12:
    out_print = 'NA'

elif int(n1) <= 12 and int(n2) <= 12:
    out_print = 'AMBIGUOUS'
    if int(n1) == 0 and int(n2)!=0:
        out_print = 'YYMM'
    elif int(n1) != 0 and int(n2) == 0:
        out_print = 'MMYY'
    elif int(n1)==0 and int(n2)==0:
        out_print = 'NA'

elif int(n1) <= 12 and int(n2) >12:
    out_print = 'MMYY'
    if int(n1) == 0:
        out_print = 'NA'

elif int(n1) > 12 and int(n2) <= 12:
    out_print = 'YYMM'
    if int(n2) == 0:
        out_print = 'NA'
print(out_print)
import itertools
import numpy as np
import fractions
from functools import reduce

N = int(input())
A = np.array(input().split()).astype(int)

def gcd(numbers):
    return reduce(fractions.gcd, numbers)
rt = 1
for i in range(N):
    ind = np.ones(N, dtype=bool)
    ind[i]=False
    A_tmp = A[ind]
    f = gcd(A_tmp)
    if rt < f:
        rt = f
print(rt)


### FIXED CODE ###

A, B, T = map(int, input().split())
print((T//A)*B)
N,A,B = map(int,input().split())
Score = 0
for i in range(N+1):
    x = sum(list(map(int,str(i)))
    if A<= x <= B :
        cnt += i
print(cnt)

### FIXED CODE ###

N,A,B = map(int,input().split())
Score = 0
for i in range(N+1):
    x = sum(list(map(int,str(i))))
    if A <= x <= B :
        Score += i
print(Score)
import sys
input = sys.stdin.buffer.readline
 
def main():
    a,b,c,d = map(int,input().split())
    MOD = 10**9+7
    N = c+d+5
    fac = [0 for _ in range(N+1)]
    fac[0],fac[1] = 1,1
 
    for j in range(2,N+1):
        fac[j] = (fac[j-1]*j)%MOD
        
    def comb(x,y):
        return (fac[x+y]*pow(fac[x],MOD-2,MOD)*pow(fac[y],MOD-2,MOD))%MOD
 
    print((comb(c+1,d+1)-comb(c+1,b)-comb(d+1,a)+comb(a,b))%MOD)
    
if _name_ == "_main_":
    main()

### FIXED CODE ###

import sys
input = sys.stdin.buffer.readline
 
def main():
    a,b,c,d = map(int,input().split())
    MOD = 10**9+7
    N = c+d+5
    fac = [0 for _ in range(N+1)]
    fac[0],fac[1] = 1,1
 
    for i in range(2,N+1):
        fac[i] = (fac[i-1]*i)%MOD
        
    def comb(g,h):
        return (fac[g+h]*pow(fac[g],MOD-2,MOD)*pow(fac[h],MOD-2,MOD))%MOD
 
    print((comb(c+1,d+1)-comb(c+1,b)-comb(d+1,a)+comb(a,b))%MOD)
    
if __name__ == "__main__":
    main()
n, z, w = map(int, input().split())
aa = list(map(int, input().split()))

memo = {}
def act(xlast, ylast, turn):
    x = z if xlast == -1 else aa[xlast]
    y = w if ylast == -1 else aa[ylast]

    if xlast == n - 1 or ylast == n - 1:
        return abs(x - y)
    
    if (xlast, ylast, turn) in memo:
        return memo[(xlast, ylast, turn)]
    
    if turn == 0:
        # x turn
        ans = 0
        for i in range(ylast + 1, n):
            ans = max(ans, act(i, ylast, 1))
    else:
        # y turn
        ans = 1 << 30
        for i in range(xlast + 1, n):
            ans = min(ans, act(xlast, i, 0))
    
    memo[(xlast, ylast, turn)] = ans
    return ans

print(act(-1, -1, 0))


### FIXED CODE ###

import sys
sys.setrecursionlimit(114514)

n, z, w = map(int, input().split())
aa = list(map(int, input().split()))

memo = {}
def act(last, turn):
    if (last, turn) in memo:
        return memo[(last, turn)]

    if turn == 0:
        # x turn
        y = w if last == -1 else aa[last]
        ans = abs(y - aa[n - 1])
        for i in range(last + 1, n - 1):
            ans = max(ans, act(i, 1))
    else:
        # y turn
        x = z if last == -1 else aa[last]
        ans = abs(x - aa[n - 1])
        for i in range(last + 1, n - 1):
            ans = min(ans, act(i, 0))
    
    memo[(last, turn)] = ans
    return ans


print(act(-1, 0))
if __name__ == '__main__':
    A = input()
    B = input()
    C = input()
    K = input()

    a = int(A)
    b = int(B)
    c = int(C)
    k = int(K)

    if a > k:
        print(k)
    elif (a+b) > k:
        print(a)
    else:
        ans = 2*a-k+b
        print(ans)


### FIXED CODE ###

if __name__ == '__main__':
    A =[]
    B = input()
    A = B.split()

    a = int(A[0])
    b = int(A[1])
    c = int(A[2])
    k = int(A[3])

    if a > k:
        print(k)
    elif (a+b) > k:
        print(a)
    else:
        ans = 2*a-k+b
        print(ans)
while True:
    m=input().split()
    h=int(m[0])
    w=int(m[1])
    if (a==0)(b==0):
      break
    for i in range(a):
       print("#"*b)
    print()
    


### FIXED CODE ###

while True:
    v=input().split()
    a=int(v[0])
    b=int(v[1])
    if a==0 and b==0:
       break
    for i in range (a):
        print('#'*b)
    print()
AB, BC = map( int, input().split() )
print( ( AB * BC ) // 2 )

### FIXED CODE ###

AB, BC, CA = map( int, input().split() )
print( ( AB * BC ) // 2 )
import sys
input = sys.stdin.readline
import numpy as np

def F(N,A,B):
    AB = list(zip(A,B))
    AB = [(a,b) for a,b in AB if a < b] # 有用なやつだけ
    AB.sort(key = lambda x: x[1]/x[0], reverse = True)
    if len(AB) == 0:
        return N
    if len(AB) == 1:
        a,b = AB[0]
        x = N//a
        return N + (b-a) * x
    if len(AB) == 2:
        (a,b),(c,d) = AB
        # 2種類目の硬価はa回未満しか使わない：ac個はa優先なので
        return max(N + (N - i * c) // a * (b-a) + i * (d-c) for i in range(M))
    # 効率の良いものから並んでいる
    dp = [0] * (N+1)
    for n in range(N+1):
        x = n
        for a,b in AB:
            if n >= a:
                y = dp[n-a] + b
                if x < y:
                    x = y
        dp[n] = x
    return dp[N]

N = int(input())
A = [int(x) for x in input().split()]
B = [int(x) for x in input().split()]

answer = F(F(N,A,B),B,A)
print(answer)

### FIXED CODE ###

# 新ステージでは、一度全部どんぐりに直してから換金を始めるとしてよい

def F(N, A, B):
  # N個のどんぐりを、Aで換金してからBに持っていく
  # Bでどんぐりに直す
  dp = [0] * (N+1)
  for n in range(N+1):
    x = n
    for j in range(3):
      if n >= A[j]:
        y = dp[n-A[j]] + B[j]
        if x < y:
          x = y
    dp[n] = x
  return dp[N]

N = int(input())
A = [int(x) for x in input().split()]
B = [int(x) for x in input().split()]

answer = F(F(N,A,B),B,A)
print(answer)
a, b = map(int, input().split())

if (a*b) % 2 == 0;
	print("Even")
else:
    print("Odd")
    

### FIXED CODE ###

a,b = map(int, input().split())
 
if (a*b) % 2 == 0:
	print("Even")
else:
    print("Odd")
s = input().rstrip()
t = input().rstrip()
s = sorted(s)
t = sorted(t, reverse=True)
if s < t:
    print('Yes')
else:
    print('No')


### FIXED CODE ###

import math

a, b = map(int, input().split())
mean = (a + b) / 2
mean = math.ceil(mean)
print(mean)
A, B = map(int, input().split())


def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    return divisors

import math

def primes(n):
    is_prime = [True] * (n + 1)
    is_prime[0] = True
    is_prime[1] = True
    for i in range(2, int(n**0.5) + 1):
        if not is_prime[i]:
            continue
        for j in range(i * 2, n + 1, i):
            is_prime[j] = False
    return is_prime

import fractions
x = fractions.gcd(A, B)
divisors = make_divisors(x)
ans = 0
P = primes(x)
for d in divisors:
    if P[d]:
        ans += 1
print(ans)

### FIXED CODE ###

A, B = map(int, input().split())


def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    return divisors

import math

def is_prime(n):
    if n == 1: return True

    for k in range(2, int(math.sqrt(n)) + 1):
        if n % k == 0:
            return False
    return True

import fractions
x = fractions.gcd(A, B)
divisors = make_divisors(x)
ans = 0
for d in divisors:
    if is_prime(d):
        ans += 1
print(ans)
N = input()
lst = input().split(" ")
list(map(int, lst))
max  = max(lst)
sum = sum(lst)
if sum - max < max:
    print("YES")
else:
    print("NO")


### FIXED CODE ###

N = input()
lst = input().split(" ")
lst2 = []
for i in lst:
    int_i = int(i)
    #print(int_i)
    lst2.append(int_i)
#print(lst2)
max  = max(lst2)
#print(max)
sum = sum(lst2)
#print(sum)
if sum - max > max:
    print("Yes")
else:
    print("No")
#input()
import math
r = int(input())
print("%f %f" % (math.pi * r ** 2, 2 * math.pi * r))

### FIXED CODE ###

import math
r = float(input())
print("%f %f" % (math.pi * r ** 2, 2 * math.pi * r))
a,b = map(int, input().split())
print(int((a-1)/(b-1)+0.5))

### FIXED CODE ###

import math
a,b = map(int, input().split())
print(math.ceil((b-1)/(a-1)))
input_ = input()

m = 0
s = 0
for i in input_.splitlines():
    n = int(i)
    if i > max:
        max = i
    sum += n

print(sum - (max / 2))


### FIXED CODE ###

n = input()
a = []
for i in range(int(n)):
    a.append(int(input()))

print(int(sum(a) - (max(a) / 2)))
r=input()
g=input()
b=input()

r=int(r)
g=int(g)
b=int(b)

if print(rgb)/4=0:
  return 'Yes'
else:
  return 'No'

### FIXED CODE ###

r,g,b,=input().split()
r=int(r)
g=int(g)
b=int(b)

if ((r*100)+(g*10)+b)%4==0:
  print('YES')
else:
  print('NO')
n,*l = map(int,open(0).read().split())
a = l[::2]
b = l[1::2]
print(sum(a) - min(b[i] for i in range(n) if b[i] < a[i]))

### FIXED CODE ###

n,*l = map(int,open(0).read().split())
a = l[::2]
b = l[1::2]
print(0 if a==b else sum(a) - min(b[i] for i in range(n) if b[i] < a[i]))
s = input()
if s == "hi" or s == "hihi" or s == "hihihi" or s == "hihihihi" or s == "hihihihihi"
	print ("Yes")
else:
	print ("No")

### FIXED CODE ###

s = input()
if s == "hi" or s == "hihi" or s == "hihihi" or s == "hihihihi" or s == "hihihihihi":
	print ("Yes")
else:
	print ("No")
A,B,C=map(int,input().split())
print('NYoe s'[a==b==c::2])


### FIXED CODE ###

A,B,C=map(int,input().split())
print('NYoe s'[A==B==C::2])
def main():
    M=10**9+7
    n,k,*a=map(int,open(0).read().split())
    x,y=[],[]
    for i in a:
        if i>0:x.append(i)
        if i<0:y.append(i)
    x.sort(reverse=1)
    y.sort()
    if len(x)+len(y)<k or len(x)<k and (k-len(x))%2 and len(x)+len(y)<n:
        print(0)
        exit()
    if len(x)<k and (k-len(x))%2:
        1/0
        c=1
        for i in x+y[::-1][:k-len(x)]:
            c=c*i%M
        print(c)
        exit()
    x=x[:k]
    m=len(y)
    i=len(x)
    j=0
    if i<k:
        j=k-i
        x+=y[:j]
        j+=1
    while i>1 and j+1<m and x[i-1]*x[i-2]<y[j]*y[j+1]:
        x[i-1],x[i-2]=y[j],y[j+1]
        i-=2
        j+=2
    c=1
    for i in x:
        c=c*i%M
    print(c)
main()

### FIXED CODE ###

def main():
    M=10**9+7
    n,k,*a=map(int,open(0).read().split())
    x,y=[],[]
    for i in a:
        if i>0:x+=i,
        if i<0:y+=i,
    if len(x)+len(y)<k or k%2 and not x and len(y)<n:
        print(0)
        return
    if n==k or k%2 and not x:
        c=1
        for i in sorted(x+y)[-k:]:
            c=c*i%M
        print(c)
        return
    x=sorted(x)[::-1][:k]
    i=len(x)
    y.sort()
    m=len(y)
    j=k-i
    if j%2:
        x=x[:-1]
        i-=1
        j+=1
    x+=y[:j]
    while i>1 and j+1<m and x[i-1]*x[i-2]<y[j]*y[j+1]:
        x[i-1],x[i-2]=y[j],y[j+1]
        i-=2
        j+=2
    c=1
    for i in x:
        c=c*i%M
    print(c)
main()
S = int(input())
print(S//3600, S//60%60, S%60, sep":")


### FIXED CODE ###

S=int(input())
print(S//3600,S//60%60,S%60,sep=":")
a,b,c,d = map(int, raw_input().split())

x = abs(c-a)
y = abs(d-b)

if x == 0 or y == 0:
	print 0
	return

def gcd(a,b):
	return a if b == 0 else gcd(b, a % b)

e = gcd(x,y)
x /= e
y /= e

print (x+y-1) * e

### FIXED CODE ###

a,b,c,d = map(int, raw_input().split())

x = abs(c-a)
y = abs(d-b)

if x == 0 or y == 0:
	print 0
	import sys
	sys.exit(0)

def gcd(a,b):
	return a if b == 0 else gcd(b, a % b)

e = gcd(x,y)
x /= e
y /= e

print (x+y-1) * e
ar = ["A","B","C","D","E","F"]
a = input().split(" ")
if ar.index(a[0]) > ar.index([1]):
  print(">")
elif ar.index(a[0]) == ar.index(a[1]):
  print("=")
else:
  print("<")

### FIXED CODE ###

ar = ["A","B","C","D","E","F"]
a = input().split(" ")
if ar.index(a[0]) > ar.index(a[1]):
  print(">")
elif ar.index(a[0]) == ar.index(a[1]):
  print("=")
else:
  print("<")
for i in range(1, 10):
    for j in range(1, 10):
        print('{}×{}＝'.format(i,j), i*j)
exit()for i in range(1, 10):
    for j in range(1, 10):
        print(str(i)+'×'+str(j)+'='+str(i*j))
exit()


### FIXED CODE ###

for i in range(1, 10):
    for j in range(1, 10):
        print(str(i)+'x'+str(j)+'='+str(i*j))
exit()
n = int(input())
p = list(map(int, input().split()))

count = 0
for i in range(n):
    if i+1 == p[i]:
        tmp = p[i]
        p[i] = p[i+1]
        p[i+1] = tmp
        count += 1

if p[-1] == n:
    count += 1

print(count)


### FIXED CODE ###

n = int(input())
p = list(map(int, input().split()))

count = 0
for i in range(n-1):
    if i+1 == p[i]:
        tmp = p[i]
        p[i] = p[i+1]
        p[i+1] = tmp
        count += 1

if p[-1] == n:
    count += 1

print(count)
n = input()
print('Yes') if int(n) % sum(map(int, n)) == 0 else print('No')

### FIXED CODE ###

n, a, b = map(int, input().split())

if n * a <= b:
    print(n * a)
else:
    print(b)
a=int(input(a))
b=int(input(b))
if (a*b)%2 =0
print ('Even')
else:
  print ('Odd')

### FIXED CODE ###

a,b=map(int,input().split())
if (a*b)%2 ==0:
  print('Even')
else:
  print('Odd')
N, M, X, Y = map(int, input().split())
x = list(map(int, input().split()))
y = list(map(int, input().split()))
for i in range(X, Y):
   if X < i <= Y and max(x) < i <= min(y):
             print("No War")
             exit(1)
print("War")
             


### FIXED CODE ###

N, M, X, Y = map(int, input().split())
x = list(map(int, input().split()))
y = list(map(int, input().split()))
for i in range(X, Y+1):
  if X < i <= Y and max(x) < i <= min(y):
    print("No War")
    exit()
print("War")
n = input() #カードの枚数
taro = 0
hanako = 0
for i in range(n):
    x = map(str, raw_input().split())  #x[0]:太郎，x[1]:花子
    #print x[0]
    #print x[1]
    if(x[0] > x[1]):
        taro += 3
    elif(x[0] == x[1]):
        taro += 1
        hanako += 1
    else:
        hanako += 3
print '%d %d' %(taro, hanako)
exit(0)

### FIXED CODE ###

n = input()
taro = 0
hanako = 0
for i in range(n):
    x = map(str, raw_input().split())
    #print x[0]
    #print x[1]
    if(x[0] > x[1]):
        taro += 3
    elif(x[0] == x[1]):
        taro += 1
        hanako += 1
    else:
        hanako += 3
print '%d %d' %(taro, hanako)

exit(0)
X,A=int(input())

if X<A:
  print(0)
else:
  print(10)

### FIXED CODE ###

X,A=map(int,input().split())
if X<A:
  print(0)
else:
  print(10)
N=int(input())
a=N//100
b=(N-a*100)//10
c=N-a*100-b*10
if a<b:
    N=(a+1)*111
elif a>b:
    N=a*111
elif a=b and a>=c:
    N=a*111
elif :
    N=(a+1)*111
print(N)
    

### FIXED CODE ###

N=int(input())
a=N//100
b=(N-a*100)//10
c=N-a*100-b*10
if a<b:
    N=(a+1)*111
elif a>b:
    N=a*111
elif a==b and a>=c :
    N=a*111
elif a==b and a<c :
    N=(a+1)*111
print(N)
import itertools

nums = [int(e) for e in input().split()]

list0 = []
A = []
A0 = list(range(0,nums[0]))
for i in range(0, nums[0]):
    val = [int(e) for e in input().split()]
    list0.append(val)
    for x in itertools.combinations(A0,i+1):
        A.append(list(x))

X = []
for i in range(0,len(A)):
    Y = [0] * (nums[1]+1)
    for j in range(0,len(A[i])):
        Y = [x + y for (x, y) in zip(Y,list0[A[i][j]])]
    if Y[1] >= nums[2] and Y[2] >= nums[2] and Y[3] >= nums[2]:
        X.append(Y[0])

if len(X) > 0:
    print(min(X))
else:
    print('-1')

### FIXED CODE ###

import itertools

nums = [int(e) for e in input().split()]

list0 = []
A = []
A0 = list(range(0,nums[0]))
for i in range(0, nums[0]):
    val = [int(e) for e in input().split()]
    list0.append(val)
    for x in itertools.combinations(A0,i+1):
        A.append(list(x))

Z = [0]
for i in range(1,nums[1]+1):
    Z.append(nums[2])

X = []
for i in range(0,len(A)):
    Y = [0] * (nums[1]+1)
    for j in range(0,len(A[i])):
        Y = [x + y for (x, y) in zip(Y,list0[A[i][j]])]
    W = [x - y for (x, y) in zip(Y,Z)]
    if min(W) >= 0:
        X.append(Y[0])

if len(X) > 0:
    print(min(X))
else:
    print('-1')
a1,a2,a3=map(int,input().split())
k=[a1,a2,a3]
print( abs(max(k)-max(k)[1]) + abs(max(k)[1]-max(k)[2]))

### FIXED CODE ###

k=list(map(int,input().split()))
k.sort() #デフォルトは昇順
print( abs(k[0]-k[1]) + abs(k[1]-k[2]))
import sympy

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

a=b=0


if x*4<y or x*2>y:
    print('No')
    exit()

if (y-2*x)%2==0:
    n=(y-2*x)/2
    if x-b>=0:
        print('Yes')

### FIXED CODE ###

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

a=b=0


if x*4<y or x*2>y:
    print('No')
    exit()

if (y-2*x)%2==0:
    n=(y-2*x)/2
    if x-b>=0:
        print('Yes')
else:
    print('No')