#Bhargey Mehta (Junior)
#DA-IICT, Gandhinagar
import sys, math, queue, collections
#sys.stdin = open('input.txt', 'r')
MOD = 10**9+7
sys.setrecursionlimit(1000000)

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