Harryxun/stf_run huggingface dataset:
H=input()
W=input()
h=input()
w=input()

H=int(H)
W=int(W)
h=int(h)
w=int(w)

print(H*W-w*H-h*W+w*h)

### FIXED CODE ###

a,b = map(int,input().split())
c,d = map(int,input().split())
print((a-c)*(b-d))
list1=[]
a,b=map(int,input().split())
d=a
for i in range(d):
    a=abs(a-b)
    list1.append(a)
list2= sorted(list1, reverse=True)
print(list2[-1])

### FIXED CODE ###

n, k = map(int, input().split())
w = n%k
w2 = abs(w-k)
if w > w2:
    print(w2)
else:
    print(w)
s=input()
ams=0

for i in s:
  if s[i]==+:
    ans+=1
  else:
    ans-=1
    
print(ans)

### FIXED CODE ###

s=input()
print(s.count("+")-s.count("-"))
N = int(input())
A = 10000 - N
while True == True:
   A = A - 1000
    if A < 0:
      break
print(A+1000)


### FIXED CODE ###

N = int(input())
A = int(N/1000)
if A != N/1000:
	print(1000*(A+1)-N)
else:
  print(0)
n = int(input())
hint = []
for i in range(n):
    a, b, c = map(int, input().split())
    hint.append([a, b, c])
frag2 = False
for i in range(101):
    for j in range(101):
        ans_h = -1
        frag = False
        for k in range(n):
            a, b, c = hint[k][0], hint[k][1], hint[k][2]
            if c != 0:
                if ans_h == -1:
                    ans_h = abs(a-i)+abs(b-j)+c
                else:
                    if ans_h != abs(a-i)+abs(b-j)+c:
                        frag = True
                        break
                    else:
                        continue
        if not frag:
            answer = [i, j, ans_h]
            frag2 = True
            break
    if frag2:
        break

for i in range(3):
    print(answer[i], end=" ")

### FIXED CODE ###

import sys

def height(a, b, c, d, e):
    return abs(a-d)+abs(b-e)+c

n = int(input())
hint = []
q = 0
for i in range(n):
    a, b, c = map(int, input().split())
    hint.append([c, a, b])
hint.sort(reverse=True)

for i in range(101):
    for j in range(101):
        frag = True
        H = height(hint[0][1], hint[0][2], hint[0][0], i, j)
        for h in hint[1:]:
            if h[0] != max(-abs(h[1]-i)-abs(h[2]-j)+H,0):
                frag = False
                break
        if frag:
            print(i, j, H)
            sys.exit()
A, B = map(int, input().split())
print('Alice' if A>B or A==1 and B==2 'Draw' if A==B 'Bob')

### FIXED CODE ###

A, B = map(int, input().split()) 
if A==B:
    print('Draw')
elif A==1:
    print('Alice')
elif B==1:
    print('Bob')
elif A>B:
    print('Alice')
else:
    print('Bob')
