Buggy python submission (verdict: Time Limit Exceeded):
a, b, m = map(int, input().split())
priceOfMicrowaves = list(map(int, input().split()))
priceOfRefrigerators = list(map(int, input().split()))
priceTable = [list(map(int,input().split())) for i in range(m)]
cheepest = priceOfMicrowaves[0] + priceOfRefrigerators[0]
for price in priceTable:
    if priceOfMicrowaves[price[0]-1]-price[2] >= cheepest:
        continue
    elif priceOfRefrigerators[price[1]-1]-price[2] >= cheepest:
        continue
    elif priceOfMicrowaves[price[0]-1]+priceOfRefrigerators[price[1]-1]-price[2] < cheepest:
        cheepest = priceOfMicrowaves[price[0]-1]+priceOfRefrigerators[price[1]-1]-price[2]
for p in priceOfMicrowaves:
    if p >= cheepest:
        continue
    for q in priceOfRefrigerators:
        if q >= cheepest:
            continue
        if p + q < cheepest:
            cheepest = p + q
print(cheepest)

Fixed submission:
a, b, m = map(int, input().split())
priceOfMicrowaves = list(map(int, input().split()))
priceOfRefrigerators = list(map(int, input().split()))
priceTable = [list(map(int,input().split())) for i in range(m)]
cheepest = priceOfMicrowaves[0] + priceOfRefrigerators[0]
for price in priceTable:
    if priceOfMicrowaves[price[0]-1]-price[2] >= cheepest:
        continue
    elif priceOfRefrigerators[price[1]-1]-price[2] >= cheepest:
        continue
    elif priceOfMicrowaves[price[0]-1]+priceOfRefrigerators[price[1]-1]-price[2] < cheepest:
        cheepest = priceOfMicrowaves[price[0]-1]+priceOfRefrigerators[price[1]-1]-price[2]
if cheepest > min(priceOfMicrowaves) + min(priceOfRefrigerators):
    cheepest = min(priceOfMicrowaves) + min(priceOfRefrigerators)
print(cheepest)

Buggy python submission (verdict: Time Limit Exceeded):
a, b, m = map(int, input().split())
priceOfMicrowaves = list(map(int, input().split()))
priceOfRefrigerators = list(map(int, input().split()))
priceTable = [list(map(int,input().split())) for i in range(m)]
cheepest = priceOfMicrowaves[0] + priceOfRefrigerators[0]
for p in priceOfMicrowaves:
    if p >= cheepest:
        continue
    for q in priceOfRefrigerators:
        if q >= cheepest:
            continue
        if p + q < cheepest:
            cheepest = p + q
for price in priceTable:
    if priceOfMicrowaves[price[0]-1]-price[2] >= cheepest:
        continue
    elif priceOfRefrigerators[price[1]-1]-price[2] >= cheepest:
        continue
    elif priceOfMicrowaves[price[0]-1]+priceOfRefrigerators[price[1]-1]-price[2] < cheepest:
        cheepest = priceOfMicrowaves[price[0]-1]+priceOfRefrigerators[price[1]-1]-price[2]
print(cheepest)


Fixed submission:
a, b, m = map(int, input().split())
priceOfMicrowaves = list(map(int, input().split()))
priceOfRefrigerators = list(map(int, input().split()))
priceTable = [list(map(int,input().split())) for i in range(m)]
cheepest = priceOfMicrowaves[0] + priceOfRefrigerators[0]
for price in priceTable:
    if priceOfMicrowaves[price[0]-1]-price[2] >= cheepest:
        continue
    elif priceOfRefrigerators[price[1]-1]-price[2] >= cheepest:
        continue
    elif priceOfMicrowaves[price[0]-1]+priceOfRefrigerators[price[1]-1]-price[2] < cheepest:
        cheepest = priceOfMicrowaves[price[0]-1]+priceOfRefrigerators[price[1]-1]-price[2]
if cheepest > min(priceOfMicrowaves) + min(priceOfRefrigerators):
    cheepest = min(priceOfMicrowaves) + min(priceOfRefrigerators)
print(cheepest)

