for _ in range(int(input())):
    a = [int(x) for x in input().split()]
    if a[1] == 0:
        ans = 0
    else:
        from_3_2 = a[2] // 2
        if from_3_2 >= a[1]:
            ans = 3*a[1]
        else:
            a[1] -= from_3_2
            from_2_1 = a[1] // 2
            times = min(from_2_1, a[0])
            ans = 3*from_3_2 + 3*times
    print(ans)