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 function llmin(x, y) return x < y and x or y end local q = io.read("*n", "*l") for iq = 1, q do local a, b, c = io.read():match("(%d+) (%d+) (%d+)") a = lltonumber(a) b = lltonumber(b) c = lltonumber(c) d = llmin(a, c) s = 2LL * d a = a - d c = c - d if b % 2LL == 1LL then s = s + b - 1LL b = 1LL else s = s + b b = 0LL end if 0LL == a then if (b + c) % 2LL == 0 then z = b + c * 2LL - (b + c) / 2LL * 3LL s = s + z else if b == 1LL then s = s + c / 2LL else s = s + (c - 1LL) / 2LL end end else s = s + llmin(a, b) end s = tostring(s):gsub("LL", "") print(s) end