Harryxun/stf_run huggingface dataset:
N,M=map(int,input().split())
A=[-1]*N
ans=0
L=list(list(map(int,input().split())) for j in range(M))
for i in range(M):
  if A[L[M][0]-1]==-1 or A[L[M][0]-1]==L[M][1]:
    A[L[M][0]-1]==L[M][1]
  else:
    ans=-1
    break
S=""
for k in range(N):
  if A[k]==-1:
    if N!=1 and k==0:
      A[k]=1
    else:
      A[k]=0
  
  if N!=1 and A[0]==0:
    ans=-1
    break
  S+=str(A[i])
if ans=-1:
  print(-1)
else:
  print(int(S))

### FIXED CODE ###

n,m = map(int,input().split())
s = list(list(map(int,input().split())) for i in range(m))
x = [-1]*n
b = True
for i in range(m):
    if x[s[i][0]-1] == -1 or x[s[i][0]-1] == s[i][1]:
        x[s[i][0]-1] = s[i][1]
    else:
        b = False
for j in range(n):
    if x[j] == -1:
        if len(x) != 1 and j == 0:
            x[j] = 1
        else:
            x[j] = 0
if len(x) != 1 and x[0] == 0:
    b = False

if b:
  S=""
  for o in range(n):
    S+=str(x[o])
  print(int(S))
else:
  print(-1)
import bisect

lis[1, 12]

str = input()
tp = int(str[:2])
bt = int(str[2:])

tplo = bisect.bisect_right(lis, tp)
btlo = bisect.bisect_right(lis, bt)

if tp == 0:
    if bt == 1:
        jd = 3
    else:
        jd == 0
elif tp == 1:
    if bt == 1:
        jd == 2
    else:
        jd == 1
else:
    if bt == 1:
        jd == 0
    else:
        jd == 3

judge = ["YYMM", "MMYY", "AMBIGUOUS", "NA"]
print(judge[jd])


### FIXED CODE ###

import bisect

lis = [1, 13]

str = input()
tp = int(str[:2])
bt = int(str[2:])

tplo = bisect.bisect_right(lis, tp)
btlo = bisect.bisect_right(lis, bt)

if tplo == 1:
    if btlo == 1:
        jd = 2
    else:
        jd = 1
else:
    if btlo == 1:
        jd = 0
    else:
        jd = 3

judge = ["YYMM", "MMYY", "AMBIGUOUS", "NA"]

print(judge[jd])
n=int(input())
s=[list(input()) for _ in range(n)]
import numpy as np
ss=[si+si for si in s]
ss=np.array(ss+ss)
ans=0
for i in range(n):
  for j in range(n):
    a=ss[i:i+n,j:j+n]
    if np.array_equal(a,a.T):
      ans+=1
print(ans)

### FIXED CODE ###

n=int(input())
s=[list(input()) for _ in range(n)]
import numpy as np
ss=[si+si for si in s]
ss=np.array(ss+ss)
ans=0
for i in range(n):
    a=ss[i:i+n,:n]
    if np.array_equal(a,a.T):
      ans+=1
print(ans*n)
x = map(int, raw_input().split())

for i in range():
  print "case %d: %d" %(i + 1, x[i])

### FIXED CODE ###

i = 1
while(1):
  x = int(raw_input())

  if x == 0:
    break

  print "Case %d: %d" %(i,x)
  i += 1
A_prev, B_prev, C_prev, K = map(int, input().split())

for _ in range(K):
  A_cur = B_prev + C_prev
  B_cur = A_prev + C_prev
  C_cur = A_prev + B_prev
  A_prev, B_prev, C_prev = A_cur, B_cur, C_cur
ans = A_cur - B_cur
print(A_cur - B_cur if ans <= 1e18 else 'Unfair')

### FIXED CODE ###

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

if K > 0:
    if K % 2 == 0:
        ans = A - B
    else:
        ans = B - A
else:
    ans = A - B
print(ans if ans <= 1e18 else 'Unfair')
if __name__ == '__main__':


    while True:
        
        a,b = map(str,raw_input().split(' '))
    
        if a == 0 and b == 0:
            break 

        a = list(a)
        b = list(b)
    #    print a


        br = 0
        hit = 0
        for i,data in enumerate(b):

            if data in a:
                if a[i] == data:
                    hit += 1

                else:
                    br += 1

        print hit,br

