#include <cstdio>
#include <vector>
#include <cstring>
#include <functional>
#include <algorithm>
#include <math.h>
#include <bitset>
#include <set>
#include <queue>
#include <iostream>
#include <string>
#include <sstream>
#include <stack>
#include <complex>
#include <numeric>
#include <map>
#include <time.h>
using namespace std;
typedef long double ld;
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int uint;
typedef pair<int,int> pii;
typedef pair<int,ll> pil;
typedef pair<ll,int> pli;
typedef pair<ll,ll> pll;
typedef pair<pii,ll> ppl;
typedef pair<ll,pii> plp;
typedef pair<int,pii> pip;
typedef pair<pii,int> ppi;
typedef pair<pii,pii> ppp;
typedef pair<double,int> pdi;
typedef pair<double,pii> pdp;
typedef pair<double,double> pdd;
typedef pair<pdd,double> pd3;
typedef vector<ll> vec;
typedef vector<vec> mat;
#define rep(i,n) for (int (i) = 0; (i) < (n); (i)++)
#define repn(i,a,n) for (int (i) = (a); (i) < (n); (i)++)
#define ALL(x) (x).begin(),(x).end()
#define pb push_back
#define SORT(x) sort((x).begin(),(x).end())
#define SORTN(x,n) sort((x),(x)+(n))
#define ERASE(x) (x).erase(unique((x).begin(),(x).end()),(x).end())
#define COUNT(x,c) count((x).begin(),(x).end(),(c))
#define REMOVE(x,c) (x).erase(remove((x).begin(),(x).end(),(c)),(x).end())
#define REVERSE(x) reverse((x).begin(),(x).end())
#define FORIT(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
#define LB(x,a) lower_bound((x).begin(),(x).end(),(a))-(x).begin()
#define lb(x,a) lower_bound((x).begin(),(x).end(),(a))
#define LBN(x,a,n) lower_bound((x),(x)+(n),(a))-(x)
#define lbN(x,a,n) lower_bound((x),(x)+(n),(a))
#define UB(x,a) upper_bound((x).begin(),(x).end(),(a))-(x).begin()
#define ub(x,a) upper_bound((x).begin(),(x).end(),(a))
#define BS(x,a) binary_search((x).begin(),(x).end(),(a))
#define BS2(x,n,a) binary_search((x),(x)+(n),(a))
#define NB(x) (((x)&~((x)+((x)&-(x))))/((x)&-(x))>>1)|((x)+((x)&-(x)))
#define NP(x) next_permutation((x).begin(),(x).end())
#define MM(x,p) memset((x),(p),sizeof(x))
#define SQ(x) (x)*(x)
#define SC(c1,c2) strcmp(c1,c2)==0
#define mp make_pair
#define INF (1<<29)
#define INFL (1LL<<61)
#define fi first
#define se second
#define MOD 1000000007
#define EPS 1e-12
#define MIN(x,a) x=min(x,a)
#define MAX(x,a) x=max(x,a)
#define madd(x,a) x=(x+a)%MOD
#define msub(x,a) x=(x+MOD-a)%MOD
#define OUTPUT(x) rep(i,x.size())printf("%d%c",x[i],i+1==x.size()?'\n':' ');

//cf 157

int N,M,A,B;
int D[1000];
double dp[1000][1000];

int main()
{
    scanf("%d%d",&N,&M);
    rep(i,N)scanf("%d",&D[i]);
    rep(i,N)rep(j,N)if(D[i]>D[j])dp[i][j]=1;
    while(M--)
    {
        scanf("%d%d",&A,&B);A--,B--;
        rep(i,N)if(i!=A&&i!=B)
        {
            dp[i][A]=dp[i][B]=(dp[i][A]+dp[i][B])/2;
            dp[A][i]=dp[B][i]=(dp[A][i]+dp[B][i])/2;
        }
        dp[A][A]=dp[B][B]=0;
        dp[A][B]=dp[B][A]=(dp[A][B]+dp[B][A])/2;
    }
    double res=0;
    rep(i,N)rep(j,i)res+=dp[j][i];
    printf("%.12f\n",res);
}


#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cstring>
using namespace std;
int n,m,x,a[1100];
double ans=0,dp[1100][1100];
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=1;j<=n;j++)
        if(i!=j)dp[i][j]=(int)(a[i]>a[j]);
    while(m--){
      int x,y;
      scanf("%d%d",&x,&y);
      for(int i=1;i<=n;i++)
        if(i!=x && i!=y){
          dp[i][x]=dp[i][y]=(dp[i][x]+dp[i][y])/2;
          dp[x][i]=dp[y][i]=(dp[x][i]+dp[y][i])/2;
          }
      dp[x][y]=dp[y][x]=(dp[x][y]+dp[y][x])/2;
    }
    ans=0;
    for(int i=1;i<=n;i++)
      for(int j=i+1;j<=n;j++)ans+=dp[i][j];
    printf("%.7lf\n",ans);
    return 0;
}


#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cstring>
using namespace std;
int n,m,x,a[1100];
double ans=0,dp[1100][1100];
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=1;j<=n;j++)
        if(i!=j)dp[i][j]=a[i]>a[j];
    while(m--){
      int x,y;
      scanf("%d%d",&x,&y);
      for(int i=1;i<=n;i++)
        if(i!=x && i!=y){
          dp[i][x]=dp[i][y]=(dp[i][x]+dp[i][y])/2;
          dp[x][i]=dp[y][i]=(dp[x][i]+dp[y][i])/2;
          }
      dp[x][y]=dp[y][x]=(dp[x][y]+dp[y][x])/2;
    }
    ans=0;
    for(int i=1;i<=n;i++)
      for(int j=1;j<i;j++)ans+=dp[i][j];
    printf("%.7lf\n",ans);
    return 0;
}


#include <cstdio>
#include <fstream>
#include <iostream>

#include <set>
#include <map>
#include <queue>
#include <deque>
#include <cmath>
#include <vector>
#include <string>
#include <cstring>
#include <algorithm>

#include <ctime>
#include <cstdlib>
#include <cassert>

#define pb push_back
#define mp make_pair
#define sz(A) (int) (A).size()
#define eprintf(...) fprintf(stderr, __VA_ARGS__)

#define sqr(A) ((A) * (A))
#define x first
#define y second

using namespace std;

typedef long long LL;
typedef unsigned long long ULL;
typedef long double LD;
typedef pair <int, int> pii;

const int N = (int) 1e3;

int n, m, a[N], pos[N];
double ans, tmp[2][N], dp[N][N], sum[N][N];

double get (int x1, int y1, int x2, int y2)
{
    return sum[x2][y2] - sum[x1][y2] - sum[x2][y1] + sum[x1][y1];
}

int main ()
{
    #ifdef DEBUG
    freopen(".in", "r", stdin);
    freopen(".out", "w", stdout);
    //freopen(".err", "w", stderr);
    #endif
    //ifstream cin (".in");
    //ofstream cout(".out");

    cin >> n >> m;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        a[i]--;
        pos[a[i]] = i;
    }

    for (int i = 0; i < n; i++)
        for (int j = i + 1; j < n; j++)
            dp[i][j] = a[i] < a[j], dp[j][i] = a[j] < a[i];

    for (int q = 0; q < m; q++) {
        int a, b;
        cin >> a >> b;
        a--, b--;

        for (int i = 0; i < n; i++)
            if (i != a && i != b) {
                dp[a][i] = dp[b][i] = dp[a][i] * 0.5 + dp[b][i] * 0.5;
                dp[i][a] = dp[i][b] = 1 - dp[a][i];
            }

        dp[a][b] = dp[b][a] = (dp[a][b] + dp[b][a]) * 0.5;
    }

    for (int i = 0; i < n; i++)
        for (int j = 0; j < i; j++)
            ans += dp[i][j];

    printf("%.10f", ans);

    return 0;
}


#include <cstdio>
#include <fstream>
#include <iostream>

#include <set>
#include <map>
#include <queue>
#include <deque>
#include <cmath>
#include <vector>
#include <string>
#include <cstring>
#include <algorithm>

#include <ctime>
#include <cstdlib>
#include <cassert>

#define pb push_back
#define mp make_pair
#define sz(A) (int) (A).size()
#define eprintf(...) fprintf(stderr, __VA_ARGS__)

#define sqr(A) ((A) * (A))
#define x first
#define y second

using namespace std;

typedef long long LL;
typedef unsigned long long ULL;
typedef long double LD;
typedef pair <int, int> pii;

const int N = (int) 1e3;

int n, m, a[N], pos[N];
double ans, dp[N][N], sum[N][N];

double get (int x1, int y1, int x2, int y2)
{
    return sum[x2][y2] - sum[x1][y2] - sum[x2][y1] + sum[x1][y1];
}

int main ()
{
    #ifdef DEBUG
    freopen(".in", "r", stdin);
    freopen(".out", "w", stdout);
    #endif
    //ifstream cin (".in");
    //ofstream cout(".out");

    cin >> n >> m;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        a[i]--;

        dp[a[i]][i] = 1;
    }

    for (int i = 0; i < m; i++) {
        int a, b;
        cin >> a >> b;

        a--, b--;

        for (int j = 0; j < n; j++) {
            double val = (dp[j][a] + dp[j][b]) * 0.5;
            dp[j][a] = dp[j][b] = val;
        }
    }

    for (int i = 0; i < n; i++)
        for (int j = 0; j < n; j++)
            sum[i + 1][j + 1] = dp[i][j] + sum[i][j + 1] + sum[i + 1][j] - sum[i][j];

    /*
    for (int i = 0; i < n; i++, cerr << endl)
        for (int j = 0; j < n; j++)
            cerr << dp[i][j] << ' ';
    cerr << endl;
    for (int i = 0; i < n; i++, cerr << endl)
        for (int j = 0; j < n; j++)
            cerr << sum[i][j] << ' ';
    cerr << endl;
    */
    for (int i = 0; i < n; i++)
        for (int j = 0; j < n; j++) {
            //ans += dp[i][j] * (get(0, j + 1, i, n) + get(i + 1, 0, n, j));
            double p1 = get(0, j + 1, i, n), p2 = get(0, 0, i, j);
            if (p1 == 0 && p2 == 0)
                continue;
            ans += dp[i][j] * (p1 + get(0, j, i, j + 1) * p1 / (p1 + p2));
        }

    printf("%.10f", ans);

    return 0;
}


#include<iostream>
#include<cstdio>
using namespace std;

double pr[1001][1001];
int a[1001];

int n, m;

int main()
{
	cin>>n>>m;
	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]) pr[i][j]=1.0;
			}
	}
	for(int i=0;i<m;i++){
		int u, v;
		cin>>u>>v;

		for(int j=1;j<=n;j++){
			if(j!=u && j!=v){
				pr[j][v]=pr[j][u]=  (pr[j][u]+pr[j][v])/2.0;
				pr[v][j]=pr[u][j]=  1.0-pr[j][u];

			}
		}

		pr[u][v]=pr[v][u]=0.5;
	}
	double ans=0.0;
	for(int i=1;i<=n;i++)
		for(int j=i+1;j<=n;j++)
			ans += pr[i][j];
	printf("%.7lf\n",ans);
//	system("PAUSE");
}


#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<int,int> PII;
#define MP make_pair
#define PB push_back
#define AA first
#define BB second
#define OP begin()
#define ED end()
#define SZ size()
#define cmin(x,y) x=min(x,y)
#define cmax(x,y) x=max(x,y)
#define NAME ""
#define VER 1

