def read_inputline_as_int_array():
    return map(int, raw_input().split(" "))

def read_inputline_without_space():
    return "".join(raw_input())

def solve():
    pass

if __name__ == "__main__":
    tcs = int(input())
    for tc in range(tcs):
        a,b,c = read_inputline_as_int_array()
        count = 0;

        while True:
            if c >=2 and b >= 1:
                c -=2
                b-=1
                count+=3
            else:
                break

        while True:
            if b >=2 and a >=1:
                b-=2
                a-=1
                count +=3
            else:
                break
        print count
