import math
from collections import deque
from sys import stdin, stdout
from string import ascii_letters
input = stdin.readline
#print = stdout.write

for _ in range(int(input())):
    arr = list(map(int, input().split()))
    res = 0
    bf = min(arr[1], arr[2] // 2)
    res += bf * 3
    arr[1] -= bf
    arr[2] -= bf * 2
    bf = min(arr[0], arr[1] // 2)
    res += bf * 3
    print(res)
    