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