#include <bits/stdc++.h>
using namespace std;
const int N = 1e3 + 7;
const int M = 1000;
const int inf = 1e9 + 7;
const long long base = 1e18;
const double pi = acos(-1);
const double ep = 1e-9;
int a[N];
int n, q;
double dp[N][N];
int main() {
  cin >> n >> q;
  for (int i = (int)1; i < (int)n + 1; i++) cin >> a[i];
  for (int i = (int)1; i < (int)n + 1; i++)
    for (int j = (int)i + 1; j < (int)n + 1; j++)
      if (a[i] < a[j])
        dp[i][j] = 0;
      else
        dp[i][j] = 1.0;
  while (q-- > 0) {
    int u, v;
    scanf("%d%d", &u, &v);
    if (u > v) swap(u, v);
    for (int i = (int)1; i < (int)u; i++) {
      dp[i][v] = dp[i][u] = dp[i][u] / 2 + dp[i][v] / 2;
    }
    for (int i = (int)u + 1; i < (int)v; i++) {
      double tmp = dp[i][v];
      dp[i][v] = (1 - dp[u][i]) / 2 + dp[i][v] / 2;
      dp[u][i] = 0.5 * dp[u][i] + 0.5 * (1 - tmp);
    }
    for (int i = (int)v + 1; i < (int)n + 1; i++) {
      dp[v][i] = dp[u][i] = (dp[u][i] + dp[v][i]) / 2;
    }
    dp[u][v] = 0.5;
  }
  double ans = 0;
  for (int i = (int)1; i < (int)n + 1; i++) {
    for (int j = (int)i + 1; j < (int)n + 1; j++) {
      ans += dp[i][j];
    }
  }
  printf("%.9lf", ans);
}
