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