#include <bits/stdc++.h>
using namespace std;
double f[3100][3100], ans;
int A[3100], bs, Q, n;
signed main() {
  cin >> n >> Q;
  for (int i = 1; i <= n; i++) cin >> A[i];
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= n; j++)
      if (A[i] < A[j]) f[i][j] = 1;
  for (int w = 1; w <= Q; w++) {
    int x, y;
    cin >> x >> y;
    for (int i = 1; i <= n; i++) {
      if (x == i || y == i) continue;
      double t1 = (f[i][x] + f[i][y]) / 2;
      double t2 = (f[x][i] + f[y][i]) / 2;
      f[i][x] = f[i][y] = t1;
      f[x][i] = f[y][i] = t2;
    }
    f[x][y] = f[y][x] = (f[x][y] + f[y][x]) / 2;
  }
  for (int i = 1; i <= n; i++)
    for (int j = 1; j < i; j++) ans += f[i][j];
  printf("%.10f\n", ans);
}
