Harryxun/stf_run huggingface dataset:
N, M = map(int, input().split())
lis = [0]*N
SC = []
ERROR = False
for _ in range(M):
  sc = list(map(int, input().split()))
  SC.append(sc)
for i in range(len(SC)-1):
  for j in range(i+1,len(SC)):
    if SC[i][0] == SC[j][0] and SC[i][1] != SC[j][1]:
      ERROR = True
if ERROR:
  print(-1)
else:
  output = ''
  for i in range(M):
    lis[SC[i][0]-1] = SC[i][1]
  if N > 1 and lis[0] == 0:
    print(-1)
  else:
    for i in range(M):
      output += str(lis[i])
    print(int(output))

### FIXED CODE ###

N, M = map(int, input().split())
lis = [0]*N
SC = []
ERROR = False
for _ in range(M):
  sc = list(map(int, input().split()))
  SC.append(sc)
for i in range(len(SC)-1):
  for j in range(i+1,len(SC)):
    if SC[i][0] == SC[j][0] and SC[i][1] != SC[j][1]:
      ERROR = True
for i in range(len(SC)):
  if N > 1 and SC[i][0] == 1 and SC[i][1] == 0:
    ERROR = True
if ERROR:
  print(-1)
else:
  output = ''
  for i in range(M):
    lis[SC[i][0]-1] = SC[i][1]
  if N > 1 and lis[0] == 0:
    lis[0] = 1
  for i in range(N):
    output += str(lis[i])
  print(int(output))
N = int(input())

ALL = N*800
TIMES = N //15

print(All - (200*TIMES))

### FIXED CODE ###