int n,m;
int a[1005];
long double p[1005][1005];
int main(){
    //freopen("F.in","r",stdin);
    //freopen("Fwa.out","w",stdout);
    int i,j,k,_T;
    while(~scanf("%d%d",&n,&m)){
        for(i=1;i<=n;i++)scanf("%d",&a[i]);
        for(i=1;i<=n;i++)
            for(j=i+1;j<=n;j++){
                if(a[i]>a[j])p[i][j]=1,p[j][i]=0;
                else p[i][j]=0,p[j][i]=1;
            }
        for(i=1;i<=m;i++){
            int a,b;
            scanf("%d%d",&a,&b);
            for(j=1;j<=n;j++)if(j!=a&&j!=b){
                long double paj=p[a][j];
                long double pbj=p[b][j];
                p[a][j]=p[b][j]=(paj+pbj)*.5;
                long double pja=p[j][a];
                long double pjb=p[j][b];
                p[j][a]=p[j][b]=(pja+pjb)*.5;
            }
            p[a][b]=p[b][a]=0.5;
        }
        long double ans=0;
        for(i=1;i<=n;i++)
            for(j=i+1;j<=n;j++)
                ans+=p[i][j];
        //cout<<ans<<"\n";
        printf("%.16f\n",(double)ans);
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<int,int> PII;
#define MP make_pair
#define PB push_back
#define AA first
#define BB second
#define OP begin()
#define ED end()
#define SZ size()
#define cmin(x,y) x=min(x,y)
#define cmax(x,y) x=max(x,y)
#define NAME ""
#define VER 1

int n,m;
int a[1005];
double p[1005][1005];
int main(){
    if(!VER)freopen(NAME".in","r",stdin);
    if(!VER)freopen(NAME".out","w",stdout);
    int i,j,k,_T;
    while(~scanf("%d%d",&n,&m)){
        for(i=1;i<=n;i++)scanf("%d",&a[i]);
        for(i=1;i<=n;i++)
            for(j=i+1;j<=n;j++){
                if(a[i]>a[j])p[i][j]=1,p[j][i]=0;
                else p[i][j]=0,p[j][i]=1;
            }
        for(i=1;i<=m;i++){
            int a,b;
            scanf("%d%d",&a,&b);
            for(j=1;j<=n;j++)if(j!=a&&j!=b){
                double paj=p[a][j];
                double pbj=p[b][j];
                p[a][j]=p[b][j]=(paj+pbj)*.5;
                double pja=p[j][a];
                double pjb=p[j][b];
                p[j][a]=p[j][b]=(pja+pjb)*.5;
            }
            p[a][b]=p[b][a]=0.5;
        }
        double ans=0;
        for(i=1;i<=n;i++)
            for(j=i+1;j<=n;j++)
                ans+=p[i][j];
        printf("%.16f\n",ans);
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<int,int> PII;
#define MP make_pair
#define PB push_back
#define AA first
#define BB second
#define OP begin()
#define ED end()
#define SZ size()
#define cmin(x,y) x=min(x,y)
#define cmax(x,y) x=max(x,y)
#define NAME ""
#define VER 1

int n,m;
int a[1005];
double p[1005][1005];
int main(){
    if(!VER)freopen(NAME".in","r",stdin);
    if(!VER)freopen(NAME".out","w",stdout);
    int i,j,k,_T;
    while(~scanf("%d%d",&n,&m)){
        for(i=1;i<=n;i++)scanf("%d",&a[i]);
        for(i=1;i<=n;i++)
            for(j=i+1;j<=n;j++){
                if(a[i]>a[j])p[i][j]=1,p[j][i]=0;
                else p[i][j]=0,p[j][i]=1;
            }
        for(i=1;i<=m;i++){
            int a,b;
            scanf("%d%d",&a,&b);
            for(j=1;j<=n;j++)if(j!=a&&j!=b){
                double paj=p[a][j];
                double pbj=p[b][j];
                p[a][j]=p[b][j]=(paj+pbj)*.5;
                double pja=p[j][a];
                double pjb=p[j][b];
                p[j][a]=p[j][b]=(pja+pjb)*.5;
            }
            p[a][b]=p[b][a]=0.5;
        }
        double ans=0;
        for(i=1;i<=n;i++)
            for(j=i+1;j<=n;j++)
                ans+=p[i][j];
        cout<<ans<<"\n";
    }
    return 0;
}


#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <algorithm>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <cstdlib>
#include <string>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cassert>
#include <climits>
//#include <ext/hash_map>

using namespace std;
using namespace __gnu_cxx;

#define REP(i,n) for(int i = 0; i < int(n); ++i)
#define REPV(i, n) for (int i = (n) - 1; (int)i >= 0; --i)
#define FOR(i, a, b) for(int i = (int)(a); i < (int)(b); ++i)

#define FE(i,t) for (__typeof((t).begin())i=(t).begin();i!=(t).end();++i)
#define FEV(i,t) for (__typeof((t).rbegin())i=(t).rbegin();i!=(t).rend();++i)

#define two(x) (1LL << (x))
#define ALL(a) (a).begin(), (a).end()

#define pb push_back
#define ST first
#define ND second
#define MP(x,y) make_pair(x, y)

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<string> vs;

template<class T> void checkmin(T &a, T b){if (b<a)a=b;}
template<class T> void checkmax(T &a, T b){if (b>a)a=b;}
template<class T> void out(T t[], int n){REP(i, n)cout<<t[i]<<" "; cout<<endl;}
template<class T> void out(vector<T> t, int n=-1){for (int i=0; i<(n==-1?t.size():n); ++i) cout<<t[i]<<" "; cout<<endl;}
inline int count_bit(int n){return (n==0)?0:1+count_bit(n&(n-1));}
inline int low_bit(int n){return (n^n-1)&n;}
inline int ctz(int n){return (n==0?-1:ctz(n>>1)+1);}
int toInt(string s){int a; istringstream(s)>>a; return a;}
string toStr(int a){ostringstream os; os<<a; return os.str();}

const int maxn=1111;

double p[maxn][maxn];
int n;
int a[maxn];

int main(){
    int m;
    cin>>n>>m;
    REP(i,n) scanf(" %d",a+i);
    REP(i,n) REP(j,i) p[j][i]=a[j]>a[i];

    REP(i,m){
        int x,y; scanf(" %d%d",&x,&y);
        --x; --y;
        if (x>y) swap(x,y);
        p[x][y]=0.5;
        FOR(j,x+1,y){
            double aa=p[x][j], bb=p[j][y];
            p[x][j]=0.5*aa+0.5*(1-bb);
            p[j][y]=0.5*bb+0.5*(1-aa);
        }
    }

    double res=0;
    REP(i,n) REP(j,i) res+=p[j][i];
    printf("%.10lf\n",res);
    return 0;
}


#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <algorithm>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <cstdlib>
#include <string>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cassert>
#include <climits>
//#include <ext/hash_map>

using namespace std;
using namespace __gnu_cxx;

#define REP(i,n) for(int i = 0; i < int(n); ++i)
#define REPV(i, n) for (int i = (n) - 1; (int)i >= 0; --i)
#define FOR(i, a, b) for(int i = (int)(a); i < (int)(b); ++i)

#define FE(i,t) for (__typeof((t).begin())i=(t).begin();i!=(t).end();++i)
#define FEV(i,t) for (__typeof((t).rbegin())i=(t).rbegin();i!=(t).rend();++i)

#define two(x) (1LL << (x))
#define ALL(a) (a).begin(), (a).end()

#define pb push_back
#define ST first
#define ND second
#define MP(x,y) make_pair(x, y)

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<string> vs;

template<class T> void checkmin(T &a, T b){if (b<a)a=b;}
template<class T> void checkmax(T &a, T b){if (b>a)a=b;}
template<class T> void out(T t[], int n){REP(i, n)cout<<t[i]<<" "; cout<<endl;}
template<class T> void out(vector<T> t, int n=-1){for (int i=0; i<(n==-1?t.size():n); ++i) cout<<t[i]<<" "; cout<<endl;}
inline int count_bit(int n){return (n==0)?0:1+count_bit(n&(n-1));}
inline int low_bit(int n){return (n^n-1)&n;}
inline int ctz(int n){return (n==0?-1:ctz(n>>1)+1);}
int toInt(string s){int a; istringstream(s)>>a; return a;}
string toStr(int a){ostringstream os; os<<a; return os.str();}

const int maxn=1111;

double p[maxn][maxn];
int n;
int a[maxn];

int main(){
    int m;
    cin>>n>>m;
    REP(i,n) scanf(" %d",a+i);
    REP(i,n) REP(j,i) p[j][i]=a[j]>a[i];

    REP(i,m){
        int x,y; scanf(" %d%d",&x,&y);
        --x; --y;
        if (x>y) swap(x,y);
        p[x][y]=0.5;
        REP(j,x){
            double aa=p[j][x], bb=p[j][y];
            p[j][x]=0.5*aa+0.5*bb;
            p[j][y]=0.5*aa+0.5*bb;
        }
        FOR(j,y+1,n){
            double aa=p[x][j], bb=p[y][j];
            p[x][j]=0.5*aa+0.5*bb;
            p[y][j]=0.5*aa+0.5*bb;

        }
        FOR(j,x+1,y){
            double aa=p[x][j], bb=p[j][y];
            p[x][j]=0.5*aa+0.5*(1-bb);
            p[j][y]=0.5*bb+0.5*(1-aa);
        }
    }

    double res=0;
    REP(i,n) REP(j,i) res+=p[j][i];
    printf("%.10lf\n",res);
    return 0;
}


#include <cstdio>
using namespace std;

const int MAXN = 1024;

double p[MAXN][MAXN];
int a[MAXN];

int main() {
	int n, m;

	scanf("%d%d", &n, &m);
	for (int i=0; i<n; ++i) {
		scanf("%d", a+i);
		for (int j=0; j<i; ++j) p[i][j] = a[i] > a[j], p[j][i] = 1 - p[i][j];
	}
	for (int x,y; m--; ) {
		scanf("%d%d", &x, &y), --x, --y;
		for (int i=0; i<n; ++i) if (i != x && i != y) {
			p[i][x] = p[i][y] = (p[i][x] + p[i][y]) / 2;
			p[x][i] = p[y][i] = 1 - p[i][x];
		}
		p[x][y] = (p[x][y] + p[y][x]) / 2, p[y][x] = 1 - p[x][y];
	}
	double e = 0;
	for (int i=0; i<n; ++i) for (int j=i+1; j<n; ++j) e += p[i][j];
	printf("%.16lf\n", e);

	return 0;
}


#include <iostream>
#include <cstdio>
#include <algorithm>
#include <set>
#include <stack>
#include <cmath>
#include <queue>
#include <cstdio>
#include <vector>
#include <list>
#define pb push_back
#define lb lower_bound
#define lowbit(x) (x)&(-x)
#define forup(i,a,b) for(int i=(a);i<=(b);i++)
#define fordown(i,a,b) for(int i=(a);i>=(b);i--)
#define maxn 3
#define maxm 100005
#define INF 107000000
#define p 777777777
#define bin(i)  (1<<(i))
#define eps 1e-8
using namespace std;
typedef long long ll;
typedef unsigned long long ull;

template<class T> inline  void read(T& num){   num = 0; bool f = true;char ch = getchar();   while(ch < '0' || ch > '9') { if(ch == '-') f = false;ch = getchar();}   while(ch >= '0' && ch <= '9') {num = num * 10 + ch - '0';ch = getchar();}   num = f ? num: -num;  }
int out[100];
template<class T> inline
void write(T x,char ch){  if (x==0) {putchar('0'); putchar(ch); return;}  if (x<0) {putchar('-'); x=-x;} int num=0; while (x){ out[num++]=(x%10); x=x/10;} fordown(i,num-1,0) putchar(out[i]+'0'); putchar(ch); }
/*========================================================*/
int n,m;
double  f[102][102][102];
int a[maxn];
int main()
{   cin>>n>>m;
  forup(i,1,n) read(a[i]);
  forup(i,1,n)
   forup(j,1,n)
   {if(i!=j)
     { if(a[i]>a[j]) f[0][i][j]=1.0;}
   }
   forup(i,1,m)
   {int x,y; read(x);read(y);
    forup(j,1,n) forup(k,1,n) f[i][j][k]=f[i-1][j][k];
	forup(j,1,n)
     if(j!=x&&j!=y)
     { if(f[i-1][x][j])
        { f[i][y][j]+=0.5*f[i-1][x][j];
		  f[i][j][y]-=0.5*f[i-1][x][j];
		}
	   if(f[i-1][j][x])
	     {f[i][j][y]+=0.5*f[i-1][j][x];
		  f[i][y][j]-=0.5*f[i-1][j][x];
		 }
	  if(f[i-1][y][j])
        { f[i][x][j]+=0.5*f[i-1][y][j];
		  f[i][j][x]-=0.5*f[i-1][y][j];
		}
	   if(f[i-1][j][y])
	     {f[i][j][x]+=0.5*f[i-1][j][y];
		  f[i][x][j]-=0.5*f[i-1][j][y];
		 }
	 }
	 f[i][x][y]=f[i][y][x]=f[i-1][y][x]*0.5+f[i-1][x][y]*0.5;
   }
   double ans=0.0;
   forup(i,1,n)
   forup(j,i+1,n)
   { ans+=f[m][i][j];}
   printf("%.10lf",ans);
	return 0;
}


#ifdef _WIN32
#  define LL "%I64d"
#else
#  define LL "%Ld"
#endif

#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <ctime>
#include <vector>
#include <deque>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <bitset>
#include <string>
#include <algorithm>
#include <complex>
#include <utility>
using namespace std;
#define null NULL
#define mp make_pair
#define pb(a) push_back(a)
#define sz(a) ((int)(a).size())
#define all(a) a.begin() , a.end()
#define fi first
#define se second
#define relaxMin(a , b) (a) = min((a),(b))
#define relaxMax(a , b) (a) = max((a),(b))
#define SQR(a) ((a)*(a))
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef long long ll;
int N , M , A[1010];
double P[1010][1010];
int main(){
  scanf("%d%d" , &N , &M);
  for(int i=0;i<N;++i)
   scanf("%d" , &A[i]);
  for(int i=0;i<N;++i)
   for(int j=0;j<N;++j)
    if(i!=j)P[i][j] = A[min(i,j)] > A[max(i,j)];
  for(int i=0;i<M;++i){
   int a,b; scanf("%d%d" , &a , &b);
   --a; --b;
   if(a > b)swap(a,b);
   if(a == b)continue;
   double bufa[1010] , bufb[1010];
   for(int S=0;S<N;++S)
    bufa[S] = P[a][S] * 0.5,
    bufb[S] = P[b][S] * 0.5;
   for(int S=a+1;S<b;++S)
    bufa[S] += 0.5 * (1-P[b][S]),
    bufb[S] += 0.5 * (1-P[a][S]);
   for(int S=0;S<a;++S)
    bufa[S] += 0.5 * P[b][S],
    bufb[S] += 0.5 * P[a][S];
   for(int S=b+1;S<N;++S)
    bufa[S] += 0.5 * P[b][S],
    bufb[S] += 0.5 * P[a][S];
   bufa[a] = bufb[b] = 0;
   bufa[b] = bufb[a] = 0.5;
   for(int S=0;S<N;++S)
    P[S][b] = P[b][S] = bufb[S],
    P[S][a] = P[a][S] = bufa[S];
                      }
  double ans = 0;
  for(int i=0;i<N;++i)
   for(int j=i+1;j<N;++j)
    ans += P[i][j];
  printf("%.12lf\n" , ans);
  return 0;
}


#ifdef _WIN32
#  define LL "%I64d"
#else
#  define LL "%Ld"
#endif

#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <ctime>
#include <vector>
#include <deque>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <bitset>
#include <string>
#include <algorithm>
#include <complex>
#include <utility>
using namespace std;
#define null NULL
#define mp make_pair
#define pb(a) push_back(a)
#define sz(a) ((int)(a).size())
#define all(a) a.begin() , a.end()
#define fi first
#define se second
#define relaxMin(a , b) (a) = min((a),(b))
#define relaxMax(a , b) (a) = max((a),(b))
#define SQR(a) ((a)*(a))
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef long long ll;
int N , M , A[1010];
double P[1010][1010];
int main(){
  scanf("%d%d" , &N , &M);
  for(int i=0;i<N;++i)
   scanf("%d" , &A[i]);
  for(int i=0;i<N;++i)
   for(int j=0;j<N;++j)
    if(i!=j)P[i][j] = A[min(i,j)] > A[max(i,j)];
  for(int i=0;i<M;++i){
   int a,b; scanf("%d%d" , &a , &b);
   --a; --b;
   double bufa[1010] , bufb[1010];
   for(int S=0;S<N;++S)
    bufa[S] = P[a][S] * ((S<a || S>b)?1.0 : 0.5),
    bufb[S] = P[b][S] * ((S<a || S>b)?1.0 : 0.5);
   for(int S=a;S<=b;++S)
    bufa[S] += 0.5 * (1-P[b][S]),
    bufb[S] += 0.5 * (1-P[a][S]);
   bufa[a] = bufb[b] = 0;
   bufa[b] = bufb[a] = 0.5;
   for(int S=0;S<N;++S)
    P[S][b] = P[b][S] = bufb[S],
    P[S][a] = P[a][S] = bufa[S];
                      }
  double ans = 0;
  for(int i=0;i<N;++i)
   for(int j=i+1;j<N;++j)
    ans += P[i][j];
  printf("%.12lf\n" , ans);
  return 0;
}


#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
using namespace std;
double f[1200][1200],ans;
int i,j,k,l,n,m,a[1200],x,y;
int main(){
	scanf("%d%d",&n,&m);
	for(i=1;i<=n;++i)scanf("%d",&a[i]);
	for(i=1;i<=n;++i)
		for(j=i+1;j<=n;++j)f[i][j]=a[i]>a[j];
	for(i=1;i<=m;++i){
		scanf("%d%d",&x,&y);
		if(x>y)swap(x,y);
		for(j=x+1;j<y;++j){
			f[x][j]=f[j][y]=(f[x][j]+1-f[j][y])/2;
			f[j][y]=1-f[j][y];
		}
		f[x][y]=0.5;
	}
	for(i=1;i<=n;++i)
		for(j=i+1;j<=n;++j)ans+=f[i][j];
	printf("%.10lf\n",ans);
}


/*
 * 258D.cpp
 *
 *  Created on: Jun 20, 2013
 *      Author: Mostafa Saad
 */

#include<set>
#include<map>
#include<list>
#include<iomanip>
#include<cmath>
#include<string>
#include<vector>
#include<queue>
#include<stack>
#include<complex>
#include<sstream>
#include<iostream>
#include<fstream>
#include<algorithm>
#include<numeric>
#include<utility>
#include<functional>
#include<stdio.h>
#include<assert.h>
#include<memory.h>
#include<bitset>
using namespace std;

#define all(v)				((v).begin()), ((v).end())
#define sz(v)				((int)((v).size()))
#define clr(v, d)			memset(v, d, sizeof(v))
#define rep(i, v)		for(int i=0;i<sz(v);++i)
#define lp(i, n)		for(int i=0;i<(int)(n);++i)
#define lpi(i, j, n)	for(int i=(j);i<(int)(n);++i)
#define lpd(i, j, n)	for(int i=(j);i>=(int)(n);--i)

typedef long long ll;
const ll OO = 1e8;

const double EPS = (1e-7);
int dcmp(double x, double y) {
	return fabs(x - y) <= EPS ? 0 : x < y ? -1 : 1;
}

#define pb					push_back
#define MP					make_pair
#define P(x)				cout<<#x<<" = { "<<x<<" }\n"
typedef long double ld;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<vi> vvi;
typedef vector<vd> vvd;
typedef vector<string> vs;

const int MAX = 1001;
int n, m;
int a[MAX];

double expected[MAX][MAX];

int main() {
#ifndef ONLINE_JUDGE
	freopen("c.in", "rt", stdin);
	//freopen(".txt", "wt", stdout);
#endif

	scanf("%d %d", &n, &m);
	lp(i, n)
		scanf("%d", &a[i]);

	lp(i, n) lp(j, n)
		expected[i][j] = a[i] > a[j];

	// Law of total expectation
	while (m--)
	{
		int a, b;
		scanf("%d %d", &a, &b);
		--a, --b;
		expected[a][b] = expected[b][a] = 0.5;

		lp(i, n)
		{
			if (i != a && i != b)
			{
				expected[i][a] = expected[i][b] = (expected[i][a] + expected[i][b]) / 2.0;
				expected[a][i] = expected[b][i] = (expected[a][i] + expected[b][i]) / 2.0;
			}
		}
	}

	double totalExp = 0;
	lp(i, n) lp(j, i)
		totalExp += expected[j][i];

	printf("%.8lf\n", totalExp);

	return 0;
}


/*
 * 258D.cpp
 *
 *  Created on: Jun 20, 2013
 *      Author: Mostafa Saad
 */

#include<set>
#include<map>
#include<list>
#include<iomanip>
#include<cmath>
#include<string>
#include<vector>
#include<queue>
#include<stack>
#include<complex>
#include<sstream>
#include<iostream>
#include<fstream>
#include<algorithm>
#include<numeric>
#include<utility>
#include<functional>
#include<stdio.h>
#include<assert.h>
#include<memory.h>
#include<bitset>
using namespace std;

#define all(v)				((v).begin()), ((v).end())
#define sz(v)				((int)((v).size()))
#define clr(v, d)			memset(v, d, sizeof(v))
#define rep(i, v)		for(int i=0;i<sz(v);++i)
#define lp(i, n)		for(int i=0;i<(int)(n);++i)
#define lpi(i, j, n)	for(int i=(j);i<(int)(n);++i)
#define lpd(i, j, n)	for(int i=(j);i>=(int)(n);--i)

typedef long long ll;
const ll OO = 1e8;

const double EPS = (1e-7);
int dcmp(double x, double y) {
	return fabs(x - y) <= EPS ? 0 : x < y ? -1 : 1;
}

#define pb					push_back
#define MP					make_pair
#define P(x)				cout<<#x<<" = { "<<x<<" }\n"
typedef long double ld;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<vi> vvi;
typedef vector<vd> vvd;
typedef vector<string> vs;

const int MAX = 1001;
int n, m;
int a[MAX];

double expected[MAX][MAX];

int main() {
#ifndef ONLINE_JUDGE
	freopen("c.in", "rt", stdin);
	//freopen(".txt", "wt", stdout);
#endif

	scanf("%d %d", &n, &m);
	lp(i, n)
		scanf("%d", &a[i]);

	lp(i, n) lp(j, n)
		expected[i][j] = a[i] > a[j];

	// Law of total expectation
	while (m--)
	{
		int a, b;
		scanf("%d %d", &a, &b);
		--a, --b;
		expected[a][b] = expected[b][a] = 0.5;

		lp(i, n)
		{
			if (i != a && i != b)
			{
				expected[i][a] = expected[i][b] = (expected[i][a] + expected[i][b]) / 2.0;
				expected[a][i] = expected[b][i] = (expected[a][i] + expected[b][i]) / 2.0;
			}
		}
	}

	double totalExp;
	lp(i, n) lp(j, i)
		totalExp += expected[j][i];

	printf("%.8lf\n", totalExp);

	return 0;
}


/*
 * 258D.cpp
 *
 *  Created on: Jun 20, 2013
 *      Author: Mostafa Saad
 */

#include<set>
#include<map>
#include<list>
#include<iomanip>
#include<cmath>
#include<string>
#include<vector>
#include<queue>
#include<stack>
#include<complex>
#include<sstream>
#include<iostream>
#include<fstream>
#include<algorithm>
#include<numeric>
#include<utility>
#include<functional>
#include<stdio.h>
#include<assert.h>
#include<memory.h>
#include<bitset>
using namespace std;

#define all(v)				((v).begin()), ((v).end())
#define sz(v)				((int)((v).size()))
#define clr(v, d)			memset(v, d, sizeof(v))
#define rep(i, v)		for(int i=0;i<sz(v);++i)
#define lp(i, n)		for(int i=0;i<(int)(n);++i)
#define lpi(i, j, n)	for(int i=(j);i<(int)(n);++i)
#define lpd(i, j, n)	for(int i=(j);i>=(int)(n);--i)

typedef long long ll;
const ll OO = 1e8;

const double EPS = (1e-7);
int dcmp(double x, double y) {
	return fabs(x - y) <= EPS ? 0 : x < y ? -1 : 1;
}

#define pb					push_back
#define MP					make_pair
#define P(x)				cout<<#x<<" = { "<<x<<" }\n"
typedef long double ld;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<vi> vvi;
typedef vector<vd> vvd;
typedef vector<string> vs;

const int MAX = 1001;
int n, m;
int a[MAX];

double expected[MAX][MAX];

int main() {
#ifndef ONLINE_JUDGE
	freopen("c.in", "rt", stdin);
	//freopen(".txt", "wt", stdout);
#endif

	scanf("%d %d", &n, &m);
	lp(i, n)
		scanf("%d", &a[i]);

	lp(i, n) lp(j, n)
		expected[i][j] = a[i] > a[j];

	// Law of total expectation
	while (m--)
	{
		int a, b;
		scanf("%d %d", &a, &b);
		--a, --b;
		expected[a][b] = expected[b][a] = 0.5;

		lp(i, n)
		{
			if (i != a && i != b)
			{
				expected[i][a] = expected[i][b] = (expected[i][a] + expected[i][b]) / 2.0;
				expected[a][i] = expected[b][i] = (expected[a][i] + expected[b][i]) / 2.0;
			}
		}
	}

	double totalExp;
	lp(i, n) lp(j, i)
		totalExp += expected[j][i];

	printf("%.8lf\n", 10.0);

	return 0;
}


/*
 * 258D.cpp
 *
 *  Created on: Jun 20, 2013
 *      Author: Mostafa Saad
 */

#include<set>
#include<map>
#include<list>
#include<iomanip>
#include<cmath>
#include<string>
#include<vector>
#include<queue>
#include<stack>
#include<complex>
#include<sstream>
#include<iostream>
#include<fstream>
#include<algorithm>
#include<numeric>
#include<utility>
#include<functional>
#include<stdio.h>
#include<assert.h>
#include<memory.h>
#include<bitset>
using namespace std;

#define all(v)				((v).begin()), ((v).end())
#define sz(v)				((int)((v).size()))
#define clr(v, d)			memset(v, d, sizeof(v))
#define rep(i, v)		for(int i=0;i<sz(v);++i)
#define lp(i, n)		for(int i=0;i<(int)(n);++i)
#define lpi(i, j, n)	for(int i=(j);i<(int)(n);++i)
#define lpd(i, j, n)	for(int i=(j);i>=(int)(n);--i)

typedef long long ll;
const ll OO = 1e8;

const double EPS = (1e-7);
int dcmp(double x, double y) {
	return fabs(x - y) <= EPS ? 0 : x < y ? -1 : 1;
}

#define pb					push_back
#define MP					make_pair
#define P(x)				cout<<#x<<" = { "<<x<<" }\n"
typedef long double ld;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<vi> vvi;
typedef vector<vd> vvd;
typedef vector<string> vs;

const int MAX = 1001;
int n, m;
int a[MAX];

double expected[MAX][MAX];

int main() {
#ifndef ONLINE_JUDGE
	freopen("c.in", "rt", stdin);
	//freopen(".txt", "wt", stdout);
#endif

	scanf("%d %d", &n, &m);
	lp(i, n)
		scanf("%d", &a[i]);

	lp(i, n) lp(j, n)
		expected[i][j] = a[i] > a[j];

	// Law of total expectation
	while (m--)
	{
		int a, b;
		scanf("%d %d", &a, &b);
		--a, --b;
		expected[a][b] = expected[b][a] = 0.5;

		lp(i, n)
		{
			if (i != a && i != b)
			{
				expected[i][a] = expected[i][b] = (expected[i][a] + expected[i][b]) / 2.0;
				expected[a][i] = expected[b][i] = (expected[a][i] + expected[b][i]) / 2.0;
			}
		}
	}

	double totalExp = 0;
	lp(i, n) lpi(j, i+1, n)
		totalExp += expected[i][j];

	printf("%.8lf\n", totalExp);

	return 0;
}


/*
 * 258D.cpp
 *
 *  Created on: Jun 20, 2013
 *      Author: Mostafa Saad
 */

#include<set>
#include<map>
#include<list>
#include<iomanip>
#include<cmath>
#include<string>
#include<vector>
#include<queue>
#include<stack>
#include<complex>
#include<sstream>
#include<iostream>
#include<fstream>
#include<algorithm>
#include<numeric>
#include<utility>
#include<functional>
#include<stdio.h>
#include<assert.h>
#include<memory.h>
#include<bitset>
using namespace std;

#define all(v)				((v).begin()), ((v).end())
#define sz(v)				((int)((v).size()))
#define clr(v, d)			memset(v, d, sizeof(v))
#define rep(i, v)		for(int i=0;i<sz(v);++i)
#define lp(i, n)		for(int i=0;i<(int)(n);++i)
#define lpi(i, j, n)	for(int i=(j);i<(int)(n);++i)
#define lpd(i, j, n)	for(int i=(j);i>=(int)(n);--i)

typedef long long ll;
const ll OO = 1e8;

const double EPS = (1e-7);
int dcmp(double x, double y) {
	return fabs(x - y) <= EPS ? 0 : x < y ? -1 : 1;
}

#define pb					push_back
#define MP					make_pair
#define P(x)				cout<<#x<<" = { "<<x<<" }\n"
typedef long double ld;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<vi> vvi;
typedef vector<vd> vvd;
typedef vector<string> vs;

const int MAX = 1001;
int n, m;
int a[MAX];

double expected[MAX][MAX];

int main() {
#ifndef ONLINE_JUDGE
	freopen("c.in", "rt", stdin);
	//freopen(".txt", "wt", stdout);
#endif

	scanf("%d %d", &n, &m);
	lp(i, n)
		scanf("%d", &a[i]);

	lp(i, n) lp(j, n)
		expected[i][j] = a[i] > a[j];

	// Law of total expectation
	while (m--)
	{
		int a, b;
		scanf("%d %d", &a, &b);
		--a, --b;
		expected[a][b] = expected[b][a] = (expected[a][b] + expected[b][a]) / 2.0;

		lpi(i, a+1, b)
		{
			if (i != a && i != b)
			{
				expected[i][a] = expected[i][b] = (expected[i][a] + expected[i][b]) / 2.0;
				expected[a][i] = expected[b][i] = (expected[a][i] + expected[b][i]) / 2.0;
			}
		}
	}

	double totalExp = 0;
	lp(i, n) lp(j, i)
		totalExp += expected[j][i];

	printf("%.8lf\n", totalExp);

	return 0;
}


/*
 * 258D.cpp
 *
 *  Created on: Jun 20, 2013
 *      Author: Mostafa Saad
 */

#include<set>
#include<map>
#include<list>
#include<iomanip>
#include<cmath>
#include<string>
#include<vector>
#include<queue>
#include<stack>
#include<complex>
#include<sstream>
#include<iostream>
#include<fstream>
#include<algorithm>
#include<numeric>
#include<utility>
#include<functional>
#include<stdio.h>
#include<assert.h>
#include<memory.h>
#include<bitset>
using namespace std;

#define all(v)				((v).begin()), ((v).end())
#define sz(v)				((int)((v).size()))
#define clr(v, d)			memset(v, d, sizeof(v))
#define rep(i, v)		for(int i=0;i<sz(v);++i)
#define lp(i, n)		for(int i=0;i<(int)(n);++i)
#define lpi(i, j, n)	for(int i=(j);i<(int)(n);++i)
#define lpd(i, j, n)	for(int i=(j);i>=(int)(n);--i)

typedef long long ll;
const ll OO = 1e8;

const double EPS = (1e-7);
int dcmp(double x, double y) {
	return fabs(x - y) <= EPS ? 0 : x < y ? -1 : 1;
}

#define pb					push_back
#define MP					make_pair
#define P(x)				cout<<#x<<" = { "<<x<<" }\n"
typedef long double ld;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<vi> vvi;
typedef vector<vd> vvd;
typedef vector<string> vs;

const int MAX = 1001;
int n, m;
int a[MAX];

double expected[MAX][MAX];

int main() {
#ifndef ONLINE_JUDGE
	freopen("c.in", "rt", stdin);
	//freopen(".txt", "wt", stdout);
#endif

	scanf("%d %d", &n, &m);
	lp(i, n)
		scanf("%d", &a[i]);

	lp(i, n) lp(j, n)
		expected[i][j] = a[i] > a[j];

	// Law of total expectation
	while (m--)
	{
		int a, b;
		scanf("%d %d", &a, &b);
		--a, --b;
		expected[a][b] = expected[b][a] = 0.5;

		lp(i, n)
		{
			if (i != a && i != b)
			{
				expected[i][a] = expected[i][b] = (expected[i][a] + expected[i][b]) / 2.0;
				expected[a][i] = expected[b][i] = (expected[a][i] + expected[b][i]) / 2.0;
			}
		}
	}

	double totalExp;
	lp(i, n) lp(j, i)
		totalExp += expected[j][i];

	printf("%.10lf\n", totalExp);

	return 0;
}


#include <algorithm>
#include <iostream>
#include <cassert>
#include <cstring>
#include <cstdio>
#include <vector>
#include <cmath>
#include <map>
#include <set>

#define SIZE(A) ((int)A.size())
#define LENGTH(A) ((int)A.length())
#define MP(A,B) make_pair(A,B)
#define PB(A) push_back(A)

typedef long long ll;
typedef double ld;

using namespace std;

const int MAXN = 3003;

int t, n, m;
int a[MAXN], b[MAXN], p[MAXN];
int goa[MAXN], gob[MAXN], next[MAXN];

bool w[MAXN][MAXN];
double d[MAXN][MAXN];
double dfs(int i, int j)
{
 	if (i >= m+m && j >= m+m) return a[i]>a[j];
 	if (w[i][j]) return d[i][j];
 	w[i][j] = 1;
 	d[i][j] = 0;

 	if (b[i] == a[j] && j<m+m && i<m+m)
// 		cerr << "I'm here i="<<i<<" j="<<j<<" goa="<<goa[i]<<" goa="<<goa[j]<<"\n",
		d[i][j] = (dfs(goa[i], goa[j])+dfs(gob[i], gob[j]))/2.;
 	else
	if (i < j)
		d[i][j] = (dfs(goa[i], j)+dfs(gob[i], j))/2.;
	else
		d[i][j] = (dfs(i, goa[j])+dfs(i, gob[j]))/2.;

 	return d[i][j];
}

int main()
{
	#ifndef ONLINE_JUDGE
		freopen("input", "r", stdin);
		freopen("output", "w", stdout);
	#endif

	scanf("%d%d", &n, &m);
	for (int i = 0; i < n; i++)
		scanf("%d", p+i),
		next[i] = m+m+i,
		a[next[i]] = i;
	for (int i = 0; i < m; i++)
		scanf("%d%d", a+i+i, b+i+i),
		a[i+i]--, b[i+i]--,
		a[i+i+1] = b[i+i],
		b[i+i+1] = a[i+i];
	for (int i = m+m-1; i >= 0; i-=2)
	{
		goa[i] = next[a[i]]; gob[i] = next[b[i]];
		goa[i-1] = next[b[i]]; gob[i-1] = next[a[i]];
		next[a[i]] = i; next[b[i]] = i-1;
	}

	double res = 0;

	for (int i = 0; i < n; i++)
		for (int j = 0; j < n; j++)
			if (p[i] < p[j])
				res += dfs(next[i], next[j]);

	printf("%.12lf\n", res);

	return 0;
}


#include <algorithm>
#include <iostream>
#include <cassert>
#include <cstring>
#include <cstdio>
#include <vector>
#include <cmath>
#include <map>
#include <set>

#define SIZE(A) ((int)A.size())
#define LENGTH(A) ((int)A.length())
#define MP(A,B) make_pair(A,B)
#define PB(A) push_back(A)

typedef long long ll;
typedef double ld;

using namespace std;

const int MAXN = 3003;

int t, n, m;
int a[MAXN], b[MAXN], p[MAXN];
int goa[MAXN], gob[MAXN], next[MAXN];

bool w[MAXN][MAXN];
double d[MAXN][MAXN];
double dfs(int i, int j)
{
 	if (i >= m+m && j >= m+m) return a[i]>a[j];
 	if (w[i][j]) return d[i][j];
 	w[i][j] = 1;
 	d[i][j] = 0;

 	if (b[i] == a[j] && b[j] == a[i])
// 		cerr << "I'm here i="<<i<<" j="<<j<<" goa="<<goa[i]<<" goa="<<goa[j]<<"\n",
		d[i][j] = (dfs(goa[i], goa[j])+dfs(gob[i], gob[j]))/2.;
 	else
	if (i < j)
		d[i][j] = (dfs(goa[i], j)+dfs(gob[i], j))/2.;
	else
		d[i][j] = (dfs(i, goa[j])+dfs(i, gob[j]))/2.;

 	return d[i][j];
}

int main()
{
	#ifndef ONLINE_JUDGE
		freopen("input", "r", stdin);
		freopen("output", "w", stdout);
	#endif

	scanf("%d%d", &n, &m);
	for (int i = 0; i < n; i++)
		scanf("%d", p+i),
		next[i] = m+m+i,
		a[next[i]] = i,
		b[next[i]] = -1;
	for (int i = 0; i < m; i++)
		scanf("%d%d", a+i+i, b+i+i),
		a[i+i]--, b[i+i]--,
		a[i+i+1] = b[i+i],
		b[i+i+1] = a[i+i];
	for (int i = m+m-1; i >= 0; i-=2)
	{
		goa[i] = next[a[i]]; gob[i] = next[b[i]];
		goa[i-1] = next[b[i]]; gob[i-1] = next[a[i]];
		next[a[i]] = i; next[b[i]] = i-1;
	}

	double res = 0;

	for (int i = 0; i < n; i++)
		for (int j = 0; j < n; j++)
			if (p[i] < p[j])
				res += dfs(next[i], next[j]);

	printf("%.12lf\n", res);

	return 0;
}


#include <cstdio>

const int MAXN = 3003;

int t, n, m;
int a[MAXN], b[MAXN], p[MAXN];
int goa[MAXN], gob[MAXN], next[MAXN];
double d[MAXN][MAXN];

int main()
{
	#ifndef ONLINE_JUDGE
		freopen("input", "r", stdin);
		freopen("output", "w", stdout);
	#endif

	scanf("%d%d", &n, &m);
	for (int i = 0; i < n; i++)
		scanf("%d", p+i),
		next[i] = m+m+i,
		a[next[i]] = i,
		b[next[i]] = -1;
	for (int i = 0; i < m; i++)
		scanf("%d%d", a+i+i, b+i+i),
		a[i+i]--, b[i+i]--,
		a[i+i+1] = b[i+i],
		b[i+i+1] = a[i+i];
	for (int i = m+m-1; i >= 0; i-=2)
	{
		goa[i] = next[a[i]]; gob[i] = next[b[i]];
		goa[i-1] = next[b[i]]; gob[i-1] = next[a[i]];
		next[a[i]] = i; next[b[i]] = i-1;
	}
	for (int i = m+m+n-1; i >= 0; i--)
		for (int j = m+m+n-1; j >= 0; j--)
			if (i>=m+m&&j>=m+m)
				d[i][j] = a[i]>a[j];
			else
			if (b[i] == a[j] && b[j] == a[i])
				d[i][j] = (d[goa[i]][goa[j]]+d[gob[i]][gob[j]])/2.;
			else
			if (i < j)
				d[i][j] = (d[goa[i]][j]+d[gob[i]][j])/2.;
			else
				d[i][j] = (d[i][goa[j]]+d[i][gob[j]])/2.;

	double res = 0;
	for (int i = 0; i < n; i++)
		for (int j = 0; j < n; j++)
			if (p[i] < p[j])
				res += d[next[i]][next[j]];

	printf("%.12lf\n", res);

	return 0;
}


/*
⣿⣿⣿⣿⣿⣿⡷⣯⢿⣿⣷⣻⢯⣿⡽⣻⢿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣇⠸⣿⣿⣆⠹⣿⣿⢾⣟⣯⣿⣿⣿⣿⣿⣿⣽⣻⣿⣿⣿⣿⣿⣿⣿
⣿⣿⣿⣿⣿⣿⣻⣽⡿⣿⣎⠙⣿⣞⣷⡌⢻⣟⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣷⣿⣿⣿⣿⣿⣿⡄⠹⣿⣿⡆⠻⣿⣟⣯⡿⣽⡿⣿⣿⣿⣿⣽⡷⣯⣿⣿⣿⣿⣿⣿
⣿⣿⣿⣿⣿⣿⣟⣷⣿⣿⣿⡀⠹⣟⣾⣟⣆⠹⣯⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡇⢠⡘⣿⣿⡄⠉⢿⣿⣽⡷⣿⣻⣿⣿⣿⣿⡝⣷⣯⢿⣿⣿⣿⣿
⣿⣿⣿⣿⣿⣿⣯⢿⣾⢿⣿⡄⢄⠘⢿⣞⡿⣧⡈⢷⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡇⢸⣧⠘⣿⣷⠈⣦⠙⢿⣽⣷⣻⣽⣿⣿⣿⣿⣌⢿⣯⢿⣿⣿⣿
⣿⣿⣿⣿⣿⣿⣟⣯⣿⢿⣿⡆⢸⡷⡈⢻⡽⣷⡷⡄⠻⣽⣿⣿⡿⣿⣿⣿⣿⣿⣿⣷⣿⣿⣿⣿⣏⢰⣯⢷⠈⣿⡆⢹⢷⡌⠻⡾⢋⣱⣯⣿⣿⣿⣿⡆⢻⡿⣿⣿⣿
⣿⣿⣿⣿⣿⣿⡎⣿⢾⡿⣿⡆⢸⣽⢻⣄⠹⣷⣟⣿⣄⠹⣟⣿⣿⣟⣿⣿⣿⣿⣿⣿⣽⣿⣿⣿⡇⢸⣯⣟⣧⠘⣷⠈⡯⠛⢀⡐⢾⣟⣷⣻⣿⣿⣿⡿⡌⢿⣻⣿⣿
⣿⣿⣿⣿⣿⣿⣧⢸⡿⣟⣿⡇⢸⣯⣟⣮⢧⡈⢿⣞⡿⣦⠘⠏⣹⣿⣽⢿⣿⣿⣿⣿⣯⣿⣿⣿⡇⢸⣿⣿⣾⡆⠹⢀⣠⣾⣟⣷⡈⢿⣞⣯⢿⣿⣿⣿⢷⠘⣯⣿⣿
⣿⣿⣿⣿⣿⣿⣿⡈⣿⢿⣽⡇⠘⠛⠛⠛⠓⠓⠈⠛⠛⠟⠇⢀⢿⣻⣿⣯⢿⣿⣿⣿⣷⢿⣿⣿⠁⣾⣿⣿⣿⣧⡄⠇⣹⣿⣾⣯⣿⡄⠻⣽⣯⢿⣻⣿⣿⡇⢹⣾⣿
⣿⣿⣿⣿⣿⣿⣿⡇⢹⣿⡽⡇⢸⣿⣿⣿⣿⣿⣞⣆⠰⣶⣶⡄⢀⢻⡿⣯⣿⡽⣿⣿⣿⢯⣟⡿⢀⣿⣿⣿⣿⣿⣧⠐⣸⣿⣿⣷⣿⣿⣆⠹⣯⣿⣻⣿⣿⣿⢀⣿⢿
⣿⣿⣿⣿⣿⣿⣿⣿⠘⣯⡿⡇⢸⣿⣿⣿⣿⣿⣿⣿⣧⡈⢿⣳⠘⡄⠻⣿⢾⣽⣟⡿⣿⢯⣿⡇⢸⣿⣿⣿⣿⣿⣿⡀⢾⣿⣿⣿⣿⣿⣿⣆⠹⣾⣷⣻⣿⡿⡇⢸⣿
⣿⣿⣿⣿⣿⣿⣿⣿⡇⢹⣿⠇⢸⣿⣿⣿⣿⣿⣿⣿⣿⣷⣄⠻⡇⢹⣆⠹⣟⣾⣽⣻⣟⣿⣽⠁⣾⣿⣿⣿⣿⣿⣿⣇⣿⣿⠿⠛⠛⠉⠙⠋⢀⠁⢘⣯⣿⣿⣧⠘⣿
⣿⣿⣿⣿⣿⣿⣿⣿⣿⡈⣿⡃⢼⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣦⡙⠌⣿⣆⠘⣿⣞⡿⣞⡿⡞⢠⣿⣿⣿⣿⣿⡿⠛⠉⠁⢀⣀⣠⣤⣤⣶⣶⣶⡆⢻⣽⣞⡿⣷⠈⣿
⣿⣿⣿⣿⣿⣿⣿⣿⡿⠃⠘⠁⠉⠉⠉⠉⠉⠉⠉⠉⠉⠙⠛⠛⢿⣄⢻⣿⣧⠘⢯⣟⡿⣽⠁⣾⣿⣿⣿⣿⣿⡃⢀⢀⠘⠛⠿⢿⣻⣟⣯⣽⣻⣵⡀⢿⣯⣟⣿⢀⣿
⣿⣿⣿⣟⣿⣿⣿⣿⣶⣶⡆⢀⣿⣾⣿⣾⣷⣿⣶⠿⠚⠉⢀⢀⣤⣿⣷⣿⣿⣷⡈⢿⣻⢃⣼⣿⣿⣿⣿⣻⣿⣿⣿⡶⣦⣤⣄⣀⡀⠉⠛⠛⠷⣯⣳⠈⣾⡽⣾⢀⣿
⣿⢿⣿⣿⣻⣿⣿⣿⣿⣿⡿⠐⣿⣿⣿⣿⠿⠋⠁⢀⢀⣤⣾⣿⣿⣿⣿⣿⣿⣿⣿⣌⣥⣾⡿⣿⣿⣷⣿⣿⢿⣷⣿⣿⣟⣾⣽⣳⢯⣟⣶⣦⣤⡾⣟⣦⠘⣿⢾⡁⢺
⣿⣻⣿⣿⡷⣿⣿⣿⣿⣿⡗⣦⠸⡿⠋⠁⢀⢀⣠⣴⢿⣿⣽⣻⢽⣾⣟⣷⣿⣟⣿⣿⣿⣳⠿⣵⣧⣼⣿⣿⣿⣿⣿⣾⣿⣿⣿⣿⣿⣽⣳⣯⣿⣿⣿⣽⢀⢷⣻⠄⠘
⣿⢷⣻⣿⣿⣷⣻⣿⣿⣿⡷⠛⣁⢀⣀⣤⣶⣿⣛⡿⣿⣮⣽⡻⣿⣮⣽⣻⢯⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣯⢀⢸⣿⢀⡆
⠸⣟⣯⣿⣿⣷⢿⣽⣿⣿⣷⣿⣷⣆⠹⣿⣶⣯⠿⣿⣶⣟⣻⢿⣷⣽⣻⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⢀⣯⣟⢀⡇
⣇⠹⣟⣾⣻⣿⣿⢾⡽⣿⣿⣿⣿⣿⣆⢹⣶⣿⣻⣷⣯⣟⣿⣿⣽⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡿⢀⡿⡇⢸⡇
⣿⣆⠹⣷⡻⣽⣿⣯⢿⣽⣻⣿⣿⣿⣿⣆⢻⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⠛⢻⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⠇⢸⣿⠇⣼⡇
⡙⠾⣆⠹⣿⣦⠛⣿⢯⣷⢿⡽⣿⣿⣿⣿⣆⠻⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⠃⠎⢸⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⠏⢀⣿⣾⣣⡿⡇
⣿⣷⡌⢦⠙⣿⣿⣌⠻⣽⢯⣿⣽⣻⣿⣿⣿⣧⠩⢻⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡏⢰⢣⠘⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡿⠃⢀⢀⢿⣞⣷⢿⡇
⣿⣽⣆⠹⣧⠘⣿⣿⡷⣌⠙⢷⣯⡷⣟⣿⣿⣿⣷⡀⡹⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣷⣈⠃⣸⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⠟⢀⣴⡧⢀⠸⣿⡽⣿⢀
⢻⣽⣿⡄⢻⣷⡈⢿⣿⣿⢧⢀⠙⢿⣻⡾⣽⣻⣿⣿⣄⠌⢿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⠛⢁⣰⣾⣟⡿⢀⡄⢿⣟⣿⢀
⡄⢿⣿⣷⢀⠹⣟⣆⠻⣿⣿⣆⢀⣀⠉⠻⣿⡽⣯⣿⣿⣷⣈⢻⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡿⠋⢀⣠⠘⣯⣷⣿⡟⢀⢆⠸⣿⡟⢸
⣷⡈⢿⣿⣇⢱⡘⢿⣷⣬⣙⠿⣧⠘⣆⢀⠈⠻⣷⣟⣾⢿⣿⣆⠹⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡿⠋⣠⡞⢡⣿⢀⣿⣿⣿⠇⡄⢸⡄⢻⡇⣼
⣿⣷⡈⢿⣿⡆⢣⡀⠙⢾⣟⣿⣿⣷⡈⠂⠘⣦⡈⠿⣯⣿⢾⣿⣆⠙⠻⠿⠿⠿⠿⡿⣿⣿⣿⣿⣿⣿⣿⣿⣿⠿⠛⢋⣠⣾⡟⢠⣿⣿⢀⣿⣿⡟⢠⣿⢈⣧⠘⢠⣿
⣿⣿⣿⣄⠻⣿⡄⢳⡄⢆⡙⠾⣽⣿⣿⣆⡀⢹⡷⣄⠙⢿⣿⡾⣿⣆⢀⡀⢀⢀⢀⢀⢀⢀⢀⢀⢀⢀⢀⢀⣀⣠⣴⡿⣯⠏⣠⣿⣿⡏⢸⣿⡿⢁⣿⣿⢀⣿⠆⢸⣿
⣿⣿⣿⣿⣦⡙⣿⣆⢻⡌⢿⣶⢤⣉⣙⣿⣷⡀⠙⠽⠷⠄⠹⣿⣟⣿⣆⢙⣋⣤⣤⣤⣄⣀⢀⢀⢀⢀⣾⣿⣟⡷⣯⡿⢃⣼⣿⣿⣿⠇⣼⡟⣡⣿⣿⣿⢀⡿⢠⠈⣿
⣿⣿⣿⣿⣿⣷⣮⣿⣿⣿⡌⠁⢤⣤⣤⣤⣬⣭⣴⣶⣶⣶⣆⠈⢻⣿⣿⣆⢻⣿⣿⣿⣿⣿⣿⣷⣶⣤⣌⣉⡘⠛⠻⠶⣿⣿⣿⣿⡟⣰⣫⣴⣿⣿⣿⣿⠄⣷⣿⣿⣿
*/

#include <bits/stdc++.h>

using namespace std;

#define x first
#define y second
#define mp make_pair
#define pb push_back
#define sqr(a) ((a) * (a))
#define sz(a) int(a.size())
#define all(a) a.begin(), a.end()
#define forn(i, n) for(int i = 0; i < int(n); i++)
#define fore(i, l, r) for(int i = int(l); i < int(r); i++)

typedef long long li;
typedef long double ld;
typedef pair<int, int> pt;

template <class A, class B> ostream& operator << (ostream& out, const pair<A, B> &a) {
	return out << "(" << a.x << ", " << a.y << ")";
}

template <class A> ostream& operator << (ostream& out, const vector<A> &v) {
	out << "[";
	forn(i, sz(v)) {
		if(i) out << ", ";
		out << v[i];
	}
	return out << "]";
}

mt19937 rnd(time(NULL));

const int INF = int(1e9);
const li INF64 = li(1e18);
const int MOD = int(1e9) + 7;
const ld EPS = 1e-9;
const ld PI = acos(-1.0);

const int N = 1000 + 7;

int n, m;
int a[N];
pt q[N];

bool read () {
	if (scanf("%d%d", &n, &m) != 2)
		return false;
	forn(i, n){
		scanf("%d", &a[i]);
		--a[i];
	}
	forn(i, m){
		scanf("%d%d", &q[i].x, &q[i].y);
		--q[i].x, --q[i].y;
	}
	return true;
}

ld ls[N][N];

void solve() {
	forn(i, n) forn(j, n) ls[i][j] = (a[i] < a[j]);
	forn(i, m){
		int x = q[i].x;
		int y = q[i].y;
		forn(j, n) if (j != x && j != y) ls[x][j] = ls[y][j] = (ls[x][j] + ls[y][j]) / 2;
		forn(j, n) if (j != x && j != y) ls[j][x] = 1 - ls[x][j], ls[j][y] = 1 - ls[y][j];
		ls[x][y] = ls[y][x] = 0.5;
	}
	ld sum = 0;
	forn(i, n) forn(j, i) sum += ls[i][j];
	printf("%.15Lf\n", sum);
}

int main() {
#ifdef _DEBUG
	freopen("input.txt", "r", stdin);
//	freopen("output.txt", "w", stdout);

	int tt = clock();

#endif

	cerr.precision(15);
	cout.precision(15);
	cerr << fixed;
	cout << fixed;

	while(read()) {
		solve();

#ifdef _DEBUG
	cerr << "TIME = " << clock() - tt << endl;
	tt = clock();
#endif

	}
}


#include<bits/stdc++.h>
using namespace std;
const int maxn=1000;
double f[maxn+50][maxn+50];
int a[maxn+50];
int n,m;
int main()
{
    scanf("%d%d",&n,&m);
    for(int i=1;i<=n;++i) scanf("%d",&a[i]);
    memset(f,0,sizeof(f));
    for(int i=1;i<=n;++i)
        for(int j=1;j<=n;++j)
            if(a[i]>a[j]) f[i][j]=1.0;
    while(m--)
    {
        int x,y;
        scanf("%d%d",&x,&y);
        for(int i=1;i<=n;++i)
        {
            if(i==x||i==y) continue;
            f[i][y]=f[i][x]=(f[i][x]+f[i][y])/2;
            f[x][i]=f[y][i]=(f[x][i]+f[y][i])/2;
        }
        f[x][y]=f[y][x]=(f[x][y]+f[y][x])/2;
    }
    double ans=0.0;
    for(int i=1;i<=n;++i)
        for(int j=i+1;j<=n;++j)
            ans+=f[i][j];
    printf("%.10f\n",ans);
    return 0;
}


#include <cstdio>
#include <cstring>

const int N = 1000;

int n, m, p[N], a[N], b[N];
double prob[N][N];

int main() {
    scanf("%d%d", &n, &m);
    for (int i = 0; i < n; ++ i) {
        scanf("%d", p + i);
    }
    for (int i = 0; i < m; ++ i) {
        scanf("%d%d", a + i, b + i);
        a[i] --;
        b[i] --;
    }
    for (int i = 0; i < n; ++ i) {
        for (int j = 0; j < n; ++ j) {
            prob[i][j] = i < j ? 1.0 : 0.0;
        }
    }
    for (int k = m - 1; k >= 0; -- k) {
        int u = a[k];
        int v = b[k];
        for (int i = 0; i < n; ++ i) {
            if (i != u && i != v) {
                prob[i][u] = prob[i][v] = (prob[i][u] + prob[i][v]) / 2.0;
                prob[u][i] = prob[v][i] = (prob[u][i] + prob[v][i]) / 2.0;
            }
        }
        prob[u][v] = prob[v][u] = (prob[u][v] + prob[v][u]) / 2.0;
    }
    double answer = 0;
    for (int i = 0; i < n; ++ i) {
        for (int j = 0; j < n; ++ j) {
            if (p[i] > p[j]) {
                answer += prob[i][j];
            }
        }
    }
    printf("%.10f\n", answer);
    return 0;
}


#include <cstdio>
#include <cstring>
#include <vector>
#include <utility>
#include <algorithm>

using std::vector;
using std::pair;
using std::make_pair;

#define foreach(i, v) for (__typeof((v).begin()) i = (v).begin(); i != (v).end(); ++ i)

const int N = 100000;

int n, m, label_count, label[N], size[N], position[N];
vector <int> tree[N];

void dfs(int p, int u) {
    label[u] = label_count ++;
    position[label[u]] = u;
    size[u] = 1;
    foreach (iter, tree[u]) {
        if (*iter != p) {
            dfs(u, *iter);
            size[u] += size[*iter];
        }
    }
}

int a[N], b[N];

vector <pair <int, int> > events;

int get_id(int l, int r) {
    return l + r | l != r;
}

int cover[N << 1], total[N << 1];

void update(int l, int r) {
    int m = l + r >> 1;
    total[get_id(l, r)] = total[get_id(l, m)] + total[get_id(m + 1, r)];
    if (cover[get_id(l, r)]) {
        total[get_id(l, r)] = r - l + 1;
    }
}

void modify(int l, int r, int a, int b, int c) {
    if (b < l || r < a) {
        return;
    }
    if (a <= l && r <= b) {
        cover[get_id(l, r)] += c;
        if (l == r) {
            total[get_id(l, r)] = cover[get_id(l, r)] > 0;
        } else {
            update(l, r);
        }
        return;
    }
    int m = l + r >> 1;
    modify(l, m, a, b, c);
    modify(m + 1, r, a, b, c);
    update(l, r);
}

int answer[N];

int main() {
    scanf("%d%d", &n, &m);
    for (int i = 0; i < n - 1; ++ i) {
        int a, b;
        scanf("%d%d", &a, &b);
        a --, b --;
        tree[a].push_back(b);
        tree[b].push_back(a);
    }
    label_count = 0;
    dfs(-1, 0);
    for (int i = 0; i < m; ++ i) {
        scanf("%d%d", a + i, b + i);
        a[i] --;
        b[i] --;
        events.push_back(make_pair(label[a[i]], i << 1));
        events.push_back(make_pair(label[a[i]] + size[a[i]], (i << 1) | 1));
        events.push_back(make_pair(label[b[i]], i << 1));
        events.push_back(make_pair(label[b[i]] + size[b[i]], (i << 1) | 1));
    }
    std::sort(events.begin(), events.end());
    memset(cover, 0, sizeof(cover));
    for (int now = 0, pt = 0; now < n; ++ now) {
        while (pt < (int)events.size() && events[pt].first == now) {
            int id = events[pt].second >> 1;
            int delta = (events[pt].second & 1) ? -1 : 1;
            modify(0, n - 1, label[a[id]], label[a[id]] + size[a[id]] - 1, delta);
            modify(0, n - 1, label[b[id]], label[b[id]] + size[b[id]] - 1, delta);
            pt ++;
        }
        answer[position[now]] = std::max(total[get_id(0, n - 1)] - 1, 0);
    }
    for (int i = 0; i < n; ++ i) {
        printf("%d%c", answer[i], i == n - 1 ? '\n' : ' ');
    }
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define pii             pair<int , int >
#define inf             1000000011
#define in(a)           scanf("%d", &a)
#define ins(a)          scanf("%s", a)
#define in2(a, b)       scanf("%d%d", &a, &b)
#define in3(a, b, c)    scanf("%d%d%d", &a, &b, &c)
#define pn              printf("\n")
#define pr(a)           printf("%d\n", a)
#define prs(a)          printf("%d ", a)
#define pr2(a, b)       printf("%d %d\n", a, b)
#define pr3(a, b, c)    printf("%d %d %d\n", a, b, c)
#define pcs(a)          printf("Case %d: ", a)
#define mp              make_pair
#define vi              vector<int >
#define _ceil(n, a)     ((n)%(a)==0?((n)/(a)):((n)/(a)+1))
#define sz              size()
#define pb              push_back
#define mem(a, b)       memset((a), (b), sizeof(a))
#define all(X)          (X).begin(), (X).end ()
#define lg2(n)          (31-__builtin_clz(n))
#define ext(a)          {printf("%s\n", a); return 0;}
#define oka(x, y)       ((x)>=0&&(x)<row&&(y)>=0&&(y)<col)
#define x               first
#define y               second
#define lc              (2*i)
#define rc              (2*i+1)

typedef long long LL;
//int  dx[]={1,0,-1,0};int dy[]={0,1,0,-1}; //4 Direction
//int  dx[]={1,1,0,-1,-1,-1,0,1,0};int dy[]={0,1,1,1,0,-1,-1,-1,0};//8 direction
//int  dx[]={2,1,-1,-2,-2,-1,1,2};int dy[]={1,2,2,1,-1,-2,-2,-1};//Knight Direction
//bool check(int n, int pos) {return (n & (1<<pos))>>pos;} //typecast 1 in case of int
//int  on(int n, int pos) {return n | (1<<pos);} //typecast 1 in case of int
//int  off(int n, int pos) {return n & ~(1<<pos);} //typecast 1 in case of int
//bool operator < (const data &d) const{return cost<d.cost;} //reverse in priority queue

const int M = 1010, mod = 1000000007;

double dp[M][M];
int A[M];

int main()
{
#ifndef ONLINE_JUDGE
    freopen("/home/lochness/Documents/in.txt", "r", stdin);
//    freopen("/home/lochness/Documents/in.txt", "w", stdout);
#endif
    ios_base::sync_with_stdio(false);

    int n, q, i, j, k;

    in2(n, q);
    for (i = 1; i <= n; i++) in(A[i]);
    for (i = 1; i <= n; i++) for (j = i+1; j <= n; j++) dp[i][j] = (A[j] < A[i]);

    while (q--)
    {
        in2(i, j);

        double a[M], b[M];
        for (k = 1; k < i; k++) dp[k][i] = .5 * dp[k][i] + .5 * dp[k][j];
        for (k = j + 1; k <= n; k++) dp[k][j] = .5 * dp[j][k] + .5 * dp[i][k];
        dp[i][j] = .5;
        for (k = i+1; k < j; k++) a[k] = dp[i][k], b[k] = dp[k][j];
        for (k = i+1; k < j; k++) dp[i][k] = .5 * a[k] + .5 * (1 - b[k]);
        for (k = i+1; k < j; k++) dp[k][j] = .5 * b[k] + .5 * (1 - a[k]);
    }

    double sum = 0;
    for (i = 1; i <= n; i++) for (j = i+1; j <= n; j++) sum += dp[i][j];

    printf("%.9f\n", sum);

    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define pii             pair<int , int >
#define inf             1000000011
#define in(a)           scanf("%d", &a)
#define ins(a)          scanf("%s", a)
#define in2(a, b)       scanf("%d%d", &a, &b)
#define in3(a, b, c)    scanf("%d%d%d", &a, &b, &c)
#define pn              printf("\n")
#define pr(a)           printf("%d\n", a)
#define prs(a)          printf("%d ", a)
#define pr2(a, b)       printf("%d %d\n", a, b)
#define pr3(a, b, c)    printf("%d %d %d\n", a, b, c)
#define pcs(a)          printf("Case %d: ", a)
#define mp              make_pair
#define vi              vector<int >
#define _ceil(n, a)     ((n)%(a)==0?((n)/(a)):((n)/(a)+1))
#define sz              size()
#define pb              push_back
#define mem(a, b)       memset((a), (b), sizeof(a))
#define all(X)          (X).begin(), (X).end ()
#define lg2(n)          (31-__builtin_clz(n))
#define ext(a)          {printf("%s\n", a); return 0;}
#define oka(x, y)       ((x)>=0&&(x)<row&&(y)>=0&&(y)<col)
#define x               first
#define y               second
#define lc              (2*i)
#define rc              (2*i+1)

typedef long long LL;
//int  dx[]={1,0,-1,0};int dy[]={0,1,0,-1}; //4 Direction
//int  dx[]={1,1,0,-1,-1,-1,0,1,0};int dy[]={0,1,1,1,0,-1,-1,-1,0};//8 direction
//int  dx[]={2,1,-1,-2,-2,-1,1,2};int dy[]={1,2,2,1,-1,-2,-2,-1};//Knight Direction
//bool check(int n, int pos) {return (n & (1<<pos))>>pos;} //typecast 1 in case of int
//int  on(int n, int pos) {return n | (1<<pos);} //typecast 1 in case of int
//int  off(int n, int pos) {return n & ~(1<<pos);} //typecast 1 in case of int
//bool operator < (const data &d) const{return cost<d.cost;} //reverse in priority queue

const int M = 1010, mod = 1000000007;

double dp[M][M];
int A[M];

int main()
{
#ifndef ONLINE_JUDGE
    freopen("/home/lochness/Documents/in.txt", "r", stdin);
//    freopen("/home/lochness/Documents/in.txt", "w", stdout);
#endif
    ios_base::sync_with_stdio(false);

    int n, q, i, j, k;

    in2(n, q);
    for (i = 1; i <= n; i++) in(A[i]);
    for (i = 1; i <= n; i++) for (j = i+1; j <= n; j++) dp[i][j] = (A[j] < A[i]);

    while (q--)
    {
        in2(i, j);
        if (i > j) swap(i, j);

        for (k = 1; k < i; k++)
        {
            double x = dp[k][i];
            double y = dp[k][j];
            dp[k][i] = dp[k][j] = .5 * x + .5 * y;
        }
        for (k = j + 1; k <= n; k++)
        {
            double x = dp[j][k];
            double y = dp[i][k];
            dp[i][k] = dp[j][k] = .5 * x + .5 * y;
        }
        dp[i][j] = .5;
        for (k = i+1; k < j; k++)
        {
            double x = dp[i][k];
            double y = dp[k][j];
            dp[i][k] = .5 * x + .5 * (1 - y);
            dp[k][j] = .5 * (1 - x) + .5 * y;
        }
    }

    double sum = 0;
    for (i = 1; i <= n; i++) for (j = i+1; j <= n; j++) sum += dp[i][j];

    printf("%.9f\n", sum);

    return 0;
}


#include <bits/stdc++.h>
#ifdef DEMETRIO
#define deb(...) fprintf(stderr,__VA_ARGS__)
#define deb1(x) cerr << #x << " = " << x << endl
#else
#define deb(...) 0
#define deb1(x) 0
#endif
#define pb push_back
#define mp make_pair
#define fst first
#define snd second
#define fore(i,a,b) for(int i=a,ThxDem=b;i<ThxDem;++i)
#define SZ(x) ((int)(x).size())
#define mset(a,v) memset(a,v,sizeof(a))
#define mcpy(a,b) memcpy(a,b,sizeof(a))
using namespace std;
typedef long long ll;

int n,m;
double p[1024][1024],s[1024][1024];

int main(){
	scanf("%d%d",&n,&m);
	fore(i,0,n){
		int t;
		scanf("%d",&t);t--;
		p[i][t]=1;
	}
	fore(_,0,m){
		int a,b;
		scanf("%d%d",&a,&b);a--;b--;
		fore(i,0,n)p[a][i]=p[b][i]=(p[a][i]+p[b][i])/2;
	}
	fore(i,0,n)fore(j,0,n)s[i][j+1]=s[i][j]+p[i][j];
	double r=0;
	fore(i,1,n){
		double t=0;
		for(int j=n-1;j>=0;--j){
			r+=t*p[j][i];
			if(p[j][i]==1)break;
			t+=s[j][i]/(1-p[j][i]);
		}
	}
	printf("%.12lf\n",r);
	return 0;
}


#include <bits/stdc++.h>
#ifdef DEMETRIO
#define deb(...) fprintf(stderr,__VA_ARGS__)
#define deb1(x) cerr << #x << " = " << x << endl
#else
#define deb(...) 0
#define deb1(x) 0
#endif
#define pb push_back
#define mp make_pair
#define fst first
#define snd second
#define fore(i,a,b) for(int i=a,ThxDem=b;i<ThxDem;++i)
#define SZ(x) ((int)(x).size())
#define mset(a,v) memset(a,v,sizeof(a))
#define mcpy(a,b) memcpy(a,b,sizeof(a))
using namespace std;
typedef long long ll;

int n,m;
double g[1024][1024],r;
int p[1024];

int main(){
	scanf("%d%d",&n,&m);
	fore(i,0,n)scanf("%d",p+i);
	fore(i,0,n)fore(j,0,n)g[i][j]=p[i]>p[j];
	fore(_,0,m){
		int a,b;
		scanf("%d%d",&a,&b);a--;b--;
		fore(i,0,n){
			if(i==a||i==b)continue;
			g[i][a]=g[i][b]=(g[i][a]+g[i][b])/2;
			g[b][i]=g[a][i]=1-g[i][a];
		}
		g[a][b]=g[b][a]=.5;
	}
	fore(i,0,n)fore(j,i+1,n)r+=g[i][j];
	printf("%.12lf\n",r);
	return 0;
}


/*
Faintly arisen, tenderly torn
Dreamlike decision, unconsciously born

Firm in conviction yet tempt me they can
Deny me of trust and a demon I hide

A drive to be less than the fortunate
A dream in the casket of Eden
Crave that which you do not desire
Cling tightly to your deepest fear

I rose the greatest monument
Again and again
I bear the greatest treasure
Of time and a word

Treason spilt on the loneliest of graves
Desperation dealt the losing hand again
Wherein lie the purpose of the day?
Is there return in sadness?

Does your ceiling differ much from mine
Where we see each other?
Here in this light
Is that pillow more than a frame
That holds the chaos fast?
Now his hand a fist
Gain control

Silence fell and eyes now widened
Filling up the strength collapsing
Capable of the ending froze in the tracks
Brought to a bitter halt

On the floor it seems the steps are showing
Left a print just like it did in me
What has been and what will be
Never care 'cause I was in between
As I said with on afoot in loneliness
You hide here in me
*/

#pragma GCC optimize("O3")
#define _CRT_SECURE_NO_WARNINGS
#include <fstream>
#include <iostream>
#include <string>
#include <complex>
#include <math.h>
#include <set>
#include <vector>
#include <map>
#include <queue>
#include <stdio.h>
#include <stack>
#include <algorithm>
#include <list>
#include <ctime>

#include <memory.h>
#include <assert.h>

#define y0 sdkfaslhagaklsldk

#define y1 aasdfasdfasdf
#define yn askfhwqriuperikldjk
#define j1 assdgsdgasghsf
#define tm sdfjahlfasfh
#define lr asgasgash
#define norm asdfasdgasdgsd
#define have adsgagshdshfhds
#define ends asdgahhfdsfshdshfd
#define prev asdgSHJsfgsdfhdsh
#define hash asdgasdgasdgdfrywewery

#define eps 1e-12
#define M_PI 3.141592653589793
#define bsize 300

#define ldouble long double
using namespace std;

#define bs 1000000007

const int N = 200031;

long double A[3031][3031];
int n,tests,ar[N];
int last_mod[N];
long long pw[N];
int T;

long long inv2;

long long P(long long a,long long b){
	if (b==0)
		return 1;
	if (b%2)
		return a*P(a,b-1)%bs;
	return P(a*a%bs,b/2);
}

long long inv(long long x){
	return P(x,bs-2);
}

int main(){
//    freopen("apache.in","r",stdin);
//    freopen("apache.out","w",stdout);
//    freopen("input.txt", "r", stdin);
//    freopen("output.txt", "w", stdout);
    ios_base::sync_with_stdio(0);
    //cin.tie(0);

    pw[0]=1;
    for (int i=1;i<N;i++){
    	pw[i]=pw[i-1]*2%bs;
    }

    inv2=inv(2);

    cin>>n>>tests;
    for (int i=1;i<=n;i++){
    	cin>>ar[i];
    }

    for (int i=1;i<=n;i++){
    	for (int j=1;j<=n;j++){
    		if (ar[i]>ar[j])
    			A[i][j]=1;
    	}
    }

    for (int i=1;i<=n;i++){
    	last_mod[i]=0;
    }

    for (int test=1;test<=tests;test++){
    	int a,b;
    	cin>>a>>b;
    	for (int i=1;i<=n;i++){
    		if (i!=a&&i!=b){
    			double here=A[a][i]+A[b][i];
    			here/=2;
    			A[a][i]=A[b][i]=here;
    			here=A[i][a]+A[i][b];
    			here=here/2;
    			A[i][a]=A[i][b]=here;
    		}
    	}
    	double here=A[a][b]+A[b][a];
    	here=here/2;
    	A[a][b]=A[b][a]=here;
    }

    long double ans=0;

    for (int i=1;i<=n;i++){
    	for (int j=i+1;j<=n;j++){
    		long double here=A[i][j];
    		ans+=here;
    	}
    }

    cout.precision(12);
    cout<<fixed<<ans<<endl;

//    cin.get(); cin.get();
    return 0;
}


#include<bits/stdc++.h>
const int MAXN = 1010;
using namespace std;
double p[MAXN][MAXN];
int arr[MAXN];
int n, m;

int main()
{

  memset(p, 0.0, sizeof p);
  scanf("%d%d", &n, &m);

  for (int i = 0; i < n; i++)
    {
       scanf("%d", &arr[i]);
       arr[i]--;
  }

  memset(p, 0.0, sizeof p);
  for (int i = 0; i < n; i++)
    for (int j = i + 1; j < n; j++)
      if  (arr[i] > arr[j])
        p[i][j] = 1.0;

  for (int it = 0; it < m; it++)
    {
      int a, b;
      scanf("%d%d", &a, &b);
      a--; b--;
      if (a > b) swap(a, b);

      p[a][b] = 0.5;

     for(int c = 0; c < a; c++) {
      double pa = p[c][a];
      double pb = p[c][b];
      p[c][a] = p[c][b] = 0.5 * pa + 0.5 * pb;
    }

    for (int c = a + 1; c < b; c++)
    {
       double pa = p[a][c];
       double pb = p[c][b];
       p[a][c] = 0.5 * pa + 0.5 * (1.0 - pb);
       p[c][b] = 0.5 * (1.0 - pa) + 0.5 * pb;
    }

    for (int c = b + 1; c < n; c++)
    {
       double pa = p[a][c];
       double pb = p[b][c];
       p[a][c] = p[b][c] = 0.5 * pa + 0.5 * pb;
    }

  }

  double res = 0.0;
  for (int i = 0; i < n; i++)
    for (int j = i + 1; j < n; j++)
      res += p[i][j];

  printf("%.10lf\n", res);
  return 0;
}


#include <bits/stdc++.h>
using namespace std;

void div2(vector<double> &v) {
	for(auto &lol : v) {
		lol/=2;
	}
}

int main() {
	int n,m;
	cin>>n>>m;
	int temp,temp2;
	vector<vector<double>> v(n+1);
	for(temp=1;temp<=n;temp++) {
		v[temp].resize(n+1,0);
		int x;
		cin>>x;
		v[temp][x]++;
	}

	while(m--) {
		int x,y;
		cin>>x>>y;
		div2(v[x]);
		div2(v[y]);
		for(temp=1;temp<=n;temp++) {
			double tmp=v[y][temp];
			v[y][temp]+=v[x][temp];
			v[x][temp]+=tmp;
		}
	}
	double ans=0;
	for(temp=1;temp<=n;temp++) {
		for(temp2=1;temp2<=n;temp2++) {
			//cout<<temp<<" "<<temp2<<" "<<v[temp][temp2]<<"\n";
			ans+=v[temp][temp2] * (temp2-1);
		}
	}
	cout<<fixed<<setprecision(9)<<ans/2<<"\n";

}


#include <bits/stdc++.h>
using namespace std;

void div2(vector<double> &v) {
	for(auto &lol : v) {
		lol/=2;
	}
}

int main() {
	int n,m;
	cin>>n>>m;
	int temp,temp2;
	double p[n+1][n+1];
	vector<double> a(n+1);
	for(temp=1;temp<=n;temp++) {
		cin>>a[temp];
	}
	for(temp=1;temp<=n;temp++)
		for(temp2=temp+1;temp2<=n;temp2++)
			p[temp][temp2]=(a[temp]>a[temp2]);

	while(m--) {
		int x,y;
		cin>>x>>y;
		if(x>y)	swap(x,y);
		for(int z=1;z<x;z++) {
			p[z][x]=p[z][y]= 0.5 * (p[z][x]+p[z][y]);
		}
		for(int z=x+1; z<y; z++) {
			double tmp=p[x][z];
			p[x][z] = 0.5 * (p[x][z] + 1.0 - p[z][y]);
			p[z][y] = 0.5 * (p[z][y] + 1.0 - tmp);
		}

		for(int z=y+1;z<=n;z++) {
			p[x][z] = p[y][z] = 0.5 * (p[x][z]+p[y][z]);
		}
		p[x][y]=0.5;
	}
	double ans=0;
	for(temp=1;temp<=n;temp++)
		for(temp2=temp+1;temp2<=n;temp2++)
			ans+=p[temp][temp2];
	cout<<fixed<<setprecision(9)<<ans<<"\n";

}


#include <bits/stdc++.h>
using namespace std;
#define  int long long int
const int MAXN=1010;
int a[MAXN];
double e[MAXN][MAXN],tmp[MAXN][MAXN];
main(){
    ios_base::sync_with_stdio(false);
    int n,m;
    cin>>n>>m;

    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    for(int i=0;i<n;i++){
        for(int j=i+1;j<n;j++){
            if(a[i]>a[j])
                e[i][j]=1;
        }
    }

    for(int i=0;i<m;i++){

        int x,y;
        cin>>x>>y;

        x--;y--;
        if(x>y)
            swap(x,y);

        for(int j=x+1;j<y;j++){
            //تبدلو + ما تبدلو
            tmp[x][j]=0.5*(1-e[j][y])+0.5*e[x][j];
            tmp[j][y]=0.5*(1-e[x][j])+0.5*e[j][y];
        }
        for(int j=y+1;j<n;j++){
            tmp[x][j]=0.5*e[y][j]+0.5*e[x][j];
            tmp[y][j]=0.5*e[y][j]+0.5*e[x][j];
            //tmp[y][j]
        }
        for(int j=0;j<x;j++){
            tmp[j][x]=tmp[j][y]=0.5*e[j][x]+0.5*e[j][y];
        }
        e[x][y]=0.5;

        for(int j=x+1;j<y;j++){
            //تبدلو + ما تبدلو
            e[x][j]=tmp[x][j];
            e[j][y]=tmp[j][y];
        }
        for(int j=y+1;j<n;j++){
            e[x][j]=e[y][j]=tmp[x][j];
        }
        for(int j=0;j<x;j++){
            e[j][x]=e[j][y]=tmp[j][x];
        }
       // e[x][y]=tmp[x][y];

    }
    double ans  = 0;
//    for(int i=0;i<n;i++){
//        for(int j=0;j<n;j++){
//            cout<<fixed<<setprecision(4)<<" "<<e[i][j]<<" ";
//        }
//        cout<<endl;
//    }
    for(int i=0;i<n;i++){
        for(int j=i+1;j<n;j++){

            ans+=e[i][j];
        }
    }
    cout<<fixed<<setprecision(10)<<ans<<endl;
}


#include <bits/stdc++.h>
using namespace std;
#define  int long long int
const int MAXN=1010;
int a[MAXN];
double e[MAXN][MAXN],tmp[MAXN][MAXN];
main(){
    ios_base::sync_with_stdio(false);
    int n,m;
    cin>>n>>m;

    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    for(int i=0;i<n;i++){
        for(int j=i+1;j<n;j++){
            if(i==j)continue;
            if(a[i]>a[j])
                e[i][j]=1;
        }
    }

    for(int i=0;i<m;i++){

        int x,y;
        cin>>x>>y;

        x--;y--;
        if(x>y)swap(x,y);

        for(int j=x;j<y;j++){
            //تبدلو + ما تبدلو
            tmp[x][j]=0.5*(1-e[j][y])+0.5*e[x][j];
            tmp[j][y]=0.5*(1-e[x][j])+0.5*e[j][y];
        }
        for(int j=y+1;j<n;j++){
            tmp[x][j]=tmp[y][j]=0.5*e[y][j]+0.5*e[x][j];
        }
        tmp[x][y]=0.5;

        for(int j=x;j<y;j++){
            //تبدلو + ما تبدلو
            e[x][j]=tmp[x][j];
            e[j][y]=tmp[j][y];
        }
        for(int j=y+1;j<n;j++){
            e[x][j]=e[y][j]=tmp[x][j];
        }
        e[x][y]=tmp[x][y];

    }
    double ans  = 0;
//    for(int i=0;i<n;i++){
//        for(int j=0;j<n;j++){
//            cout<<fixed<<setprecision(4)<<" "<<e[i][j]<<" ";
//        }
//        cout<<endl;
//    }
    for(int i=0;i<n;i++){
        for(int j=i+1;j<n;j++){
            ans+=e[i][j];
        }
    }
    cout<<fixed<<setprecision(10)<<ans<<endl;
}


#include <bits/stdc++.h>
#include <string>

using namespace std;

#define ms(s, n) memset(s, n, sizeof(s))
#define pb push_back
#define pf push_front
#define mp make_pair
#define f first
#define s second
#define prec(n) fixed<<setprecision(n)
#define sll(x) scanf("%lld",&x);
#define pll(x) printf("%lld",x);
#define pn printf("\n");
#define ps printf(" ");
#define pc(c) printf("%c",c);
typedef long long int ll;
#define EPS 1e-9
const int MOD = (int) 1e9 + 7;
const int INF = (int) 1e9;
const ll LINF = (ll) 1e18;

ll gcd(ll a, ll b) {
    ll r;
    while (b)
    {
        r = a % b;
        a = b;
        b = r;
    }
    return a;
}

ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }

ll fpow(ll n, ll k, int p = MOD) {
    ll r = 1;
    for (; k; k >>= 1)
    {
        if (k & 1) r = r * n % p;
        n = n * n % p;
    }
    return r;
}

void addmod(ll &a, ll val, ll p = MOD) { if ((a = (a + val)) >= p) a -= p; }

void submod(ll &a, ll val, ll p = MOD) { if ((a = (a - val)) < 0) a += p; }

int mult(ll a, ll b, ll p = MOD) { return (ll) a * b % p; }

int inv(ll a, ll p = MOD) { return fpow(a, p - 2, p); }

double p[1010][1010];
int n, m,x,y,a[1010];

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    cin >> n >> m;
    memset(p, 0, sizeof p);
    for (int i = 1; i <= n; ++i)
    {
        cin >> a[i];
    }
    for (int i = 1; i <= n; ++i)
    {
        for (int j = 1; j <= n; ++j)
        {
            p[i][j] = a[i] > a[j];
        }
    }
    while (m--)
    {
        cin >> x >> y;
        p[x][y] = p[y][x] = .5;
        for (int i = 1; i <= n; ++i)
        {
            if (i != x && i != y)
            {
                p[i][y] = p[i][x] = (p[i][x] + p[i][y]) / 2;
                p[y][i] = p[x][i] = (p[y][i] + p[x][i]) / 2;
            }
        }
    }
    double t = 0;
    for (int i = 1; i <= n; ++i)
    {
        for (int j = n; j > i; j--)
        {
            t += p[i][j];
        }
    }
    printf("%f", t);
    return 0;
}


////////////////////////////////////////////
///                                      ///
///        Template ver. 1.2. rapel      ///
/// Fear is Temporary, Regret is Forever ///
///          Must Try and Get AC         ///
///                                      ///
////////////////////////////////////////////
#include <stdio.h>
#include <iostream>
#include <sstream>
#include <iomanip>

#include <algorithm>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <utility>

#include <math.h>
#include <complex>

#include <assert.h>
#include <time.h>
//#include <chrono>
//#include <random>

#include <vector>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <queue>
#include <stack>
#include <list>
#include <bitset>

#define F first
#define S second
#define pb push_back
#define pf push_front
#define pob pop_back
#define pof pop_front
#define endl '\n'
using namespace std;

typedef long long ll;
typedef unsigned long long ull;

void desperate_optimization(int precision){
  	ios_base::sync_with_stdio(false);
  	cin.tie(0);
  	cout.tie(0);
  	cout.setf(ios::fixed);
  	cout.setf(ios::showpoint);
  	cout.precision(precision);
}

const int N = 1e3;
double prob[N + 5][N + 5];
int arr[N + 5];

void hora(int tc) {
	int n, m;
	cin>>n>>m;
	for(int i = 1;i <= n;i++) cin>>arr[i];
	for(int i = 1;i <= n;i++) {
		for(int j = 1;j <= n;j++) {
			if(arr[i] > arr[j]) prob[i][j] = 1;
		}
	}
	while(m--) {
		int x, y;
		cin>>x>>y;
		for(int i = 1;i <= n;i++) {
			if(i == x || i == y) continue;
			prob[i][x] = prob[i][y] = (prob[i][x] + prob[i][y]) / 2.0;
			prob[x][i] = prob[y][i] = (prob[x][i] + prob[y][i]) / 2.0;
		}
		prob[x][y] = prob[y][x] = 0.5;
	}
	double tot = 0;
	for(int i = 1;i <= n;i++) {
		for(int j = 1;j <= n;j++) tot += prob[i][j];
	}
	cout<<tot / 2.0<<endl;
}

int main(){
	desperate_optimization(10);
	int ntc = 1;
	//cin>>ntc;
	for(int tc = 1;tc <= ntc;tc++) hora(tc);
	return 0;
}


////////////////////////////////////////////
///                                      ///
///        Template ver. 1.2. rapel      ///
/// Fear is Temporary, Regret is Forever ///
///          Must Try and Get AC         ///
///                                      ///
////////////////////////////////////////////
#include <stdio.h>
#include <iostream>
#include <sstream>
#include <iomanip>

#include <algorithm>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <utility>

#include <math.h>
#include <complex>

#include <assert.h>
#include <time.h>
//#include <chrono>
//#include <random>

#include <vector>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <queue>
#include <stack>
#include <list>
#include <bitset>

#define F first
#define S second
#define pb push_back
#define pf push_front
#define pob pop_back
#define pof pop_front
#define endl '\n'
using namespace std;

typedef long long ll;
typedef unsigned long long ull;

void desperate_optimization(int precision){
  	ios_base::sync_with_stdio(false);
  	cin.tie(0);
  	cout.tie(0);
  	cout.setf(ios::fixed);
  	cout.setf(ios::showpoint);
  	cout.precision(precision);
}

const int N = 1e3;
double prob[N + 5][N + 5];
int arr[N + 5];

void hora(int tc) {
	int n, m;
	cin>>n>>m;
	for(int i = 1;i <= n;i++) cin>>arr[i];
	for(int i = 1;i <= n;i++) {
		for(int j = 1;j <= n;j++) {
			if(arr[i] > arr[j]) prob[i][j] = 1;
		}
	}
	while(m--) {
		int x, y;
		cin>>x>>y;
		for(int i = 1;i <= n;i++) {
			if(i == x || i == y) continue;
			prob[i][x] = prob[i][y] = (prob[i][x] + prob[i][y]) / 2.0;
			prob[x][i] = prob[y][i] = 1.0 - prob[i][x];
		}
		prob[x][y] = prob[y][x] = 0.5;
	}
	double tot = 0;
	for(int i = 1;i <= n;i++) {
		for(int j = 1;j < i;j++) tot += prob[i][j];
	}
	cout<<tot / 2.0<<endl;
}

int main(){
	desperate_optimization(10);
	int ntc = 1;
	//cin>>ntc;
	for(int tc = 1;tc <= ntc;tc++) hora(tc);
	return 0;
}


////////////////////////////////////////////
///                                      ///
///        Template ver. 1.2. rapel      ///
/// Fear is Temporary, Regret is Forever ///
///          Must Try and Get AC         ///
///                                      ///
////////////////////////////////////////////
#include <stdio.h>
#include <iostream>
#include <sstream>
#include <iomanip>

#include <algorithm>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <utility>

#include <math.h>
#include <complex>

#include <assert.h>
#include <time.h>
//#include <chrono>
//#include <random>

#include <vector>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <queue>
#include <stack>
#include <list>
#include <bitset>

#define F first
#define S second
#define pb push_back
#define pf push_front
#define pob pop_back
#define pof pop_front
#define endl '\n'
using namespace std;

typedef long long ll;
typedef unsigned long long ull;

void desperate_optimization(int precision){
  	ios_base::sync_with_stdio(false);
  	cin.tie(0);
  	cout.tie(0);
  	cout.setf(ios::fixed);
  	cout.setf(ios::showpoint);
  	cout.precision(precision);
}

const int N = 1e3;
double prob[N + 5][N + 5];
int arr[N + 5];

void hora(int tc) {
	int n, m;
	cin>>n>>m;
	for(int i = 1;i <= n;i++) cin>>arr[i];
	for(int i = 1;i <= n;i++) {
		for(int j = 1;j <= n;j++) {
			if(arr[i] > arr[j]) prob[i][j] = 1;
		}
	}
	while(m--) {
		int x, y;
		cin>>x>>y;
		for(int i = 1;i <= n;i++) {
			if(i == x || i == y) continue;
			prob[i][x] = prob[i][y] = (prob[i][x] + prob[i][y]) / 2.0;
			prob[x][i] = prob[y][i] = (prob[x][i] + prob[y][i]) / 2.0;
		}
		prob[x][y] = prob[y][x] = 0.5;
	}
	double tot = 0;
	for(int i = 1; i <= n;i++) {
		for(int j = i + 1;j <= n;j++) tot += prob[i][j];
	}
	cout<<tot<<endl;
}

int main(){
	desperate_optimization(10);
	int ntc = 1;
	//cin>>ntc;
	for(int tc = 1;tc <= ntc;tc++) hora(tc);
	return 0;
}


////////////////////////////////////////////
///                                      ///
///        Template ver. 1.2. rapel      ///
/// Fear is Temporary, Regret is Forever ///
///          Must Try and Get AC         ///
///                                      ///
////////////////////////////////////////////
#include <stdio.h>
#include <iostream>
#include <sstream>
#include <iomanip>

#include <algorithm>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <utility>

#include <math.h>
#include <complex>

#include <assert.h>
#include <time.h>
//#include <chrono>
//#include <random>

#include <vector>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <queue>
#include <stack>
#include <list>
#include <bitset>

#define F first
#define S second
#define pb push_back
#define pf push_front
#define pob pop_back
#define pof pop_front
#define endl '\n'
using namespace std;

typedef long long ll;
typedef unsigned long long ull;

void desperate_optimization(int precision){
  	ios_base::sync_with_stdio(false);
  	cin.tie(0);
  	cout.tie(0);
  	cout.setf(ios::fixed);
  	cout.setf(ios::showpoint);
  	cout.precision(precision);
}

const int N = 1e3;
double prob[N + 5][N + 5];
int arr[N + 5];

void hora(int tc) {
	int n, m;
	cin>>n>>m;
	for(int i = 1;i <= n;i++) cin>>arr[i];
	for(int i = 1;i <= n;i++) {
		for(int j = 1;j <= n;j++) {
			if(arr[i] > arr[j]) prob[i][j] = 1;
		}
	}
	while(m--) {
		int x, y;
		cin>>x>>y;
		for(int i = 1;i <= n;i++) {
			if(i == x || i == y) continue;
			prob[i][x] = prob[i][y] = (prob[i][x] + prob[i][y]) / 2.0;
			prob[x][i] = prob[y][i] = 1.0 - prob[i][x];
		}
		prob[x][y] = prob[y][x] = 0.5;
	}
	double tot = 0;
	for(int i = 1;i <= n;i++) {
		for(int j = 1;j < i;j++) tot += prob[i][j];
	}
	cout<<tot<<endl;
}

int main(){
	desperate_optimization(10);
	int ntc = 1;
	//cin>>ntc;
	for(int tc = 1;tc <= ntc;tc++) hora(tc);
	return 0;
}


#include <iostream>
#include <cstdio>
#include <fstream>
#include <algorithm>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <limits.h>
#include <math.h>
#include <functional>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <float.h>
#include <random>

#define repeat(i,n) for (int i = 0; (i) < (n); ++ (i))
#define debug(x) cerr << #x << ": " << x << '\n'
#define debugArray(x,n) for(long long hoge = 0; (hoge) < (n); ++ (hoge)) cerr << #x << "[" << hoge << "]: " << x[hoge] << '\n'
#define debugArrayP(x,n) for(long long hoge = 0; (hoge) < (n); ++ (hoge)) cerr << #x << "[" << hoge << "]: " << x[hoge].first<< " " << x[hoge].second << '\n'

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> Pii;
typedef vector<int> vint;
typedef vector<ll> vll;
const ll INF = LLONG_MAX/10;
const ll MOD = 1e9+7;

int N,M;
int p[1010];
double dp[1010][1010];

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin>>N>>M;
  repeat(j,N){
    cin>>p[j];
  }
  repeat(i,N){
    repeat(j,i){
      dp[j][i] = p[j]>p[i];
      //debug(dp[j][i]);
    }
  }
  repeat(i,M){
    int a,b;cin>>a>>b;a--;b--;
    if(a>b)swap(a,b);
    double tmp[1010][1010];
    repeat(j,N){
      if(j<a)tmp[j][a]=tmp[j][b] = (dp[j][a]+dp[j][b])/2;
      if(a<j&&j<b){
        tmp[j][b] = (1-dp[a][j]+dp[j][b])/2;
        tmp[a][j] = (dp[a][j]+1-dp[j][b])/2;
      }
      if(b<j)tmp[b][j]=tmp[a][j] = (dp[a][j]+dp[b][j])/2;
    }
    repeat(j,N){
      if(j<a){
        dp[j][a] = tmp[j][a];
        dp[j][b] = tmp[j][b];
      }
      if(a<j&&j<b){
        dp[j][b] = tmp[j][b];
        dp[a][j] = tmp[a][j];
      }
      if(b<j){
        dp[b][j] = tmp[b][j];
        dp[a][j] = tmp[a][j];
      }
    }
    dp[a][b] = 1./2;
  }
  /*
  repeat(i,N){
    repeat(j,i){
      //dp[j][i] = p[j]>p[i];
      debug(dp[j][i]);
    }
  }
  */
  double ans = 0;
  repeat(i,N){
    repeat(j,i){
      ans += dp[j][i];
    }
  }
  printf("%.7lf\n",ans);
  return 0;
}


#include<bits/stdc++.h>
#define ui unsigned int
#define ll long long
#define db double
#define ld long double
#define ull unsigned long long
#define ft first
#define sd second
#define pb(a) push_back(a)
#define PII std::pair<int,int>
#define PLL std::pair<ll,ll>
#define mp(a,b) std::make_pair(a,b)
#define ITR(a,b) for(auto a:b)
#define REP(a,b,c) for(register int a=(b),a##end=(c);a<=a##end;++a)
#define DEP(a,b,c) for(register int a=(b),a##end=(c);a>=a##end;--a)
const int MAXN=1000+10;
int n,m,A[MAXN];
db f[MAXN][MAXN],ans;
template<typename T> inline void read(T &x)
{
	T data=0,w=1;
	char ch=0;
	while(ch!='-'&&(ch<'0'||ch>'9'))ch=getchar();
	if(ch=='-')w=-1,ch=getchar();
	while(ch>='0'&&ch<='9')data=((T)data<<3)+((T)data<<1)+(ch^'0'),ch=getchar();
	x=data*w;
}
template<typename T> inline void write(T x,char ch='\0')
{
	if(x<0)putchar('-'),x=-x;
	if(x>9)write(x/10);
	putchar(x%10+'0');
	if(ch!='\0')putchar(ch);
}
template<typename T> inline bool chkmin(T &x,T y){return y<x?(x=y,true):false;}
template<typename T> inline bool chkmax(T &x,T y){return y>x?(x=y,true):false;}
template<typename T> inline T min(T x,T y){return x<y?x:y;}
template<typename T> inline T max(T x,T y){return x>y?x:y;}
int main()
{
	read(n);read(m);
	REP(i,1,n)read(A[i]);
	REP(i,1,n)REP(j,1,n)if(A[i]>A[j])f[i][j]=1.0;
	REP(i,1,m)
	{
		int a,b;read(a);read(b);db sum;
		sum=f[a][b]+f[b][a];
		f[a][b]=f[b][a]=sum/2.0;
		REP(j,1,n)if(j!=a&&j!=b)
		{
			sum=f[j][a]+f[j][b],f[j][a]=f[j][b]=sum/2.0;
			sum=f[a][j]+f[b][j],f[a][j]=f[b][j]=sum/2.0;
		}
	}
	REP(i,1,n)REP(j,i+1,n)ans+=f[i][j];
	printf("%.6f\n",ans);
	return 0;
}


#include <bits/stdc++.h>

using namespace std;

const int N = 1010;

int a[N];
double p[N][N];
int n, m;

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 = 1; j <= n; ++j)
      p[i][j] = a[i] > a[j] ? 1 : 0;
  for (int i = 1; i <= m; ++i) {
    int u, v;
    scanf("%d%d", &u, &v);
    for (int j = 1; j <= n; ++j) {
      if (j == u || j == v)
	continue;
      p[j][u] = p[j][v] = (p[j][v] + p[j][u]) / 2;
      p[u][j] = p[v][j] = (p[v][j] + p[u][j]) / 2;
    }
    p[u][v] = p[v][u] = 0.5;
  }
  double ans = 0;
  for (int i = 1; i <= n; ++i)
    for (int j = i + 1; j <= n; ++j)
      ans += p[i][j];
  printf("%.12f\n", ans);
  return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i = (int)(a); i <= (int)(b); i++)
#define NFOR(i,a,b) for(int i = (int)(a); i >= (int)(b); --i)
#define endl "\n"
#define mp make_pair
#define X first
#define Y second
#define inf 1e15
#define mod 1000000007
#define pb push_back
#define Case cout<<"Case #"<<++cas<<": ";
#define fastio ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define all(v) v.begin(),v.end()
#define sz(x) int(x.size())
// #define lli int
typedef long long int lli;
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<pii> vii;
typedef pair<lli,lli> pll;
typedef vector<lli> vl;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<vl> vvl;

#define pr(...) dbs(#__VA_ARGS__, __VA_ARGS__)
template <class T> void dbs(string str, T t) {cerr << str << " : " << t << "\n";}
template <class T, class... S> void dbs(string str, T t, S... s) {int idx = str.find(','); cerr << str.substr(0, idx) << " : " << t << ","; dbs(str.substr(idx + 1), s...);}
template <class S, class T>ostream& operator <<(ostream& os, const pair<S, T>& p) {return os << "(" << p.first << ", " << p.second << ")";}
template <class T>ostream& operator <<(ostream& os, const vector<T>& p) {os << "[ "; for (auto& it : p) os << it << " "; return os << "]";}
template <class T>ostream& operator <<(ostream& os, const set<T>& p) {os << "[ "; for (auto& it : p) os << it << " "; return os << "]";}
template <class S, class T>ostream& operator <<(ostream& os, const map<S, T>& p) {os << "[ "; for (auto& it : p) os << it << " "; return os << "]";}
template <class T> void prc(T a, T b) {cerr << "["; for (T i = a; i != b; ++i) {if (i != a) cerr << ", "; cerr << *i;} cerr << "]\n";}

const int N = 1001;

double dp[N + 1][N + 1];
int a[N + 1];

void solve(int l, int r, int n) {
	if (l > r) swap(l, r);
	FOR(i, 1, n) {
		if (i != l and i != r) {
			if (i < l) {
				dp[i][l] = dp[i][r] = 0.5 * dp[i][l] + 0.5 * dp[i][r];
			}
			if (i > r) {
				dp[l][i] = dp[r][i] = 0.5 * dp[l][i] + 0.5 * dp[r][i];
			}
			if (i > l and i < r) {
				double temp = dp[l][i];
				dp[l][i] = 0.5 * (dp[l][i] + 1 - dp[i][r]);
				dp[i][r] = 0.5 * (dp[i][r] + 1 - temp);
			}
		}
	}
	dp[l][r] = dp[r][l] = 0.5;
}

int main() {
	int n, m; cin >> n >> m;
	FOR(i, 1, n) {
		int temp; cin >> temp; a[i] = temp;
	}
	FOR(i, 1, n) {
		FOR(j, i + 1, n) {
			if (a[i] < a[j]) dp[i][j] = 0;
			else dp[i][j] = 1;
		}
	}
	FOR(i, 1, m) {
		int l1, r1; cin >> l1 >> r1;
		solve(l1, r1, n);
	}
	double answer = 0;
	FOR(i, 1, n) {
		FOR(j, i + 1, n) {
			answer += dp[i][j];
		}
	}
	cout << fixed << setprecision(10) << answer << "\n";
return 0;}


#include<bits/stdc++.h>
#define pb push_back
#define ff first
#define ss second
#define ll long long
using namespace std;
typedef pair<int,int> pii;
double dp[1010][1010];
int a[1010],n,m;
void init(){

    for(int i=1;i<=n;i++)
        for(int j=i+1;j<=n;j++)
            if(a[i]>a[j])dp[i][j]=1;
}
int main(){

    ///freopen("test.txt","r",stdin);

    scanf("%d %d",&n,&m);
    for(int i=1;i<=n;i++)scanf("%d",&a[i]);
    init();

    for(int i=1;i<=m;i++){
        int l,r;
        scanf("%d %d",&l,&r);
        if(l>r)swap(l,r);

        for(int j=1;j<l;j++){
            double pom=0.5*dp[j][l]+0.5*dp[j][r];
            dp[j][l]=pom;
            dp[j][r]=pom;
        }

        for(int j=r+1;j<=n;j++){
            double pom=0.5*dp[l][j]+0.5*dp[r][j];
            dp[l][j]=pom;
            dp[r][j]=pom;
        }

        for(int j=l+1;j<r;j++){
            double pom=0.5*dp[j][r]+0.5*(1-dp[l][j]);
            double pom2=0.5*dp[l][j]+0.5*(1-dp[j][r]);
            dp[j][r]=pom;
            dp[l][j]=pom2;
        }

        dp[l][r]=0.5;
    }

    double rez=0;
    for(int i=1;i<=n;i++)
        for(int j=i+1;j<=n;j++)rez+=dp[i][j];

    cout<<rez<<endl;

    return 0;
}


#include<bits/stdc++.h>
#define pb push_back
#define ff first
#define ss second
#define ll long long
using namespace std;
typedef pair<int,int> pii;
double dp[1010][1010];
int a[1010],n,m;
void init(){

    for(int i=1;i<=n;i++)
        for(int j=i+1;j<=n;j++)
            if(a[i]>a[j])dp[i][j]=1;
}
int main(){

    ///freopen("test.txt","r",stdin);

    scanf("%d %d",&n,&m);
    for(int i=1;i<=n;i++)scanf("%d",&a[i]);
    init();

    for(int i=1;i<=m;i++){
        int l,r;
        scanf("%d %d",&l,&r);
        if(l>r)swap(l,r);

        for(int j=1;j<l;j++){
            double pom=0.5*dp[j][l]+0.5*dp[j][r];
            dp[j][l]=pom;
            dp[j][r]=pom;
        }

        for(int j=r+1;j<=n;j++){
            double pom=0.5*dp[l][j]+0.5*dp[r][j];
            dp[l][j]=pom;
            dp[r][j]=pom;
        }

        for(int j=l+1;j<r;j++){
            double pom=0.5*dp[j][r]+0.5*(1-dp[l][j]);
            double pom2=0.5*dp[l][j]+0.5*(1-dp[j][r]);
            dp[j][r]=pom;
            dp[l][j]=pom2;
        }

        dp[l][r]=0.5;
    }

    double rez=0;
    for(int i=1;i<=n;i++)
        for(int j=i+1;j<=n;j++)rez+=dp[i][j];

    cout<<fixed<<setprecision(8)<<rez<<endl;

    return 0;
}


#include <bits/stdc++.h>
#ifdef LOCAL
#include "debuger.hpp"
#else
#define DUMP(...) 1145141919810
#define CHECK(...) (__VA_ARGS__)
#endif

int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  std::vector<int> perm(n);
  for (int i = 0; i < n; ++i) {
    scanf("%d", &perm[i]); --perm[i];
  }
  std::vector<std::vector<double>> f(n, std::vector<double>(n));
  for (int i = 0; i < n; ++i) {
    for (int j = i + 1; j < n; ++j) {
      f[i][j] = perm[i] > perm[j] ? 1.0 : 0.0;
      f[j][i] = 1.0 - f[i][j];
    }
  }
  while (m--) {
    int x, y;
    scanf("%d%d", &x, &y); --x; --y;
    for (int i = 0; i < n; ++i) {
      if (i != x && i != y) {
        f[i][x] = f[i][y] = 0.5 * (f[i][x] + f[i][y]);
        f[x][i] = 1.0 - f[i][x];
        f[y][i] = 1.0 - f[i][y];
      }
    }
    f[x][y] = f[y][x] = 0.5;
  }
  double result = 0.0;
  for (int i = 0; i < n; ++i) {
    for (int j = i + 1; j < n; ++j) {
      result += f[i][j];
    }
  }
  printf("%.15f\n", result);
}


