By swapping, O(mn)