def calculate_inversions(n: int, m: int, permutation: List[int], operations: List[Tuple[int, int]]) -> float:
    """
    The Little Elephant loves permutations of integers from 1 to n very much. But most of all he loves sorting them. To sort a permutation, the Little Elephant repeatedly swaps some elements. As a result, he must receive a permutation 1, 2, 3, ..., n.
    
    This time the Little Elephant has permutation p_1, p_2, ..., p_{n}. Its sorting program needs to make exactly m moves, during the i-th move it swaps elements that are at that moment located at the a_{i}-th and the b_{i}-th positions. But the Little Elephant's sorting program happened to break down and now on every step it can equiprobably either do nothing or swap the required elements.
    
    Now the Little Elephant doesn't even hope that the program will sort the permutation, but he still wonders: if he runs the program and gets some permutation, how much will the result of sorting resemble the sorted one? For that help the Little Elephant find the mathematical expectation of the number of permutation inversions after all moves of the program are completed.
    
    We'll call a pair of integers i, j (1 ≤ i < j ≤ n) an inversion in permutatuon p_1, p_2, ..., p_{n}, if the following inequality holds: p_{i} > p_{j}.
    
    
    -----Input-----
    
    The first line contains two integers n and m (1 ≤ n, m ≤ 1000, n > 1) — the permutation size and the number of moves. The second line contains n distinct integers, not exceeding n — the initial permutation. Next m lines each contain two integers: the i-th line contains integers a_{i} and b_{i} (1 ≤ a_{i}, b_{i} ≤ n, a_{i} ≠ b_{i}) — the positions of elements that were changed during the i-th move.
    
    
    -----Output-----
    
    In the only line print a single real number — the answer to the problem. The answer will be considered correct if its relative or absolute error does not exceed 10^{ - 6}.
    
    
    -----Examples-----
    Input
    2 1
    1 2
    1 2
    
    Output
    0.500000000
    
    Input
    4 3
    1 3 2 4
    1 2
    2 3
    1 4
    
    Output
    3.000000000
    """


# Tests

def check(candidate):
    assert candidate(2, 1, [1, 2], [(1, 2)]) == 0.500000000
    assert candidate(4, 3, [1, 3, 2, 4], [(1, 2), (2, 3), (1, 4)]) == 3.000000000
    assert candidate(7, 4, [7, 6, 4, 2, 1, 5, 3], [(1, 3), (2, 1), (7, 2), (3, 5)]) == 11.250000000
    assert candidate(10, 1, [1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [(1, 10)]) == 8.500000000
    assert candidate(9, 20, [9, 8, 7, 6, 5, 4, 3, 2, 1], [(4, 6), (9, 4), (5, 9), (6, 8), (1, 9), (5, 8), (6, 9), (7, 3), (1, 9), (8, 3), (4, 5), (9, 6), (3, 8), (4, 1), (1, 2), (3, 2), (4, 9), (6, 7), (7, 5), (9, 6)]) == 20.105407715
    assert candidate(20, 7, [3, 17, 7, 14, 11, 4, 1, 18, 20, 19, 13, 12, 5, 6, 15, 16, 9, 2, 8, 10], [(19, 13), (20, 6), (19, 11), (12, 3), (10, 19), (14, 10), (3, 16)]) == 102.250000000
    assert candidate(100, 1, [78, 52, 95, 76, 96, 49, 53, 59, 77, 100, 64, 11, 9, 48, 15, 17, 44, 46, 21, 54, 39, 68, 43, 4, 32, 28, 73, 6, 16, 62, 72, 84, 65, 86, 98, 75, 33, 45, 25, 3, 91, 82, 2, 92, 63, 88, 7, 50, 97, 93, 14, 22, 20, 42, 60, 55, 80, 85, 29, 34, 56, 71, 83, 38, 26, 47, 90, 70, 51, 41, 40, 31, 37, 12, 35, 99, 67, 94, 1, 87, 57, 8, 61, 19, 23, 79, 36, 18, 66, 74, 5, 27, 81, 69, 24, 58, 13, 10, 89, 30], [(17, 41)]) == 2659.500000000
    assert candidate(125, 8, [111, 69, 3, 82, 24, 38, 4, 39, 42, 22, 92, 6, 16, 10, 8, 45, 17, 91, 84, 53, 5, 46, 124, 47, 18, 57, 43, 73, 114, 102, 121, 105, 118, 95, 104, 98, 72, 20, 56, 60, 123, 80, 103, 70, 65, 107, 67, 112, 101, 108, 99, 49, 12, 94, 2, 68, 119, 109, 59, 40, 86, 116, 88, 63, 110, 14, 13, 120, 41, 64, 89, 71, 15, 35, 81, 51, 113, 90, 55, 122, 1, 75, 54, 33, 28, 7, 125, 9, 100, 115, 19, 58, 61, 83, 117, 52, 106, 87, 11, 50, 93, 32, 21, 96, 26, 78, 48, 79, 23, 36, 66, 27, 31, 62, 25, 77, 30, 74, 76, 44, 97, 85, 29, 34, 37], [(33, 17), (84, 103), (71, 33), (5, 43), (23, 15), (65, 34), (125, 58), (51, 69)]) == 3919.000000000
    assert candidate(100, 2, [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100], [(88, 90), (62, 77)]) == 16.000000000
check(calculate_inversions)