#include <bits/stdc++.h>
using namespace std;

// Hate My Life //

#define ff first
#define ss second
#define pb push_back
#define pf push_front
#define ppb pop_back()
#define ppf pop_front()
#define all(vec) vec.begin(), vec.end()
#define fol(i,a,b) for(int i=a;i<b;i++)
#define loop(i,a,b) for(int i=a;i>=b;i--)
#define forr(x,arr) for(auto& x:arr)
#define mod 1000000007
#define INF 0x3f3f3f3f3f3f3f3f
#define EPS 1e-7
#define sz(x) ((lli)(x).size())

using   lli     =   long long;
using   lld     =   long double;
using   ulli    =   unsigned long long int;
using   pll     =   pair<lli, lli>;
using   ttt     =   pair<lli, pll>;
using   vttt    =   vector<ttt>;
using   vll     =   vector<pll>;
using   vl      =   vector<lli>;
using   vi      =   vector<int>;
using   vvi     =   vector<vector<int>>;
using   cd      =   complex<lld>;
const double PI = acos(-1);

#ifndef tejasp
#define trace(...) {}
#define cotra(...) {}
#define end_routine() {}
#define localsys 0
#define endl '\n'
#endif

int tejas_919(int kkkk)
{
    lli n, m, k, q, u, v, temp=0, ans=0;
    cin>>n>>m;
    int arr[n];
    lld prob[n][n] = {};
    fol(i,0,n) cin>>arr[i];
    fol(i,0,n) fol(j,0,n) if(arr[j] > arr[i]) prob[i][j] = 1;
    fol(i,0,m) {
        cin>>u>>v;
        u--; v--;
        prob[u][v] = prob[v][u] = (prob[u][v] * 0.5) + (prob[v][u] * 0.5);
        fol(i,0,n) if (i != u and i != v) {
            prob[i][v] = prob[i][u] = (prob[i][v] * 0.5) + (prob[i][u] * 0.5);
            prob[u][i] = prob[v][i] = (prob[u][i] * 0.5) + (prob[v][i] * 0.5);
        }
    }
    fol(i,0,n) fol(j,0,i) prob[0][0] += prob[i][j];
    cout<<prob[0][0]<<endl;
    return 0;
}

