Go: package main

import "fmt"

func main() {
	var sTime, fTime, exists, eSTime, eFTime int

	fmt.Scan(&sTime, &fTime)
	fmt.Scan(&exists)

	var flag bool

	for i := 0; i < exists; i++ {
		fmt.Scan(&eSTime, &eFTime)

		if sTime > eSTime && sTime < eFTime {
			flag = true
		}
		if fTime > eSTime && fTime < eFTime {
			flag = true
		}
		if eSTime >= sTime && eFTime <= fTime {
			flag = true
		}
	}

	if flag {
		fmt.Println(1)
	} else {
		fmt.Println(0)
	}
}

Python: a,b = map(int,input().split())
N = int(input())
n = 1009
reserve = [0]*n

#新しい予約
b = b-1
reserve[a] += 1
reserve[b+1] -= 1

#既存の予約
for i in range(N):
    s,f = map(int,input().split())
    f = f-1
    reserve[s] += 1
    reserve[f+1] -= 1

judge = 0
for i in range(n):
 if(i != 0): reserve[i] += reserve[i-1]
 if(reserve[i] >= 2): judge = 1

#print(reserve)
print(judge)

Python: a, b= map(int,input().split())
N = int(input())
 
for i in range(N):
  c, d = map(int,input().split())
  if d <= a or b <= c:continue
  else:
    print("1")
    exit()
print("0")

Python: a,b = map(int,list(input().split(" ")))
n = int(input())
c = [0 for i in range(1002)]
ans = 0
c[a]+=1
c[b]-=1
for i in range(n):
      s,f = map(int,list(input().split(" ")))
      c[s]+=1
      c[f]-=1
for i in range(1001):
      c[i+1] += c[i]
      if(c[i]>1):
            ans = 1
print(ans)

Python: a,b = map(int,list(input().split(" ")))
n = int(input())
c = [0 for i in range(1002)]
ans = 0
c[a]+=1
c[b]-=1
for i in range(n):
      s,f = map(int,list(input().split(" ")))
      c[s]+=1
      c[f]-=1
for i in range(1002):
      c[i+1] += c[i]
      if(c[i]>1):
            ans = 1
print(ans)

Python: 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)

Python: b,e = map(int,input().split())
r = [0]*1000
for _ in range(int(input())):
 b1,e2 =map(int,input().split())
 for x in range(b1,e2):
     r[x] = 1
def check():
 for x in range(b,e):
   if r[x] ==1:
     return 1
 return 0
print(check())

Python: import numpy
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
if list(numpy.cumsum(line)).count(2):
    print(1)
else:
    print(0)

Python: s = input()
print(s)

Python: a,b = [int(i) for i in input().split()]
N = int(input())

ans = 0

for l in range(N):
    s,f = [int(i) for i in input().split()]
#    if f <= a or b <= s:
    if a < f and s < b:
        ans = 1
        break

print(ans)

Python: a, b = map(int,input().split())
t = []
for _ in range(int(input())):
    t += list(map(int, input().split()))
print(sum(i <= a for i in t) % 2 or sum(i >= b for i in t) % 2)

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

ans = 0

for i in range(n):
   A,B = map(int,input().split())

   if not (A >= b or B<= a):
       ans = 1
       
 
print(ans)

Python: a, b = map(int,input().split())
t = []
for _ in range(int(input())):
    t += list(map(int, input().split()))
print(1 if sum(i <= a for i in t) % 2 or sum(i >= b for i in t) % 2 or sum(a < i and i < b for i in t) else 0)

Python: a,b = list(map(int, input().split()))
n = int(input())
sf = [list(map(int, input().split())) for _ in range(n)]

ans = 0
li = [True] * 1000
sf.sort()
for i in sf:
    for j in range(i[0], i[1]):
        li[j] = False
for i in range(a,b):
    if li[i] == False:
        ans = 1
        break


print(ans)

Python: a, b= map(int,input().split())
N = int(input())

for i in range(N):
  c, d = map(int,input().split())
  if d <= a or b <= c:continue
  else:
    print("1")
    exit()
print("0")

Python: a, b =map(int,input().split())
n=int(input())
m=0
for i in range(n):
    c,d=map(int,input().split())
    if d<=a or c>=b:
        pass
    else:
        m=m+1