N = int(input())
sum = 800 * N
otsuri = (N // 15) * 200

print(sum - otsuri)
a = int(input())
b = int(input())
c = int(input())
x = int(input())
count = 0
for i in range(a+1):
    for j in range(b+1):
        for k in range(c+1):
            if 500*i+100*j+50*k == x:
                count += 1 
print(count)

### FIXED CODE ###

x = int(input()) 
a = int(input())
b = int(input())
print((x-a)%b)
import math
N, K = list(map(int, input().split()))

def combo(n, k):
    x = math.factorial(n)//(math.factorial(k)*math.factorial(n-k))
    return x

for i in range(1,K+1):
    n = combo(N-K+1,i)
    k = n * combo(K-1,i-1)
    ans = k%(math.pow(10,9)+7)
    print("%d" %(ans))


### FIXED CODE ###

import math
N, K = list(map(int, input().split()))

def combo(n, k):
    x = math.factorial(n)//(math.factorial(k)*math.factorial(n-k))
    return x

for i in range(1,K+1):
    if N-K+1 < i or K-1 < i-1:
        print(0)
    else:
        k = combo(N-K+1,i) * combo(K-1,i-1)
        ans = k%(10**9+7)
        print("%d" %(ans))
s = input()
li = ["Sunny","Cloudy","Rainy"]
id = 0

if s == "Sunny":
  id = 1
elif s == "Cloudy:
  id = 2
else:
  id = 0
  
print(li[id])

### FIXED CODE ###

s = input()
li = ["Sunny","Cloudy","Rainy"]
id = 0

if s == "Sunny":
  id = 1
elif s == "Cloudy":
  id = 2
else:
  id = 0
  
print(li[id])
T = input()

S = T[ : : -1]
SL = list(S)

for i in range(len(SL) - 1):
    if SL[i] == '?' and SL[i+1] == 'P':
        SL[i] = 'D'
    elif SL[i] == '?' and SL[i+1] == 'D':
        SL[i] = 'P'
    elif SL[i] == '?' and SL[i+1] == '?':
        SL[i] = 'D'
        SL[i+1] = 'P'

SR = SL[ : : -1]
if SR[0] == '?' and SR[1] == 'P':
    SR[0] = 'D'
elif SR[0] == '?' and SR[1] == 'D':
    SR[0] = 'D'

print(''.join(SR))

### FIXED CODE ###

T = input()

S = T.replace('?', 'D')
print(S)
# C - Remainder Minimization 2019
import numpy as np

l, r = map(int, input().split())

a = np.arange(l, r+1)
a = a%2019
np.sort(a)

print(a[0]*a[1])

### FIXED CODE ###

# C - Remainder Minimization 2019
import numpy as np

l, r = map(int, input().split())

ans = 2019
for i in range(l,r):
    for j in range(i+1, r+1):
        ans = min(ans, (i*j)%2019)
        if ans==0:
            break
    else:
        continue
    break

print(ans)
import sys
import numpy as np

for i in sys.stdin:
    a,b,c,d,e,f=list(map(float, i.split()))
    A=np.matrix([[a,b],[d,e]])
    inv_A = np.linalg.inv(A)
    P=np.matrix([[c],[f]])
    X=inv_A.dot(P)
    print("{0:.3f} {1:.3f}".format(X[0,0], X[1,0]))

### FIXED CODE ###

import sys
#import numpy as np

for i in sys.stdin:
    a,b,c,d,e,f=list(map(float, i.split()))
    #A=np.matrix([[a,b],[d,e]])
    #inv_A = np.linalg.inv(A)
    #P=np.matrix([[c],[f]])
    #X=inv_A.dot(P)
    y = (f-(d*c)/a)/((a*e-d*b)/a)
    x = (c-b*y)/a
    print("{0:.3f} {1:.3f}".format(x,y))
r = int(input())
S=r*r
print(f'{S}')


### FIXED CODE ###

r = int(input())
S=r*r
print(int(S))
N, A, B, C, D = map(int, input().split())
S = input()
cou1 = 0
ans1 = 0
cou2 = 0
ans2 = []
if C < D:
    S1 = S[A: D-1]
    for i in S1:
        if i == "#":
            cou1 += 1
        else:
            ans1 = max(ans1, cou1)
            cou1 = 0
    if ans1 < 2:
        print("Yes")
    else:
        print("No")
else:
    S1 = S[A: C-1]
    S2 = S[B: D+1]
    for i in S1:
        if i == "#":
            cou1 += 1
        else:
            ans1 = max(ans1, cou1)
            cou1 = 0
    for j in S2:
        if i == ".":
            cou2 += 1
        else:
            ans2.append(cou2)
            cou2 = 0
    if ans1 < 2 and min(ans2) >= 3:
        print("Yes")
    else:
        print("No")

### FIXED CODE ###

N, A, B, C, D = map(int, input().split())
S = input()
Sac = S[A-1:C]
Sbd = S[B-1:D]
if "##" in Sac or "##" in Sbd:
    print("No")
elif C < D:
    print("Yes")
elif "..." in Sbd:
    print("Yes")
else:
    s1 = S[A-1:B-1] + "#" + S[B:C]
    s2 = S[A-1:D-1] + "#" + S[D:C]
    if "##" not in s1 or "##" not in s2:
        print("Yes")
    else:
        print("No")
S=input()
if s=="ABC":
    ans=ARC
else:
    ans=ABC
print(ans)

### FIXED CODE ###

S=input()
if S=="ABC":
    ans="ARC"
else:
    ans="ABC"
print(ans)
S=input()
QN=int(input())
front=''
rear=''
rev=False

for i in range(QN):
    op=input()
    if op[0]=='1':
        rev=not(rev)
    else:
        if op[2]=='1':
            if rev:
                rear+=[4]
            else:
                front+=op[4]
        else:
            if rev:
                front+=op[4]
            else:
                rear+=op[4]

if rev:
    print(rear[::-1]+S+front)
else:
    print(front[::-1]+S+rear)

### FIXED CODE ###

S=input()
QN=int(input())
front=''
rear=''
rev=False

for i in range(QN):
    op=input()
    if op[0]=='1':
        rev=not(rev)
    else:
        if op[2]=='1':
            if rev:
                rear+=op[4]
            else:
                front+=op[4]
        else:
            if rev:
                front+=op[4]
            else:
                rear+=op[4]

if rev:
    print(rear[::-1]+S[::-1]+front)
else:
    print(front[::-1]+S+rear)
n=int(input())
print(1000 - (input % 1000))

### FIXED CODE ###

N = int(input())
mod = N % 1000
res = 0 if mod == 0 else 1000 - mod
print(res)
from fractions import gcd

n=int(input())
t=[int(input()) for i in range(n)]

for i in range(0,n-1):
    lcm=(t[i]*t[i+1]//gcd(t[i],t[i+1]))
    t[i+1]=lcm
print(lcm)

### FIXED CODE ###

from fractions import gcd

n=int(input())
t=[int(input()) for i in range(n)]

lcm=t[0]
for i in range(n-1):
    lcm=(t[i]*t[i+1]//gcd(t[i],t[i+1]))
    t[i+1]=lcm
print(lcm)
n,k,q, *aa = map(int, open(0).read().split())

scores = [k-q]*n

for a in aa:
    scores[a] += 1

for s in scores:
    if s<=0:
        print('No')
    else:
        print('Yes')

### FIXED CODE ###

n,k,q, *aa = map(int, open(0).read().split())

scores = [k-q]*n

for a in aa:
    scores[a-1] += 1

for s in scores:
    if s<=0:
        print('No')
    else:
        print('Yes')
n=int(input())

num,a,b=0,0,0

for i in range(n):
  t,x,y=map(int,input().split())
  num,a,b=abs(t-num),abs(x-a),abs(y-b)
  su=a+b
  if num<su:
    ans="No"
    break
  else:
    if num%su==0:
      ans="Yes"
    elif su==0 and num%2==0:
      ans="Yes"
    else:
      ans="No"
      
print(ans)

### FIXED CODE ###

n=int(input())

num,a,b=0,0,0

for i in range(n):
  t,x,y=map(int,input().split())
  num,a,b=abs(t-num),abs(x-a),abs(y-b)
  su=a+b
  if num>=su and num%2 == su%2:
    ans="Yes"
  else:
    ans="No"
    break
      
print(ans)
import math
a, b, x = map(int, input().split())

if a**2*b == x:
    print(0)
if x > (a**2*b)/2:
    p = a/(2*(b-x/a**2))
    print(90-math.degrees(math.atan(p)))
else:
    p = 2*x/(a*b**2)
    print(90-math.degrees(math.atan(p)))


### FIXED CODE ###

import math
a, b, x = map(int, input().split())

if a**2*b == x:
    print(0)
elif x > (a**2*b)/2:
    p = a/(2*(b-x/a**2))
    print(90-math.degrees(math.atan(p)))
else:
    p = 2*x/(a*b**2)
    print(90-math.degrees(math.atan(p)))
from collections import defaultdict

inf = float('inf')

n, k = map(int, input().split())

dd = defaultdict(list)
for _ in range(n):
    t, d = map(int, input().split())
    dd[t].append(d)

for key in dd:
    dd[key].sort(reverse=True)

h1 = []
h2 = []
for key in dd:
    for i, d in enumerate(dd[key]):
        if i == 0:
            h1.append(d)
        else:
            h2.append(d)

h1.sort(reverse=True)
h2.sort(reverse=True)

c1 = [0]
for hh in h1:
    c1.append(c1[-1] + hh)
if len(c1) < k:
    c1.extend([-inf] * (k - len(c1) + 1))

c2 = [0]
for hh in h2:
    c2.append(c2[-1] + hh)
if len(c2) < k:
    c2.extend([-inf] * (k - len(c2) + 1))

# print(h1, c1)
# print(h2, c2)

ans = -inf
for kind in range(1, k + 1):
    # print(kind, c1[kind], c2[k - kind])
    ans = max(ans, c1[kind] + c2[k - kind] + kind * kind)
print(ans)


### FIXED CODE ###

# 解説放送

N, K = map(int, input().split())

e = [None for _ in range(N + 1)] # 種別の美味しさ
t_kinds_count = 0 # 何種類あるか
rest_length = 0 # 各種の2番手以降の個数の総数

tops = [] # 各種の最大美味しさ
c_tops = [0] # 各種の最大美味しさの累積和
rests = [] # 各種の2番手以降
c_rests = [0] # 各種の2番手以降の累積和

for _ in range(N):
    t, d = map(int, input().split())
    if e[t] is None:
        e[t] = []
        t_kinds_count += 1
    e[t].append(d)


for t in range(1, N + 1):
    if e[t] is None:
        continue
    e[t].sort(reverse=True)
    tops.append(e[t][0])
    rests.extend(e[t][1:])

tops.sort(reverse=True)
rests.sort(reverse=True)

s = 0
for tt in tops:
    s += tt
    c_tops.append(s)

s = 0
for rr in rests:
    s += rr
    c_rests.append(s)
    rest_length += 1

ans = 0
for yy in range(1, min(t_kinds_count, K) + 1):
    if 0 <= K - yy <= rest_length:
        ans = max(ans, c_tops[yy] + c_rests[K - yy] + yy * yy)

# print(e)
# print(tops)
# print(c_tops)
# print(rests)
# print(c_rests)
print(ans)
n=int(input())
s=input()

if n % 2:
  print("No")
  exit()

half=s[0:n//2]
print("Yes" if half+half==s else "No)

### FIXED CODE ###

n = int(input())
s = input()
if n % 2:
    print("No")
    exit()
half = s[0:n // 2]
print("Yes" if s == half + half else "No")
a=input()
m=a.split()
N=m[0]
M=m[1]
if M==N:
  print 'Yes'
else:
  print 'No'

### FIXED CODE ###

a=raw_input()
m=a.split()
N,M=map(int,m)
if N==M:
  print 'Yes'
else:
  print 'No'
d, t, s = map(int,input().split())

arrival = d/s

if arrival > t:
  print('no')
 else:
   print('yes')


### FIXED CODE ###

d,t,s = map(int, input().split())

if d/s > t:
  print('No')
else:
  print('Yes')
S = int(input())
W = int(input())
if W >= S:
  print("unsafe")
else:
  print("safe")

### FIXED CODE ###

s, w = map(int, input().split())
 
if s <= w:
  print('unsafe')
else:
  print('safe')
h, w = map(int, input().split())

a = [input() for i in range(h)]

for i in range(h):
  if "#" not in a[i]:
    del a[i]

aT = zip(*a)

for i in range(len(aT)):
  if "#" not in aT[i]:
    del aT[i]

a = zip(*aT)

for i in a:
  print(i)

### FIXED CODE ###

h, w = map(int, input().split())

a = [list(input()) for i in range(h)]

a = [x for x in a if "#" in x]

aT = list(zip(*a))
aT = [x for x in aT if "#" in x]

a = list(zip(*aT))

for i in a:
    print("".join(i))
#!/usr/bin/python
# -*- coding: utf-8 -*-

import sys

if __name__ == '__main__':
    num = int(sys.argv[1])
    print num ** 3

### FIXED CODE ###

n=input()
print n**3
print(" ".jpin(input().split(",")))

### FIXED CODE ###

print(" ".join(input().split(",")))
n = int(input())
a = []
for i in range(n):
    s, p = list(map(int, input().split()))
    a.append((s, -int(p), i))
a.sort()

for _, _, i in a:
    print(i + 1)


### FIXED CODE ###

n = int(input())
a = []
for i in range(n):
    s, p = input().split()
    a.append((s, -int(p), i))
a.sort()

for _, _, i in a:
    print(i + 1)
class BinaryTree():
    def __init__(self):
        self.key = None
        self.parent = None
        self.left = None
        self.right = None

def insert(z):
    global root
    y = None
    x = root
    while x != None:
        y = x
        if z.key < x.key:
            x = x.left
        else:
            x = x.right
    z.parent = y
    if y == None:
        root = z
    elif z.key < y.key:
        y.left = z
    else:
        y.right = z

def inoder(x):
    if x == No???e: return []
    else:
        r = []
        r.extend(inoder(x.left))
        r.append(str(x.key))
        r.extend(inoder(x.right))
    return r

def preoder(x):
    if x == None: return []
    else:
        r = []
        r.append(str(x.key))
        r.extend(preoder(x.left))
        r.extend(preoder(x.right))
    return r

def show(x):
    print(" ".join(inoder(x)))
    print(" ".join(preoder(x)))


root = None
n = int(input())
for i in range(n):
    L = input().split()
    if L[0] == "insert":
        T = BinaryTree()
        T.key = int(L[1])
        insert(T)
    else:
        show(root)

### FIXED CODE ###

#BinarySearchTree
class TreeNode():
    def __init__(self):
        self.key = None
        self.parent = None
        self.left = None
        self.right = None
    def inoder(self):
        r=[]
        if self.left:
            r += self.left.inoder()
        r += [self.key]
        if self.right:
            r += self.right.inoder()
        return r

    def preoder(self):
        r = [self.key]
        if self.left:
            r += self.left.preoder()
        if self.right:
            r += self.right.preoder()
        return r

class BinaryTree():
    def __init__(self):
        self.root = None

    def insert(self, z):
        y = None
        x = self.root
        while x != None:
            y = x
            if z.key < x.key:
                x = x.left
            else:
                x = x.right
        z.parent = y
        if y == None:
            self.root = z
        elif z.key < y.key:
            y.left = z
        else:
            y.right = z

    def show(self):
        x = self.root
        print(" " + " ".join(map(str, self.root.inoder())))
        print(" " + " ".join(map(str, self.root.preoder())))
 
 
n = int(input())
Tree = BinaryTree()
for i in range(n):
    L = input().split()
    if L[0] == "insert":
        Node = TreeNode()
        Node.key = int(L[1])
        Tree.insert(Node)
    else:
        Tree.show()
n = int(input())
d = list(map(int, input().split()))
m = int(input())
t = list(map(int, input().split()))
d.sort()
t.sort()

l = [0] * (d[-1] + 1)
for i in d:
    l[i] += 1

for i in t:
    l[i] -= 1

l.sort()
if l[0] >= 0:
    print("YES")
else:
    print("NO")

### FIXED CODE ###

n = int(input())
d = list(map(int, input().split()))
m = int(input())
t = list(map(int, input().split()))
d.sort()
t.sort()

a = 0
b = 0
cnt = 0
last = t[-1]
for i in range(a, n):
    for j in range(b, m):
        if d[i] == t[j]:
            cnt += 1
            b = j+1
            break
        elif d[i] < t[j]:
            break

if cnt == m:
    print("YES")
else:
    print("NO")
a=list(map(int,input().split()))
print(str(a.index(0))+1)

### FIXED CODE ###

a=list(map(int,input().split()))
print(a.index(0)+1)
n,k = map(int,input().split())
l = []
for _ in range(n):
    a = int(input())
    l.append(a)

ans = 10**9
l.sort()
for i in range(n-k+1):
    tmp = max(l[i:k+i]) - min(l[i:k+i])
    if tmp < ans:
        ans = tmp

print(ans)

### FIXED CODE ###

d = int(input())

if d == 22:
    print("Christmas Eve Eve Eve")
elif d == 23:
    print("Christmas Eve Eve")
elif d == 24:
    print("Christmas Eve")
else:
    print("Christmas")
import sys

def resolve():
    read = sys.stdin.read
    readline = sys.stdin.readline

    N, M = map(int, readline().split())
    a = [int(x) for x in read().split()]
    
    dp = [0] * N * 2
    dp[0] = 1
    for i in range(N):
        one = i + 1
        two = i + 2
        now = dp[i]
        if one not in a:
            dp[one] += now
        if two not in a:
            dp[two] += now
    print(dp[N] % 1_000_000_007)


resolve()


### FIXED CODE ###

def resolve():
    import sys
    
    read = sys.stdin.read
    readline = sys.stdin.readline

    N, M = map(int, readline().split())
    a = set(int(x) for x in read().split())
    
    dp = [0] * (N + 2)
    dp[0] = 1

    for i in range(N):
        now = dp[i]
        if i + 1 not in a:
            dp[i + 1] += now
        if i + 2 not in a:
            dp[i + 2] += now

    print(dp[N] % 1_000_000_007)


resolve()
B = np.array(B)
if np.sum(A) < np.sum(B):
    print(-1) 
else:
    sub_a_b = A-B
    p_sub = sorted(list(sub_a_b[sub_a_b>0]),reverse = True)
    # print(p_sub)  
    m_sub = list(sub_a_b[sub_a_b<0])
    max_counter = p_sub[0]
    m_sub_sum = abs(sum(m_sub))
    count = len(m_sub) 
    # print(p_sub[0:1])
    if max_counter >= m_sub_sum:
        print(count)
    else:
        count+=1

        for i in range(len(p_sub)):
            if max_counter >= m_sub_sum:
                print(count)
                exit()
            else:
                max_counter += p_sub[i+1]
                count += 1

### FIXED CODE ###

import numpy as np
n = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
A = np.array(A)
B = np.array(B)
if np.sum(A) < np.sum(B):
    print(-1) 
else:
    sub_a_b = A-B
    p_sub = sorted(list(sub_a_b[sub_a_b>0]),reverse = True)
    # print(p_sub)  
    m_sub = list(sub_a_b[sub_a_b<0])
    max_counter = p_sub[0]
    m_sub_sum = abs(sum(m_sub))
    count = len(m_sub) 
    # print(p_sub[0:1])
    # print(type(list(np.where(sub_a_b<0)[0])))
    # print(np.array([]))
    if list(np.where(sub_a_b<0)[0]) == [] :
        print(0)
        exit()
    else:
        count+=1

        for i in range(len(p_sub)):
            if max_counter >= m_sub_sum:
                print(count)
                exit()
            else:
                max_counter += p_sub[i+1]
                count += 1
i=input
n=int(i())
a=eval('eval("list(map(int,i().split())),"*int(i())),'*n)
#print(max(all([y==i>>x-1&1for j,t in enumerate(a)if i>>j&1for x,y in t]+[1])*bin(i).count('1')for i in range(2**n)))

### FIXED CODE ###

n=int(input())
a=[[list(map(int,input().split()))for _ in'_'*int(input())]for _ in'_'*n]
m=0
for i in range(2**n):
  *s,=map(int,bin(i)[2:].zfill(n))
  f=1
  for j,t in enumerate(a):
    if s[~j]:
      for x,y in t:f&=s[-x]==y
  m=max(m,sum(s)*f)
print(m)
import math, string, itertools, fractions, heapq, collections, re,  array, bisect, sys, random, time, copy, functools


sys.setrecursionlimit(10**7)
inf = 10 ** 20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)]


def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)


N, M = LI()
P, Y = [], []
for i in range(M):
    j, k = LI()
    P.append(j)
    Y.append(k)

#  N = 10**5
#  M = 10**5
#  P, Y = [], []
#  for i in range(M):
#      P.append(10)
#      Y.append(i*100)

city_records = [[]for i in range(10**5)]
for p, y in zip(P, Y):
    #  print('p,y', p, y)
    #  print('city_records[p]', city_records[p])
    city_records[p].append([p, y])

#  print(city_records)

for i in range(len(city_records)):
    if city_records[i] == []:
        continue
    city_records[i].sort(key=lambda x: x[1])

#  print(city_records)

for p, y in zip(P, Y):
    #  order = (city_records[p].index([p, y])) + 1
    order = bisect.bisect_left(city_records[p], [p, y]) + 1
    print(str(p).zfill(6) + str(order).zfill(6))


### FIXED CODE ###

import math, string, itertools, fractions, heapq, collections, re,  array, bisect, sys, random, time, copy, functools


sys.setrecursionlimit(10**7)
inf = 10 ** 20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)]


def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)


