#include <bits/stdc++.h>
using namespace std;
const int mod = 1e9 + 7;
int n, q;
int a[3005];
double f[3005][3005], ans;
int 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]++;
  for (int i = 1; i <= q; i++) {
    int x, y;
    cin >> x >> y;
    for (int j = 1; j <= n; j++) {
      f[x][j] = f[y][j] = 0.5 * (f[x][j] + f[y][j]);
      f[j][x] = f[j][y] = 1 - f[x][j];
    }
    f[x][y] = f[y][x] = 0.5;
  }
  for (int i = 1; i <= n; i++)
    for (int j = i + 1; j <= n; j++) ans += f[i][j];
  cout << fixed << setprecision(9) << ans;
  return 0;
}