### FIXED CODE ###




if __name__ == '__main__':


    while True:

        a,b = map(str,raw_input().split(' '))

        if a == '0' and b == '0':
            break

      #  print a,b

        a = list(a)
        b = list(b)
    #    print a


        br = 0
        hit = 0
        for i,data in enumerate(b):

            if data in a:
                if a[i] == data:
                    hit += 1

                else:
                    br += 1

        print hit,br
a = input()
s = input()
d = input()
f = input()
g = input()
h = input()
j = min(int(s), int(d), int(f), int(g), int(h))

if int(a)%j = 0:
    k = int(a)//j + 4
else:
    k = int(a)//j + 5
print(i)



### FIXED CODE ###

a = input()
s = input()
d = input()
f = input()
g = input()
h = input()
j = min(int(s), int(d), int(f), int(g), int(h))

if int(a)%j == 0:
    k = int(a)//j + 4
else:
    k = int(a)//j + 5
print(k)
line = input().split()
a = int( line[0] )
b = int( line[1] )
print( str( a * b ), str( 2 * ( a + b ) ) )



### FIXED CODE ###

a,b = input().split()
a = int( a )
b = int( b )
print(  a * b, 2 * ( a + b ) )
# coding: utf-8

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

if c <= b:
	if c <= d:
	  print(b - c)
	 else:
	 	print(d - c)
else:
	print(0)


### FIXED CODE ###

# coding: utf-8

a, b, c, d = map(int, input().split())
alice_time = [x for x in range(a, b+1)]
bob_time = [x for x in range(c, d+1)]
pushed_time = set(alice_time) & set(bob_time)

if len(pushed_time) == 0:
  print(0)
else:
  print(len(pushed_time) - 1)
import collections
ds = []
N = int(input())
for _ in range(N):
    ds.append(input())
print(len(ollections.Counter(ds)))

### FIXED CODE ###

import collections
ds = []
N = int(input())
for _ in range(N):
    ds.append(input())
print(len(collections.Counter(ds)))
def gcd(a,b):
    if b > 0:
        return gcd(b,a%b)
    elif b == 0:
        return a

N,X = map(int,input().split())
x = list(map(int,input().split()))
if N == 1:
    print(abs(x[0] - X))
else:
    xlen = [abs(x[0]-X)]
    for i in range(N-1):
        xlen.append(x[i+1]- x[i])
    ans = xlen[0]
    for i in range(N-2):
        ans = gcd(ans,xlen[i+1])
    #print(ans)
    print(ans)

### FIXED CODE ###

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


N,X = map(int,input().split())
x = list(map(int,input().split()))
if N == 1:
    print(abs(x[0] - X))
else:
    xlen = []
    for i in range(N):
        xlen.append(abs(x[i] - X))
        #print(xlen[i])
    ans = xlen[0]
    for i in range(1,N):
        ans = gcd(ans,xlen[i])
        #print(ans)
    print(ans)