N, M = LI()
P, Y = [], []
for i in range(M):
    j, k = LI()
    P.append(j)
    Y.append(k)

#  N = 10**5
#  M = 10**5
#  P, Y = [], []
#  for i in range(M):
#      P.append(10)
#      Y.append(i*100)

city_records = [[]for i in range(10**6)]
for p, y in zip(P, Y):
    #  print('p,y', p, y)
    #  print('city_records[p]', city_records[p])
    city_records[p].append(y)

#  print(city_records)

for i in range(len(city_records)):
    if city_records[i] == []:
        continue
    city_records[i].sort()

#  print(city_records)

for p, y in zip(P, Y):
    #  order = (city_records[p].index(y)) + 1
    order = bisect.bisect_left(city_records[p], y) + 1
    print(str(p).zfill(6) + str(order).zfill(6))
import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x+"\n")


M = 10**9+7 # 出力の制限
N = 10**6+2 # 必要なテーブルサイズ

g1 = [None] * (N+1) # 元テーブル
g2 = [None] * (N+1) #逆元テーブル
inverse = [None] * (N+1) #逆元テーブル計算用テーブル
g1[0] = g1[1] = g2[0] = g2[1] = 1
inverse[0], inverse[1] = [0, 1] 

for i in range( 2, N + 1 ):
    g1[i] = ( g1[i-1] * i ) % M 
    inverse[i] = ( -inverse[M % i] * (M//i) ) % M # ai+b==0 mod M <=> i==-b*a^(-1) <=> i^(-1)==-b^(-1)*aより
    g2[i] = (g2[i-1] * inverse[i]) % M 

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

ans = 0
r1,c1,r2,c2 = map(int, input().split())
for c in range(c1, c2+1):
    ans += cmb(r2+c, r2, M) - cmb(r1-1+c, r1-1, M)
for r in range(r1, r2+1):
    ans += cmb(c2+r, c2, M) - cmb(c1-1+r, c1-1, M)
    
# for r in range(r1+1, r2+1):
#     val = cmb(r+c1, r, M)
#     ans += val * (c2-c1) * (r2-r+1)
#     ans += val
#     ans %= M
# ans += cmb(r1+c1, r1, M)
# for c in range(c1+1, c2+1):
#     val = cmb(r1+c, c, M)
#     ans += val * (r2-r1) * (c2-c+1)
#     ans += val
#     ans %= M
print(ans%M)

### FIXED CODE ###

import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x+"\n")

M = 10**9+7 # 出力の制限
N = 2*10**6+4 # 必要なテーブルサイズ

g1 = [None] * (N+1) # 元テーブル
g2 = [None] * (N+1) #逆元テーブル
inverse = [None] * (N+1) #逆元テーブル計算用テーブル
g1[0] = g1[1] = g2[0] = g2[1] = 1
inverse[0], inverse[1] = [0, 1] 

for i in range( 2, N + 1 ):
    g1[i] = ( g1[i-1] * i ) % M 
    inverse[i] = ( -inverse[M % i] * (M//i) ) % M # ai+b==0 mod M <=> i==-b*a^(-1) <=> i^(-1)==-b^(-1)*aより
    g2[i] = (g2[i-1] * inverse[i]) % M 

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

ans = 0
r1,c1,r2,c2 = map(int, input().split())
for c in range(c1, c2+1):
    ans += cmb(r2+c, r2, M) - cmb(r1-1+c, r1-1, M)
for r in range(r1, r2+1):
    ans += cmb(c2+r, c2, M) - cmb(c1-1+r, c1-1, M)
    
# for r in range(r1+1, r2+1):
#     val = cmb(r+c1, r, M)
#     ans += val * (c2-c1) * (r2-r+1)
#     ans += val
#     ans %= M
# ans += cmb(r1+c1, r1, M)
# for c in range(c1+1, c2+1):
#     val = cmb(r1+c, c, M)
#     ans += val * (r2-r1) * (c2-c+1)
#     ans += val
#     ans %= M
print(ans%M)