t = int(input())
for i in range(t):
    a, b, c = map(int, input().split())
    tmp2 = min(b, c//2)
    tmp1 = min(a, (b - tmp2)//2)
    tmp1 += tmp2
    print(tmp1 * 3)

# Codeforcesian
# ♥
# VRmAM.ML