#include <bits/stdc++.h>
using namespace std;
const int Max_N(1050);
struct node {
  int a, b;
  long double v;
  void give(const int &_a, const int &_b, const long double &_v) {
    a = _a, b = _b, v = _v;
  }
};
int N, M, Tot, A[Max_N];
node V[Max_N << 1];
long double P[Max_N][Max_N], Ans;
inline void get(const node &x) { P[x.a][x.b] = x.v; }
int main() {
  scanf("%d%d", &N, &M);
  for (int i = 1; i <= N; ++i) scanf("%d", A + i);
  for (int i = 1; i <= N; ++i)
    for (int j = i + 1; j <= N; ++j) P[i][j] = (A[i] > A[j]) * 1.0;
  int a, b;
  while (M--) {
    scanf("%d%d", &a, &b);
    if (a > b) swap(a, b);
    Tot = 0;
    V[++Tot].give(a, b, 0.5);
    for (int i = 1; i <= a - 1; ++i) {
      V[++Tot].give(i, a, 0.5 * P[i][b] + 0.5 * P[i][a]);
      V[++Tot].give(i, b, 0.5 * P[i][a] + 0.5 * P[i][b]);
    }
    for (int i = a + 1; i <= b - 1; ++i) {
      V[++Tot].give(a, i, 0.5 * (1.0 - P[i][b]) + 0.5 * P[a][i]);
      V[++Tot].give(i, b, 0.5 * (1.0 - P[a][i]) + 0.5 * P[i][b]);
    }
    for (int i = b + 1; i <= N; ++i) {
      V[++Tot].give(a, i, 0.5 * P[b][i] + 0.5 * P[a][i]);
      V[++Tot].give(b, i, 0.5 * P[a][i] + 0.5 * P[b][i]);
    }
    for (int i = 1; i <= Tot; ++i) get(V[i]);
  }
  for (int i = 1; i <= N; ++i)
    for (int j = i + 1; j <= N; ++j) Ans += P[i][j];
  printf("%.10lf", static_cast<double>(Ans));
  return 0;
}