signed main()
{
    #ifdef tejasp
            freopen("input.txt", "rt", stdin);
            freopen("output.txt", "wt", stdout);
    #endif
    if(!localsys) { ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL); }
    cout << fixed << setprecision(10);
    int t=1;
    //cin>>t;
    fol(i,0,t) { tejas_919(i+1); }
    end_routine();
    //if(localsys) system("pause");
}


#include <bits/stdc++.h>
using namespace std;

// Hate My Life //

#define ff first
#define ss second
#define pb push_back
#define pf push_front
#define ppb pop_back()
#define ppf pop_front()
#define all(vec) vec.begin(), vec.end()
#define fol(i,a,b) for(int i=a;i<b;i++)
#define loop(i,a,b) for(int i=a;i>=b;i--)
#define forr(x,arr) for(auto& x:arr)
#define mod 1000000007
#define INF 0x3f3f3f3f3f3f3f3f
#define EPS 1e-7
#define sz(x) ((lli)(x).size())

using   lli     =   long long;
using   lld     =   long double;
using   ulli    =   unsigned long long int;
using   pll     =   pair<lli, lli>;
using   ttt     =   pair<lli, pll>;
using   vttt    =   vector<ttt>;
using   vll     =   vector<pll>;
using   vl      =   vector<lli>;
using   vi      =   vector<int>;
using   vvi     =   vector<vector<int>>;
using   cd      =   complex<lld>;
const double PI = acos(-1);

