#include <bits/stdc++.h>
using namespace std;
int IN() {
  int c, x;
  while (!isdigit(c = getchar()))
    ;
  x = c - '0';
  while (isdigit(c = getchar())) x = (x << 1) + (x << 3) + c - '0';
  return x;
}
const int N = 1000 + 19;
double f[N][N], Ans;
int A[N], n, Q, L, R;
int main() {
  n = IN(), Q = IN();
  for (int i = 1; i < n + 1; i++) A[i] = IN();
  for (int i = 1; i < n + 1; i++)
    for (int j = i + 1; j < n + 1; j++) f[i][j] = (A[i] > A[j] ? 1 : 0);
  while (Q--) {
    L = IN();
    R = IN();
    if (L > R) swap(L, R);
    f[L][R] = 0.5;
    for (int i = L + 1; i < R; i++) {
      double a = f[L][i], b = f[i][R];
      f[L][i] = 0.5 * a + 0.5 * (1 - b), f[i][R] = 0.5 * b + 0.5 * (1 - a);
    }
    for (int i = 1; i < L; i++) f[i][L] = f[i][R] = (f[i][L] + f[i][R]) / 2.0;
    for (int i = R + 1; i < n + 1; i++)
      f[L][i] = f[R][i] = (f[L][i] + f[R][i]) / 2.0;
  }
  for (int i = 1; i < n + 1; i++)
    for (int j = i + 1; j < n + 1; j++) Ans += f[i][j];
  printf("%.10lf\n", Ans);
}
