#include <bits/stdc++.h>
using namespace std;
const int maxn = 1000 + 15;
int n, m, a, b, x;
long double f[maxn][maxn], g[maxn][maxn];
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &x);
    f[i][x] = 1;
  }
  for (int i = 1; i <= m; i++) {
    scanf("%d%d", &a, &b);
    for (int j = 1; j <= n; j++)
      g[a][j] = f[a][j] * 0.5 + f[b][j] * 0.5,
      g[b][j] = f[b][j] * 0.5 + f[a][j] * 0.5;
    for (int j = 1; j <= n; j++) f[a][j] = g[a][j], f[b][j] = g[b][j];
  }
  long double ans = 0;
  memcpy(g, f, sizeof(f));
  for (int i = n; i >= 1; i--)
    for (int j = 1; j <= n; j++) g[i][j] += g[i][j - 1];
  for (int i = n; i >= 1; i--)
    for (int j = 1; j <= n; j++) g[i][j] += g[i + 1][j];
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= n; j++)
      ans +=
          f[i][j] * (g[i + 1][j - 1] + (g[i + 1][j] - g[i + 1][j - 1]) * 0.5);
  printf("%.9lf\n", (double)ans);
  return 0;
}
