for _ in range(int(input())):
    a, b, c = [int(i) for i in input().split()]

    res1 = 0
    temp1 = min(a, b // 2)
    res1 += 3 * temp1
    b -= 2 * temp1
    temp2 = min(b, c // 2)
    res1 += 3 * temp2
    b += 2 * temp1

    res2 = 0
    temp1 = min(b, c // 2)
    res2 += 3 * temp1
    b -= temp1
    temp2 = min(a, b // 2)
    res2 += 3 * temp2
    print(max(res1, res2))