Step 1 : Replace all ' O ' s with '-
for i in range ( M ) : NEW_LINE INDENT for j in range ( N ) : NEW_LINE INDENT if ( mat [ i ] [ j ] == ' O ' ) : NEW_LINE INDENT mat [ i ] [ j ] = ' - ' NEW_LINE DEDENT DEDENT DEDENT