if __name__ == '__main__':
    t = int(input())
    while t:
        a, b, c, = map(int, input().split(' '))
        r1 = min(a, b // 2)
        r2 = min(b, c // 2)
        a1 = r1*3 + min(b - r1*2, c // 2)*3
        a2 = r2*3 + min((b - r2) // 2, a)*3
        print(max(a1, a2))
        t -= 1
