Print the matrix
for ( int i = 0 ; i < n ; i ++ ) { if ( i == p3 . first ) { for ( int j = 0 ; j < n ; j ++ ) { if ( j == p3 . second ) System . out . print ( '1' ) ; else System . out . print ( arr . get ( i ) . charAt ( j ) ) ; } } else if ( i == p4 . first ) { for ( int j = 0 ; j < n ; j ++ ) { if ( j == p4 . second ) System . out . print ( '1' ) ; else System . out . print ( arr . get ( i ) . charAt ( j ) ) ; } } else System . out . print ( arr . get ( i ) ) ; System . out . println ( ) ; } }