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