Buggy python submission (verdict: Time Limit Exceeded):
a, b, m = map(int, input().split())
priceOfMicrowaves = list(map(int, input().split()))
priceOfRefrigerators = list(map(int, input().split()))
priceTable = [list(map(int,input().split())) for i in range(m)]
cheepest = priceOfMicrowaves[0] + priceOfRefrigerators[0]
for p in priceOfMicrowaves:
    if p >= cheepest:
        continue
    for q in priceOfRefrigerators:
        if q >= cheepest:
            continue
        if p + q < cheepest:
            cheepest = p + q
for price in priceTable:
    if priceOfMicrowaves[price[0]-1]+priceOfRefrigerators[price[1]-1]-price[2] < cheepest:
        cheepest = priceOfMicrowaves[price[0]-1]+priceOfRefrigerators[price[1]-1]-price[2]
print(cheepest)


Fixed submission:
a, b, m = map(int, input().split())
priceOfMicrowaves = list(map(int, input().split()))
priceOfRefrigerators = list(map(int, input().split()))
priceTable = [list(map(int,input().split())) for i in range(m)]
cheepest = priceOfMicrowaves[0] + priceOfRefrigerators[0]
for price in priceTable:
    if priceOfMicrowaves[price[0]-1]-price[2] >= cheepest:
        continue
    elif priceOfRefrigerators[price[1]-1]-price[2] >= cheepest:
        continue
    elif priceOfMicrowaves[price[0]-1]+priceOfRefrigerators[price[1]-1]-price[2] < cheepest:
        cheepest = priceOfMicrowaves[price[0]-1]+priceOfRefrigerators[price[1]-1]-price[2]
if cheepest > min(priceOfMicrowaves) + min(priceOfRefrigerators):
    cheepest = min(priceOfMicrowaves) + min(priceOfRefrigerators)
print(cheepest)

Buggy python submission (verdict: Time Limit Exceeded):
a, b, m = map(int, input().split())
priceOfMicrowaves = list(map(int, input().split()))
priceOfRefrigerators = list(map(int, input().split()))
priceTable = [list(map(int,input().split())) for i in range(m)]
cheepest = priceOfMicrowaves[0] + priceOfRefrigerators[0]
for p in priceOfMicrowaves:
    if p >= cheepest:
        continue
    for q in priceOfRefrigerators:
        if q >= cheepest:
            continue
        if p + q < cheepest:
            cheepest = p + q
for price in priceTable:
    if priceOfMicrowaves[price[0]-1]+priceOfRefrigerators[price[1]-1]-price[2] < cheepest:
        cheepest = priceOfMicrowaves[price[0]-1]+priceOfRefrigerators[price[1]-1]-price[2]
print(cheepest)


Fixed submission:
a, b, m = map(int, input().split())
priceOfMicrowaves = list(map(int, input().split()))
priceOfRefrigerators = list(map(int, input().split()))
priceTable = [list(map(int,input().split())) for i in range(m)]
cheepest = priceOfMicrowaves[0] + priceOfRefrigerators[0]
for price in priceTable:
    if priceOfMicrowaves[price[0]-1]-price[2] >= cheepest:
        continue
    elif priceOfRefrigerators[price[1]-1]-price[2] >= cheepest:
        continue
    elif priceOfMicrowaves[price[0]-1]+priceOfRefrigerators[price[1]-1]-price[2] < cheepest:
        cheepest = priceOfMicrowaves[price[0]-1]+priceOfRefrigerators[price[1]-1]-price[2]
if cheepest > min(priceOfMicrowaves) + min(priceOfRefrigerators):
    cheepest = min(priceOfMicrowaves) + min(priceOfRefrigerators)
print(cheepest)

Buggy python submission (verdict: Runtime Error):
def main():
    a, b, m = map(int, input().split())
    priceOfMicrowaves = list(map(int, input().split()))
    priceOfRefrigerators = list(map(int, input().split()))
    priceTable = [list(map(int,input().split())) for i in range(m)]
    cheepest = priceOfMicrowaves[0] + priceOfRefrigerators[0]
    for p in priceOfMicrowaves:
        if cheepest == 0:
            break
        if p >= cheepest:
            continue
        for q in priceOfRefrigerators:
            if q >= cheepest:
                continue
            if p + q < cheepest:
                cheepest = p + q
    for price in priceTable:
        if cheepest == 0:
            break
        if priceOfMicrowaves[price[0]-1] >= cheepest:
            continue
        elif priceOfMicrowaves[price[1]-1] >= cheepest:
            continue
        elif priceOfMicrowaves[price[0]-1]+priceOfRefrigerators[price[1]-1]-price[2] < cheepest:
            cheepest = priceOfMicrowaves[price[0]-1]+priceOfRefrigerators[price[1]-1]-price[2]
    print(cheepest)
    