n,k=map(int,input().split())
p=[int(i)-1for i in input().split()]
c=list(map(int,input().split()))
ans=-10**9
a=[1]*n
for i in range(n):
    if a[i]:
        a[i]=1
        start=i
        cycle=[0]
        for _ in range(n):
            i=p[i]
            cycle+=[cycle[-1]+c[i]]
            a[i]=1
            if i==start:break
        S,L=cycle[-1],len(cycle)-1
        if S<0:ans=max(ans,max(cycle[1:k]))
        else:ans=max(ans,k//L*S+max(cycle[:k%L+1]))
print(ans)

### FIXED CODE ###

n,k=map(int,input().split())
p=[int(i)-1for i in input().split()]
c=list(map(int,input().split()))
ans=-10**9
for i in range(n):
    start=i
    cycle=[0]
    for _ in range(n):
        i=p[i]
        cycle+=[cycle[-1]+c[i]]
        if i==start:break
    S,L=cycle[-1],len(cycle)-1
    if S<=0:ans=max(ans,max(cycle[1:k+1]))
    else:
        if k>L:ans=max(ans,(k//L-1)*S+max(max(cycle),max(cycle[:k%L+1])+S)) 
        else:ans=max(ans,max(cycle[:k+1]))
print(ans)
n = int(input())
s = input()
if s < 3200:
  print("red")
else:
  print(s)

### FIXED CODE ###

n = int(input())
s = input()
if n < 3200:
  print("red")
else:
  print(s)
N, T = map(int, input().split())
weight = []
value = []

dp = [[0] * (3010) for i in range(3010)]

for i in range(N):
    w, v = map(int, input().split())
    weight.append(w)
    value.append(v)
#配る
for i, (ww, vv) in enumerate(zip(weight, value)):
    for w in range(T):            
        dp[i+1][w] = max(dp[i+1][w], dp[i][w])
        dp[i+1][w+ww] = max(dp[i][w+ww], dp[i][w] + vv)
        #else: dp[i+1][w] = dp[i][w]


print(max(dp[N]))
"""
for i, v in enumerate(dp[N][:200]):
    print("{}:{}, ".format(i, v), end="")
"""


### FIXED CODE ###

import sys
def input(): return sys.stdin.readline().strip()

def main():
    N, T = map(int, input().split())
    cv = [tuple(map(int, input().split())) for _ in range(N)]
    cv = sorted(cv, key=lambda x : x[0])

    dp = [[0]*(T+1) for _ in range(N+1)]
    dp_ext = [[0]*(T+1) for _ in range(N+1)]

    values = [v for c, v in cv]
    max_values = [max(values[i:]) for i in range(N)]
    # 貰うdp
    for i in range(N):
        cost, value = cv[i]
        for now in range(cost, T+1):
            old = now - cost
            dp[i+1][now] = max(dp[i][now], dp[i][old] + value)

        for j in range(1, T+1):
            dp[i+1][j] = max(dp[i+1][j], dp[i+1][j-1])
        
        for j in range(1, T+1):
            dp_ext[i+1][j] = max(dp[i+1][j], dp[i][j-1] + max_values[i], dp_ext[i][j])

    print(dp_ext[N][T])

if __name__ == "__main__":
    main()
N=int(input())
A = list(map(int, input().split()))

big = max(A)
small = min(A)
print(big - small)


### FIXED CODE ###

N = int(input())
if N % 2 == 0:
    ans = N
else:
    ans = N * 2
print(ans)
import fraction

A, B = map(int,input().split())
GCD = fraction.gcd(A, B)

def prime_factorize(n):
    a = [1]
    flag = 1
    while n % 2 == 0:
        if flag:
            a.append(2)
            flag = 0
        n //= 2
    f = 3
    flag = 1
    while f * f <= n:
        if n % f == 0:
            if flag:
                a.append(f)
                flag = 0
            n //= f
        else:
            f += 2
            flag = 1
    if n != 1 and n != a[-1]:
        a.append(n)
    return a

a = prime_factorize(GCD)

print(len(a))

### FIXED CODE ###

import fractions

A, B = map(int,input().split())
GCD = fractions.gcd(A, B)

def prime_factorize(n):
    a = [1]
    flag = 1
    while n % 2 == 0:
        if flag:
            a.append(2)
            flag = 0
        n //= 2
    f = 3
    flag = 1
    while f * f <= n:
        if n % f == 0:
            if flag:
                a.append(f)
                flag = 0
            n //= f
        else:
            f += 2
            flag = 1
    if n != 1 and n != a[-1]:
        a.append(n)
    return a

a = prime_factorize(GCD)

print(len(a))
s=list(input())
q=int(input())
start=[]
owari=[]
r=1
for i in range(q):
    data=input().split()
    if(len(data)==1):
        r*=-1
    elif(data[1]=="1"):
        if(r==1):
            start.append(data[2])
        else:
            owari.append(data[2])
    else:
        if(r==1):
            owari.append(data[2])
        else:
            start.append(data[2])
    print(start,owari,r)

if(r==1):
    start.reverse()
    print(''.join(start),end='')
    print(''.join(s),end='')
    print(''.join(owari),end='')
else:
    owari.reverse()
    s.reverse()
    print(''.join(owari),end='')
    print(''.join(s),end='')
    print(''.join(start),end='')


### FIXED CODE ###

s=list(input())
q=int(input())
start=[]
owari=[]
r=1
for i in range(q):
    data=input().split()
    if(len(data)==1):
        r*=-1
    elif(data[1]=="1"):
        if(r==1):
            start.append(data[2])
        else:
            owari.append(data[2])
    else:
        if(r==1):
            owari.append(data[2])
        else:
            start.append(data[2])

if(r==1):
    start.reverse()
    print(''.join(start),end='')
    print(''.join(s),end='')
    print(''.join(owari),end='')
else:
    owari.reverse()
    s.reverse()
    print(''.join(owari),end='')
    print(''.join(s),end='')
    print(''.join(start),end='')
n, k = map(int, input().split())
s=input()
if s[k-1] == 'A':
  s[k-1] = 'a'
elif s[k-1] == 'B':
  s[k-1] = 'b'
else:
  s[k-1] = 'c'
print(s)if s[k-1] == 'A':
  s[k-1] = 'a'

### FIXED CODE ###

n, k = map(int, input().split())
s = list(input())
if s[k-1] == 'A':
  s[k-1] = 'a'
elif s[k-1] == 'B':
  s[k-1] = 'b'
else:
  s[k-1] = 'c'
print(''.join(s))
a,b,c,d=map(int,input().split())
if c>b and d>b:
  print(b-a+1)
  exit()
elif c>b:
  for i in range(b):
    if d*i>=a:
      d1=i*d
  print(b-a-(b-d1)//d)
  exit()
elif d>b:
  for i in range(b):
    if c*i>=a:
      c1=i*c
  print(b-a-(b-c1)//c)
  exit()
else :
  clst=[c*i for i in range(a//c+1,(b-c*i)//c+i+1)]    
  dlst=[d*i for i in range(a//c+1,(b-d*i)//d+i+1)]
  lst=set(clst+dlst)
  print(b-a+1-len(lst))
  


### FIXED CODE ###

a,b,c,d=map(int,input().split())
if d>c:
  euclid2,euclid1=c,d
  e1,e2=euclid1,euclid2
  while not euclid2==0:
    euclid1=euclid1%euclid2
    euclid1,euclid2=euclid2,euclid1
    cd=c*d//euclid1
else:
  euclid2,euclid1=d,c
  e1,e2=euclid1,euclid2
  while not euclid2==0:
    euclid1=euclid1%euclid2
    euclid1,euclid2=euclid2,euclid1
    cd=c*d//euclid1
  
c1=(a-1)//c+1
c2=(b-c1*c)//c+1
d1=(a-1)//d+1
d2=(b-d1*d)//d+1
cd1=(a-1)//cd+1
cd2=(b-cd1*cd)//cd+1  
print(b-a+1-c2-d2+cd2)
num = int(input())
print(math.pi * 2 * num)

### FIXED CODE ###

import math
radius = int(input())
c = 2 * math.pi * radius
print("%.2f" % c)
a, b, c = map(int, input().split())
if (a =< c) and (c =< b):
    print('Yes')
    
else:
    print('No')

### FIXED CODE ###

a, b, c = map(int, input().split())
if (a <= c) and (c <= b):
    print('Yes')
    
else:
    print('No')
n , k = map(int, input().split())
a = list(map(int, input().split()))
neg = []
pos = []
mod = 10**9+7
for i in range(n):
    if a[i] >= 0:
        pos.append(a[i])
    else:
        neg.append(a[i])
neg.sort()
pos.sort(reverse = True)
min_num = 0
good_num = 0
if k % 2 == 1 and len(pos) == 0:
    ans = 1
    neg.sort(reverse = True)
    for i in range(k):
        ans *= neg[i]
        ans %= mod
    print(ans)
else:
    #最大化するとき
    for i in range(0,k+1,2):
        #i個だけnegから取る。
        if i > len(neg) or k - i > len(pos):
            continue
        m = 0
        if i - 1 >= 0:
            m = abs(neg[i-1])
        if k-i-1 >= 0:
            m = min(m, pos[k-i-1])
        if m > min_num:
            min_num = m
            good_num = i
    ans = 1
    for i in range(good_num):
        ans *= neg[i]
        ans %= mod
    for i in range(k - good_num):
        ans *= pos[i]
        ans %= mod
    print(ans % mod)

### FIXED CODE ###

n , k = map(int, input().split())
a = list(map(int, input().split()))
neg = []
pos = []
mod = 10**9+7
for i in range(n):
    if a[i] >= 0:
        pos.append(a[i])
    else:
        neg.append(a[i])
neg.sort()
pos.sort(reverse = True)
if (len(pos) == 0 and k % 2 == 1) or n == k:
    ans = 1
    a.sort(reverse = True)
    for i in range(k):
        ans *= a[i]
        ans %= mod
    print(ans % mod)
else:
    #最大化するとき
    from collections import deque
    ans = 1
    neg_new = []
    for i in range(0, len(neg)//2):
        neg_new.append(neg[2*i] * neg[2*i+1])
    neg_new = deque(sorted(neg_new, reverse = True))
    pos = deque(pos)
    if k % 2 == 1:
        k -= 1
        ans = pos.popleft()
    else:
        ans = 1
    while k > 0:
        if len(pos) >= 2 and len(neg_new) >= 1:
            if pos[0] * pos[1] > neg_new[0]:
                ans *= pos.popleft() * pos.popleft()
            else:
                ans *= neg_new.popleft()
        elif len(pos) >= 2:
            ans *= pos.popleft() * pos.popleft()
        else:
            ans *= neg_new.popleft()
        k -= 2
        ans %= mod
    print(ans % mod)
a = input().split()

odd = int(a[0])
mean = int(a[1])
arr[0]*odd+mean
t = 0
c = 0

for i in range(0,odd+mean):
  if(i%2==0):
    arr[i] = i
  else:
    arr[i] = i
    
for i in range(0,odd+mean):
  for j in range(0,odd+mean):
    t = 0
    t = arr[i] + arr[j]
    if(t%2==0):
      c = c + 1
    else:
      continue
print(c)

### FIXED CODE ###

a = input().split()

m = int(a[0])
o = int(a[1])

t = (m*(m-1))/2
s = (o*(o-1))/2

print(int(t+s))
# -*- coding: utf-8 -*-
import numpy as np
A_ele = []
B_ele = []
ele = [int(x) for x in input().split()]
for i in range(ele[0]):
    A_ele.append([int(x) for x in input().split()])
A_ele = np.array(A_ele)
for i in range(ele[1]):
    B_ele.append([int(x) for x in input().split()])
B_ele = np.array(B_ele)
C_ele = A_ele.dot(B_ele)

for i in range(ele[0]):
    print(' '.join(map(str,C_ele[i])))


### FIXED CODE ###

# -*- coding: utf-8 -*-
A_ele = []
B_ele = []
C_ele = []
ele = [int(x) for x in input().split()]
for i in range(ele[0]):
    A_ele.append([int(x) for x in input().split()])
for i in range(ele[1]):
    B_ele.append([int(x) for x in input().split()])
for i in range(ele[0]):
    C_ele.append([])
    for j in range(ele[1]):
        for k in range(ele[2]):
            if j == 0:
                C_ele[i].append(0)
            C_ele[i][k] = C_ele[i][k] + A_ele[i][j] * B_ele[j][k]
for i in range(ele[0]):
    print(' '.join(map(str,C_ele[i])))
ans = False
for i in range(n):
  d1,d2 = map(int,input().split())
  if d1 == d2:
    conseq += 1
    if conseq >= 3:
      ans = True
  else:
    conseq = 0

if ans:
  print('Yes')
else:
  print('No')

### FIXED CODE ###

n = int(input())
conseq = 0
ans = False
for i in range(n):
  d1,d2 = map(int,input().split())
  if d1 == d2:
    conseq += 1
    if conseq >= 3:
      ans = True
  else:
    conseq = 0

if ans:
  print('Yes')
else:
  print('No')
x,y,z = sorted(map(int, input().split()))
print((b-a)+(c-b))

### FIXED CODE ###

x,y,z = sorted(map(int, input().split()))
print((y-x)+(z-y))
import sys

for line in sys.stdin:
    a,b,c,d,e,f=list(map(int,input().split()))
    x=(c*e-b*f)/(a*e-b*d)
    y=(a*f-c*d)/(a*e-b*d)
    print("{0:.3f} {1:.3f}".format(x,y))

### FIXED CODE ###

import sys

for line in sys.stdin:
    a,b,c,d,e,f=list(map(int,line.split()))
    x=(c*e-b*f)/(a*e-b*d)
    y=(a*f-c*d)/(a*e-b*d)
    print("{0:.3f} {1:.3f}".format(x+0.0,y+0.0))
from multiprocessing import Pool
from functools import reduce
from math import ceil

class Solver(object):
    def __init__(self):
        pass

    def solve(self):
        pass

memo = {}
def gcd(a, b):
    """a = bq + r"""
    if (a, b) not in memo:
        a, b = (max(a, b), min(a, b))
        if b == 0:
            memo[(a, b)] = a
        else:
            r = a % b
            memo[(a, b)] = gcd(b, r)
    return memo[(a, b)]

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


if __name__ == "__main__":
    n = int(input())
    a_s = list(map(int, input().split(" ")))
    gcd_a = int(reduce(gcd, a_s))
    lcm_a = int(reduce(lcm, a_s))
    def mod(x):
        return (lcm_a-1) % x
    fm = sum(map(mod, a_s))
    print(fm)


### FIXED CODE ###

from functools import reduce
import math
import fractions

memo = {}
def gcd(a, b):
    """a = bq + r"""
    if (a, b) not in memo:
        a, b = (max(a, b), min(a, b))
        if b == 0:
            memo[(a, b)] = a
        else:
            r = a % b
            memo[(a, b)] = gcd(b, r)
    return memo[(a, b)]

def steins_gcd(a, b) : 
    a = int(a)
    b = int(b)
  
    # GCD(0, b) == b; GCD(a, 0) == a, 
    # GCD(0, 0) == 0  
    if (a == 0) : 
        return b 
      
    if (b == 0) : 
        return a 
  
    # Finding K, where K is the  
    # greatest power of 2 that  
    # divides both a and b.  
    k = 0
      
    while(((a | b) & 1) == 0) : 
        a = a >> 1
        b = b >> 1
        k = k + 1
          
    # Dividing a by 2 until a becomes odd  
    while ((a & 1) == 0) : 
        a = a >> 1
  
    # From here on, 'a' is always odd.  
    while(b != 0) : 
          
        # If b is even, remove all  
        # factor of 2 in b  
        while ((b & 1) == 0) : 
            b = b >> 1
  
        # Now a and b are both odd. Swap if 
        # necessary so a <= b, then set  
        # b = b - a (which is even). 
        if (a > b) : 
          
            # Swap u and v. 
            a, b = b, a
  
        b = (b - a) 
      
    # restore common factors of 2  
    return int(a << k)

def another_gcd(x, y):
    while y != 0:
        (x, y) = (y, x % y)
    return x


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

if __name__ == "__main__":
    n = int(input())
    a_s = list(map(int, input().split(" ")))

    lcm_a = int(reduce(lcm, a_s))

    fm = 0
    for a in a_s:
        fm += (lcm_a-1) % a
    print(fm)
N,M = map(int,input().split())
Xi = list(map(int,input().split()))

Xi.sort()

Li = [Xi[i] - Xi[i-1] for i in range(1,len(Xi))]
Li.sort()

if N == M:
    print(0)
else:
    for _ in range(N-1):
        Li.pop(-1)
print(sum(Li))


### FIXED CODE ###

N,M = map(int,input().split())
Xi = list(map(int,input().split()))

Xi.sort()

Li = [Xi[i] - Xi[i-1] for i in range(1,len(Xi))]
Li.sort()

if N == M or N > M:
    print(0)
else:
    for _ in range(N-1):
        Li.pop(-1)
    print(sum(Li))
N,M=map(int,input().split())
a=[0 for i in range(N)]
b=[0 for i in range(N)]
for i in range(M):
    a[i],b[i]=map(int,input().split())
    a[i]-=1
    b[i]-=1
X=[0 for i in range(N)]
for i in range(M):
    X[a[i]]+=1
    X[b[i]]+=1
for i in range(N):
    if X[i]%2==1:
        print("NO")
        exit()
print("YES")


### FIXED CODE ###

N,M=map(int,input().split())
a=[0 for i in range(M)]
b=[0 for i in range(M)]
for i in range(M):
    a[i],b[i]=map(int,input().split())
    a[i]-=1
    b[i]-=1
X=[0 for i in range(N)]
for i in range(M):
    X[a[i]]+=1
    X[b[i]]+=1
for i in range(N):
    if X[i]%2==1:
        print("NO")
        exit()
print("YES")
a = input()
b = input()
print(a*b,2*a+2*b)

### FIXED CODE ###

a,b = map( int,raw_input().split() )
print a*b, 2*(a+b)
a = int(raw_input())
b = int(raw_input())

print(1)

### FIXED CODE ###

a = int(input())
b = int(input())
 
if (a != 1 and b != 1):
  print(1)
elif (a != 2 and b != 2):
  print(2)
else:
  print(3)
k = input()
s = input()
i = 0

while i < int(k):
	print(s[i])
    i = i + 1

### FIXED CODE ###

k = input()
s = input()
i = 0
l = int(k)
p = str()
 
while i < l and len(s) > l:
    p = p + s[i]
    i = i + 1
while i < len(s) and len(s) <=l:
    p = p + s[i]
    i = i + 1
if len(s) > l:
	print(p + '...')
else:
	print(p)
n,l=map(int,raw_input().split())
a=[]
for i in range(n):
    a.append(raw_input())
a.sort()
print ''.join(a)
    

### FIXED CODE ###

a,b,c=map(int,raw_input().split())
p=[]
p.append(a)
p.append(b)
p.append(c)
p.sort()
if p==[5,5,7]:
    print "YES"
else:
    print "NO"
N, A, B, C, D = map(int, input().split())
S = list(input())

A -= 1
B -= 1
C -= 1
D -= 1

if S[A:C] in '##' or S[B:D] in '##':
    print("No")
    exit()
if C > D:
    if S[B:D] in '...':
        print("Yes")
        exit()
    else:
        print("No")
        exit()
print("Yes")


### FIXED CODE ###

N, A, B, C, D = map(int, input().split())
S = input()

A -= 1
B -= 1
C -= 1
D -= 1

if '##' in S[A:C] or '##' in S[B:D]:
    print("No")
    exit()
if C > D:
    if  '...' not in S[B-1:D+2]:
        print("No")
        exit()
print("Yes")
def resolve():
    r1, c1, r2, c2 = map(int, input().split())

    def cmb(n, r, mod):
        if (r<0 or r>n):
            return 0
        r = min(r, n-r)
        return g1[n] * g2[r] * g2[n-r] % mod

    mod = 10**9+7 #出力の制限
    N = 10**6
    g1 = [1, 1] # 元テーブル
    g2 = [1, 1] #逆元テーブル
    inverse = [0, 1] #逆元テーブル計算用テーブル

    for i in range(2, N + 1):
        g1.append((g1[-1] * i ) % mod)
        inverse.append((-inverse[mod % i] * (mod//i)) % mod)
        g2.append((g2[-1] * inverse[-1]) % mod)

    print((cmb(r2+1+c2+1, r2+1, mod) - cmb(r1+c2+1, r1, mod) - cmb(r2+1+c1, c1, mod) + cmb(r1+c1, r1, mod)%mod))
resolve()

### FIXED CODE ###

def resolve():
    r1, c1, r2, c2 = map(int, input().split())
    r1 -= 1
    c1 -= 1

    def cmb(n, r, mod):
        if (r<0 or r>n):
            return 0
        r = min(r, n-r)
        return g1[n] * g2[r] * g2[n-r] % mod

    mod = 10**9+7 #出力の制限
    N = 3*10**6
    g1 = [1, 1] # 元テーブル
    g2 = [1, 1] #逆元テーブル
    inverse = [0, 1] #逆元テーブル計算用テーブル

    for i in range(2, N + 1):
        g1.append((g1[-1] * i) % mod)
        inverse.append((-inverse[mod % i] * (mod//i)) % mod)
        g2.append((g2[-1] * inverse[-1]) % mod)

    print((cmb(r2+c2+2, r2+1, mod) - cmb(r1+c2+2, r1+1, mod) - cmb(r2+c1+2, c1+1, mod) + cmb(r1+c1+2, r1+1, mod))%mod)
resolve()