'''
21:40
분석끝21:42
'''
n = int(input())
for _ in range(n):
    a, b, c = map(int, input().split())
    res = 0
    c2 = c//2
    if b < c2:
        res += b
        res += b*2
        b = 0
    else:
        res += c2 * 2
        res += c2
        b -= c2
    b2 = b// 2
    if a < b2:
        res += a
        res += a*2
    else:
        res += b2 * 2
        res += b2
    print(res)