n = int(input())
mli = []
for i in range(n):
    tli = []
    tli = list(map(int, input().split(" ")))
    mli.append(tli)
for i in range(n):
    init = 0
    while (mli[i][1] >= 1 and mli[i][2] >= 2):
        init = init + 3
        mli[i][1] = mli[i][1] - 1
        mli[i][2] = mli[i][2] - 2
    while (mli[i][0] >= 1 and mli[i][1] >= 2):
        init = init + 3
        mli[i][0] = mli[i][0] - 1
        mli[i][1] = mli[i][1] - 2
    print(init)
