import sys
input = sys.stdin.readline
sys.setrecursionlimit(100000)

def getN():
    return int(input())
def getList():
    return list(map(int, input().split()))
import math

def solve():
    a,b,c = getList()
    ans = 0
    ans += min(b, c // 2) * 3
    # print(ans)
    b -= ans // 3
    ans += min(a, b // 2) * 3
    print(ans)

def main():
    t = getN()
    for times in range(t):
        solve()


if __name__ =="__main__":
    main()