#include <bits/stdc++.h>
using namespace std;
long long int ABS(long long int a) {
  if (a < 0) return (-a);
  return a;
}
void input() {}
double dp[1005][1005];
int a[1005];
int main() {
  input();
  int n, m;
  scanf("%d", &n);
  scanf("%d", &m);
  for (int i = (0); i < (n); ++i) scanf("%d", &a[i]);
  for (int i = (0); i < (n); ++i)
    for (int j = (i + 1); j < (n); ++j) {
      if (a[i] > a[j])
        dp[i][j] = 1.0;
      else
        dp[i][j] = 0.0;
    }
  for (int j = (0); j < (m); ++j) {
    int x, y;
    scanf("%d", &x);
    scanf("%d", &y);
    x--;
    y--;
    if (x > y) swap(x, y);
    for (int i = (0); i < (n); ++i) {
      if (i < x)
        dp[i][x] = dp[i][y] = 0.5 * dp[i][x] + 0.5 * dp[i][y];
      else if (i > x && i < y) {
        double temp = dp[x][i];
        dp[x][i] = 0.5 * dp[x][i] + 0.5 * (1.0 - dp[i][y]);
        dp[i][y] = 0.5 * dp[i][y] + 0.5 * (1.0 - temp);
      } else if (i > y) {
        dp[y][i] = dp[x][i] = 0.5 * dp[y][i] + 0.5 * dp[x][i];
      }
    }
    dp[x][y] = 0.5;
  }
  double res = 0.0;
  for (int i = (0); i < (n); ++i)
    for (int j = (i + 1); j < (n); ++j) res += dp[i][j];
  printf("%.12lf\n", res);
  return 0;
}
