------
## 最终结论
```python
def min_cost_to_make_fence_great(q, queries):
    results = []  # Initialize results list to store the results of each query
    for query in queries:  # Loop through each query
        n, boards = query  # Get the number of boards and their dimensions
        prev_costs = [0, float('inf'), float('inf')]  # initial costs for height increases of the first board

        for i in range(1, n):  # Iterate over the boards starting from the second one
            a_i, b_i = boards[i]  # Get the height and cost of the current board
            current_costs = [float('inf')] * 3  # Initialize current costs

            for prev_h in range(3):  # Check previous height options
                prev_height = boards[i - 1][0] + prev_h  # Calculate previous board height with increase
                for curr_h in range(3):  # Check current height options
                    current_height = a_i + curr_h  # Calculate current board height with increase
                    if current_height != prev_height:  # Ensure heights are not equal
                        current_costs[curr_h] = min(current_costs[curr_h], prev_costs[prev_h] + curr_h * b_i)

            prev_costs = current_costs  # Update previous costs

        results.append(min(prev_costs))  # Store minimum cost for this query
    
    return results

# Example usage:
q = 3
queries = [
    (3, [(2, 4), (2, 1), (3, 5)]),
    (3, [(2, 3), (2, 10), (2, 6)]),
    (4, [(1, 7), (3, 3), (2, 6), (1000000000, 2)])
]

for result in min_cost_to_make_fence_great(q, queries):
    print(result)
```