t = int(input());
for i in range(t):
    a,b,c = map(int,input().split());
    res = 0;
    ca = c//2;
    cb = min(b,c//2);
    b = b - cb;
    res += cb*3;
    cs = min(a,b//2);
    res += cs*3;
    print(res)
    
