t = gets.to_i t.times do n, m = gets.chomp.split.map &:to_i puts [(n/4.0).ceil, ((n+m)/8.0).ceil].max end