q = io.read("*n") for iq = 1, q do a, b = io.read("*n", "*n") c = math.ceil(a / 4) d = math.ceil((a + b) / 8) print(math.max(c, d)) end