for _ in range(int(input())):
    a, b, c = map(int, input().split())
    temp = c//2;
    temp=min(temp, b)
    ans = 3*temp
    b -= temp
    temp = b//2
    temp = min(temp, a)
    ans+= 3*temp
    print(ans)