------
## 最终结论
```python
def min_operations_to_alternate(t, test_cases):
    results = []
    for n, s in test_cases:
        # Calculate the number of mismatches for both patterns
        pattern1_mismatches = 0  # Pattern 010101...
        pattern2_mismatches = 0  # Pattern 101010...

        for i in range(n):
            expected_char_pattern1 = '0' if i % 2 == 0 else '1'
            expected_char_pattern2 = '1' if i % 2 == 0 else '0'

            if s[i] != expected_char_pattern1:
                pattern1_mismatches += 1
            if s[i] != expected_char_pattern2:
                pattern2_mismatches += 1

        # The minimum number of operations is the minimum mismatches between the two patterns
        results.append(min(pattern1_mismatches, pattern2_mismatches) // 2)

    return results

# Example usage:
t = 3
test_cases = [
    (2, "10"),
    (4, "0110"),
    (8, "11101000")
]

output = min_operations_to_alternate(t, test_cases)
for result in output:
    print(result)
```