#ifndef tejasp
#define trace(...) {}
#define cotra(...) {}
#define end_routine() {}
#define localsys 0
#define endl '\n'
#endif

int tejas_919(int kkkk)
{
    lli n, m, k, q, u, v, temp=0, ans=0;
    cin>>n>>m;
    int arr[n];
    lld prob[n][n] = {};
    fol(i,0,n) cin>>arr[i];
    fol(i,0,n) fol(j,0,n) if(arr[j] > arr[i]) prob[i][j] = 1;
    fol(i,0,m) {
        cin>>u>>v;
        u--; v--;
        prob[u][v] = prob[v][u] = (prob[u][v] * 0.5) + (prob[v][u] * 0.5);
        fol(i,0,n) if (i != u and i != v) {
            prob[i][v] = prob[i][u] = (prob[i][v] * 0.5) + (prob[i][u] * 0.5);
            prob[u][i] = prob[v][i] = (prob[u][i] * 0.5) + (prob[v][i] * 0.5);
        }
    }
    fol(i,0,n) fol(j,i+1,n) prob[0][0] += prob[i][j];
    cout<<prob[0][0]<<endl;
    return 0;
}

signed main()
{
    #ifdef tejasp
            freopen("input.txt", "rt", stdin);
            freopen("output.txt", "wt", stdout);
    #endif
    if(!localsys) { ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL); }
    cout << fixed << setprecision(10);
    int t=1;
    //cin>>t;
    fol(i,0,t) { tejas_919(i+1); }
    end_routine();
    //if(localsys) system("pause");
}


