------
## 最终结论
```python
def min_steps_to_valid_grid(grid):
    n = len(grid)
    
    # Find the position of the first 1 in each row from the right
    first_one_pos = []
    for row in grid:
        pos = -1
        for j in range(n-1, -1, -1):
            if row[j] == 1:
                pos = j
                break
        first_one_pos.append(pos)
    
    steps = 0
    
    # We will check from the top row to the bottom row
    for i in range(n):
        # If the current row's first 1 position is less than i, it's impossible to make it valid
        if first_one_pos[i] < i:
            return -1
        
        # We need to find the minimum row we can swap with to ensure that the current row can be valid
        min_row_index = i
        for j in range(i, n):
            if first_one_pos[j] >= i:  # Valid rows can be at or above this column index
                min_row_index = j
                break
        
        # Count how many swaps are needed to bring that valid row to the current position i
        while min_row_index > i:
            first_one_pos[min_row_index], first_one_pos[min_row_index - 1] = first_one_pos[min_row_index - 1], first_one_pos[min_row_index]
            min_row_index -= 1
            steps += 1
            
    return steps

# Example usage:
print(min_steps_to_valid_grid([[0,0,1],[1,1,0],[1,0,0]]))  # Output: 3
print(min_steps_to_valid_grid([[0,1,1,0],[0,1,1,0],[0,1,1,0],[0,1,1,0]]))  # Output: -1
print(min_steps_to_valid_grid([[1,0,0],[1,1,0],[1,1,1]]))  # Output: 0
```