if __name__ == '__main__':
    n = int(input())
    for i in range(n):
        item = list(map(int, input().split()))
        second = min(item[2] // 2, item[1])
        first = min(item[0] , (item[1] - second) // 2)
        print((first + second) * 3)