#include <bits/stdc++.h>
int m, n;
double dp[1005][1005];
int a[1005];
void swap(int *a, int *b) {
  int c = *a;
  *a = *b;
  *b = c;
}
int main() {
  int i, j, k, x, y, z;
  scanf("%d%d", &n, &m);
  for (i = 1; i <= n; i++) scanf("%d", a + i);
  for (i = 1; i <= n; i++) {
    for (j = i + 1; j <= n; j++) {
      dp[i][j] = (a[i] > a[j]);
    }
  }
  while (m--) {
    scanf("%d%d", &x, &y);
    if (x > y) swap(&x, &y);
    dp[x][y] = 0.5;
    for (i = 1; i < x; i++) {
      dp[i][x] = 0.5 * dp[i][x] + 0.5 * dp[i][y];
      dp[i][y] = dp[i][x];
    }
    for (i = x + 1; i < y; i++) {
      dp[x][i] = 0.5 * dp[x][i] + 0.5 * (1 - dp[i][y]);
      dp[i][y] = 1 - dp[x][i];
    }
    for (i = y + 1; i <= n; i++) {
      dp[x][i] = 0.5 * dp[x][i] + 0.5 * dp[y][i];
      dp[y][i] = dp[x][i];
    }
  }
  double ans = 0;
  for (i = 1; i <= n; i++) {
    for (j = i + 1; j <= n; j++) {
      ans += dp[i][j];
    }
  }
  printf("%lf\n", ans);
  getchar();
  getchar();
}
