https://www.luogu.org/problemnew/show/P1424
x, n = map(int, input().split())
ans = (n//7)*5
n %= 7
while n > 0 :
if x != 6 and x != 7 :
ans += 1
x += 1
n -= 1
print(ans*250)
x, n = map(int, input().split())
ans = (n//7)*5
n %= 7
while n > 0 :
if x != 6 and x != 7 :
ans += 1
x += 1
n -= 1
print(ans*250)