num1, num2 = [int(i) for i in input().split()]
if (num1 + (num2 % 7)) > 7:
print((num1 + (num2 % 7)) - 7)
else:
print((num1 + (num2 % 7)))
num1, num2 = [int(i) for i in input().split()]
if (num1 + (num2 % 7)) > 7:
print((num1 + (num2 % 7)) - 7)
else:
print((num1 + (num2 % 7)))