#include <bits/stdc++.h>
using namespace std;
const int N = 2005;
int a[N];
int tree[N][2];
int u[N][N];
double dp[N][N];
int n, m;
double ask(int l, int r) {
  if (u[l][r]) return dp[l][r];
  u[l][r] = 1;
  if (l <= n && r <= n) {
    return dp[l][r] = l > r ? 1.0 : 0.0;
  }
  if (l == r)
    return dp[l][r] = 0.5;
  else if (l < r)
    return dp[l][r] = 0.5 * ask(l, tree[r][0]) + 0.5 * ask(l, tree[r][1]);
  else
    return dp[l][r] = 0.5 * ask(tree[l][0], r) + 0.5 * ask(tree[l][1], r);
}
int main(void) {
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
  for (int i = n + 1; i <= n + m; i++) {
    int x, y;
    scanf("%d%d", &x, &y);
    tree[i][0] = a[x];
    tree[i][1] = a[y];
    a[x] = a[y] = i;
  }
  double ans = 0;
  for (int i = 1; i <= n; i++)
    for (int j = i + 1; j <= n; j++) {
      ans += ask(a[i], a[j]);
    }
  printf("%.9f\n", ans);
  return 0;
}