# include <stdio.h>
# include <bits/stdc++.h>

#define _USE_MATH_DEFINES_
#define ll long long
#define ld long double
#define Accepted 0
#define pb push_back
#define mp make_pair
#define sz(x) (int)(x.size())
#define every(x) x.begin(),x.end()
#define F first
#define S second
#define For(i,x,y)  for (ll i = x; i <= y; i ++)
#define FOr(i,x,y)  for (ll i = x; i >= y; i --)
#define SpeedForce ios_base::sync_with_stdio(0), cin.tie(0)
// ROAD to...                                                                                Red

using namespace std;

inline bool isvowel (char c) {
	c = tolower(c);
    if (c == 'a' || c == 'e' || c == 'i' || c == 'y' || c == 'o' || c == 'u') return 1;
    return 0;
}

const double eps = 0.000001;
const ld pi = acos(-1);
const int maxn = 1e7 + 9;
const int mod = 1e9 + 7;
const ll MOD = 1e18 + 9;
const ll INF = 1e18 + 123;
const int inf = 2e9 + 11;
const int mxn = 1e6 + 9;
const int N = 1123;
const int M = 22;
const int pri = 997;
const int Magic = 2101;

const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, -1, 0, 1};

int n, m;
int a[N];
double dp[N][N];

int main () {
	cin >> n >> m;
	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])
				dp[i][j] = 1.0;
	}
	for (int i = 1; i <= m; i ++) {
		int x, y;
		cin >> x >> y;
		dp[x][y] = 0.5;
		dp[y][x] = 0.5;
		for (int v = 1; v <= n ; v ++) {
			if (v == x || v == y) continue;
			dp[v][x] = dp[v][y] = (dp[v][x] + dp[v][y]) * (double)0.5;
		}

		for (int v = 1; v <= n ; v ++) {
			if (v == x || v == y) continue;
			dp[x][v] = 1.0 - dp[v][x];
			dp[y][v] = 1.0 - dp[v][y];
		}
	}
	double ans = 0.0;
	for (int i = 1; i <= n; i ++)
		for (int j = i + 1; j <= n; j ++)
			ans += dp[i][j];

	cout << fixed << setprecision(12) << ans;
	return Accepted;
}

