#include <bits/stdc++.h>
using namespace std;
double dp[1005][1005];
int main() {
  int n, q;
  vector<int> num;
  cin >> n >> q;
  for (int i = 0; i < n; i++) {
    int x;
    cin >> x;
    num.push_back(x);
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      if (num[i] > num[j]) dp[i][j] = 1.0;
    }
  }
  for (int i = 0; i < q; i++) {
    int a, b;
    scanf("%d %d", &a, &b);
    a--;
    b--;
    for (int j = 0; j < n; j++) {
      dp[j][a] = dp[j][b] = 0.5 * (dp[j][a] + dp[j][b]);
      dp[a][j] = 1 - dp[j][a];
      dp[b][j] = 1 - dp[j][b];
    }
    dp[a][b] = dp[b][a] = 0.5;
  }
  double ret = 0.0;
  for (int i = 0; i < n; i++)
    for (int j = i + 1; j < n; j++) ret += dp[i][j];
  printf("%.20f\n", ret);
}
