import sys
import math

if __name__ == '__main__':
    input = sys.stdin.readline
    T = int(input())
    for i in range (0,T):
        a,b,c=map(int,input().split())
        ans1 = min(a,b//2)
        ans1 += min(b-2*ans1,c//2)
        ans2 = min(b,c//2)
        ans2 += min(a,(b-ans2)//2)
        print(3*ans2)
       