SP6860 ASISTENT - Asistent

Description

You are given a permutation of first N natural numbers on which you are to perform K operations of following type: given integers A and B, your task is to swap elements on positions A and B in permutation and then output permutation rank modulo 1000 000 007. **Note:** Difference from original task is that elements remain swapped after query.

Input Format

On first line of standard input you are given two integers (2 On the next line there is permutation of first N natural numbers. In next K lines there are two integers A, B ( 1

Output Format

Output permutation rank after applying each of K operations.