import math

case = int(input())
for caseNum in range(0, case):
    a, b, c = [int(x) for x in input().split()]
    getStone2 = min(b, math.floor(c/2))
    b -= getStone2
    getStone1 = min(a, math.floor(b/2))
    print(3 * (getStone1 + getStone2))