// B...a


# include <stdio.h>
# include <bits/stdc++.h>

#define _USE_MATH_DEFINES_
#define ll long long
#define ld long double
#define Accepted 0
#define pb push_back
#define mp make_pair
#define sz(x) (int)(x.size())
#define every(x) x.begin(),x.end()
#define F first
#define S second
#define For(i,x,y)  for (ll i = x; i <= y; i ++)
#define FOr(i,x,y)  for (ll i = x; i >= y; i --)
#define SpeedForce ios_base::sync_with_stdio(0), cin.tie(0)
// ROAD to...                                                                                Red

using namespace std;

inline bool isvowel (char c) {
	c = tolower(c);
    if (c == 'a' || c == 'e' || c == 'i' || c == 'y' || c == 'o' || c == 'u') return 1;
    return 0;
}

const double eps = 0.000001;
const ld pi = acos(-1);
const int maxn = 1e7 + 9;
const int mod = 1e9 + 7;
const ll MOD = 1e18 + 9;
const ll INF = 1e18 + 123;
const int inf = 2e9 + 11;
const int mxn = 1e6 + 9;
const int N = 1123;
const int M = 22;
const int pri = 997;
const int Magic = 2101;

const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, -1, 0, 1};

int n, m;
int a[N];
double dp[N][N];

