#include <bits/stdc++.h>
using namespace std;
double dp[1001][1001];
long long int a[1001];
int main() {
  ios::sync_with_stdio(false);
  ;
  cin.tie(0);
  ;
  cout << fixed << setprecision(10);
  long long int i, j, n, q, x, y;
  double x1, y1, ans = 0.0;
  cin >> n >> q;
  for (i = 1; i <= n; i++) cin >> a[i];
  for (i = 1; i <= n; i++) {
    for (j = i + 1; j <= n; j++) {
      if (a[i] > a[j]) dp[i][j] = 1.0;
    }
  }
  while (q--) {
    cin >> x >> y;
    if (x > y) swap(x, y);
    for (i = y + 1; i <= n; i++) {
      x1 = dp[x][i];
      y1 = dp[y][i];
      dp[x][i] = 0.5 * (x1 + y1);
      dp[y][i] = 0.5 * (x1 + y1);
    }
    for (i = 1; i < x; i++) {
      x1 = dp[i][x];
      y1 = dp[i][y];
      dp[i][x] = 0.5 * (x1 + y1);
      dp[i][y] = 0.5 * (x1 + y1);
    }
    for (i = x + 1; i < y; i++) {
      x1 = dp[x][i];
      y1 = dp[i][y];
      dp[x][i] = 0.5 * x1 + 0.5 * (1.0 - y1);
      dp[i][y] = 0.5 * y1 + 0.5 * (1.0 - x1);
    }
    dp[x][y] = 0.5 * dp[x][y] + 0.5 * (1.0 - dp[x][y]);
  }
  for (i = 1; i <= n; i++) {
    for (j = i + 1; j <= n; j++) ans += dp[i][j];
  }
  cout << ans;
  return 0;
}
