/*
* problem: UVA 972 Horizon Line
* url: http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=913
* strtege: 离散化
* Author: johnsondu
* time: 2013-4-25
*/
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <cstring>
#include <iostream>
using namespace std ;
#define M 10005
#define min(x, y) (x > y ? y : x)
#define max(x, y) (x > y ? x : y)
double ft[M], gt[M] ;
int n, m ;
double res ;
struct Node
{
double x, y ;
}f[M], g[M] ;
void solve ()
{
int i = 1, j = 1 ;
while (1)
{
if (ft[i] <= gt[j]) //判断覆盖范围
{
res = min(res, max(f[i].y, g[j].y)) ;
i ++ ;
}
else {
res = min(res, max(f[i].y, g[j].y)) ;
j ++ ;
}
if (i == n || j == m)
break ;
}
if (i != n) //范围判断
for (; i <= n; i ++)
res = min(res, max(f[i].y, g[m].y)) ;
if (j != m) //范围判断
for (; j <= m; j ++)
res = min(res, max(f[n].y, g[j].y)) ;
printf ("%.3lf\n", res) ;
}
int main()
{
while (~scanf ("%d", &n))
{
res = 101.0 ;
ft[0] = gt[0] = 0 ;
for (int i = 1; i <= n; i ++)
{
scanf ("%lf%lf", &f[i].y, &f[i].x) ;
ft[i] = f[i].x + ft[i-1] ;//累加时间轴
}
scanf ("%d", &m) ;
for (int i = 1; i <= m; i ++)
{
scanf ("%lf%lf", &g[i].y, &g[i].x) ;
gt[i] = gt[i-1] + g[i].x ;//累加时间轴
}
solve () ;
}
return 0 ;
}