int main () {
	cin >> n >> m;
	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])
				dp[i][j] = 1.0;
	}
	for (int i = 1; i <= m; i ++) {
		int x, y;
		cin >> x >> y;
		dp[x][y] = 0.5;
		dp[y][x] = 0.5;
		for (int v = 1; v <= n ; v ++) {
			if (v == x || v == y) continue;
			dp[v][x] = dp[v][y] = (dp[v][x] + dp[v][y]) * (double)0.5;
		}

		for (int v = 1; v <= n ; v ++) {
			if (v == x || v == y) continue;
			dp[x][v] = 1.0 - dp[v][x];
			dp[y][v] = 1.0 - dp[v][y];
		}
	}
	double ans = 0.0;
	for (int i = 1; i <= n; i ++)
		for (int j = i + 1; j <= n; j ++)
			ans += dp[i][j];

	cout << fixed << setprecision(12) << ans;
	return Accepted;
}

// B...a


# include <stdio.h>
# include <bits/stdc++.h>

#define _USE_MATH_DEFINES_
#define ll long long
#define ld long double
#define Accepted 0
#define pb push_back
#define mp make_pair
#define sz(x) (int)(x.size())
#define every(x) x.begin(),x.end()
#define F first
#define S second
#define For(i,x,y)  for (ll i = x; i <= y; i ++)
#define FOr(i,x,y)  for (ll i = x; i >= y; i --)
#define SpeedForce ios_base::sync_with_stdio(0), cin.tie(0)
// ROAD to...                                                                                Red

using namespace std;

inline bool isvowel (char c) {
	c = tolower(c);
    if (c == 'a' || c == 'e' || c == 'i' || c == 'y' || c == 'o' || c == 'u') return 1;
    return 0;
}

const double eps = 0.000001;
const ld pi = acos(-1);
const int maxn = 1e7 + 9;
const int mod = 1e9 + 7;
const ll MOD = 1e18 + 9;
const ll INF = 1e18 + 123;
const int inf = 2e9 + 11;
const int mxn = 1e6 + 9;
const int N = 1123;
const int M = 22;
const int pri = 997;
const int Magic = 2101;

const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, -1, 0, 1};

int n, m;
int a[N];
double dp[N][N];

int main () {
	cin >> n >> m;
	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])
				dp[i][j] = 1.0;
	}
	for (int i = 1; i <= m; i ++) {
		int x, y;
		cin >> x >> y;
		dp[x][y] = 0.5;
		dp[y][x] = 0.5;
		for (int v = 1; v <= n ; v ++) {
			if (v == x || v == y) continue;
			dp[v][x] = dp[v][y] = (dp[v][x] + dp[v][y]) / 2.0;
		}

		for (int v = 1; v <= n ; v ++) {
			if (v == x || v == y) continue;
			dp[x][v] = 1.0 - dp[v][x];
			dp[y][v] = 1.0 - dp[v][y];
		}
	}
	double ans = 0.0;
	for (int i = 1; i <= n; i ++)
		for (int j = i + 1; j <= n; j ++)
			ans += dp[i][j];

	cout << fixed << setprecision(12) << ans;
	return Accepted;
}

// B...a


# include <stdio.h>
# include <bits/stdc++.h>

#define _USE_MATH_DEFINES_
#define ll long long
#define ld long double
#define Accepted 0
#define pb push_back
#define mp make_pair
#define sz(x) (int)(x.size())
#define every(x) x.begin(),x.end()
#define F first
#define S second
#define For(i,x,y)  for (ll i = x; i <= y; i ++)
#define FOr(i,x,y)  for (ll i = x; i >= y; i --)
#define SpeedForce ios_base::sync_with_stdio(0), cin.tie(0)
// ROAD to...                                                                                Red

using namespace std;

inline bool isvowel (char c) {
	c = tolower(c);
    if (c == 'a' || c == 'e' || c == 'i' || c == 'y' || c == 'o' || c == 'u') return 1;
    return 0;
}

const double eps = 0.000001;
const ld pi = acos(-1);
const int maxn = 1e7 + 9;
const int mod = 1e9 + 7;
const ll MOD = 1e18 + 9;
const ll INF = 1e18 + 123;
const int inf = 2e9 + 11;
const int mxn = 1e6 + 9;
const int N = 1123;
const int M = 22;
const int pri = 997;
const int Magic = 2101;

const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, -1, 0, 1};

int n, m;
int a[N];
double dp[N][N];

int main () {
	cin >> n >> m;
	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])
				dp[j][i] = 1.0;
	}
	for (int i = 1; i <= m; i ++) {
		int x, y;
		cin >> x >> y;
		dp[x][y] = 0.5;
		dp[y][x] = 0.5;
		for (int v = 1; v <= n ; v ++) {
			if (v == x || v == y) continue;
			dp[v][x] = dp[v][y] = (dp[v][x] + dp[v][y]) * (double)0.5;
		}

		for (int v = 1; v <= n ; v ++) {
			if (v == x || v == y) continue;
			dp[x][v] = 1.0 - dp[v][x];
			dp[y][v] = 1.0 - dp[v][y];
		}
	}
	double ans = 0.0;
	for (int i = 1; i <= n; i ++)
		for (int j = i + 1; j <= n; j ++)
			ans += dp[i][j];

	cout << fixed << setprecision(12) << ans;
	return Accepted;
}

// B...a


import java.util.ArrayList;
import java.util.HashMap;
import java.util.Scanner;

public class main2 {

    public static void main(String []args){
        Scanner scanner = new Scanner(System.in);
        String s = scanner.next();
        String t = scanner.next();
        int n = 0;
        if (s.length()-t.length()>0){
            n = s.length()-t.length();
            s = s.substring(n,s.length());
        }else if (t.length()-s.length()>0){
            n = t.length()-s.length();
            t = t.substring(n,t.length());
        }
        if (s.equals(t)){
            System.out.println(n);
            return;
        }
        while (!s.equals(t)&&s.length()!=0){
            s = s.substring(1,s.length());
            t = t.substring(1,t.length());
            n+=2;
//            if (s.length()==0||s.equals(t)){break;}

        }
        System.out.println(n);

    }

}


import java.util.ArrayList;
import java.util.HashMap;
import java.util.Scanner;

public class main2 {

    public static void main(String []args){
        Scanner scanner = new Scanner(System.in);
        String s = scanner.next();
        String t = scanner.next();
        int n = 0;
        if (s.length()-t.length()>0){

            n = s.length()-t.length();
            s = s.substring(n,s.length());
        }else if (t.length()-s.length()>0){
            n = t.length()-s.length();
            t = t.substring(n,t.length());
        }
        while (!s.equals(t)&&s.length()!=0){
            int k = 1;
            while (k<s.length()&&s.charAt(k)!=t.charAt(k)){
                k++;
            }
            s = s.substring(k,s.length());
            t = t.substring(k,t.length());
            n+=2;

        }
        System.out.println(n);

    }

}