local ffi = require("ffi") local C = ffi.C ffi.cdef[[ long long atoll(const char*); ]] local function lltonumber(str) return C.atoll(str) end local q = io.read("*n", "*l") for iq = 1, q do local d, a = io.read():match("(%d+) (%d+)") d = tonumber(d) a = lltonumber(a) local ha = a / 2LL local s = io.read() local t = {} for w in s:gmatch("%d+") do w = (ha + lltonumber(w)) / a w = tostring(w):gsub("LL", "") table.insert(t, w) end print(table.concat(t, " ")) end