main()

Fixed submission:
a, b, m = map(int, input().split())
priceOfMicrowaves = list(map(int, input().split()))
priceOfRefrigerators = list(map(int, input().split()))
priceTable = [list(map(int,input().split())) for i in range(m)]
cheepest = priceOfMicrowaves[0] + priceOfRefrigerators[0]
for price in priceTable:
    if priceOfMicrowaves[price[0]-1]-price[2] >= cheepest:
        continue
    elif priceOfRefrigerators[price[1]-1]-price[2] >= cheepest:
        continue
    elif priceOfMicrowaves[price[0]-1]+priceOfRefrigerators[price[1]-1]-price[2] < cheepest:
        cheepest = priceOfMicrowaves[price[0]-1]+priceOfRefrigerators[price[1]-1]-price[2]
if cheepest > min(priceOfMicrowaves) + min(priceOfRefrigerators):
    cheepest = min(priceOfMicrowaves) + min(priceOfRefrigerators)
print(cheepest)

Buggy python submission (verdict: Runtime Error):
def main():
    a, b, m = map(int, input().split())
    priceOfMicrowaves = list(map(int, input().split()))
    priceOfRefrigerators = list(map(int, input().split()))
    priceTable = [list(map(int,input().split())) for i in range(m)]
    cheepest = priceOfMicrowaves[0] + priceOfRefrigerators[0]
    for p in priceOfMicrowaves:
        if cheepest == 0:
            break
        if p >= cheepest:
            continue
        for q in priceOfRefrigerators:
            if q >= cheepest:
                continue
            if p + q < cheepest:
                cheepest = p + q
    for price in priceTable:
        if cheepest == 0:
            break
        if priceOfMicrowaves[price[0]-1] >= cheepest:
            continue
        elif priceOfMicrowaves[price[1]-1] >= cheepest:
            continue
        elif priceOfMicrowaves[price[0]-1]+priceOfRefrigerators[price[1]-1]-price[2] < cheepest:
            cheepest = priceOfMicrowaves[price[0]-1]+priceOfRefrigerators[price[1]-1]-price[2]
    print(cheepest)
    
main()

Fixed submission:
a, b, m = map(int, input().split())
priceOfMicrowaves = list(map(int, input().split()))
priceOfRefrigerators = list(map(int, input().split()))
priceTable = [list(map(int,input().split())) for i in range(m)]
cheepest = priceOfMicrowaves[0] + priceOfRefrigerators[0]
for price in priceTable:
    if priceOfMicrowaves[price[0]-1]-price[2] >= cheepest:
        continue
    elif priceOfRefrigerators[price[1]-1]-price[2] >= cheepest:
        continue
    elif priceOfMicrowaves[price[0]-1]+priceOfRefrigerators[price[1]-1]-price[2] < cheepest:
        cheepest = priceOfMicrowaves[price[0]-1]+priceOfRefrigerators[price[1]-1]-price[2]
if cheepest > min(priceOfMicrowaves) + min(priceOfRefrigerators):
    cheepest = min(priceOfMicrowaves) + min(priceOfRefrigerators)
print(cheepest)

Buggy python submission (verdict: Runtime Error):
def main():
    a, b, m = map(int, input().split())
    priceOfMicrowaves = list(map(int, input().split()))
    priceOfRefrigerators = list(map(int, input().split()))
    priceTable = [list(map(int,input().split())) for i in range(m)]
    cheepest = priceOfMicrowaves[0] + priceOfRefrigerators[0]
    for price in priceTable:
        if priceOfMicrowaves[price[0]-1] - price[2] >= cheepest:
            continue
        elif priceOfMicrowaves[price[1]-1] - price[2] >= cheepest:
            continue
        if priceOfMicrowaves[price[0]-1]+priceOfRefrigerators[price[1]-1]-price[2] < cheepest:
            cheepest = priceOfMicrowaves[price[0]-1]+priceOfRefrigerators[price[1]-1]-price[2]
    for p in priceOfMicrowaves:
        if p >= cheepest:
            continue
        for q in priceOfRefrigerators:
            if q >= cheepest:
                continue
            if p + q < cheepest:
                cheepest = p + q
    print(cheepest)
    
