P,Q,R = map(int,input().split())

PR = P + R
QR = Q + R
QP = Q + P

ans = min(PR,min(QR,QP))

print(ans) P,Q,R = map(int,input().split()) P map(int,input().split()) map int input().split() ().split () input split Q R PR = P + R PR P + R P R QR = Q + R QR Q + R Q R QP = Q + P QP Q + P Q P ans = min(PR,min(QR,QP)) ans min(PR,min(QR,QP)) min PR min(QR,QP) min QR QP print(ans) print ans QR = Q + R Q + R QR QP = Q + P Q + P QP ans = min(PR,min(QR,QP)) min(PR,min(QR,QP)) ans P,Q,R = map(int,input().split()) map(int,input().split()) P R = map(int,input().split()) map(int,input().split()) R Q,R = map(int,input().split()) map(int,input().split()) Q PR = P + R P + R PR
P,Q,R = map(int,input().split())

PR = P + R
QR = Q + R
QP = Q + P

ans = min(PR,min(QR,QP))

print(ans)