#include <bits/stdc++.h>
using namespace std;
int n, m, a[1010];
double f[1010][1010], g[1010][1010], ans = 0.0;
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
  for (int i = 1; i <= n; i++)
    for (int j = i + 1; j <= n; j++) f[i][j] = a[i] > a[j];
  for (int i = 1; i <= m; i++) {
    int x, y;
    scanf("%d%d", &x, &y);
    if (x > y) swap(x, y);
    if (x == y) continue;
    g[x][y] = 0.5;
    for (int i = 1; i < x; i++) {
      g[i][x] = (f[i][x] + f[i][y]) / 2;
      g[i][y] = (f[i][y] + f[i][x]) / 2;
    }
    for (int i = x + 1; i < y; i++) {
      g[x][i] = (f[x][i] + (1 - f[i][y])) / 2;
      g[i][y] = (f[i][y] + (1 - f[x][i])) / 2;
    }
    for (int i = y + 1; i <= n; i++) {
      g[x][i] = (f[x][i] + f[y][i]) / 2;
      g[y][i] = (f[y][i] + f[x][i]) / 2;
    }
    for (int i = 1; i <= n; i++) {
      if (i < x)
        f[i][x] = g[i][x];
      else if (i > x)
        f[x][i] = g[x][i];
      if (i < y)
        f[i][y] = g[i][y];
      else if (i > y)
        f[y][i] = g[y][i];
    }
  }
  for (int i = 1; i <= n; i++)
    for (int j = i + 1; j <= n; j++) ans += f[i][j];
  printf("%.8lf", ans);
}