main()

Fixed submission:
a, b, m = map(int, input().split())
priceOfMicrowaves = list(map(int, input().split()))
priceOfRefrigerators = list(map(int, input().split()))
priceTable = [list(map(int,input().split())) for i in range(m)]
cheepest = priceOfMicrowaves[0] + priceOfRefrigerators[0]
for price in priceTable:
    if priceOfMicrowaves[price[0]-1]-price[2] >= cheepest:
        continue
    elif priceOfRefrigerators[price[1]-1]-price[2] >= cheepest:
        continue
    elif priceOfMicrowaves[price[0]-1]+priceOfRefrigerators[price[1]-1]-price[2] < cheepest:
        cheepest = priceOfMicrowaves[price[0]-1]+priceOfRefrigerators[price[1]-1]-price[2]
if cheepest > min(priceOfMicrowaves) + min(priceOfRefrigerators):
    cheepest = min(priceOfMicrowaves) + min(priceOfRefrigerators)
print(cheepest)

Buggy python submission (verdict: Runtime Error):
def main():
    a, b, m = map(int, input().split())
    priceOfMicrowaves = list(map(int, input().split()))
    priceOfRefrigerators = list(map(int, input().split()))
    priceTable = [list(map(int,input().split())) for i in range(m)]
    cheepest = priceOfMicrowaves[0] + priceOfRefrigerators[0]
    for price in priceTable:
        if priceOfMicrowaves[price[0]-1] >= cheepest:
            continue
        elif priceOfMicrowaves[price[1]-1] >= cheepest:
            continue
        if priceOfMicrowaves[price[0]-1]+priceOfRefrigerators[price[1]-1]-price[2] < cheepest:
            cheepest = priceOfMicrowaves[price[0]-1]+priceOfRefrigerators[price[1]-1]-price[2]
    for p in priceOfMicrowaves:
        if p >= cheepest:
            continue
        for q in priceOfRefrigerators:
            if q >= cheepest:
                continue
            if p + q < cheepest:
                cheepest = p + q
    print(cheepest)
    
main()

Fixed submission:
a, b, m = map(int, input().split())
priceOfMicrowaves = list(map(int, input().split()))
priceOfRefrigerators = list(map(int, input().split()))
priceTable = [list(map(int,input().split())) for i in range(m)]
cheepest = priceOfMicrowaves[0] + priceOfRefrigerators[0]
for price in priceTable:
    if priceOfMicrowaves[price[0]-1]-price[2] >= cheepest:
        continue
    elif priceOfRefrigerators[price[1]-1]-price[2] >= cheepest:
        continue
    elif priceOfMicrowaves[price[0]-1]+priceOfRefrigerators[price[1]-1]-price[2] < cheepest:
        cheepest = priceOfMicrowaves[price[0]-1]+priceOfRefrigerators[price[1]-1]-price[2]
if cheepest > min(priceOfMicrowaves) + min(priceOfRefrigerators):
    cheepest = min(priceOfMicrowaves) + min(priceOfRefrigerators)
print(cheepest)

Buggy python submission (verdict: Time Limit Exceeded):
def main():
    a, b, m = map(int, input().split())
    priceOfMicrowaves = list(map(int, input().split()))
    priceOfRefrigerators = list(map(int, input().split()))
    priceTable = [list(map(int,input().split())) for i in range(m)]
    cheepest = priceOfMicrowaves[0] + priceOfRefrigerators[0]
    for price in priceTable:
        if priceOfMicrowaves[price[0]-1]+priceOfRefrigerators[price[1]-1]-price[2] < cheepest:
            cheepest = priceOfMicrowaves[price[0]-1]+priceOfRefrigerators[price[1]-1]-price[2]
    for p in priceOfMicrowaves:
        if p >= cheepest:
            continue
        for q in priceOfRefrigerators:
            if q >= cheepest:
                continue
            if p + q < cheepest:
                cheepest = p + q
    print(cheepest)
    
