# Arup Guha
# 4/12/2025
# Solution to Kattis Problem: Monk
# https://open.kattis.com/problems/monk

# Return the height climb or descend if we travel the segments in segs
# for time t.
def evaluate(segs, t):

    # Where we start.
    h = 0

    # Go through each segment.
    for i in range(len(segs)):

        # We have time for this whole segment.
        if segs[i][1] < t:
            t -= segs[i][1]
            h += segs[i][0]

        # We end in the middle of this segment.
        else:
            frac = t/segs[i][1]
            h += frac*segs[i][0]
            break

    # This is how far we got.
    return h

# Solves the problem via binary search where segU is segments
# going up, segsD is segments going down, the total height of
# the climb is sumH and the time descending is sumT.
def binsearch(segU, segD, sumH, sumT):

    # Bounds for binary search.
    low = 0
    high = sumT

    # For real valued we run a fixed number of times.
    for i in range(100):

        # Time we are trying.
        mid = (low+high)/2

        # See elevation for path up and path down.
        up = evaluate(segU, mid)
        down = sumH - evaluate(segD, mid)

        # We need more time, so mid is lowest the answer could be.
        if up < down:
            low = mid

        # We went too far, so mid is the highest the answer could be.
        else:
            high = mid

    return low

def main():

    toks = input().split()
    numU = int(toks[0])
    numD = int(toks[1])

    # This info is useful.
    sumH = 0

    # Get info for going up.
    segU = []
    for i in range(numU):
        tmp = [int(x) for x in input().split()]
        segU.append(tmp)
        sumH += tmp[0]

    # And going down.
    sumT = 0
    segD = []
    for i in range(numD):
        tmp = [int(x) for x in input().split()]
        segD.append(tmp)
        sumT += tmp[1]

    # Solve it!
    print(binsearch(segU, segD, sumH, sumT))

# Run it!
main()