n = int(input())
A = [int(input()) for _ in range(n)]
A.sort()
if n%2==1:print(max(2*sum(x[n-n//2:])-sum(x[n-n//2-2:n-n//2])-2*sum(x[:n-n//2-2]),-2*sum(x[:n//2])+sum(x[n//2:n//2+2])+2*sum(x[n//2+2:])))
else:print(-2*sum(A[:(n-2)//2])-A[(n-2)//2]+A[(n-2)//2+1]+2*sum(A[(n-2)//2+2:]))

### FIXED CODE ###

n = int(input())
A = [int(input()) for _ in range(n)]
A.sort()
if n%2==1:print(max(2*sum(A[n-n//2:])-sum(A[n-n//2-2:n-n//2])-2*sum(A[:n-n//2-2]),-2*sum(A[:n//2])+sum(A[n//2:n//2+2])+2*sum(A[n//2+2:])))
else:print(-2*sum(A[:(n-2)//2])-A[(n-2)//2]+A[(n-2)//2+1]+2*sum(A[(n-2)//2+2:]))
n = int(input())
graph = [[] for _ in range(n)]
for _ in range(n-1):
  a, b, c = map(int, input().split())
  a-=1
  b-=1
  graph[a].append((b, c))
  graph[b].append((a, c))
q, k = map(int, input().split())
k-=1
seen = [False]*n
l = [0]*n
def DFS(node, length):
  seen[node] = True
  for i, j in graph[node]:
    if seen[i]:
      continue
    l[i] = length+j
    DFS(i, length+j)

DFS(k, 0)
for _ in range(q):
  x, y = map(int, input().split())
  print(l[x-1]+l[y-1])

### FIXED CODE ###

import sys
n = int(input())
graph = [[] for _ in range(n)]
for _ in range(n-1):
    a, b, c = map(int, input().split())
    a-=1
    b-=1
    graph[a].append((b, c))
    graph[b].append((a, c))
q, k = map(int, input().split())
k -= 1
xy = []
for _ in range(q):
    x, y = map(int, input().split())
    x-=1
    y-=1
    xy.append((x, y))

def DFS(node, p_node, length):
    l[node] = length
    for i, j in graph[node]:
        if i==p_node:
            continue
        DFS(i, node, length+j)
sys.setrecursionlimit(2 * n)
l = [0]*n
DFS(k, -1, 0)
for x, y in xy:
    print(l[x]+l[y])
N = int(input())
A = []
for i in range(0,N):
    A.append(list(map(int,input().split())))

def dfs(d,h,pre):
    if d == N - 1:
        return h
    tmp = [0] 
    for idx,a in enumerate(A[d]):
        if idx != pre:
            res = dfs(d + 1,h + a,idx)
            tmp.append(res)
    return max(tmp)


print(dfs(-1,0,-1))

### FIXED CODE ###

N = int(input())
A = []
for i in range(0,N):
    A.append(list(map(int,input().split())))

dp = [[0 for _ in range(3)] for _ in range(N)]
for i in range(N):
    for j in range(3):
        if i == 0:
            dp[i][j]= A[i][j]
        else:
            tmp = [0] 
            for k in range(3):
                if j !=k:
                    tmp.append(dp[i-1][k])
            dp[i][j] = max(tmp) + A[i][j]
print(max(dp[-1]))
from collections import deque
N,M = map(int,input().split())

G = [[] for i in range(M)]
for i in range(M):
  x,y = map(int,input().split())
  G[x-1].append(y-1)
  G[y-1].append(x-1)

dist = [-1]*N #全頂点を未訪問に初期化(-1)で未訪問
que = deque([0])   #初期条件 (頂点 0 を初期ノードとする) 
dist[0] = 0 #0を訪問済み

#BFS 開始 (キューが空になるまで探索を行う)
while que:
    v = que.popleft() #キューから先頭要素を取る
    d = dist[v]
    #v から辿れる頂点をすべて調べる
    for w in G[v]:
        if dist[w] > -1:#探索済みの頂点は無視
            continue
        dist[w] = d + 1 #新たな頂点wについて距離情報を更新してキューに追加する
        que.append(w)
# 結果出力 (各頂点の頂点 0 からの距離を見る)
print("Yes")
for i in range(N-1):
  print(dist[i+1])

### FIXED CODE ###

n,m = map(int,input().split())
map_li = [[] for i in range(n)]
for i in range(m):
    a,b = map(int,input().split())
    a,b = a-1,b-1
    map_li[a].append(b)
    map_li[b].append(a)

ans_li = [-1]*n
queue=[0]
visited = [False]*n

while queue:
    x = queue.pop(0)
    for g in map_li[x]:
        if visited[g]==False:
            queue.append(g)
            if ans_li[g]==-1:
                ans_li[g]=x
                visited[g]=True 
if -1 in ans_li[1:]:
    print('No')
else:
    print('Yes')
    for ans in ans_li[1:]:
        print(ans+1)
#include<bits/stdc++.h>
using namespace std;
using ll = long long;

int main(){
    string s; cin >> s;
    int a, b;
    int ans = 1000;
    for(int i = 0; i < s.size() -2; i++){
        a = (s[i] - '0')*100 + (s[i+1] - '0')*10 + s[i+2];
        b = abs(a - 753);
        ans = min(b, ans);
    }
    cout << ans << endl;
}


### FIXED CODE ###

s = str(input())
ans = 1000
for i in range(len(s)-2):
    x = int(s[i:i+3])
    ans = min(ans, abs(x-753))
print(ans)
N=int(input())
S=list(input())
for i in S:
  S[i]=chr(ord(i)+N)
print(S)

### FIXED CODE ###

N=int(input())
S=list(input())
A=''
for i in S:
    if ord(i)+N<=ord('Z'):
        A+=chr(ord(i)+N)
    else:
        A+=chr(ord(i)+N-(ord('Z')-ord('A')+1))
print(A)
a = list( input().split())

if a[0]*a[1]<=a[2]:
  return a[0]*a[1]

if a[0]*a[1]>a[2]:
  return a[2]



### FIXED CODE ###

a = [int(i) for i in input().split()]

if a[0]*a[1]<=a[2]:
  print(a[0]*a[1])
  
else:
  print(a[2])
K = input().split()
N = int(K[0])
K = int(K[1])

count = 0
for b in range(K+1, N+1):
        count += int((N+K*(K+1)/2-(b-2)*(b-1)/2)/b)


if K != 0:
    for a in range(K, N+1):
        count += N-a
if K == 0:
        for a in range(1, N+1):
            count += N-a

print(count)

### FIXED CODE ###

sanmoji=[0]*3
for i in range(3):
    sanmoji[i] = input()[i]

moji=""
for i in range(3):
    moji += sanmoji[i]
print(moji)
a, b = map(int, input().split())
n = int(input())
l = sorted([list(map(int, input().split())) for _ in range(n)])
line = [0]*(max(l)[1]+2)
line[a] += 1
line[b] -= 1
for a, b in l:
    line[a] += 1
    line[b] -= 1
for i in range(len(line)-1):
    line[i+1] += line[i]
if line.count(2):
    print(1)
else:
    print(0)


### FIXED CODE ###

a, b = map(int, input().split())
n = int(input())
l = sorted([list(map(int, input().split())) for _ in range(n)])
line = [0]*1010
line[a] += 1
line[b] -= 1
for a, b in l:
    line[a] += 1
    line[b] -= 1
for i in range(1006):
    line[i+1] += line[i]
if line.count(2):
    print(1)
else:
    print(0)
N,L=map(int,input().split())
T=list(map(int,input().split()))
for i in range(N-1):
  if T[i]+T[i+1]>=L:
    K=i
    break
K=K+1
R=list(range(1,K))
R.extend(list(range(K+1,N)))
R.append(K)
R=list(map(str,R))
print(" ".join(R))

### FIXED CODE ###

K=10**10
import sys
N,L=map(int,input().split())
T=list(map(int,input().split()))
for i in range(N-1):
  if T[i]+T[i+1]>=L:
    K=i
    print("Possible")
    break
if K==10**10:
  print("Impossible")
  sys.exit()
K=K+1
R=list(range(1,K))
M=list(range(K+1,N))
M.reverse()
R.extend(M)
R.append(K)
for i in range(N-1):
  print(R[i])
import fractions
import math

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

if a>b:
  a,b = b,a
  
n=fractions.gcd(a,b)

t = [True]*(2*n)
d = [1]

for i in range(2, n):
  if t[i] is False:
    continue
  if n % i == 0:
    d.append(i)
    for j in range(i+1, n):
      if j%i==0:
        t[j] = False
print(len(d))

### FIXED CODE ###

def main():
  import fractions
  import math

  a,b = map(int,input().split())
  g = fractions.gcd(a,b)
  
  d = [1]
  num = 2

  while num**2 <= g:
    #print("num",num)
    if g%num == 0:
      d.append(num)
    while g%num == 0 and g>1:
      g = g//num
      #print(g)
    num += 1
  
  print(len(d) + (g > 1))

if __name__ == "__main__":
  main()
m = 0
t = 0
pre = H[0]
for hi in H[1:]:
    if pre > hi:
        t += 1
    else:
        m = max(m, t)
        t = 0
    pre = hi
    
m = max(m, t)
if N == 1:
    print(1)
else:
    print(m)

### FIXED CODE ###

N = int(input())
H = list(map(int, input().split()))

m = 0
t = 0

pre = H[0]
for hi in H[1:]:
    if pre >= hi:
        t += 1
    else:
        m = max(m, t)
        t = 0
    pre = hi

print(max(m, t))
A,B,C=map(str,input().split())
if B=="+":
  print(A+C)
else:
  print(A-C)

### FIXED CODE ###

A,B,C=map(str,input().split())
if B=="+":
  print(int(A)+int(C))
else:
  print(int(A)-int(C))
li=int(input().split())
print(li[0]*li[1]*1/2)

### FIXED CODE ###

li=list(map(int, input().split()))
print(int(li[0]*li[1]*1/2))
#coding: utf-8
N, M = map(int, input().split())
points = list(map(int, input().split()))
points.sort()
koma = [points[i+1] - points[i] for i in range(M-1)]
koma.sort()
print(sum(koma[:M-N]))

### FIXED CODE ###

#coding: utf-8
x, t = map(int, input().split())
print(x / t)
while True:
    n = int(input())
    a = sorted(list(map(int, input().split())))
    if n == 0:
        break
    ans = 1000
    for i in range(n - 1):
        j = a[i + 1] - a[i]
        if j < ans:
            ans = j
    print(ans)

### FIXED CODE ###

while True:
    n = int(input())
    if n == 0:
        break
    a = sorted(list(map(int, input().split())))
    ans = 1000001
    for i in range(n - 1):
        j = a[i + 1] - a[i]
        if j < ans:
            ans = j
    print(ans)
import math 
while 1 :
	e = int(raw_input())
	if e == 0:
		break
	z = 0
	m = e
	while math.pow(z,3) <= e:
		y = 0
		while y ** 2 <= e - math.pow(z,3):
			m = min(e + y + z - y**2 - math.pow(z,3), m)
			y += 1
		z += 1
	print int(m)

### FIXED CODE ###

from math import sqrt
while 1 :
	e = int(raw_input())
	if e == 0:
		break
	z = 0
	m = float("inf")
	while z ** 3 <= e:
		y = int(sqrt(e - z**3))
		m = min(m, e  - y**2 - z**3 + y + z)
		z += 1
	print int(m)
a,b=map(int,input().split())
k=int(input())
for i in range (k):
  if a > 0:
    a-=1
  elif　a<=0:
  	if b > 0:
      b-=1
print(a, b)

### FIXED CODE ###

a,b,k=map(int,input().split())
if a-k>=0:
    print(a-k,b)
elif a+b>=k:
    print(0,a+b-k)
else:
    print(0,0)
list=list(map(int,input().split()))
x=list[0]
k=list[1]
if list[0]>=list[1]:
  y=x%k
z=k-y
if z >=y:
  print(y)
else:
  print(z)
  

### FIXED CODE ###

list=list(map(int,input().split()))
x=list[0]
k=list[1]
if list[0]>=list[1]:
  x=x%k
z=abs(k-x)
if z >=x:
  print(x)
else:
  print(z)
n = int(input())
plcs = [list(map(int,input().split())) for _ in range(n)]
A = [0, 0, 0]
for i in range(n):
    A = [plcs[i][j] - A[j] for j in range(3)]
    if A[0] >= A[1] + A[2] and A[0] % 2 == (abs(A[1]) + abs(A[2])) % 2:
        continue
    else:
        print('No')
        exit()
print('Yes')

### FIXED CODE ###

num_list = list(map(int, input().split()))
if (num_list[0] * num_list[1]) % 2 == 1:
    print('Odd')
else:
    print('Even')
import random
from collections import defaultdict
from itertools import accumulate
import sys
input = sys.stdin.readline
n = int(input())
s = input().rstrip()
mod = (1<<61)-1
base = 1000+random.randint(0,100)
power = [1]
for i in range(1,n):
  power.append((power[-1]*base)%mod)
hvalue = [0]
for i in range(n):
  hvalue.append((hvalue[-1]+(ord(s[i])*power[i]))%mod)
def rollinghash(l,r):
  return ((hvalue[r]-hvalue[l])*power[n-r])%mod
def pun(i):
  dc = defaultdict(int)
  if i>n//2:
    return False
  for j in range(n-i+1):
    x = rollinghash(j,i+j)
    if dc[x]:
      rg =dc[x]
      if rg<=j:
        return True
      else:
        dc[x] = i+j
  return False
l=0
r=n//2+1
while l+1<r:
  mi=(l+r)//2
  if pun(mi):
    l=mi
  else:
    r=mi
print(l)

### FIXED CODE ###

x=input()
if x=="Sunny":
  print("Cloudy")
if x=="Cloudy":
  print("Rainy")
if x=="Rainy":
  print("Sunny")
#! /usr/bin/env python3

from fractions import gcd
from collections import Counter, deque, defaultdict
from heapq import heappush, heappop, heappushpop, heapify, heapreplace, merge
from bisect import bisect_left, bisect_right, bisect, insort_left, insort_right, insort
from itertools import accumulate, product, permutations, combinations, combinations_with_replacement

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


a = N // (A+B)
b = N % (A+B)
if b > A:
    b = A

print(int(a * A + b))

### FIXED CODE ###

#! /usr/bin/env python3

from fractions import gcd
from collections import Counter, deque, defaultdict
from heapq import heappush, heappop, heappushpop, heapify, heapreplace, merge
from bisect import bisect_left, bisect_right, bisect, insort_left, insort_right, insort
from itertools import accumulate, product, permutations, combinations, combinations_with_replacement

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


a = N // (A+B)
b = N % (A+B)
if b > A:
    b = A

print(int(a * A + b))
i,j = 0
while True:
    a, b = map(int, input().split())
    if a == 0 and b ==0:
        break
    for j in range(a+1):
        for i in range(b+1):
            print("#", end="")
        print()


### FIXED CODE ###

while True:
    H, W = map(int, input().split())
    if H == 0 and W == 0:
        break
    for i in range(H):
        print("#" * W)
    print()
from collections import deque
S = deque(list(input()))
q = int(input())
r = False
for _ in range(q):
    t = input().split()
    if len(t) == 1:
        r = not r
    else:
        t[1] = int(t[1]) - 1
        if (not t[1] and not r) or (t[1] and r):
            S.appendleft(t[2])
        else:
            S.append(t[2])
if r:
    print(''.join(S[::-1]))
else:
    print(''.join(S))


### FIXED CODE ###

from collections import deque
S = deque(list(input()))
q = int(input())
r = False
for _ in range(q):
    t = input().split()
    if len(t) == 1:
        r = not r
    else:
        t[1] = int(t[1]) - 1
        if (not t[1] and not r) or (t[1] and r):
            S.appendleft(t[2])
        else:
            S.append(t[2])
if r:
    S = list(S)
    print(''.join(S[::-1]))
else:
    print(''.join(S))
A, B = map(int, input().split())
print(max(A - 2 * B, 0)

### FIXED CODE ###

A, B = map(int, input().split())
print(max(A - 2 * B, 0))
N = int(input())
edges = [[] for _ in range(N)]
for _ in range(1, N):
    a, b, c = map(int, input().split())
    a, b = a - 1, b - 1
    edges[a].append([b, c])
    edges[b].append([a, c])

Q, K = map(int, input().split())
K -= 1
dist = [pow(10, 9) + 1] * N
dist[K] = 0


def dfs(s, before=-1):
    for edge in edges[s]:
        to = edge[0]
        c = edge[1]
        if to != before:
            dist[to] = dist[s] + c
            dfs(to, s)


dfs(K)
X = []
Y = []
for _ in range(Q):
    x, y = map(int, input().split())
    X.append(x-1)
    Y.append(y-1)

for i in range(Q):
    print(dist[X[i]] + dist[Y[i]])


### FIXED CODE ###

import sys

sys.setrecursionlimit(10 ** 7)

N = int(input())
edges = [[] for _ in range(N)]
for _ in range(1, N):
    a, b, c = map(int, input().split())
    a, b = a - 1, b - 1
    edges[a].append([b, c])
    edges[b].append([a, c])

Q, K = map(int, input().split())
K -= 1
dist = [pow(10, 9) + 1] * N
dist[K] = 0


def dfs(s, before=-1):
    for edge in edges[s]:
        to = edge[0]
        c = edge[1]
        if to != before:
            dist[to] = dist[s] + c
            dfs(to, s)


dfs(K)
for _ in range(Q):
    x, y = map(int, input().split())
    x, y = x-1, y-1
    print(dist[x] + dist[y])
import math

a, b = map(float, input().split())
a = int(a)
b = int(b * 100)
ans = str(a * b)

print(int(ans[:-2]))


### FIXED CODE ###

import math

a, b = map(str, input().split())
a = int(a)
b = int(b.replace('.', ''))
ans = str(a * b)

if len(ans) > 2:
    print(int(ans[:-2]))
else:
    print(0)
l = map(int, raw_input().split())
l1 = [int(i) for i in l]
sum = (l1[0] + l1[1])
print(int(math.log10(sum) + 1))

### FIXED CODE ###

while True:
    try:
        a,b = map(int, input().split())
        print(len(str(a+b)))
    except EOFError:
        break
import sys
sys.setrecursionlimit(200001)
N, Q = map(int, input().split())
paths = [list() for _ in range(N+1)] # paths[i] : 頂点iと繋がってる点を全て表す
for _ in range(N-1):
    a, b = map(int, input().split())
    paths[a].append(b)
    paths[b].append(a)
# ab = [list(map(int, input().split())) for _ in range(N-1)]
px = [list(map(int, input().split())) for _ in range(Q)]

ans = [0]*(N+1) # ans[i] : 頂点iについて答える値を格納

counters = [0]*(N+1) # そのノードの部分木に与える点数の総和を格納
for x in px:
    counters[x[0]] += x[1]

visit = [0]*(N+1) #dfsをする時に一度訪れた点に再訪しないための確認
def dfs(node, score, ans):
    visit[node] = 1 # 訪問したことを記録
    score += counters[node] # 自分の部分木に加点する分を加えて後世に残す
    ans[node] = score # 点数の記録
    for loof in paths[node]: # 自分と繋がってる各ノードについて
        if visit[loof] == 0: # まだ探索していなければ
            dfs(loof, score, ans) # 探索

dfs(1, 0, ans)
    

for i in range(1, N+1):
    print(ans[i])

### FIXED CODE ###

import sys
sys.setrecursionlimit(400000)
N, Q = map(int, input().split())
paths = [list() for _ in range(N+1)] # paths[i] : 頂点iと繋がってる点を全て表す
for _ in range(N-1):
    a, b = map(int, input().split())
    paths[a].append(b)
    paths[b].append(a)
# ab = [list(map(int, input().split())) for _ in range(N-1)]
px = [list(map(int, input().split())) for _ in range(Q)]

ans = [0]*(N+1) # ans[i] : 頂点iについて答える値を格納

counters = [0]*(N+1) # そのノードの部分木に与える点数の総和を格納
for x in px:
    counters[x[0]] += x[1]

visit = [0]*(N+1) #dfsをする時に一度訪れた点に再訪しないための確認
def dfs(node, score, ans):
    visit[node] = 1 # 訪問したことを記録
    score += counters[node] # 自分の部分木に加点する分を加えて後世に残す
    ans[node] = score # 点数の記録
    for loof in paths[node]: # 自分と繋がってる各ノードについて
        if visit[loof] == 0: # まだ探索していなければ
            dfs(loof, score, ans) # 探索

dfs(1, 0, ans)
    

for i in range(1, N+1):
    print(ans[i])
n,*a=map(int,input().split)

val=1
for x in a:
    val*=x

print(val if val<=10**18 else '-1')

### FIXED CODE ###


def main ():
    N = int(input())
    A = list(map(int,input().split()))

    if 0 in A:
        print(0)
        return

    prod = 1
    for a in A:
        prod *= a
        if prod > 1000000000000000000:
            print(-1)
            return

    print(prod)
    return

main ()
n, m = map(int, input().split())
sc = [list(map(int, input().split())) for i in range(m)]
sorted(sc)

def f1():
    if m == 0:
        return 0
    l = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
    for i in l:
        for j in range(m):
            if i == s[m][1]:
                return i
    return -1

def f2():
    if m == 0:
        return 10
    for i in range(1, m):
        if sc[i - 1][0] == sc[i][0] and sc[i - 1][1] != sc[i][1]:
            return -1
    l = [10 * i + j for i in range(1, 10) for j in range(0, 10)]
    sl = ["1", "0"]
    for i in range(m):
        sl[sc[i][0] - 1] = str(sc[i][1])
    s = sl[0] + sl[1]
    for i in l:
        if str(i) == s:
            return i
    return -1

def f3():
    if m == 0:
        return 10
    for i in range(1, m):
        if sc[i - 1][0] == sc[i][0] and sc[i - 1][1] != sc[i][1]:
            return -1
    l = [100 * i + 10 * j + k for i in range(1, 10) for j in range(0, 10) for k in range(0, 10)]
    sl = ["1", "0", "0"]
    for i in range(m):
        sl[sc[i][0] - 1] = str(sc[i][1])
    s = sl[0] + sl[1] + sl[2]
    for i in l:
        if str(i) == s:
            return i
    return -1

if n == 1:
    print(f1())
elif n == 2:
    print(f2())
else:
    print(f3())


### FIXED CODE ###

n, m = map(int, input().split())
sc = [list(map(int, input().split())) for i in range(m)]
sorted(sc)

def f1():
    if m == 0:
        return 0
    for i in range(1, m):
        if sc[i - 1][0] == sc[i][0] and sc[i - 1][1] != sc[i][1]:
            return -1
    """
    l = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
    for i in l:
        for j in range(m):
            if i == s[j][1]:
                return i
    return -1
    """
    return sc[0][1]

def f2():
    if m == 0:
        return 10
    for i in range(1, m):
        if sc[i - 1][0] == sc[i][0] and sc[i - 1][1] != sc[i][1]:
            return -1
    l = [10 * i + j for i in range(1, 10) for j in range(0, 10)]
    sl = ["1", "0"]
    for i in range(m):
        sl[sc[i][0] - 1] = str(sc[i][1])
    s = sl[0] + sl[1]
    for i in l:
        if str(i) == s:
            return i
    return -1

def f3():
    if m == 0:
        return 100
    for i in range(1, m):
        if sc[i - 1][0] == sc[i][0] and sc[i - 1][1] != sc[i][1]:
            return -1
    l = [100 * i + 10 * j + k for i in range(1, 10) for j in range(0, 10) for k in range(0, 10)]
    sl = ["1", "0", "0"]
    for i in range(m):
        sl[sc[i][0] - 1] = str(sc[i][1])
    s = sl[0] + sl[1] + sl[2]
    for i in l:
        if str(i) == s:
            return i
    return -1

if n == 1:
    print(f1())
elif n == 2:
    print(f2())
else:
    print(f3())
print(sum(range(int(input()+1))))

### FIXED CODE ###

N=int(input())
k=0
for s in range(1,N+1):
    k+=s
print(k)
def lcm(a):
    from fractions import gcd
    x = a[0]
    for i in range(1, len(a)):
        x = (x * a[i]) // gcd(x, a[i])
    return x
  
N = int(input())
lst = list(map(int, input().split()))
const = 10**9 + 7

L = lcm(lst)
answer = int(sum(map(lambda x: L/x % const, lst)) % const)

print(answer)


### FIXED CODE ###

def lcm(a):
    from fractions import gcd
    x = a[0]
    for i in range(1, len(a)):
        x = (x * a[i]) // gcd(x, a[i])
    return x
  
N = int(input())
lst = list(map(int, input().split()))
const = 10**9 + 7

def solve(arr):
    ab = lcm(arr)
    sum = 0
    for a in arr:
        sum += ab // a
    return sum % const

answer = solve(lst)

print(int(answer))
n=int(input())
for i in range(math.inf):
  if 2**i < n:
    continue
  else:
    print(2**(i-1))
    break

### FIXED CODE ###

n=int(input())
for i in range(99):
  if 2**i <= n:
    continue
  else:
    print(2**(i-1))
    break
a,b,c,d,e = map(int,input.split())

time = c*60+d-a*60-b

if time>=e:
  print(time-e)
else:
  print(0)

### FIXED CODE ###

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

time = c*60+d-a*60-b

if time>=e:
  print(time-e)
else:
  print(0)
r = int(input())
ans = "AGC"
if r < 1200:
    ans = "ABC"
else r < 2800:
    ans = "ARC"
print(ans)

### FIXED CODE ###

r = int(input())
ans = "AGC"
if r < 1200:
    ans = "ABC"
elif r < 2800:
    ans = "ARC"
print(ans)
# -*- coding: utf-8 -*-
"""
Created on Fri May 15 00:52:33 2020

@author: Kanaru Sato
"""

import fraction

def divnum(x,y,n):
    if x%n == 0:
        return y//n - x//n + 1
    else:
        return y//n - x//n

a,b,c,d = list(map(int,input().split()))
cd = (c*d)/fraction.gcd(c,d)
ans = divnum(a,b,c) + divnum(a,b,d) - divnum(a,b,cd)
print(int(b-a+1-ans))

### FIXED CODE ###

# -*- coding: utf-8 -*-
"""
Created on Fri May 15 00:52:33 2020

@author: Kanaru Sato
"""

import fractions

def divnum(x,y,n):
    if x%n == 0:
        return y//n - x//n + 1
    else:
        return y//n - x//n

a,b,c,d = list(map(int,input().split()))
cd = (c*d)//fractions.gcd(c,d)
ans = divnum(a,b,c) + divnum(a,b,d) - divnum(a,b,cd)
print(b-a+1-ans)