main()

Fixed submission:
a, b, m = map(int, input().split())
priceOfMicrowaves = list(map(int, input().split()))
priceOfRefrigerators = list(map(int, input().split()))
priceTable = [list(map(int,input().split())) for i in range(m)]
cheepest = priceOfMicrowaves[0] + priceOfRefrigerators[0]
for price in priceTable:
    if priceOfMicrowaves[price[0]-1]-price[2] >= cheepest:
        continue
    elif priceOfRefrigerators[price[1]-1]-price[2] >= cheepest:
        continue
    elif priceOfMicrowaves[price[0]-1]+priceOfRefrigerators[price[1]-1]-price[2] < cheepest:
        cheepest = priceOfMicrowaves[price[0]-1]+priceOfRefrigerators[price[1]-1]-price[2]
if cheepest > min(priceOfMicrowaves) + min(priceOfRefrigerators):
    cheepest = min(priceOfMicrowaves) + min(priceOfRefrigerators)
print(cheepest)

Buggy python submission (verdict: Time Limit Exceeded):
def main():
    a, b, m = map(int, input().split())
    priceOfMicrowaves = list(map(int, input().split()))
    priceOfRefrigerators = list(map(int, input().split()))
    priceTable = [list(map(int,input().split())) for i in range(m)]
    cheepest = priceOfMicrowaves[0] + priceOfRefrigerators[0]
    for price in priceTable:
        if priceOfMicrowaves[price[0]-1]+priceOfRefrigerators[price[1]-1]-price[2] < cheepest:
            cheepest = priceOfMicrowaves[price[0]-1]+priceOfRefrigerators[price[1]-1]-price[2]
    for p in priceOfMicrowaves:
        for q in priceOfRefrigerators:
            if p + q < cheepest:
                cheepest = p + q
    print(cheepest)
    
main()

Fixed submission:
a, b, m = map(int, input().split())
priceOfMicrowaves = list(map(int, input().split()))
priceOfRefrigerators = list(map(int, input().split()))
priceTable = [list(map(int,input().split())) for i in range(m)]
cheepest = priceOfMicrowaves[0] + priceOfRefrigerators[0]
for price in priceTable:
    if priceOfMicrowaves[price[0]-1]-price[2] >= cheepest:
        continue
    elif priceOfRefrigerators[price[1]-1]-price[2] >= cheepest:
        continue
    elif priceOfMicrowaves[price[0]-1]+priceOfRefrigerators[price[1]-1]-price[2] < cheepest:
        cheepest = priceOfMicrowaves[price[0]-1]+priceOfRefrigerators[price[1]-1]-price[2]
if cheepest > min(priceOfMicrowaves) + min(priceOfRefrigerators):
    cheepest = min(priceOfMicrowaves) + min(priceOfRefrigerators)
print(cheepest)

Buggy python submission (verdict: Time Limit Exceeded):
def main():
    a, b, m = map(int, input().split())
    priceOfMicrowaves = list(map(int, input().split()))
    priceOfRefrigerators = list(map(int, input().split()))
    priceTable = [list(map(int,input().split())) for i in range(m)]
    cheepest = priceOfMicrowaves[0] + priceOfRefrigerators[0]
    for p in priceOfMicrowaves:
        for q in priceOfRefrigerators:
            if p + q < cheepest:
                cheepest = p + q
    for price in priceTable:
        if priceOfMicrowaves[price[0]-1]+priceOfRefrigerators[price[1]-1]-price[2] < cheepest:
            cheepest = priceOfMicrowaves[price[0]-1]+priceOfRefrigerators[price[1]-1]-price[2]
    print(cheepest)
    
main()

