from sys import stdin
import json
stdin.readline()
rng = [
0, 0, 3, 0, 5, 3, 0, 0, 3, 50,
0, 3, 0, 0, 15, 0, 0, 3, 0, 50,
3, 0, 0, 3, 5, 0, 3, 0, 0, 150
]
for line in stdin:
start, end = [int(i) for i in line.split()]
sc, sm = divmod(start, 30)
ec, em = divmod(end, 30)
result = 0
result += (ec - sc - 1) * (sum(rng))
result += sum(rng[sm:])
result += sum(rng[:em + 1])
print(result)
ZnJvbSBzeXMgaW1wb3J0IHN0ZGluCmltcG9ydCBqc29uCgpzdGRpbi5yZWFkbGluZSgpCgoKCnJuZyA9IFsKICAgIDAsIDAsIDMsIDAsIDUsICAzLCAwLCAwLCAzLCA1MCwKICAgIDAsIDMsIDAsIDAsIDE1LCAwLCAwLCAzLCAwLCA1MCwKICAgIDMsIDAsIDAsIDMsIDUsICAwLCAzLCAwLCAwLCAxNTAKXQoKZm9yIGxpbmUgaW4gc3RkaW46CiAgICBzdGFydCwgZW5kID0gW2ludChpKSBmb3IgaSBpbiBsaW5lLnNwbGl0KCldCgogICAgc2MsIHNtID0gZGl2bW9kKHN0YXJ0LCAzMCkKICAgIGVjLCBlbSA9IGRpdm1vZChlbmQsIDMwKQoKICAgIHJlc3VsdCA9IDAKICAgIHJlc3VsdCArPSAoZWMgLSBzYyAtIDEpICogKHN1bShybmcpKQogICAgcmVzdWx0ICs9IHN1bShybmdbc206XSkKICAgIHJlc3VsdCArPSBzdW0ocm5nWzplbSArIDFdKQoKICAgIHByaW50KHJlc3VsdCkK