Anton likes to play chess. Also he likes to do programming. No wonder that he decided to attend chess classes and programming classes.

Anton has *n* variants when he will attend chess classes, *i*-th variant is given by a period of time (*l*<sub class="lower-index">1, *i*</sub>, *r*<sub class="lower-index">1, *i*</sub>). Also he has *m* variants when he will attend programming classes, *i*-th variant is given by a period of time (*l*<sub class="lower-index">2, *i*</sub>, *r*<sub class="lower-index">2, *i*</sub>).

Anton needs to choose exactly one of *n* possible periods of time when he will attend chess classes and exactly one of *m* possible periods of time when he will attend programming classes. He wants to have a rest between classes, so from all the possible pairs of the periods he wants to choose the one where the distance between the periods is maximal.

The distance between periods (*l*<sub class="lower-index">1</sub>, *r*<sub class="lower-index">1</sub>) and (*l*<sub class="lower-index">2</sub>, *r*<sub class="lower-index">2</sub>) is the minimal possible distance between a point in the first period and a point in the second period, that is the minimal possible |*i* - *j*|, where *l*<sub class="lower-index">1</sub> ≤ *i* ≤ *r*<sub class="lower-index">1</sub> and *l*<sub class="lower-index">2</sub> ≤ *j* ≤ *r*<sub class="lower-index">2</sub>. In particular, when the periods intersect, the distance between them is 0.

Anton wants to know how much time his rest between the classes will last in the best case. Help Anton and find this number!
The first line of the input contains a single integer *n* (1 ≤ *n* ≤ 200 000) — the number of time periods when Anton can attend chess classes.

Each of the following *n* lines of the input contains two integers *l*<sub class="lower-index">1, *i*</sub> and *r*<sub class="lower-index">1, *i*</sub> (1 ≤ *l*<sub class="lower-index">1, *i*</sub> ≤ *r*<sub class="lower-index">1, *i*</sub> ≤ 10<sup class="upper-index">9</sup>) — the *i*-th variant of a period of time when Anton can attend chess classes.

The following line of the input contains a single integer *m* (1 ≤ *m* ≤ 200 000) — the number of time periods when Anton can attend programming classes.

Each of the following *m* lines of the input contains two integers *l*<sub class="lower-index">2, *i*</sub> and *r*<sub class="lower-index">2, *i*</sub> (1 ≤ *l*<sub class="lower-index">2, *i*</sub> ≤ *r*<sub class="lower-index">2, *i*</sub> ≤ 10<sup class="upper-index">9</sup>) — the *i*-th variant of a period of time when Anton can attend programming classes.
In the first sample Anton can attend chess classes in the period (2, 3) and attend programming classes in the period (6, 8). It's not hard to see that in this case the distance between the periods will be equal to 3.

In the second sample if he chooses any pair of periods, they will intersect. So the answer is 0.
3
1 5
2 6
2 3
2
2 4
6 8
3
3
1 5
2 6
3 7
2
2 4
1 4
0
20
13 141
57 144
82 124
16 23
18 44
64 65
117 133
84 117
77 142
40 119
105 120
71 92
5 142
48 132
106 121
5 80
45 92
66 81
7 93
27 71
3
75 96
127 140
54 74
104
10
16 16
20 20
13 13
31 31
42 42
70 70
64 64
63 63
53 53
94 94
8
3 3
63 63
9 9
25 25
11 11
93 93
47 47
3 3
91
1
45888636 261444238
1
244581813 591222338
0
1
166903016 182235583
1
254223764 902875046
71988181
1
1 1
1
1000000000 1000000000
999999999
1
1000000000 1000000000
1
1 1
999999999
1
1000000000 1000000000
1
1000000000 1000000000
0
6
2 96
47 81
3 17
52 52
50 105
1 44
4
40 44
59 104
37 52
2 28
42
4
528617953 528617953
102289603 102289603
123305570 123305570
481177982 597599007
1
239413975 695033059
137124372
7
617905528 617905554
617905546 617905557
617905562 617905564
617905918 617906372
617905539 617905561
617905516 617905581
617905538 617905546
9
617905517 617905586
617905524 617905579
617905555 617905580
617905537 617905584
617905556 617905557
617905514 617905526
617905544 617905579
617905258 617905514
617905569 617905573
404
5
999612104 999858319
68705639 989393889
297814302 732073321
577979321 991069087
601930055 838139173
14
109756300 291701768
2296272 497162877
3869085 255543683
662920943 820993688
54005870 912134860
1052 70512
477043210 648640912
233115268 920170255
575163323 756904529
183450026 469145373
359987405 795448062
287873006 872825189
360460166 737511078
76784767 806771748
999541592
1
1 100000000
1
200000000 200000010
100000000
1
999999995 999999996
1
999999998 999999999
2
1
10 100
1
2 5
5
1
999999992 999999993
1
999999996 999999997
3
1
999999997 999999997
1
999999999 999999999
2
1
999999999 999999999
1
1000000000 1000000000
1
1
1 1000000000
1
1000000000 1000000000
0
1
1000000000 1000000000
1
999999999 999999999
1
1
100000000 100000001
1
100000009 100000011
8
1
5 5
1
6 6
1
1
1000000000 1000000000
1
1000000000 1000000000
0
1
200000000 200000001
1
200000000 200000001
0
1
2 6
1
4 8
0
def max_rest_between_classes(n, chess_periods, m, programming_periods):
    chess_periods.sort()  # Sorting by starting time
    programming_periods.sort()  # Sorting by starting time

    i = 0  # Pointer for chess classes periods
    j = 0  # Pointer for programming classes periods

    max_distance = 0  # Maximal possible distance

    while i < n and j < m:
        chess_start, chess_end = chess_periods[i]
        programming_start, programming_end = programming_periods[j]

        distance = abs(chess_start - programming_start)
        max_distance = max(max_distance, distance)

        if chess_end < programming_end:
            i += 1
        else:
            j += 1

    return max_distance

# Read input
n = int(input())
chess_periods = []
for _ in range(n):
    start, end = map(int, input().split())
    chess_periods.append((start, end))

m = int(input())
programming_periods = []
for _ in range(m):
    start, end = map(int, input().split())
    programming_periods.append((start, end))

# Calculate and print the maximal possible distance
result = max_rest_between_classes(n, chess_periods, m, programming_periods)
print(result)

			 			 		  		 						 		    	