if m != 0:
    print(1)
else:
    print (0)

Python: a, b = map(int, input().split())
for i in range(int(input())):
    s, f = map(int, input().split())
    if s <= a and a < f\
    or s < b and b <= f:
        print("1")
        break
else:
    print("0")

Python: time=[0]*1001
a,b=list(map(int,input().split()))
n=int(input())
for i in range(n):
    s,f=list(map(int,input().split()))
    time[s:f]=[1]*(f-s)
if sum(time[a:b])==0:print("0")
else:print("1")

Python: a,b=map(int,input().split())
c=0
for i in range(int(input())):
    s,t=map(int,input().split())
    if not (t<=a or b<=s):
        c=1
print(c)

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

res = []
for _ in range(n):
    s, f = map(int, input().split())
    res.append([s, f])

for r in res:
    if r[1] > a and r[0] < b:
        print(1)
        break
else:
    print(0)

Python: a, b = map(int,input().split())
t = []
for _ in range(int(input())):
    t += list(map(int, input().split()))
print(1 if sum(i <= a for i in t) % 2 or sum(i >= b for i in t) % 2 or (a < i and i < b for i in t) else 0)

Python: a, b = map(int, input().split())
for i in range(int(input())):
    s, f = map(int, input().split())
    if s <= a and a < f\
    or s < b and b <= f:
        print("1")
        break
else:
    print("0")

Python: a, b = map(int, input().split())
for i in range(int(input())):
    s, f = map(int, input().split())
    if s <= a and a < f\
    or s < b and b <= f:
        print("1")
        break
    else:
        print("0")

Python: b,e = map(int,input().split())
r = [0]*1000
for _ in range(int(input())):
  b1,e2 =map(int,input().split())
  for x in range(b1,e2):
      r[x] = 1
def check():
  for x in range(b,e):
    if r[x] ==1:
      return 1
  return 0
print(check())

Python: a, b = map(int, input().split())
N = int(input())
flag = 0
for _ in range(N):
    s, f = map(int, input().split())
    if f > a or s < b:
        flag = 1
        break
print(1 if flag else 0)

Python: a,b=map(int,input().split())
c=0
for i in range(int(input())):
    s,t=map(int,input().split())
    if not (t<=a or b<=s):
        c=1
print(c)

Python: A, B = map(int, input().split())
N = int(input())
SF = [[0, 0], [1000, 1000]]
for _ in range(N):
	SF.append(list(map(int, input().split())))
SF.sort()
R = 1
for i in range(N+1):
	if SF[i][1]<=A and B<=SF[i+1][0]:
		R = 0
		break
print(R)

Python: def solve():
    from sys import stdin
    f_i = stdin
    
    a, b = map(int, f_i.readline().split())
    N = int(f_i.readline())
    for i in range(N):
        s, f = map(int, f_i.readline().split())
        if b <= s or f <= a:
            pass
        else:
            print(1)
            break
    else:
        print(0)

solve()

Python: a, b = map(int, input().split())
n = int(input())
flag = True
for i in range(n):
  aa, bb = map(int, input().split())
  if bb <= a or aa >= b:
    pass
  else:
    flag = False
if(flag == True):
  print("0")
else:
  print("1")

Python: time=[]
a,b=map(int,input().split())
N=int(input())
for i in range(N):
  s,f=map(int,input().split())
  for i in range(s,f):
    time.append(i)
#print(time)
for i in range(a,b):
  #print(i)
  if i in time:
    print(1)
    break
  elif i==b-1:
    print(0)

Python: a,b=map(int,input().split())
N=int(input())
judge=0
for i in range(N):
    rs,re=map(int,input().split())
    if judge==0:
        if a<=rs and b>rs:
            judge=1
        elif a>rs and a<re:
            judge=1
print(judge)

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

ans = 0
for _ in range(n):
    a, b = map(int, input().split())
    if x < b and a < y:
        ans = 1

print(ans)

Python: n,m = map(int,input().split())
a = int(input())
for i in range(a):
  a,b = map(int,input().split())
  if b <= n or m <= a:continue
  else:
    print("1")
    exit()
print("0")