Check permutation
while True : NEW_LINE INDENT IsCorrect = True NEW_LINE for i in range ( N ) : NEW_LINE INDENT if ( A [ i ] != q [ i ] ) : NEW_LINE INDENT IsCorrect = False NEW_LINE break NEW_LINE DEDENT DEDENT if ( IsCorrect ) : NEW_LINE INDENT break NEW_LINE DEDENT b += 1 NEW_LINE if ( not next_permutation ( A ) ) : NEW_LINE INDENT break NEW_LINE DEDENT DEDENT