import sys
sys.setrecursionlimit(1000000000)
#
# Solution Template for Atlantis III: Twin Rivers
#
# Australian Informatics Olympiad 2024
#
# This file is provided to assist with reading and writing of the input
# files for the problem. You may modify this file however you wish, or
# you may choose not to use this file at all.
#
# N is the number of bridges.
N = 0
# L is the length of the city.
L = 0
# B and R describe the bridges. Note that the lists start from 0, and so the
# bridges are (B[0], R[0]) to (B[N-1], R[N-1]).
B = []
R = []
# T is the number of trips.
T = 0
# X and S describe the trips. Note that the lists start from 0, and so the
# trips are (X[0], S[0]) to (X[T-1], S[T-1]).
X = []
S = []
# Open the input and output files.
input_file = open("twinin.txt", "r")
output_file = open("twinout.txt", "w")
# Read the values of N, L, B, R, T, X, and S from input file.
input_line = input_file.readline().strip()
N, L = map(int, input_line.split())
for i in range(0, N):
input_vars = list(map(int, input_file.readline().strip().split()))
B.append(input_vars[0])
R.append(input_vars[1])
T = int(input_file.readline().strip())
for i in range(0, T):
input_vars = list(map(int, input_file.readline().strip().split()))
X.append(input_vars[0])
S.append(input_vars[1])
# TODO: This is where you should compute your solution. Store the smallest
# possible sum of trip distances you can achieve after building one more bridge
# into the variable answer.
answer = 0
# Write the answer to the output file.
output_file.write("%d\n" % (answer))
# Finally, close the input/output files.
input_file.close()
output_file.close()