Fixed submission:
a, b, m = map(int, input().split())
priceOfMicrowaves = list(map(int, input().split()))
priceOfRefrigerators = list(map(int, input().split()))
priceTable = [list(map(int,input().split())) for i in range(m)]
cheepest = priceOfMicrowaves[0] + priceOfRefrigerators[0]
for price in priceTable:
    if priceOfMicrowaves[price[0]-1]-price[2] >= cheepest:
        continue
    elif priceOfRefrigerators[price[1]-1]-price[2] >= cheepest:
        continue
    elif priceOfMicrowaves[price[0]-1]+priceOfRefrigerators[price[1]-1]-price[2] < cheepest:
        cheepest = priceOfMicrowaves[price[0]-1]+priceOfRefrigerators[price[1]-1]-price[2]
if cheepest > min(priceOfMicrowaves) + min(priceOfRefrigerators):
    cheepest = min(priceOfMicrowaves) + min(priceOfRefrigerators)
print(cheepest)

Buggy python submission (verdict: Runtime Error):
a, b, m = map(int, input().split())
    priceOfMicrowaves = list(map(int, input().split()))
    priceOfRefrigerators = list(map(int, input().split()))
    priceTable = [list(map(int,input().split())) for i in range(m)]
    cheepest = priceOfMicrowaves[0] + priceOfRefrigerators[0]
    for p in priceOfMicrowaves:
        for q in priceOfRefrigerators:
            if p + q < cheepest:
                cheepest = p + q
    for price in priceTable:
        if priceOfMicrowaves[price[0]-1]+priceOfRefrigerators[price[1]-1]-price[2] < cheepest:
            cheepest = priceOfMicrowaves[price[0]-1]+priceOfRefrigerators[price[1]-1]-price[2]
    print(cheepest)


Fixed submission:
a, b, m = map(int, input().split())
priceOfMicrowaves = list(map(int, input().split()))
priceOfRefrigerators = list(map(int, input().split()))
priceTable = [list(map(int,input().split())) for i in range(m)]
cheepest = priceOfMicrowaves[0] + priceOfRefrigerators[0]
for price in priceTable:
    if priceOfMicrowaves[price[0]-1]-price[2] >= cheepest:
        continue
    elif priceOfRefrigerators[price[1]-1]-price[2] >= cheepest:
        continue
    elif priceOfMicrowaves[price[0]-1]+priceOfRefrigerators[price[1]-1]-price[2] < cheepest:
        cheepest = priceOfMicrowaves[price[0]-1]+priceOfRefrigerators[price[1]-1]-price[2]
if cheepest > min(priceOfMicrowaves) + min(priceOfRefrigerators):
    cheepest = min(priceOfMicrowaves) + min(priceOfRefrigerators)
print(cheepest)

Buggy python submission (verdict: Runtime Error):
a, b, m = map(int, input().split())
priceOfMicrowaves = map(int, input().split())
priceOfRefrigerators = map(int, input().split())
priceTable = [list(map(int,input().split())) for i in range(m)]

cheepest = priceOfMicrowaves[0] + priceOfRefrigerators[0]
for p in priceOfMicrowaves:
    for q in priceOfRefrigerators:
        if p + q < cheepest:
            cheepest = p + q
    
for price in priceTable:
    if priceOfMicrowaves[price[0]-1]+priceOfRefrigerators[price[1]-1]-price[2] < cheepest:
        cheepest = priceOfMicrowaves[price[0]-1]+priceOfRefrigerators[price[1]-1]-price[2]
        
print(cheepest)

Fixed submission:
a, b, m = map(int, input().split())
priceOfMicrowaves = list(map(int, input().split()))
priceOfRefrigerators = list(map(int, input().split()))
priceTable = [list(map(int,input().split())) for i in range(m)]
cheepest = priceOfMicrowaves[0] + priceOfRefrigerators[0]
for price in priceTable:
    if priceOfMicrowaves[price[0]-1]-price[2] >= cheepest:
        continue
    elif priceOfRefrigerators[price[1]-1]-price[2] >= cheepest:
        continue
    elif priceOfMicrowaves[price[0]-1]+priceOfRefrigerators[price[1]-1]-price[2] < cheepest:
        cheepest = priceOfMicrowaves[price[0]-1]+priceOfRefrigerators[price[1]-1]-price[2]
if cheepest > min(priceOfMicrowaves) + min(priceOfRefrigerators):
    cheepest = min(priceOfMicrowaves) + min(priceOfRefrigerators)
print(cheepest)