#include<stdio.h>
#include<algorithm>
#include<stdlib.h>
#include<vector>
#include<queue>
#include<cmath>
using namespace std;
vector<int> g[25];
double p[25],out[25],a[505][505],ans[25];
int n,m,s,t,du[25],hs[25][25],cnt,endd[25];
void suan(void)
{
	for(int i=1;i<=cnt;i++)
	{
		int sb=i;
		for(int j=i+1;j<=cnt;j++)
		if(fabs(a[i][j])>fabs(a[i][sb]))
		sb=j;
		if(sb!=i)
		swap(a[i],a[sb]);
		for(int j=i+1;j<=cnt+1;j++)
			a[i][j]/=a[i][i];
		a[i][i]=1;
		for(int j=1;j<=cnt;j++)
		if(j!=i)
			{for(int k=i+1;k<=cnt+1;k++)
			a[j][k]-=a[j][i]*a[i][k];
			a[j][i]=0;
		}
	}
}

int main()
{
	scanf("%d%d%d%d",&n,&m,&s,&t);
	for(int i=1;i<=m;i++)
	{
		int x,y;
		scanf("%d%d",&x,&y);
		g[x].push_back(y);
		g[y].push_back(x);
		du[x]++,du[y]++;
	}
	for(int i=1;i<=n;i++)
	scanf("%lf",&p[i]),out[i]=(1.0-p[i])/du[i];
	if(s==t)
	{
		for(int i=1;i<=n;i++)
		printf("%.10lf ",i==s?1.0:0.0);
		printf("\n");
		return 0;
	}
	for(int i=1;i<=n;i++)
	for(int j=1;j<=n;j++)
	if(i!=j)
	cnt++,hs[i][j]=cnt;
	for(int tt=1;tt<=n;tt++)
	{
		for(int i=1;i<=n;i++)
		endd[i]=0;
		endd[tt]=1;
		for(int i=1;i<=500;i++)
		for(int j=1;j<=500;j++)
		a[i][j]=0;
		for(int i=1;i<=n;i++)
		for(int j=1;j<=n;j++)
		if(i!=j)
		{
			a[hs[i][j]][hs[i][j]]=1-p[i]*p[j];
			for(int k=0;k<g[i].size();k++)
				if(g[i][k]==j)  a[hs[i][j]][cnt+1]+=out[i]*p[j]*endd[g[i][k]];
				else a[hs[i][j]][hs[g[i][k]][j]]-=out[i]*p[j];
			for(int k=0;k<g[j].size();k++)
			if(g[j][k]==i)  a[hs[i][j]][cnt+1]+=out[j]*p[i]*endd[g[j][k]];
				else a[hs[i][j]][hs[i][g[j][k]]]-=out[j]*p[i];
			for(int k=0;k<g[i].size();k++)
			for(int kk=0;kk<g[j].size();kk++)
				if(g[i][k]==g[j][kk]) a[hs[i][j]][cnt+1]+=out[j]*out[i]*endd[g[i][k]];
				else a[hs[i][j]][hs[g[i][k]][g[j][kk]]]-=out[j]*out[i];
		}
        suan();
		ans[tt]=a[hs[s][t]][cnt+1];
	}
	for(int i=1;i<=n;i++)
	printf("%.10lf ",ans[i]);
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
const int N = 30;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
const double eps = 1e-9;

struct edge
{
	int to , nxt;
} e[N * N * 2];

int n , m , A , B , tot;
int head[N * N];
double deg[N * N] , a[N * N][N * N] , b[N * N] , p[N * N] , ans[N * N];

template <typename T> inline void chkmin(T &x , T y) { x = min(x , y); }
template <typename T> inline void chkmax(T &x , T y) { x = max(x , y); }
template <typename T> inline void read(T &x)
{
   T f = 1; x = 0;
   char c = getchar();
   for (; !isdigit(c); c = getchar()) if (c == '-') f = -f;
   for (; isdigit(c); c = getchar()) x = (x << 3) + (x << 1) + c - '0';
   x *= f;
}
inline int id(int x , int y)
{
	return (x - 1) * n + y;
}
inline void addedge(int u , int v)
{
	++tot;
	e[tot] = (edge){v , head[u]};
	head[u] = tot;
}
int dcmp(double x)
{
    if (x<=eps&&x>=-eps) return 0;
    return (x>0)?1:-1;
}

int main()
{

	scanf("%d%d%d%d" , &n , &m , &A , &B);
	for (int i = 1; i <= m; i++)
	{
		int u , v;
		scanf("%d%d" , &u , &v);
		addedge(u , v);
		addedge(v , u);
		deg[u] += 1.0;
		deg[v] += 1.0;
	}
	for (int i = 1; i <= n; i++) scanf("%lf" , &p[i]);
	for (int i = 1; i <= n; i++)
	{
		for (int j = 1; j <= n; j++)
		{
			a[id(i , j)][id(i , j)] = 1;
			if (i != j) a[id(i , j)][id(i , j)] -= p[i] * p[j];
			for (int k = head[i]; k; k = e[k].nxt)
				if (e[k].to != j && e[k].to != i) a[id(i , j)][id(e[k].to , j)] -= (1 - p[e[k].to]) / deg[e[k].to] * p[j];
			for (int k = head[j]; k; k = e[k].nxt)
				if (i != e[k].to && j != e[k].to) a[id(i , j)][id(i , e[k].to)] -= (1 - p[e[k].to]) / deg[e[k].to] * p[i];
			for (int k = head[i]; k; k = e[k].nxt)
			{
				for (int l = head[j]; l; l = e[l].nxt)
				{
					if (e[k].to != e[l].to)
						a[id(i , j)][id(e[k].to , e[l].to)] -= (1 - p[e[k].to]) / deg[e[k].to] * (1 - p[e[l].to]) / deg[e[l].to];
				}
			}
		}
	}
	b[id(A , B)] = 1.0;
	for (int i=1;i<=n*n;++i)
    {
        int num=i;
        for (int j=i+1;j<=n*n;++j)
            if (dcmp(a[j][i]-a[num][i])>0) num=j;
        if (num!=i)
        {
            for (int j=1;j<=n*n;++j) swap(a[num][j],a[i][j]);
            swap(b[num],b[i]);
        }
        for (int j=i+1;j<=n*n;++j)
            if (dcmp(a[j][i]))
            {
                double t=a[j][i]/a[i][i];
                for (int k=1;k<=n*n;++k)
                    a[j][k]-=t*a[i][k];
                b[j]-=b[i]*t;
            }
    }
    for (int i=n*n;i>=1;--i)
    {
        for (int j=i+1;j<=n*n;++j) b[i]-=a[i][j]*ans[j];
        ans[i]=b[i]/a[i][i];
    }
	for (int i = 1; i <= n; i++) printf("%.6lf " , ans[id(i , i)]);
	printf("\n");

    return 0;
}


#include<stdio.h>
#include<algorithm>
#include<stdlib.h>
#include<vector>
#include<queue>
#include<cmath>
using namespace std;
vector<int> g[25];
double p[25],out[25],a[505][505],ans[25];
int n,m,s,t,du[25],hs[25][25],cnt,end[25];
void suan(void)
{
	for(int i=1;i<=cnt;i++)
	{
		int sb=i;
		for(int j=i+1;j<=cnt;j++)
		if(fabs(a[i][j])>fabs(a[i][sb]))
		sb=j;
		if(sb!=i)
		swap(a[i],a[sb]);
		for(int j=i+1;j<=cnt+1;j++)
			a[i][j]/=a[i][i];
		a[i][i]=1;
		for(int j=1;j<=cnt;j++)
		if(j!=i)
			{for(int k=1;k<=cnt+1;k++)
			if(k!=i)
			a[j][k]-=a[j][i]*a[i][k];
			a[j][i]=0;
		}
	}
}

int main()
{
	scanf("%d%d%d%d",&n,&m,&s,&t);
	for(int i=1;i<=m;i++)
	{
		int x,y;
		scanf("%d%d",&x,&y);
		g[x].push_back(y);
		g[y].push_back(x);
		du[x]++,du[y]++;
	}
	for(int i=1;i<=n;i++)
	scanf("%lf",&p[i]),out[i]=(1.0-p[i])/du[i];
	if(s==t)
	{
		for(int i=1;i<=n;i++)
		printf("%.10lf ",i==s?1.0:0.0);
		printf("\n");
		return 0;
	}
	for(int i=1;i<=n;i++)
	for(int j=1;j<=n;j++)
	if(i!=j)
	cnt++,hs[i][j]=cnt;
	for(int tt=1;tt<=n;tt++)
	{
		for(int i=1;i<=n;i++)
		end[i]=0;
		end[tt]=1;
		for(int i=1;i<=500;i++)
		for(int j=1;j<=500;j++)
		a[i][j]=0;
		for(int i=1;i<=n;i++)
		for(int j=1;j<=n;j++)
		if(i!=j)
		{
			a[hs[i][j]][hs[i][j]]=1-p[i]*p[j];
			for(int k=0;k<g[i].size();k++)
				if(g[i][k]==j)  a[hs[i][j]][cnt+1]+=out[i]*p[j]*end[g[i][k]];
				else a[hs[i][j]][hs[g[i][k]][j]]-=out[i]*p[j];
			for(int k=0;k<g[j].size();k++)
			if(g[j][k]==i)  a[hs[i][j]][cnt+1]+=out[j]*p[i]*end[g[j][k]];
				else a[hs[i][j]][hs[i][g[j][k]]]-=out[j]*p[i];
			for(int k=0;k<g[i].size();k++)
			for(int kk=0;kk<g[j].size();kk++)
				if(g[i][k]==g[j][kk]) a[hs[i][j]][cnt+1]+=out[j]*out[i]*end[g[i][k]];
				else a[hs[i][j]][hs[g[i][k]][g[j][kk]]]-=out[j]*out[i];
		}
        suan();
		ans[tt]=a[hs[s][t]][cnt+1];
	}
	for(int i=1;i<=n;i++)
	printf("%.10lf ",ans[i]);
	return 0;
}


#include<iostream>

#include<cstdio>

#include<cstdlib>

#include<cmath>

#include<cstring>

#include<algorithm>

#include<iomanip>

#define F(i,j,n) for(int i=j;i<=n;i++)

#define D(i,j,n) for(int i=j;i>=n;i--)

#define ll long long

#define maxn 405

using namespace std;

int n,m,s,t,cnt,tot;

int f[21][21],d[21],head[21];

double p[maxn],a[maxn][maxn];

struct edge_type{int next,to;}e[maxn];

inline int read()

{

	int x=0,f=1;char ch=getchar();

	while (ch<'0'||ch>'9'){if (ch=='-') f=-1;ch=getchar();}

	while (ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}

	return x*f;

}

inline void add_edge(int x,int y)

{

	e[++cnt]=(edge_type){head[x],y};head[x]=cnt;

	e[++cnt]=(edge_type){head[y],x};head[y]=cnt;

}

inline void solve(int x,int y)

{

	int num=f[x][y];

	a[num][num]=-1;

	for(int i=head[x];i;i=e[i].next) for(int j=head[y];j;j=e[j].next)

	{

		int tx=e[i].to,ty=e[j].to,t1=f[x][y],t2=f[tx][ty];

		if (tx!=ty)

		{

			if (tx==x&&ty==y) a[t1][t2]+=p[tx]*p[ty];

			else if (tx==x) a[t1][t2]+=p[tx]*(1-p[ty])/d[ty];

			else if (ty==y) a[t1][t2]+=p[ty]*(1-p[tx])/d[tx];

			else a[t1][t2]+=(1-p[tx])*(1-p[ty])/d[tx]/d[ty];

		}

	}

}

inline void gauss()//高斯-约当消元

{

	for(int i=1;i<=tot;i++)

	{

		int tmp=i;

		while (!a[tmp][i]&&tmp<=tot) tmp++;

		if (tmp>tot) continue;

		if (tmp!=i) F(j,1,tot+1) swap(a[i][j],a[tmp][j]);

		F(j,1,tot) if (j!=i)

		{

			double t=a[j][i]/a[i][i];

			F(k,1,tot+1) a[j][k]-=a[i][k]*t;

		}

	}

}

int main()

{

	n=read();m=read();s=read();t=read();

	F(i,1,n) e[++cnt]=(edge_type){head[i],i},head[i]=cnt;

	F(i,1,m)

	{

		int x=read(),y=read();

		add_edge(x,y);

		d[x]++;d[y]++;

	}

	F(i,1,n) scanf("%lf",&p[i]);

	F(i,1,n) F(j,1,n) f[i][j]=++tot;

	a[f[s][t]][tot+1]=-1;

	F(i,1,n) F(j,1,n) solve(i,j);

	gauss();

	F(i,1,n)

	{

		int tmp=f[i][i];

		printf("%.10lf ",a[tmp][tot+1]/a[tmp][tmp]);

	}

	printf("\n");

	return 0;

}


#include<bits/stdc++.h>
#define LL long long
#define F(x,y,z) for (int x=y;x<=z;++x)
#define D(x,y,z) for (int x=y;x>=z;--x)
using namespace std;
const int N=10010;
inline LL R(){
	LL x=0,f=1;char c=getchar();
	for (;!isdigit(c);c=getchar())if(c=='-')f=-1;
	for (; isdigit(c);c=getchar())x=x*10+c-'0';
	return x*f;
}
double d[30];
int to[N],ne[N],st[N],sl,a,b,n,m;
double g[500][500],p[500][500];
double f[30][30];
void Ads(int x,int y){to[++sl]=y;ne[sl]=st[x];st[x]=sl;}
void pr(){
	/*putchar('\n');
	F(i,1,n*n){
		F(j,1,n*n)printf("%5.2lf",g[i][j]);
		printf("  |  ");
		F(j,1,n)printf("%5.2lf",p[i][j]);
		putchar('\n');
	}*/
}
int main(){
	//freopen("A.in","r",stdin);
	cin>>n>>m>>a>>b;
	F(i,1,m){
		int x,y;
		cin>>x>>y;
		++d[x];++d[y];
		Ads(x,y);Ads(y,x);
	}
	F(i,1,n){
		cin>>f[i][i];
		double lft=(1-f[i][i])/d[i];
		for(int j=st[i];j;j=ne[j])
			f[i][to[j]]=lft;
	}

	F(i,1,n)F(j,1,n){
		if(i==j){g[i*n+j-n][i*n+j-n]=1;continue;}
		F(ii,1,n)F(jj,1,n)
			g[i*n+j-n][ii*n+jj-n]=-f[i][ii]*f[j][jj];
		g[i*n+j-n][i*n+j-n]=1-f[i][i]*f[j][j];
	}
	F(i,1,n)p[i*n+i-n][i]=1;
	pr();
	F(i,1,n*n){
		F(j,i+1,n*n){
			double bs=g[j][i]/g[i][i];
			F(k,i,n*n)g[j][k]-=bs*g[i][k];
			F(k,1,n)p[j][k]-=bs*p[i][k];
		}
		pr();
	}
	D(i,n*n,1){
		F(j,i+1,n*n){
			double bs=g[i][j];
			F(k,1,n)p[i][k]-=bs*p[j][k];
			g[i][j]=0;

		}
		F(k,1,n)p[i][k]/=g[i][i];pr();
	}
	F(i,1,n)printf("%.8lf\n",p[a*n-n+b][i]);
	return 0;
}


#include<stdio.h>
#include<algorithm>
#include<stdlib.h>
#include<vector>
#include<queue>
#include<cmath>
using namespace std;
vector<int> g[25];
double p[25],out[25],a[505][505],ans[25];
int n,m,s,t,du[25],hs[25][25],cnt,endd[25];
void suan(void)
{
	for(int i=1;i<=cnt;i++)
	{
		int sb=i;
		for(int j=i+1;j<=cnt;j++)
		if(fabs(a[i][j])>fabs(a[i][sb]))
		sb=j;
		if(sb!=i)
		swap(a[i],a[sb]);
		for(int j=i+1;j<=cnt+1;j++)
			a[i][j]/=a[i][i];
		a[i][i]=1;
		for(int j=1;j<=cnt;j++)
		if(j!=i)
			{for(int k=1;k<=cnt+1;k++)
			if(k!=i)
			a[j][k]-=a[j][i]*a[i][k];
			a[j][i]=0;
		}
	}
}

int main()
{
	scanf("%d%d%d%d",&n,&m,&s,&t);
	for(int i=1;i<=m;i++)
	{
		int x,y;
		scanf("%d%d",&x,&y);
		g[x].push_back(y);
		g[y].push_back(x);
		du[x]++,du[y]++;
	}
	for(int i=1;i<=n;i++)
	scanf("%lf",&p[i]),out[i]=(1.0-p[i])/du[i];
	if(s==t)
	{
		for(int i=1;i<=n;i++)
		printf("%.10lf ",i==s?1.0:0.0);
		printf("\n");
		return 0;
	}
	for(int i=1;i<=n;i++)
	for(int j=1;j<=n;j++)
	if(i!=j)
	cnt++,hs[i][j]=cnt;
	for(int tt=1;tt<=n;tt++)
	{
		for(int i=1;i<=n;i++)
		endd[i]=0;
		endd[tt]=1;
		for(int i=1;i<=500;i++)
		for(int j=1;j<=500;j++)
		a[i][j]=0;
		for(int i=1;i<=n;i++)
		for(int j=1;j<=n;j++)
		if(i!=j)
		{
			a[hs[i][j]][hs[i][j]]=1-p[i]*p[j];
			for(int k=0;k<g[i].size();k++)
				if(g[i][k]==j)  a[hs[i][j]][cnt+1]+=out[i]*p[j]*endd[g[i][k]];
				else a[hs[i][j]][hs[g[i][k]][j]]-=out[i]*p[j];
			for(int k=0;k<g[j].size();k++)
			if(g[j][k]==i)  a[hs[i][j]][cnt+1]+=out[j]*p[i]*endd[g[j][k]];
				else a[hs[i][j]][hs[i][g[j][k]]]-=out[j]*p[i];
			for(int k=0;k<g[i].size();k++)
			for(int kk=0;kk<g[j].size();kk++)
				if(g[i][k]==g[j][kk]) a[hs[i][j]][cnt+1]+=out[j]*out[i]*endd[g[i][k]];
				else a[hs[i][j]][hs[g[i][k]][g[j][kk]]]-=out[j]*out[i];
		}
        suan();
		ans[tt]=a[hs[s][t]][cnt+1];
	}
	for(int i=1;i<=n;i++)
	printf("%.10lf ",ans[i]);
	return 0;
}


#include <cstdio>
#include <algorithm>
#include <cstring>
#include <cmath>
using namespace std;

const double esp=1e-5;

int dis[30][30],du[30],id[30][30];
double p[30],a[500][500];

double solve(int i,int j,int x,int y)
{//i,j直接转移到相邻x,y的概率
	double ans=0;
	if (i==x && j==y) ans=p[i]*p[j];
	else if (i==x && j!=y) ans=p[i]*(1-p[j])/du[j]*dis[j][y];
	else if (i!=x && j==y) ans=p[j]*(1-p[i])/du[i]*dis[i][x];
	else if (i!=x && j!=y) ans=(1-p[i])*(1-p[j])/du[i]/du[j]*dis[i][x]*dis[j][y];
	return ans;
}

int main()
{
	int n,m,st1,st2;
	scanf ("%d%d%d%d",&n,&m,&st1,&st2);
	for (int i=1; i<=m; i++){
		int u,v;
		scanf ("%d%d",&u,&v);
		du[u]++;du[v]++;
		dis[u][v]=dis[v][u]=1;
	}
	for (int i=1; i<=n; i++)
		scanf ("%lf",&p[i]);
	if (st1==st2){
		for (int i=1; i<=n; i++){
			if (i==st1) printf("%.6f%c",1.0,i==n?'\n':' ');
			else printf("%.6f%c",0.0,i==n?'\n':' ');
		}
		return 0;
	}
	int cnt=0;
	for (int i=1; i<=n; i++)
		for (int j=1; j<=n; j++)
			if (i!=j)
				id[i][j]=++cnt;

	int len=n*n-n;
	for (int i=1; i<=n; i++){//i,j到x,y的系数求解
		for (int j=1; j<=n; j++){
			if (i==j) continue;
			int u=id[i][j];
			a[u][u]=-1;//i,j到i,j的系数,-p_x,y+Σp_i,j*A即i,j->i,j有一个-1的系数
			for (int x=1; x<=n; x++){
				for (int y=1; y<=n; y++){
					if (x==y) {//移项后多出的额外的n维
						a[u][len+x]-=solve(i,j,x,y);
						continue;
					}
					int v=id[x][y];
					a[u][v]+=solve(i,j,x,y);
				}
			}
		}
	}

	for (int i=1; i<=len; i++){//化为上三角
		if (fabs(a[i][i])<esp){//系数为0
			int pos=-1;
			for (int j=i+1; j<=len; j++)
				if (fabs(a[j][i])>=esp){
					pos=j;break;
				}
			swap(a[i],a[pos]);
		}

		//消去下面行的该列元素
		for (int j=i+1; j<=len; j++){
			double f=a[j][i]/a[i][i];
			for (int k=i; k<=n*n; k++)
				a[j][k]-=f*a[i][k];
		}
	}

	for (int i=len; i>=1; i--){
		double f=a[i][i];
		for (int j=len+1; j<=n*n; j++)//i,j到k,k在i,j到i,j的系数化为1后的系数
			a[i][j]/=f;

		a[i][i]=1;
		for (int j=i-1; j>=1; j--){//上面的每一行减去该行
			f=a[j][i];//f=a[j][i]/a[i][i]
			for (int k=len+1; k<=n*n; k++)
				a[j][k]-=f*a[i][k];
		}
	}
	for (int i=1; i<=n; i++)
		printf("%.6f%c",a[id[st1][st2]][len+i],i==n?'\n':' ');
	return 0;
}


#include<cstdio>
#include<iostream>
#include<cmath>
#include<algorithm>
#include<cstring>
#include<cstdlib>
#include<cctype>
#include<vector>
#include<stack>
#include<queue>
#include<assert.h>
using namespace std;
#define enter puts("")
#define space putchar(' ')
#define Mem(a, x) memset(a, x, sizeof(a))
#define In inline
typedef long long ll;
typedef double db;
const int INF = 0x3f3f3f3f;
const db eps = 1e-8;
const int maxn = 25;
const int maxN = 505;
In ll read()
{
  ll ans = 0;
  char ch = getchar(), last = ' ';
  while(!isdigit(ch)) last = ch, ch = getchar();
  while(isdigit(ch)) ans = (ans << 1) + (ans << 3) + ch - '0', ch = getchar();
  if(last == '-') ans = -ans;
  return ans;
}
In void write(ll x)
{
  if(x < 0) x = -x, putchar('-');
  if(x >= 10) write(x / 10);
  putchar(x % 10 + '0');
}
In void MYFILE()
{
#ifndef mrclr
  freopen(".in", "r", stdin);
  freopen(".out", "w", stdout);
#endif
}

int n, m, A, B, cnt;
db p[maxn];
struct Edge
{
  int nxt, to;
}e[maxn * maxn * 2];
int head[maxn], ecnt = -1, du[maxn];
In void addEdge(int x, int y)
{
  ++du[x];
  e[++ecnt] = (Edge){head[x], y};
  head[x] = ecnt;
}

In int N(int x, int y) {return (x - 1) * n  + y;}

db f[maxN][maxN], ans[maxN];
In void init()
{
  f[N(A, B)][cnt + 1] = 1;
  for(int i = 1; i <= n; ++i)
    for(int j = 1; j <= n; ++j)
      {
	//if(i == A && j == B) continue;
	int u = N(i, j);
	f[u][u] = 1;
	if(i ^ j) f[u][u] -= p[i] * p[j];
	for(int k = head[j], v; ~k; k = e[k].nxt)
	  if((v = e[k].to) ^ i) f[u][N(i, v)] -= p[i] * (1 - p[v]) / du[v];
	for(int k = head[i], v; ~k; k = e[k].nxt)
	  if((v = e[k].to) ^ j) f[u][N(v, j)] -= p[j] * (1 - p[v]) / du[v];
	for(int k = head[i], v1; ~k; k = e[k].nxt)
	  for(int h = head[j], v2; ~h; h = e[h].nxt)
	    if((v1 = e[k].to) ^ (v2 = e[h].to))
	      f[u][N(v1, v2)] -= (1 - p[v1]) * (1 - p[v2]) / du[v1] / du[v2];
      }
}
In void Gauss()
{
  for(int i = 1; i <= cnt; ++i)
    {
      int pos = i;
      for(int j = i + 1; j <= cnt; ++j)
	if(fabs(f[j][i]) > fabs(f[pos][i])) pos = j;
      if(pos ^ i) swap(f[pos], f[i]);
      if(fabs(f[i][i]) < eps) continue;
      db tp = f[i][i];
      for(int j = i; j <= cnt + 1; ++j) f[i][j] /= tp;
      for(int j = i + 1; j <= cnt; ++j)
	{
	  db tp = f[j][i];
	  for(int k = i; k <= cnt + 1; ++k) f[j][k] -= tp * f[i][k];
	}
    }
  for(int i = cnt; i; --i)
    {
      ans[i] = f[i][cnt + 1];
      for(int j = i - 1; j; --j) f[j][cnt + 1] -= f[j][i] * ans[i];
    }
}

int main()
{
  //MYFILE();
  Mem(head, -1);
  n = read(), m = read(), A = read(), B = read();
  cnt = n * n;
  for(int i = 1; i <= m; ++i)
    {
      int x = read(), y = read();
      addEdge(x, y), addEdge(y, x);
    }
  for(int i = 1; i <= n; ++i) scanf("%lf", &p[i]);
  init(), Gauss();
  for(int i = 1; i <= n; ++i) printf("%.8lf\n", ans[N(i, i)]);
  return 0;
}


#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
using namespace std;
const int N=50;
const int M=(N-1)*N>>1;
int n,m,S,T,du[N],adj[N],e;
double A[M][M],p[N],k[N],ans[N];
struct node{int qi,zhong,next;}s[M<<1];
inline void add(int qi,int zhong)
{s[++e].zhong=zhong;s[e].qi=qi;s[e].next=adj[qi];adj[qi]=e;}
int num[N][N],cnt,f[N];
inline void gasse()
{
    for(int i=1;i<=cnt;i++)
    {
        int p=i;
        for(int j=i+1;j<=cnt;j++)
            if(fabs(A[p][i])<fabs(A[j][i]))p=j;
        if(p!=i)
        for(int j=1;j<=cnt+1;j++)
            swap(A[i][j],A[p][j]);
        for(int j=i+1;j<=cnt;j++)
        {
            double tmp=A[j][i]/A[i][i];
            for(int k=i;k<=cnt+1;k++)
                A[j][k]-=tmp*A[i][k];
        }
    }
    for(int i=cnt;i>=1;i--)
    {
        for(int j=i+1;j<=cnt;j++)
            A[i][cnt+1]-=A[j][cnt+1]*A[i][j];
        A[i][cnt+1]/=A[i][i];
    }
}
int main()
{
    scanf("%d%d%d%d",&n,&m,&S,&T);
    for(int i=1;i<=m;i++)
    {
        int a,b;scanf("%d%d",&a,&b);
        add(a,b),add(b,a),du[a]++,du[b]++;
    }
    for(int i=1;i<=n;i++)
        scanf("%lf",&p[i]),k[i]=(1.0-p[i])/du[i];
    if(S==T)
    {
        for(int i=1;i<=n;i++)
            printf("%.10lf%c",i==S?1.0:0.0,i==n?'\n':' ');
        return 0;
    }
    for(int i=1;i<=n;i++)
        for(int j=1;j<=n;j++)
            if(i!=j)
                num[i][j]=++cnt;
    for(int t=1;t<=n;t++)
    {
        memset(f,0,sizeof(f));f[t]=1;
        for(int i=1;i<M;i++)
            for(int j=1;j<M;j++)
                A[i][j]=0;
        for(int i=1;i<=n;i++)
            for(int j=1;j<=n;j++)
            {
                if(i==j)continue;
                int nu=num[i][j];
                A[nu][nu]=1.0-p[i]*p[j];
                for(int a=adj[i];a;a=s[a].next)
                {
                    int u=s[a].zhong;
                    int nui=num[u][j];
                    if(u==j)A[nu][cnt+1]+=k[i]*p[j]*f[j];
                    else A[nu][nui]-=k[i]*p[j];
                }
                for(int b=adj[j];b;b=s[b].next)
                {
                    int v=s[b].zhong;
                    int nui=num[i][v];
                    if(i==v)A[nu][cnt+1]+=p[i]*k[j]*f[i];
                    else A[nu][nui]-=p[i]*k[j];
                }
                for(int a=adj[i];a;a=s[a].next)
                    for(int b=adj[j];b;b=s[b].next)
                    {
                        int u=s[a].zhong,v=s[b].zhong;
                        int nui=num[u][v];
                        if(u==v)A[nu][cnt+1]+=k[i]*k[j]*f[u];
                        else A[nu][nui]-=k[i]*k[j];
                    }
            }
        gasse();
        ans[t]=A[num[S][T]][cnt+1];
    }
    printf("%.10lf",ans[1]);
    for(int i=2;i<=n;i++)
        printf(" %.10lf",ans[i]);
}


#include <cstdio>
#include <algorithm>
#include <cstring>
#include <cmath>
using namespace std;

const double esp=1e-5;

int dis[30][30],du[30],id[30][30];
double p[30],a[500][500];

double solve(int i,int j,int x,int y)
{//i,j直接转移到相邻x,y的概率
	double ans=0;
	if (i==x && j==y) ans=p[i]*p[j];
	else if (i==x && j!=y) ans=p[i]*(1-p[j])/du[j]*dis[j][y];
	else if (i!=x && j==y) ans=p[j]*(1-p[i])/du[i]*dis[i][x];
	else if (i!=x && j!=y) ans=(1-p[i])*(1-p[j])/du[i]/du[j]*dis[i][x]*dis[j][y];
	return ans;
}

int main()
{
	int n,m,st1,st2;
	scanf ("%d%d%d%d",&n,&m,&st1,&st2);
	for (int i=1; i<=m; i++){
		int u,v;
		scanf ("%d%d",&u,&v);
		du[u]++;du[v]++;
		dis[u][v]=dis[v][u]=1;
	}
	for (int i=1; i<=n; i++)
		scanf ("%lf",&p[i]);
	if (st1==st2){
		for (int i=1; i<=n; i++){
			if (i==st1) printf("%.6f%c",1.0,i==n?'\n':' ');
			else printf("%.6f%c",0.0,i==n?'\n':' ');
		}
		return 0;
	}
	int cnt=0;
	for (int i=1; i<=n; i++)
		for (int j=1; j<=n; j++)
			if (i!=j)
				id[i][j]=++cnt;

	int len=n*n-n;
	for (int i=1; i<=n; i++){
		for (int j=1; j<=n; j++){
			if (i==j) continue;
			int u=id[i][j];
			a[u][u]=-1;//i,j到i,j的系数，移项为1。
			for (int x=1; x<=n; x++){
				for (int y=1; y<=n; y++){
					if (x==y) {
						a[u][len+x]-=solve(i,j,x,y);
						continue;
					}
					int v=id[x][y];
					a[u][v]+=solve(i,j,x,y);
				}
			}
		}
	}

	for (int i=1; i<=len; i++){//化为上三角
		if (fabs(a[i][i])<esp){//系数为0
			int pos=-1;
			for (int j=i+1; j<=len; j++)
				if (fabs(a[j][i])>=esp){
					pos=j;break;
				}
			swap(a[i],a[pos]);
		}

		//消去下面行的该列元素
		for (int j=i+1; j<=len; j++){
			double f=a[j][i]/a[i][i];
			for (int k=i; k<=n*n; k++)
				a[j][k]-=f*a[i][k];
		}
	}

	for (int i=len; i>=1; i--){
		double f=a[i][i];
		for (int j=len+1; j<=n*n; j++)//i,j到k,k在i,j到i,j的系数化为1后的系数
			a[i][j]/=f;

		a[i][i]=1;
		for (int j=i-1; j>=1; j--){//上面的每一行减去该行
			f=a[j][i];//f=a[j][i]/a[i][i]
			for (int k=len+1; k<=n*n; k++)
				a[j][k]-=f*a[i][k];
		}
	}
	for (int i=1; i<=n; i++)
		printf("%.6f%c",a[id[st1][st2]][len+i],i==n?'\n':' ');
	return 0;
}


#include <bits/stdc++.h>
#include <cstdio>
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
//#include <queue>
#define endl '\n'
#define ls rt << 1
#define rs rt << 1 | 1
#define pb push_back
#define mp(a,b) make_pair(a,b)
#define clr(a,b) memset(a,b,sizeof(a));
#define FIN freopen("in.txt","r",stdin);
#define debug1(x) cout << "[" << #x << " = " << (x) << "]\n"
#define debug2(x,y) cout << "[" << #x << " = " << (x) << "  " << #y << " = " << (y) << "]\n"
#define debug3(x,y,z) cout << "[" << #x << " = " << (x) << "  " << #y << " = " << (y) << "  " << #z << " = " << (z) << "]\n"
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const double pi = acos(-1.0);
const long double eps = 1e-8;
const int INF = 0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3f;
const int MX = 25 + 7;
const int maxbit = 30;
const int mod = 1e9 + 7;
ll gcd(ll a,ll b){return b ? gcd(b,a%b):a;}
ll quimod(ll a,ll k){ll res = 1;while(k){if(k & 1) res = (res * a) % mod; a = (a * a) % mod;k >>= 1;}return res;}
ll lcm(ll a,ll b){return a / gcd(a,b) * b;}

int n,m,A,B,cnt;
double p[MX];

inline int F(int x,int y){return (x - 1) * n + y;}
struct Edge{
	int v,next;
}e[2 * MX * MX];
int head[MX],ecnt,deg[MX];
void add(int u,int v){
	deg[u]++;
	e[++ecnt].v = v;
	e[ecnt].next = head[u];
	head[u] = ecnt;
}

double f[MX*MX][MX*MX];

void build(){
	cnt = n * n;
	f[F(A,B)][cnt+1] = 1;
	for(int i = 1;i <= n;++i){
		for(int j = 1;j <= n;++j){
			int u = F(i,j);
			f[u][u] = 1;
			if(i != j) f[u][u] -= (p[i] * p[j]);
			for(int k = head[j];k;k = e[k].next){
				int v = e[k].v;
				if(v != i) f[u][F(i,v)] -= p[i] * (1 - p[v]) / deg[v];
			}
			for(int k = head[i];k;k = e[k].next){
				int v = e[k].v;
				if(v != j) f[u][F(v,j)] -= p[j] * (1 - p[v]) / deg[v];
			}
			for(int k = head[i];k;k = e[k].next){
				for(int h = head[j];h;h = e[h].next){
					int v1 = e[k].v, v2 = e[h].v;
					if(v1 != v2) f[u][F(v1,v2)] -= (1 - p[v1]) * (1 - p[v2]) / (1.0 * deg[v1] * deg[v2]);
				}
			}
		}
	}
}
double ans[MX*MX];
void Gauss(){
	for(int i = 1;i <= cnt;++i){
		int r = i;
		for(int j = i + 1;j <= cnt;++j) if(fabs(f[r][i]) < fabs(f[j][i])) r = j;
		if(fabs(f[r][i]) < eps) continue;
		if(i != r) swap(f[i],f[r]);
		double div = f[i][i];
		for(int j = i;j <= cnt + 1;++j) f[i][j] /= div;
		for(int j = i + 1;j <= cnt;++j){
			div = f[j][i];
			for(int k = i;k <= cnt + 1;++k)
				f[j][k] -= f[i][k] * div;
		}
	}
	ans[cnt] = f[cnt][cnt+1];
	for(int i = cnt - 1;i;--i){
		ans[i] = f[i][cnt+1];
		for(int j = i + 1;j <= cnt;++j)
			ans[i] -= (f[i][j] * ans[j]);
	}
}
int main(){
	scanf("%d %d %d %d",&n,&m,&A,&B);
	for(int i = 1;i <= m;++i){
		int u,v;scanf("%d %d",&u,&v);
		add(u,v);add(v,u);
	}
	for(int i = 1;i <= n;++i) scanf("%lf",&p[i]);
	build();Gauss();
	for(int i = 1;i <= n;++i) printf("%.6f%c", ans[F(i,i)],(i == n) ? '\n' : ' ');
	return 0;
}


#include<stdio.h>
#include<algorithm>
#include<stdlib.h>
#include<vector>
#include<queue>
#include<cmath>
using namespace std;
vector<int> g[25];
double p[25],out[25],a[505][505],ans[25];
int n,m,s,t,du[25],hs[25][25],cnt,endd[25];
void suan(void)
{
	for(int i=1;i<=cnt;i++)
	{
		int sb=i;
		for(int j=i+1;j<=cnt;j++)
		if(fabs(a[i][j])>fabs(a[i][sb]))
		sb=j;
		if(sb!=i)
		swap(a[i],a[sb]);
		for(int j=i+1;j<=cnt+1;j++)
			a[i][j]/=a[i][i];
		a[i][i]=1;
		for(int j=1;j<=cnt;j++)
		if(j!=i)
			{for(int k=1;k<=cnt+1;k++)
			if(k!=i)
			a[j][k]-=a[j][i]*a[i][k];
			a[j][i]=0;
		}
	}
}

int main()
{
	scanf("%d%d%d%d",&n,&m,&s,&t);
	for(int i=1;i<=m;i++)
	{
		int x,y;
		scanf("%d%d",&x,&y);
		g[x].push_back(y);
		g[y].push_back(x);
		du[x]++,du[y]++;
	}
	for(int i=1;i<=n;i++)
	scanf("%lf",&p[i]),out[i]=(1.0-p[i])/du[i];
	if(s==t)
	{
		for(int i=1;i<=n;i++)
		printf("%.10lf ",i==s?1.0:0.0);
		printf("\n");
		return 0;
	}
	for(int i=1;i<=n;i++)
	for(int j=1;j<=n;j++)
	if(i!=j)
	cnt++,hs[i][j]=cnt;
	for(int tt=1;tt<=n;tt++)
	{
		for(int i=1;i<=n;i++)
		endd[i]=0;
		endd[tt]=1;
		for(int i=1;i<=500;i++)
		for(int j=1;j<=500;j++)
		a[i][j]=0;
		for(int i=1;i<=n;i++)
		for(int j=1;j<=n;j++)
		if(i!=j)
		{
			a[hs[i][j]][hs[i][j]]=1-p[i]*p[j];
			for(int k=0;k<g[i].size();k++)
				if(g[i][k]==j)  a[hs[i][j]][cnt+1]+=out[i]*p[j]*endd[g[i][k]];
				else a[hs[i][j]][hs[g[i][k]][j]]-=out[i]*p[j];
			for(int k=0;k<g[j].size();k++)
			if(g[j][k]==i)  a[hs[i][j]][cnt+1]+=out[j]*p[i]*endd[g[j][k]];
				else a[hs[i][j]][hs[i][g[j][k]]]-=out[j]*p[i];
			for(int k=0;k<g[i].size();k++)
			for(int kk=0;kk<g[j].size();kk++)
				if(g[i][k]==g[j][kk]) a[hs[i][j]][cnt+1]+=out[j]*out[i]*end[g[i][k]];
				else a[hs[i][j]][hs[g[i][k]][g[j][kk]]]-=out[j]*out[i];
		}
        suan();
		ans[tt]=a[hs[s][t]][cnt+1];
	}
	for(enddi=1;i<=n;i++)
	printf("%.10lf ",ans[i]);
	return 0;
}


#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<vector>
#define eps 1e-8
using namespace std;
int read()
{
    int x=0,f=1;
    char ch=getchar();
    while(ch-'0'<0||ch-'0'>9){if(ch=='-') f=-1;ch=getchar();}
    while(ch-'0'>=0&&ch-'0'<=9){x=x*10+ch-'0';ch=getchar();}
    return x*f;
}
int n,m,tot,A,B;
vector<int>e[30];
double a[500][500];
int P(int x,int y)
{
    return (x-1)*n+y;
}
double p[30];
int deg[30];
void Build(int x,int y)
{
    a[P(x,y)][P(x,y)]--;
    for(int i=0;i<e[x].size();i++)
    {
        for(int j=0;j<e[y].size();j++)
        {
            int tx=e[x][i],ty=e[y][j];
            int t1=P(x,y),t2=P(e[x][i],e[y][j]);
            if(tx==ty)  continue;
            if(tx==x&&ty==y)  a[t1][t2]+=p[tx]*p[ty];
            else if(tx==x)    a[t1][t2]+=p[tx]*(1-p[ty])/deg[ty];
            else if(ty==y)    a[t1][t2]+=(1-p[tx])/deg[tx]*p[ty];
            else              a[t1][t2]+=(1-p[tx])/deg[tx]*(1-p[ty])/deg[ty];
        }
    }
}
bool dcmp(double x)
{
    return fabs(x)<eps;
}
void Gauss()
{
    for(int i=1;i<=tot;i++)
    {
        int pos=i;
        while(dcmp(a[pos][i])&&pos<=tot) pos++;
        if(pos>tot)  continue;
        swap(a[i],a[pos]);
        for(int j=1;j<=tot;j++)
        {
            if(i==j)  continue;
            double tmp=a[j][i]/a[i][i];
            for(int k=i;k<=tot+1;k++)  a[j][k]-=a[i][k]*tmp;
        }
    }
}
int main()
{
    n=read();m=read();A=read();B=read();
    tot=n*n;
    a[P(A,B)][tot+1]=-1;
    for(int i=1;i<=n;i++)  e[i].push_back(i);
    for(int i=1;i<=m;i++)
    {
        int q=read(),w=read();
        e[q].push_back(w);
        e[w].push_back(q);
        deg[q]++;deg[w]++;
    }
    for(int i=1;i<=n;i++)  scanf("%lf",&p[i]);
    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=n;j++)  Build(i,j);
    }
    Gauss();
    for(int i=1;i<=n;i++)
    {
        int id=P(i,i);
        printf("%.7lf ",a[id][tot+1]/a[id][id]);
    }
    puts("");
    return 0;
}


#include <iostream>
#include <cstdio>
#include <string>
#include <string.h>
#include <queue>
#include <math.h>
#include <cmath>
#include <map>
#include <set>
#include <vector>
#include <algorithm>
#include <bitset>
#include <list>
#include <ctype.h>
#include <cassert>
#include <stack>
#include <fstream>
#include <unordered_map>
#include <unordered_set>
#include <ctime>
#include <functional>
#include <ctime>
#include <limits>
#include <tuple>
#include <complex>

using namespace std;

#define snd second
#define fst first
#define mp make_pair
#define ll long long
#define ull unsigned long long
#define ld long double
#define pb push_back
#define left _left
#define right _right

const ld pi = acos(-1.0l);

template<typename T>
T abs(T x) {
    return x > 0 ? x : -x;
}

template<typename T>
T sqr(T x) {
    return x * x;
}

template<typename T>
void chmin(T &x, T y) {
    x = min(x, y);
}

template<typename T>
void chmax(T &x, T y) {
    x = max(x, y);
}

template<typename U, typename V>
ostream &operator<<(ostream &s, const pair<U, V> &x) {
    s << "(" << x.fst << ", " << x.snd << ")";
    return s;
}

template<typename U>
ostream &operator<<(ostream &s, const vector<U> &x) {
    s << "[";
    bool was = false;
    for (auto it : x) {
        if (was) {
            s << ", ";
        }
        was = true;
        s << it;
    }
    s << "]";
    return s;
}

template<typename U>
ostream &operator<<(ostream &s, const set<U> &x) {
    s << "{";
    bool was = false;
    for (auto it : x) {
        if (was) {
            s << ", ";
        }
        was = true;
        s << it;
    }
    s << "}";
    return s;
}

template<int sz>
ostream operator<<(ostream &s, const bitset<sz> &x) {
    for (int i = 0; i < sz; i++) {
        s << x[i];
    }
    return s;
}

//-----------------------------------------------------------------------------

const int maxn = 25;
vector<int> g[maxn];
ld p[maxn];
const ld eps = 1e-9;

vector<ld> gauss(vector<vector<ld>> a, vector<ld> b) {
    int n = a.size();
    for (int i = 0; i < n; i++) {
        int j = i;
        while (j < n && abs(a[j][i]) < eps) {
            j++;
        }

        if (j == n) {
            assert(0);
        }

        for (int h = 0; h < n; h++) {
            swap(a[i][h], a[j][h]);
        }
        swap(b[i], b[j]);

        for (int h = 0; h < n; h++) {
            if (h == i) {
                continue;
            }

            ld c = a[h][i] / a[i][i];
            for (int k = 0; k < n; k++) {
                a[h][k] -= c * a[i][k];
            }

            b[h] -= b[i] * c;
        }
    }

    for (int i = 0; i < n; i++) {
        b[i] /= a[i][i];
    }

    return b;
}

int main() {

    srand(time(NULL));

    retry:

#ifdef LOCAL
    //gen();
    //cerr << 1 << endl;
    freopen("a.in", "r", stdin);
    //freopen("a.out", "w", stdout);

#else
    //freopen("hovels.in", "r", stdin);
    //freopen("hovels.out", "w", stdout);
#endif

    int n, m, s, t;
    cin >> n >> m >> s >> t;
    //n = 22, m = 21, s = 1, t = 22;

    if (s == t) {
        for (int i = 1; i <= n; i++) {
            cout << ((i == s) ? 1 : 0) << endl;
        }
        return 0;
    }

    for (int i = 0; i < m; i++) {
        int u, v;
        cin >> u >> v;
        //u = i + 1, v = i + 2;
        g[u].pb(v);
        g[v].pb(u);
    }

    for (int i = 1; i <= n; i++) {
        cin >> p[i];
        //p[i] = 0.99;
    }

    auto enc = [&](int i, int j) {
        return (i - 1) * n + (j - 1);
    };

    vector<vector<ld>> a(n * n + 1, vector<ld>(n * n + 1, 0));
    vector<ld> b(n * n + 1);

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

    b[n * n] = 1;

    auto gen = [&](int u, int v, bool s = false) {
        vector<pair<ld, pair<int,int>>> res;

        if (u == v && !s) {
            return res;
        }

        ld w = p[u] * p[v];
        res.pb(mp(w, mp(u, v)));

        w = (1 - p[u]) / g[u].size() * p[v];
        for (int to : g[u]) {
            res.pb(mp(w, mp(to, v)));
        }

        w = (1 - p[v]) / g[v].size() * p[u];
        for (int to : g[v]) {
            res.pb(mp(w, mp(u, to)));
        }

        w = (1 - p[u]) / g[u].size() * (1 - p[v]) / g[v].size();
        for (int to1 : g[u]) {
            for (int to2 : g[v]) {
                res.pb(mp(w, mp(to1, to2)));
            }
        }

        return res;
    };

    for (auto x : gen(s, t, true)) {
        a[enc(x.snd.fst, x.snd.snd)][n * n] -= x.fst;
    }

    for (int i = 1; i <= n; i++) {
        for (int j = 1; j <= n; j++) {
            for (auto x : gen(i, j)) {
                a[enc(x.snd.fst, x.snd.snd)][enc(i, j)] -= x.fst;
            }
        }
    }

    //cout << a << endl;

    auto res = gauss(a, b);

    cout.precision(20);
    for (int i = 0; i < n; i++) {
        cout << fixed << res[enc(i + 1, i + 1)] << endl;
    }

    return 0;
}


#include<bits/stdc++.h>
#define RG register
#define IL inline
#define eps (1e-10)
using namespace std;
int g[24][24],num[24][24],cnt;
int S,T,n,m;
double fun[23*23][24*24];
int du[24];
double P1[24],P2[24];
IL void guass(){
	int N = cnt;
	for(RG int i=1,I;i<=N;++i){
		I = i;
		for(RG int j=I;j<=N;++j)if(fabs(fun[j][i])-fabs(fun[I][i])>eps) I = j;
		//for(RG int j=I;j<=N;++j)if(fabs(fun[j][i) I = j;
		if(I!=i)swap(fun[I],fun[i]);
		//if(fabs(fun[i][i])<=eps)return puts("No")
		for(RG int j=N+1;j>=i;--j)fun[i][j]/=fun[i][i];
		for(RG int j=1;j<=N;++j)if(i!=j)for(RG int D = N+1;D>=i;--D) fun[j][D]-=fun[j][i]*fun[i][D];
	}return;
}
int main(){
/*#ifndef ONLINE_JUDGE
	//freopen("1.in","r",stdin);
	//freopen("1.out","w",stdout);
	#endif*/
	scanf("%d%d%d%d",&n,&m,&S,&T);
	for(RG int i=1;i<=m;++i){
		RG int a, b;
		scanf("%d%d",&a,&b);
		g[a][b]=g[b][a]=1;++du[a],++du[b];
	}
	for(RG int i=1;i<=n;++i)g[i][i]=1,scanf("%lf",&P1[i]),P2[i]=(1-P1[i])/du[i];//.预处理连出一条边的概率
	for(RG int i=1;i<=n;++i)
		for(RG int j=1;j<=n;++j){
			num[i][j]=++cnt;
			//if(i==j)num[i+n][j]=num[]
		}//.预处理点对的标号
	for(RG int i=1;i<=n;++i){//.枚举点对中第一个点
		for(RG int j=1;j<=n;++j){//.枚举点对中第二个点
			if(i!=j)fun[num[i][j]][num[i][j]]=P1[i]*P1[j]-1;
			else fun[num[i][j]][num[i][j]]=-1;
			for(RG int ii=1;ii<=n;++ii){//.枚举第一个点相连的点
				if(!g[i][ii])continue;
				for(RG int jj = 1;jj<=n;++jj){//.枚举第二个点相连的点
					if(!g[j][jj])continue;
					if(ii==jj)continue;
					if(i==ii&&j==jj)continue;
					RG double p1,p2;
					p1=i==ii?P1[ii]:P2[ii];
					p2=j==jj?P1[jj]:P2[jj];
					fun[num[i][j]][num[ii][jj]]+=p1*p2;
				}
			}
		}
	}
	/*for(RG int i=1;i<=n;++i)
		for(RG int j=1;j<=n;++j){
			if(i!=j)fun[num[i][j]][num[i][j]]=P1[i]*P1[j]-1;
			else fun[num[i][j]][num[i][j]]=-1;
			}*/
	fun[num[S][T]][cnt+1]=-1;
	/*for(RG int i=1;i<=cnt;++i){
		for(RG int j=1;j<=cnt+1;++j){
			printf("%.3lf ",fun[i][j]);
		}
		puts("");
	}*/
	guass();
	for(RG int i=1;i<=n;++i)printf("%.10lf ",fun[num[i][i]][cnt+1]);
}
/*
3 3 1 2
1 2
2 3
1 3
0 0 0
 */


#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
using namespace std;

const int N = 505;
const double eps = 1e-8;
#define rep(i,a,b) for(int i=a;i<b;i++)
double A[N][N];

void Gauss(int n, int m) {
	int i = 0, x = 0;
	for (; i < n && x < m; i++, x++) {
		int r = i;
		rep(j,i+1,n) if (fabs(A[j][x]) > fabs(A[r][x])) {r=j;}
		if (fabs(A[r][x]) < eps) --i;
		else {
			if (r!=i) rep(j,0,m+1) swap(A[r][j],A[i][j]);
			for (int j = m; j >= x; j--) A[i][j] /= A[i][x];
			rep(j,0,n) if (i!=j && fabs(A[j][x]) >= eps)
			for (int k = m; k >= x; k--)
				A[j][k] -= A[i][k] * A[j][x];
		}
	}
}

int n, a, b, m;
int g[25][25], d[25];
double p[25][25];

int main() {
	scanf("%d%d%d%d", &n, &m, &a, &b);
	a--; b--;
	int u, v;
	while (m--) {
		scanf("%d%d", &u, &v);
		u--; v--;
		p[u][v] = p[v][u] = 1.0;
		d[u]++; d[v]++;
	}
	for (int i = 0; i < n; i++) scanf("%lf", &p[i][i]);
	for (int i = 0; i < n; i++)
		for (int j = 0; j < n; j++)
			if (i != j) p[i][j] *= (1 - p[i][i]) / d[i];
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			A[i * n + j][i * n + j] -= 1;
			if (i == j) continue;
			for (int k = 0; k < n; k++)
				for (int l = 0; l < n; l++)
					A[k * n + l][i * n + j] += p[i][k] * p[j][l];
		}
	}
	A[a * n + b][n * n] -= 1.0;
	for (int i = 0; i < n*n; i++)
	{
		for(int j=v=i;j<n*n;j++)
			if(fabs(A[j][i])>fabs(A[v][i]))
				v=j;
		for (int k =0; k <=n*n; k++)
			swap(A[v][k],A[i][k]);
		double u;
		u=A[i][i];
		for (int k = 0; k <=n * n ;k++)
			A[i][k]/=u;
		for (int j =0; j<n*n;j++)
			if(u=A[j][i],i!=j)
				for (int k = 0; k <=n * n;k++)
					A[j][k]-=u*A[i][k];
	}
	//Gauss(n * n, n * n);
	for (int i = 0; i < n; i++) printf("%.10f ", A[i * n + i][n * n]); printf("\n");
	return 0;
}


#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
using namespace std;

const int N = 505;
const double eps = 1e-8;
#define rep(i,a,b) for(int i=a;i<b;i++)
double A[N][N];

void Gauss(int n, int m) {
	int i = 0, x = 0;
	for (; i < n && x < m; i++, x++) {
		int r = i;
		rep(j,i+1,n) if (fabs(A[j][x]) > fabs(A[r][x])) {r=j;}
		if (fabs(A[r][x]) < eps) --i;
		else {
			if (r!=i) rep(j,0,m+1) swap(A[r][j],A[i][j]);
			for (int j = m; j >= x; j--) A[i][j] /= A[i][x];
			rep(j,0,n) if (i!=j && A[j][x])
			for (int k = m; k >= x; k--)
				A[j][k] -= A[i][k] * A[j][x];
		}
	}
}

int n, a, b, m;
int g[25][25], d[25];
double p[25][25];

int main() {
	scanf("%d%d%d%d", &n, &m, &a, &b);
	a--; b--;
	int u, v;
	while (m--) {
		scanf("%d%d", &u, &v);
		u--; v--;
		g[u][v] = g[v][u] = 1;
		d[u]++; d[v]++;
	}
	for (int i = 0; i < n; i++) scanf("%lf", &p[i][i]);
	for (int i = 0; i < n; i++)
		for (int j = 0; j < n; j++)
			if (i != j && g[i][j]) p[i][j] = (1 - p[i][i]) / d[i];
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			A[i * n + j][i * n + j] -= 1;
			if (i == j) continue;
			for (int k = 0; k < n; k++)
				for (int l = 0; l < n; l++)
					A[k * n + l][i * n + j] += p[i][k] * p[j][l];
		}
	}
	A[a * n + b][n * n] -= 1.0;
/*	for (int i = 0; i < n*n; i++)
	{
		for(int j=v=i;j<n*n;j++)
			if(fabs(A[j][i])>fabs(A[v][i]))
				v=j;
		for (int k =0; k <=n*n; k++)
			swap(A[v][k],A[i][k]);
		double u;
		u=A[i][i];
		for (int k = 0; k <=n * n ;k++)
			A[i][k]/=u;
		for (int j =0; j<n*n;j++)
			if(u=A[j][i],i!=j)
				for (int k = 0; k <=n * n;k++)
					A[j][k]-=u*A[i][k];
	}*/
	Gauss(n * n, n * n);
	for (int i = 0; i < n; i++) printf("%.10f ", A[i * n + i][n * n]); printf("\n");
	return 0;
}


#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
using namespace std;

const int N = 505;
const double eps = 1e-12;
#define rep(i,a,b) for(int i=a;i<b;i++)
double A[N][N];

void Gauss(int n, int m) {
	int i = 0, x = 0;
	for (; i < n && x < m; i++, x++) {
		int r = i;
		rep(j,i+1,n) if (fabs(A[j][x]) > fabs(A[r][x])) {r=j;}
		if (fabs(A[r][x]) < eps) --i;
		else {
			if (r!=i) rep(j,0,m+1) swap(A[r][j],A[i][j]);
			for (int j = m; j >= x; j--) A[i][j] /= A[i][x];
			rep(j,0,n) if (i!=j && fabs(A[j][x]) >= eps)
			for (int k = m; k >= x; k--)
				A[j][k] -= A[i][k] * A[j][x];
		}
	}
}

int n, a, b, m;
int g[25][25], d[25];
double p[25][25];

int main() {
	scanf("%d%d%d%d", &n, &m, &a, &b);
	a--; b--;
	int u, v;
	while (m--) {
		scanf("%d%d", &u, &v);
		u--; v--;
		g[u][v] = g[v][u] = 1;
		d[u]++; d[v]++;
	}
	for (int i = 0; i < n; i++) scanf("%lf", &p[i][i]);
	for (int i = 0; i < n; i++)
		for (int j = 0; j < n; j++)
			if (i != j && g[i][j]) p[i][j] = (1 - p[i][i]) / d[i];
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			A[i * n + j][i * n + j] -= 1;
			if (i == j) continue;
			for (int k = 0; k < n; k++)
				for (int l = 0; l < n; l++)
					A[k * n + l][i * n + j] += p[i][k] * p[j][l];
		}
	}
	A[a * n + b][n * n] -= 1.0;
/*	for (int i = 0; i < n*n; i++)
	{
		for(int j=v=i;j<n*n;j++)
			if(fabs(A[j][i])>fabs(A[v][i]))
				v=j;
		for (int k =0; k <=n*n; k++)
			swap(A[v][k],A[i][k]);
		double u;
		u=A[i][i];
		for (int k = 0; k <=n * n ;k++)
			A[i][k]/=u;
		for (int j =0; j<n*n;j++)
			if(u=A[j][i],i!=j)
				for (int k = 0; k <=n * n;k++)
					A[j][k]-=u*A[i][k];
	}*/
	Gauss(n * n, n * n);
	for (int i = 0; i < n; i++) printf("%.10f ", A[i * n + i][n * n]); printf("\n");
	return 0;
}


#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
using namespace std;

const int N = 505;
const double eps = 1e-8;
#define rep(i,a,b) for(int i=a;i<b;i++)
double A[N][N];

void Gauss(int n, int m) {
	int i = 0, x = 0;
	for (; i < n && x < m; i++, x++) {
		int r = i;
		rep(j,i+1,n) if (fabs(A[j][x]) > fabs(A[r][x])) {r=j;}
		if (fabs(A[r][x]) < eps) --i;
		else {
			if (r!=i) rep(j,0,m+1) swap(A[r][j],A[i][j]);
			for (int j = m; j >= x; j--) A[i][j] /= A[i][x];
			rep(j,0,n) if (i!=j && fabs(A[j][x]) >= eps)
			for (int k = m; k >= x; k--)
				A[j][k] -= A[i][k] * A[j][x];
		}
	}
}

int n, a, b, m;
int g[25][25], d[25];
double p[25][25];

int main() {
	scanf("%d%d%d%d", &n, &m, &a, &b);
	a--; b--;
	int u, v;
	while (m--) {
		scanf("%d%d", &u, &v);
		u--; v--;
		g[u][v] = g[v][u] = 1;
		d[u]++; d[v]++;
	}
	for (int i = 0; i < n; i++) scanf("%lf", &p[i][i]);
	for (int i = 0; i < n; i++)
		for (int j = 0; j < n; j++)
			if (i != j && g[i][j]) p[i][j] = (1 - p[i][i]) / d[i];
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			A[i * n + j][i * n + j] -= 1;
			if (i == j) continue;
			for (int k = 0; k < n; k++)
				for (int l = 0; l < n; l++)
					A[k * n + l][i * n + j] += p[i][k] * p[j][l];
		}
	}
	A[a * n + b][n * n] -= 1.0;
	Gauss(n * n, n * n);
	for (int i = 0; i < n; i++) printf("%.12f ", A[i * n + i][n * n]); printf("\n");
	return 0;
}


#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
using namespace std;

const int N = 505;
const double eps = 1e-8;
#define rep(i,a,b) for(int i=a;i<b;i++)
double A[N][N];

void Gauss(int n, int m) {
	int i = 0, x = 0;
	for (; i < n && x < m; i++, x++) {
		int r = i;
		rep(j,i+1,n) if (fabs(A[j][x]) > fabs(A[r][x])) {r=j;}
		if (fabs(A[r][x]) < eps) --i;
		else {
			if (r!=i) rep(j,0,m+1) swap(A[r][j],A[i][j]);
			for (int j = m; j >= x; j--) A[i][j] /= A[i][x];
			rep(j,0,n) if (i!=j && fabs(A[j][x]) >= eps)
			for (int k = m; k >= x; k--)
				A[j][k] -= A[i][k] * A[j][x];
		}
	}
}

int n, a, b, m;
int g[25][25], d[25];
double p[25][25];

int main() {
	scanf("%d%d%d%d", &n, &m, &a, &b);
	a--; b--;
	int u, v;
	while (m--) {
		scanf("%d%d", &u, &v);
		u--; v--;
		g[u][v] = g[v][u] = 1;
		d[u]++; d[v]++;
	}
	for (int i = 0; i < n; i++) scanf("%lf", &p[i][i]);
	for (int i = 0; i < n; i++)
		for (int j = 0; j < n; j++)
			if (i != j && g[i][j]) p[i][j] = (1 - p[i][i]) / d[i];
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			A[i * n + j][i * n + j] -= 1;
			if (i == j) continue;
			for (int k = 0; k < n; k++)
				for (int l = 0; l < n; l++)
					A[k * n + l][i * n + j] += p[i][k] * p[j][l];
		}
	}
	A[a * n + b][n * n] -= 1.0;
/*	for (int i = 0; i < n*n; i++)
	{
		for(int j=v=i;j<n*n;j++)
			if(fabs(A[j][i])>fabs(A[v][i]))
				v=j;
		for (int k =0; k <=n*n; k++)
			swap(A[v][k],A[i][k]);
		double u;
		u=A[i][i];
		for (int k = 0; k <=n * n ;k++)
			A[i][k]/=u;
		for (int j =0; j<n*n;j++)
			if(u=A[j][i],i!=j)
				for (int k = 0; k <=n * n;k++)
					A[j][k]-=u*A[i][k];
	}*/
	Gauss(n * n, n * n);
	for (int i = 0; i < n; i++) printf("%.10f ", A[i * n + i][n * n]); printf("\n");
	return 0;
}


/* package whatever; // don't place package name! */

import java.util.*;
import java.lang.*;
import java.io.*;

/* Name of the class has to be "Main" only if the class is public. */
class Main
{
	public static char[] reverse(char[] c, int a, int n){
		int i=a-1;
		int j=n-a;
		char temp =c[i];
		c[i]=c[j];
		c[j]=temp;
		return c;
	}
	public static void main (String[] args) throws java.lang.Exception
	{
	BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
	 String p = bf.readLine();
	 char[] c = p.toCharArray();
	 boolean[]rev=new boolean[(p.length()/2)+1];
	 bf.readLine();
	 StringTokenizer st = new StringTokenizer(bf.readLine());
	 while(st.hasMoreTokens()){
		 int i=Integer.parseInt(st.nextToken());
		 rev[i]=!rev[i];
	 }
	 boolean reverse=false;
	 for(int i=0; i<rev.length; i++){
		 if(rev[i])
			 reverse=!reverse;
		 if(reverse)
			c= reverse(c,i, p.length());

	 }
	 System.out.println(c);
	}
}


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

typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> ii;

string s;
bitset<1000000> marked;
int m;

void f(int i, bool rev) {
    if (i >= s.length()/2) return;
    if (marked[i]) {
        //cout << "true at i = " << i << endl;
        rev = !rev;
    }
    if (rev) {
        char tmp = s[i];
        s[i] = s[s.length() - 1 - i];
        s[s.length() - 1 - i] = tmp;
        //cout << "reversed " << s[i] << " and " << s[s.length() - 1 - i] << endl;
        f(i+1, rev);
    } else {
        f(i+1, rev);
    }
}

int main() {
    cin >> s;
    cin >> m;
    for(int i = 0; i < m; i++) {
        int a;
        cin >> a;
        marked[a-1] = !marked[a-1];
    }
    f(0, 0);
    cout << s << endl;
}


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

typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> ii;

string s;
vector<bool> marked;
int m;

void f(int i, bool rev) {
    if (i >= s.length()/2) return;
    if (marked[i]) {
        //cout << "true at i = " << i << endl;
        rev = !rev;
    }
    if (rev) {
        char tmp = s[i];
        s[i] = s[s.length() - 1 - i];
        s[s.length() - 1 - i] = tmp;
        //cout << "reversed " << s[i] << " and " << s[s.length() - 1 - i] << endl;
        f(i+1, rev);
    } else {
        f(i+1, rev);
    }
}

int main() {
    cin >> s;
    cin >> m;
    marked.assign(m, false);
    for(int i = 0; i < m; i++) {
        int a;
        cin >> a;
        marked[a-1] = !marked[a-1];
    }
    f(0, 0);
    cout << s << endl;
}


#include <bits/stdc++.h>
using namespace std;
#define lp(i, n) for(int i = 0; i < n; i++)

bitset<100010> bs;
int m;
string s;

int main() {
    cin >> s;
    cin >> m;
    bs.reset();
    lp(i, m) {
        int tmp;
        cin >> tmp;
        bs[--tmp] = 1;
    }
    bool rev = false;
    lp(i, s.length()/2) {
        if (bs[i]) {
            rev = !rev;
        }
        if (rev) {
            char c = s[i];
            s[i] = s[s.length() - i - 1];
            s[s.length() - i - 1] = c;
        }
    }
    cout << s << endl;
}


/* package whatever; // don't place package name! */

import java.util.*;
import java.lang.*;
import java.io.*;

/* Name of the class has to be "Main" only if the class is public. */
class Ideone
{
	public static char[] reverse(char[] c, int a, int n){
		int i=a-1;
		int j=n-a;
		char temp =c[i];
		c[i]=c[j];
		c[j]=temp;
		return c;
	}
	public static void main (String[] args) throws java.lang.Exception
	{
	BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
	 String p = bf.readLine();
	 char[] c = p.toCharArray();
	 boolean[]rev=new boolean[(p.length()/2)+1];
	 bf.readLine();
	 StringTokenizer st = new StringTokenizer(bf.readLine());
	 while(st.hasMoreTokens()){
		 int i=Integer.parseInt(st.nextToken());
		 rev[i]=!rev[i];
	 }
	 boolean reverse=false;
	 for(int i=0; i<rev.length; i++){
		 if(rev[i])
			 reverse=!reverse;
		 if(reverse)
			c= reverse(c,i, p.length());

	 }
	 System.out.println(c);
	}
}


#include <bits/stdc++.h>
using namespace std;
#define lp(i, n) for(int i = 0; i < n; i++)

bitset<100010> bs;
int m;
string s;

int main() {
    cin >> s;
    cin >> m;
    bs.reset();
    lp(i, m) {
        int tmp;
        cin >> tmp;
        tmp--;
        bs[tmp] = !bs[tmp];
    }
    bool rev = false;
    lp(i, s.length()/2) {
        if (bs[i]) {
            rev = !rev;
        }
        if (rev) {
            char c = s[i];
            s[i] = s[s.length() - i - 1];
            s[s.length() - i - 1] = c;
        }
    }
    cout << s << endl;
}


/* package whatever; // don't place package name! */

import java.util.*;
import java.lang.*;
import java.io.*;

public class Main
{
	public static char[] reverse(char[] c, int a, int n){
		int i=a-1;
		int j=n-a;
		char temp =c[i];
		c[i]=c[j];
		c[j]=temp;
		return c;
	}
	public static void main (String[] args) throws java.lang.Exception
	{
	BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
	 String p = bf.readLine();
	 char[] c = p.toCharArray();
	 boolean[]rev=new boolean[(p.length()/2)+1];
	 bf.readLine();
	 StringTokenizer st = new StringTokenizer(bf.readLine());
	 while(st.hasMoreTokens()){
		 int i=Integer.parseInt(st.nextToken());
		 rev[i]=!rev[i];
	 }
	 boolean reverse=false;
	 for(int i=0; i<rev.length; i++){
		 if(rev[i])
			 reverse=!reverse;
		 if(reverse)
			c= reverse(c,i, p.length());

	 }
	 System.out.println(c);
	}
}


#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<string.h>
#include<cstring>
#include<string>
#include<map>
#include<set>
#include<vector>
#include<queue>

using namespace std;
typedef long long ll;
#define sp  system("pause")
#define mt(dp) memset(dp,0,sizeof dp)

int cot[2*100000+50];

int main()
{
	string str;
	memset(cot,0,sizeof cot);
	cin>>str;
	int n;
	cin>>n;
	for(int i=0;i<n;i++)
	{
		int x;
		scanf("%d",&x);
		cot[x]++;
	}
	int  sw=0;
	int len=str.size();
	for(int i=0;i<len/2+1;i++)
	{
		sw+=cot[i];
		sw=sw&1;
		if(sw)
		{
			swap(str[i-1],str[len-i]);
		}
	}
	cout<<str<<endl;
	//sp;
	return 0;
}


#include <iostream>
#include <cmath>
#include <cstring>
#include <string>
#include <cstdio>
#include <vector>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <map>
using namespace std;
#define LL long long
#define ll long long
/*int a[105][105];
int n;
int main(){
	int t;
	cin >> t;
	while( t-- ){
		cin >> n;
		for( int i=0 ; )
	}

	return 0;
}*/
int main(){
	char a[200005];
	cin >> a;
	int n;
	cin >> n;
	int s;
	int len = strlen(a);
	for( int i=0 ; i<n ; i++ ){
		scanf("%d", &s);
		reverse( a+s-1, a+len-s+1 );
	}
	cout << a << endl;
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
string s;
int n;
void op(int x)
{
    string temp;
    temp=s.substr(x-1,s.size()-2*x+2);
    reverse(temp.begin(),temp.end());
    //cout<<temp<<endl;
    s.replace(x-1,temp.size(),temp);
}

int main()
{
    cin>>s;
    cin>>n;
    for(int i=0; i<n; i++)
    {
        int x;
        cin>>x;
        op(x);
    }
    cout<<s<<endl;
    return 0;
}


#include<iostream>
#include<utility>
#include<vector>
#include<cstring>
#include<map>
#include<algorithm>
#include<string>
#include<cmath>
#include<cstdio>
#include<set>
#include<queue>
#define mod 1000000007
using namespace std;
typedef long long ll;
const double PI = acos(-1.0);
#define pb push_back
#define lson l , m , rt << 1
#define rson m + 1 , r , rt << 1 | 1
const int inf=90000000;
const int maxn = 200050;
char a[maxn];
int cnt[maxn];
int main(){
	while (scanf("%s",a))
	{
		int m,te;
		int str = strlen(a);
		scanf("%d", &m);
		memset(cnt, 0, sizeof(cnt));
		for (int i = 0; i < m; i++){
			scanf("%d", &te);
			te = te - 1;
	   for (; te<str/2;te++)
			if (te>str/ 2)
				cnt[str-1- te]++;
			else
				cnt[te]++;
		}
		for (int i = 0; i < str / 2;i++)
			if (cnt[i] % 2){
				char s = a[i];
				a[i] = a[str -1 - i];
				a[str -1- i] = s;
			}
		printf("%s\n", a);
	}
	return 0;
}


#include<iostream>
#include<string>
#include<cstdio>
#include<cmath>
#include<algorithm>
using namespace std;
int ss[200002]={};
int main()
{
	string s;
	cin>>s;
	int n,i,temp,l,m,j;
	l=s.size();
	cin>>n;
	for(i=0;i<n;++i)
		cin>>ss[i];
	sort(ss,ss+n);
	for(i=0;i<n;i=i+2)
	{
		if(i+1!=n)
		{
			for(int j=ss[i]-1;j<ss[i+1]-1;j++)
			{
				temp=s[j];
				s[j]=s[l-j-1];
				s[l-j-1]=temp;
			}
		}
		else
		{
			for(int j=ss[i]-1;j<=l/2-1;j++)
			{
				temp=s[j];
				s[j]=s[l-j-1];
				s[l-j-1]=temp;
			}
		}
	}
	cout<<s<<endl;
	return 0;
}


#include<iostream>
#include<string>
#include<cstdio>
#include<cmath>
#include<algorithm>
using namespace std;
int ss[200002]={};
int main()
{
	string s;
	cin>>s;
	int n,i,temp,l,m;
	l=s.size();
	cin>>n;
	while(n--)
	{
		cin>>m;
		for(i=m-1;i<=l/2-1;++i)
			++ss[i];
	}
	for(int i=0;i<=l/2-1;i++)
		{
			if(ss[i]%2==1)
			{
				temp=s[i];
				s[i]=s[l-i-1];
				s[l-i-1]=temp;
			}
		}
	cout<<s<<endl;
	return 0;
}


#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<string.h>
#include<cstring>
#include<string>
#include<map>
#include<set>
#include<vector>
#include<queue>

using namespace std;
typedef long long ll;
#define sp  system("pause")
#define mt(dp) memset(dp,0,sizeof dp)

int cot[2*100000+50];

int main()
{
	string str;
	memset(cot,0,sizeof cot);
	cin>>str;
	int n;
	cin>>n;
	for(int i=0;i<n;i++)
	{
		int x;
		scanf("%d",&x);
		cot[x]++;
	}
	int  sw=0;
	int len=str.size();
	for(int i=0;i<len/2+1;i++)
	{
		sw+=cot[i];
		sw=sw&1;
		if(sw)
		{
			swap(str[i-1],str[len-i]);
		}
	}
	cout<<str<<endl;
	sp;
	return 0;
}


#include <stdio.h>
#include <string.h>

int main()
{
    int i,j,n,m,k,len,num[200005]={0};
    char s[200005];
    scanf("%s %d",s,&m);
    len=strlen(s);
    for(i=0;i<m;i++)
    {
        scanf("%d",&k);
        for(j=k;j<=len-k+1;j++)
        {
            num[j]++;
            if(num[j]==2)
                num[j]=0;
        }
    }
    for(i=0;i<len;i++)
    {
        if(num[i+1]==0)
            printf("%c",s[i]);
        else
            printf("%c",s[len-i-1]);
    }
    printf("\n");
    return 0;
}


#include <stdio.h>
#include <stdlib.h>
#include <string.h>

char str[200005];
int mark[100005];

int main()
{
    char c;
    int n,i,a,len;
    memset(mark,0,sizeof(mark));
    scanf("%s",str);
    scanf("%d",&n);
    len=strlen(str);
    for(i=0;i<n;i++)
    {
        scanf("%d",&a);
        mark[a-1]++;
    }
    for(i=1;i<=len/2;i++)
        mark[i]+=mark[i-1];
    for(i=0;i<=len/2;i++)
    {
        if(mark[i]%2!=0)
        {
            c=str[i];
            str[i]=str[len-i-1];
            str[len-i-1]=c;
        }
    }
    printf("%s\n",str);
    return 0;
}


#include <iostream>
#include <string>
#include <map>
#include <cstdio>
#include <algorithm>

using namespace std;

int main(){
    int m, a;
    string str;
    int mp[10000];
    while(cin>>str>>m){
        map < int, int > map;
        while(m--){
            cin >> a;
            if(!mp[a]){mp[a] = 1;}
            else{mp[a]++;}
        }
        int sum = 0;
        int len = str.length();
        for(int i = 0; i < len / 2; i++){
            sum += mp[i + 1];
            if(sum & 1){
                swap(str[i], str[len - 1 -i]);
            }

        }
        cout << str << endl;
    }
    return 0;
}


#include<stdio.h>
#include<string.h>
#include<algorithm>
using namespace std;
char s[200050];
int a[100050];
int main()
{
    int m,i,k=0;
    gets(s);
    int len=strlen(s);
    scanf("%d",&m);
    for(i=0;i<m;i++)
    {
        scanf("%d",&a[k]);
        a[k]--;
        k++;
        a[k]=len-a[k-1];
        k++;
    }
    sort(a,a+k);
    a[k]=999999999;
    int j=0;
    for(i=0;i<len;i++)
    {
        while(a[j]<=i) j++;
        if(j%2)
        {
            printf("%c",s[len-i-1]);
        }
        else printf("%c",s[i]);
    }
    return 0;
}


#include <stdio.h>
#include <string.h>

int main()
{
    int i,j,n,m,k,mid,len,num[200005]={0};
    char s[200005];
    scanf("%s %d",s,&m);
    len=strlen(s);
    mid=(len+1)/2;
    for(i=0;i<m;i++)
    {
        scanf("%d",&k);
        if(k>mid)
            k=len-k+1;
        for(j=k;j<=mid;j++)
        {
            num[j]++;
            if(num[j]==2)
                num[j]=0;
        }
    }
    for(i=0;i<len;i++)
    {
        if(i<mid)
            j=i+1;
        else
            j=len-i;
        if(num[j]==0)
            printf("%c",s[i]);
        else
            printf("%c",s[len-i-1]);
    }
    printf("\n");
    return 0;
}


#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
const int MAXN = 200100;
char str[MAXN];
int operate[MAXN];
int len, n;

int main() {
	scanf("%s", str+1);
	len = strlen(str+1);
	scanf("%d", &n);
	for(int i=1; i<=n; ++i) {
		int x;
		scanf("%d", &x);
		operate[i] = min(x, len+1-x);
	}
	sort(operate+1, operate+n+1);
	operate[n+1] = len/2+1;
	for(int i=0,j=1; i<=n; ++i)
		for(; j<operate[i+1]; ++j)
			if(i&1) swap(str[j], str[len+1-j]);
	printf("%s\n", str+1);
	return 0;
}


#include <iostream>
#include <string>
#include <map>
#include <cstdio>
#include <algorithm>
using namespace std;

int main()
{
    int m, a;
    string str;
    while(cin >> str >> m)
    {
        map <int,int> mp;
        while(m--)
        {
            cin >> a;
            if(!mp[a])
            mp[a] = 1;
            else
            mp[a]++;
        }
        /*for(int i=0;i<str.length();i++)
        {
            printf("%d\n", mp[i]);
        }*/
        int sum = 0;
        int len = str.length();
        for(int i = 0; i < len / 2; i++)
        {
            sum += mp[i + 1];
            if(sum & 1)
            swap(str[i], str[len - 1 - i]);
        }
        cout << str << endl;
    }
    return 0;
}


#include<cstdio>
#include<cstring>
const int MAXN = 200100;
bool rev[MAXN];
char str[MAXN];
int len, m, mid;

int main() {
	scanf("%s", str+1);
	len = strlen(str+1);
	mid = len/2;
	scanf("%d", &m);
	while(m--) {
		int l;
		scanf("%d", &l);
		for(int i=l; i<=mid; ++i)
			rev[i] = !rev[i];
	}
	for(int i=1; i<=len; ++i)
	{
		if(rev[i]) {
			char c = str[i];
			str[i] = str[len+1-i];
			str[len+1-i] = c;
		}
		putchar(str[i]);
	}
	putchar('\n');
	return 0;
}


#include<stdio.h>
#include<string.h>
#include<stdlib.h>
char s[200005];
int m,len,num,tot,d[100005];
void change(int a,int b,int k)
{
  char c;
  for(int i=a;i<k;i++)
  {
  	c=s[i];
  	s[i]=s[b-i+a];
  	s[b-i+a]=c;
  }
}
int main()
{
  gets(s+1);
  len=strlen(s+1);
  scanf("%d",&m);
  for(int i=1;i<=m;i++)
  	scanf("%d",&d[i]);
  for(int i=1;i<=m;i++)
  {
    if(d[i]==d[i+1])i++;
    else if(d[i]<d[i+1]&&i+1<=m||i==m){change(d[i],len-d[i]+1,d[i]+1);i++;}
    else if(d[i]>d[i+1])i++;
  }
  puts(s+1);
  return 0;
}


#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main()
{
   char STR[200860],str;
   int M,j,i,Len,Num,sign[200860],sum;
   gets(STR);
   Len=strlen(STR);
   scanf("%d",&M);
   memset(sign,0,sizeof(sign));
    for(j=0;j<M;j++)
    {
        scanf("%d",&Num);
        sign[Num]++;
    }
    for(j=1,sum=0;j<=Len/2;j++)
    {
        sum+=sign[j];
        if(sum%2==1)
        {
            i=j-1;
            str=STR[i];
            STR[i]=STR[Len-i-1];
            STR[Len-i-1]=str;
        }
    }
    puts(STR);
    return 0;
}


#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<algorithm>
#include <iostream>
using namespace std;
#define MAXN 10000000
char s[MAXN];
int m,a[MAXN], n, i;
bool b[MAXN]= {0};
int main()
{
    scanf("%s",s+1);
    n=strlen(s+1);
    scanf("%d",&m);
    for(i = 1; i <= m; i++) scanf("%d",&a[i]);
    for(i = 1; i <= m; i++)
    {
        b[a[i]]^=1;
    }
    bool flag=0;
    for(i = 1; i <= n/2; i++)
    {
        flag^=b[i];
        if (flag) swap(s[i],s[n-i+1]);
    }

    printf("%s\n",s+1);

    return 0;
}


#include<stdio.h>
#include<string.h>
#include<algorithm>
using namespace std;
char s[200050];
int a[200050];
int main()
{
    int m,i,k=0;
    gets(s);
    int len=strlen(s);
    scanf("%d",&m);
    for(i=0;i<m;i++)
    {
        scanf("%d",&a[k]);
        a[k]--;
        k++;
        a[k]=len-a[k-1];
        k++;
    }
    sort(a,a+k);
    a[k]=999999999;
    int j=0;
    for(i=0;i<len;i++)
    {
        while(a[j]<=i) j++;
        if(j%2)
        {
            printf("%c",s[len-i-1]);
        }
        else printf("%c",s[i]);
    }
    return 0;
}


#include<cstdio>
#include<cstring>
#include<iostream>
using namespace std;
const int maxn=200009;
int num[100002];
char str[maxn];
int main(){
    int m,n;
    char t;
    memset(num,0,sizeof(num));
    scanf("%s",str);
    int c=strlen(str);
    scanf("%d",&m);
    for(int i=0;i<m;i++){
        scanf("%d",&num[i]);
    }
    for(int i=0;i<m;i++){
        n=num[i];
        t=str[n-1];
        str[n-1]=str[c-n];
        str[c-n]=t;
    }
    printf("%s\n",str);
    return 0;
}


#include<cstdio>
#include<cstring>

using namespace std;

char a[200005], t;
int s, ai[100005], m, i, j, k;

int main(void)
{
	scanf("%s", a);
	s = strlen(a);
	scanf("%d", &m);
    for (k=1; k<=m; k++)
	{
        scanf("%d", &ai[k]);
	}
	for (k=1; k<=m; k++)
	{
		while (a[k] == a[k+1] || a[k] == a[k-1])
		{
            k++;
            if (k > m)
			{
				break;
			}
		}
		if (k > m)
		{
			break;
		}
		for (i=ai[k]-1, j=s-ai[k]; i<j; i++, j--)
		{
			t = a[i];
			a[i] = a[j];
			a[j] = t;
		}
	}
	printf("%s\n", a);

	return 0;
}


#include <cstdio>
#include <cstring>
#include <algorithm>
#define maxn 200005
using namespace std;
int vis[maxn];
char str[maxn];

int main()
{
    int len, n, m, v;
    memset(vis, 0, sizeof(vis));
    scanf("%s", str);
    len = strlen(str);
    scanf("%d", &m);
    while (m--)
    {
        scanf("%d", &v);
        vis[v]++;
    }
    v = 0;
    for (int i = 1; i<=(len>>1); i++)
    {
        v += vis[i];
        if (v & 1) swap(str[i-1], str[len-i]);
    }
    puts(str);
    return 0;
}


#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int swmp(char a[],int n,int l)
{
    char t;
    int i;
    for(i=n-1;i<=((l-n)+n-1)/2;i++)
    {
        t=a[i];
        a[i]=a[l-i];
        a[l-i]=t;
    }
}
int main()
{
    int n,m,l,i,max=0;
    char a[200005];
    int b[100005]={0};
    scanf(" %s",a);
    l=strlen(a);
    scanf("%d",&n);
    for(i=0;i<n;i++)
    {
        scanf("%d",&m);
        b[m]=!b[m];
        if(m>max)
            max=m;
    }
    for(i=0;i<=m;i++)
    {
        if(b[i]==1)
        {
            swmp(a,i,l-1);
        }
    }
    printf("%s\n",a);
    return 0;
}


#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main()
{
   char STR[100860],str;
   int M,j,i,Len,Num,sign[100860],sum;
   gets(STR);
   Len=strlen(STR);
   scanf("%d",&M);
   memset(sign,0,sizeof(sign));
    for(j=0;j<M;j++)
    {
        scanf("%d",&Num);
        sign[Num]++;
    }
    for(j=1,sum=0;j<=Len/2;j++)
    {
        sum+=sign[j];
        if(sum%2==1)
        {
            i=j-1;
            str=STR[i];
            STR[i]=STR[Len-i-1];
            STR[Len-i-1]=str;
        }
    }
    puts(STR);
    return 0;
}


#include<cstdio>
#include<cstring>

using namespace std;

char a[200005], t;
int s, ai[100005] = {0}, m, i, j, k;

int main(void)
{
	scanf("%s", a);
	s = strlen(a);
	scanf("%d", &m);
    for (k=1; k<=m; k++)
	{
        scanf("%d", &ai[k]);
	}
	for (k=1; k<=m; k++)
	{
		while (a[k] == a[k+1] || a[k] == a[k-1])
		{
            k++;
            if (k > m)
			{
				break;
			}
		}
		if (k > m)
		{
			break;
		}
		for (i=ai[k]-1, j=s-ai[k]; i<j; i++, j--)
		{
			t = a[i];
			a[i] = a[j];
			a[j] = t;
		}
	}
	printf("%s\n", a);

	return 0;
}


#include <stdio.h>
#include <string.h>
int main(){
    char str[200005];
    int stri[100005]={0};
    int m,i,j,k,len;
    scanf("%s",str);
    len = strlen(str);
    scanf("%d",&m);
    for(i=0;i<m;i++){
        int fir;
        scanf("%d",&k);
        fir = k -1;
        if(stri[fir]!=0)
            stri[fir]--;
        else stri[fir]++;
    }
    int con=0;
    for(i=0;i*2<=len;i++){
        if(stri[i]){
           stri[i]+=con;
           con++;
        }
        else stri[i]+=con;
        if(stri[i]%2){
            char t;
            t = str[i];
            str[i] = str[len-i-1];
            str[len-i-1] = t;
        }
    }
    printf("%s\n",str);
    return 0;
}


#include<cstdio>
#include<cstring>

using namespace std;

char a[200005], t;
int s, ai[100005], m, i, j, k;

int main(void)
{
	scanf("%s", a);
	s = strlen(a);
	scanf("%d", &m);
    for (k=1; k<=m; k++)
	{
        scanf("%d", &ai[k]);
	}
	for (k=1; k<=m; k++)
	{
		while (a[k] == a[k+1] || a[k] == a[k-1])
		{
            k++;
		}
		for (i=ai[k]-1, j=s-ai[k]; i<j; i++, j--)
		{
			t = a[i];
			a[i] = a[j];
			a[j] = t;
		}
	}
	printf("%s\n", a);

	return 0;
}


#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<cmath>
#include<iostream>
#include<algorithm>
using namespace std;
char s[200005];
int d[200005];
bool used[200005];
int main()
{
    int m;
    scanf("%s",s);
    int n=strlen(s);
    scanf("%d",&m);
    int a;
    for(int i=1;i<=m;i++)
    {
        scanf("%d",&a);
        d[a-1]^=1;
    }
    int tot=0;
    for(int i=0;i<n/2;i++)
    {
        tot^=d[i];
        if(tot)
        {
            printf("%c",s[n-i-1]);
            used[n-i-1]=1;
        }
        else
        {
            printf("%c",s[i]);
            used[i]=1;
        }
    }
    for(int i=n/2;i<n;i++)
    {
        if(used[i])
        {
            printf("%c",s[n-i-1]);
        }
        else
        {
            printf("%c",s[i]);
        }
    }
    return 0;
}


#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main()
{
   char STR[100860],str;
   int M,j,i,Len,tmp,Num,sign[100860];
   gets(STR);
   Len=strlen(STR);
   scanf("%d",&M);
   memset(sign,0,sizeof(sign));
    for(j=0;j<M;j++)
    {
        scanf("%d",&Num);
        for(i=Num;i<=Len/2;i++)
        {
            sign[i]++;
        }
    }
    for(j=1;j<=Len/2;j++)
    {
        if(sign[j]%2==1)
        {i=j-1;
        str=STR[i];
        STR[i]=STR[Len-i-1];
        STR[Len-i-1]=str;}
    }
    puts(STR);
    return 0;
}


#include<stdio.h>
#include<string.h>
#include<stdlib.h>
char s[200005];
int m,len,num,tot,c[100005],d[100005];
void change(int a,int b)
{
  char c;
  for(int i=a;i<=((a+b)>>1);i++)
  {
  	c=s[i];
  	s[i]=s[b-i+a];
  	s[b-i+a]=c;
  }
}
int main()
{
  gets(s+1);
  len=strlen(s+1);
  scanf("%d",&m);
  for(int i=1;i<=m;i++)
  {
  	scanf("%d",&d[i]);
  	if(c[d[i]])c[d[i]]=0;
  	else c[d[i]]=1;
  }
  for(int i=1;i<=m;i++)
    if(!c[d[i]])continue;
    else
    {
      c[d[i]]=1;
      change(d[i],len-d[i]+1);
	}
  puts(s+1);
  return 0;
}


#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int swmp(char a[],int n,int l)
{
    char t;
    int i,p;
    for(i=n-1;i<=((l-n)+n-1)/2;i++)
    {
        t=a[i];
        a[i]=a[l-i];
        a[l-i]=t;
    }
}
int main()
{
    int n,m,l,i,max=0;
    char a[200005];
    int b[100005]={0};
    scanf(" %s",a);
    l=strlen(a);
    scanf("%d",&n);
    for(i=0;i<n;i++)
    {
        scanf("%d",&m);
        if(m>(l-1)/2)
            m=l-m+1;
        b[m]=!b[m];
        if(m>max)
            max=m;
    }
    for(i=0;i<=m;i++)
    {
        if(b[i]==1)
        {
            swmp(a,i,l-1);
        }
    }
    printf("%s\n",a);
    return 0;
}


#include <stdio.h>
#include <stdlib.h>
#include <string.h>

char str[200005];
int mark[100005];

int main()
{
    char c;
    int n,i,a,len;
    memset(mark,0,sizeof(mark));
    scanf("%s",str);
    scanf("%d",&n);
    len=strlen(str);
    for(i=0;i<n;i++)
    {
        scanf("%d",&a);
        mark[a-1]++;
    }
    for(i=1;i<len/2;i++)
        mark[i]+=mark[i-1];
    for(i=0;i<len/2;i++)
    {
        if(mark[i]%2!=0)
        {
            c=str[i];
            str[i]=str[len-i-1];
            str[len-i-1]=c;
        }
    }
    printf("%s\n",str);
    return 0;
}


#include<stdio.h>
#include<string.h>
#include<stdlib.h>
char s[200005];
int m,len,num,tot,d[100005];
void change(int a,int b,int k)
{
  char c;
  for(int i=a;i<k;i++)
  {
  	c=s[i];
  	s[i]=s[b-i+a];
  	s[b-i+a]=c;
  }
}
int main()
{
  gets(s+1);
  len=strlen(s+1);
  scanf("%d",&m);
  for(int i=1;i<=m;i++)
  	scanf("%d",&d[i]);
  for(int i=1;i<=m;i++)
  {
    if(d[i]==d[i+1])i++;
    else if(d[i]<d[i+1]&&i+1<=m||i==m){change(d[i],len-d[i]+1,d[i]+1);i++;}
    else if(d[i]>d[i+1]){change(d[i],len-d[i]+1,(len+1)>>1);}
  }
  puts(s+1);
  return 0;
}


#include<cstdio>
#include<cstring>

using namespace std;

char a[200005], t;
int s, ai, m, i, j, js[200005] = {0};

int main(void)
{
	scanf("%s", a);
	s = strlen(a);
	scanf("%d", &m);
    while (m--)
	{
        scanf("%d", &ai);
        j = s-ai;
        i = ai-1;
        while (i<=j)
		{
            js[i]++;
            i++;
		}
	}
    for (i=0, j=s-1; i<j; i++, j--)
	{
        if (js[i]%2)
		{
            t = a[i];
            a[i] = a[j];
            a[j] = t;
		}
	}
	printf("%s\n", a);

	return 0;
}


#include<cstdio>
#include<cstring>

using namespace std;

char a[200005], t;
int s, ai, m, i, j, k, js[200005] = {0};

int main(void)
{
	scanf("%s", a);
	s = strlen(a);
	scanf("%d", &m);
    while (m--)
	{
        scanf("%d", &ai);
        j = s-ai;
        i = ai-1;
        while (i<=j)
		{
            js[i++]++;
		}
	}
    for (i=0, j=s-1; i<j; i++, j--)
	{
        if (js[i]%2)
		{
            t = a[i];
            a[i] = a[j];
            a[j] = t;
		}
	}
	printf("%s\n", a);

	return 0;
}


#include<cstdio>
#include<cstring>

using namespace std;

char a[200005], t;
int s, ai, m, i, j, k;

int main(void)
{
	scanf("%s", a);
	s = strlen(a);
	scanf("%d", &m);
    while(m--)
	{
        scanf("%d", &ai);
        for (i=ai-1, j=s-ai; i<j; i++, j--)
		{
            t = a[i];
            a[i] = a[j];
            a[j] = t;
		}
	}
	printf("%s\n", a);

	return 0;
}


#include <stdio.h>
#include <stdlib.h>
#include <string.h>

char str[200005];
int mark[200005]={0};

int main()
{
    char c;
    int n,i,j,a,len;
    scanf("%s",str);
    scanf("%d",&n);
    len=strlen(str);
    for(i=0;i<n;i++)
    {
        scanf("%d",&a);
        mark[a-1]++;
    }
    for(i=1;i<=len/2;i++)
        mark[i]+=mark[i-1];
    for(i=0;i<=len/2;i++)
    {
        if(mark[i]%2!=0)
        {
            c=str[i];
            str[i]=str[len-i-1];
            str[len-i-1]=c;
        }
    }
    printf("%s\n",str);
    return 0;
}


#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
char s[200005];
int a[100005];

int main()
{
    scanf("%s", s + 1);
    int len = strlen(s + 1), m, get, i;
    scanf("%d", &m);
    while(m--)
    {
        scanf("%d", &get);		// 1  2  3
        a[get] ++;     //a[1] = 1   a[2] = 1  a[3] = 1
    }
    for(i = 1; i <= len / 2; i++)
        a[i] += a[i - 1];
    for(i = 1; i <= len / 2; i++)
        if(a[i] % 2)
            swap(s[i], s[len + 1 - i]);
    printf("%s\n", s + 1);

	return 0;
}


#include<cstdio>
#include<cstring>

using namespace std;

char a[200005], t;
int s, ai[100005], m, i, j, k;

int main(void)
{
	scanf("%s", a);
	s = strlen(a);
	scanf("%d", &m);
    for (k=1; k<=m; k++)
	{
        scanf("%d", &ai[k]);
        if (ai[k] != ai[k-1])
		{
			for (i=ai[k]-1, j=s-ai[k]; i<j; i++, j--)
			{
				t = a[i];
				a[i] = a[j];
				a[j] = t;
			}
		}
	}
	printf("%s\n", a);

	return 0;
}


#include <iostream>
#include <string>
#include <map>
#include <cstdio>
#include <algorithm>
using namespace std;

int main()
{
    int m, a;
    string str;
    while(cin >> str >> m)
    {
        map <int,int> mp;
        while(m--)
        {
            cin >> a;
            if(mp[a])
            mp[a] = 1;
            else
            mp[a]++;
        }
        int sum = 0;
        int len = str.length();
        for(int i = 0; i < len / 2; i++)
        {
            sum += mp[i + 1];
            if(sum & 1)
            swap(str[i], str[len - 1 - i]);
        }
        cout << str << endl;
    }
    return 0;
}


#include <cstdio>
#include <cstring>
#include <iostream>
#include <map>
#include <vector>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#define eps 1e-8
#define mod 1000000007
using namespace std;

const int maxn = 2e5+100;
typedef long long LL;

char s[maxn];
int cnt[maxn];

int main()
{
    scanf("%s", s);
    int len = strlen(s);
    int m;
    scanf("%d", &m);
    memset(cnt, 0, sizeof(cnt));
    for(int i = 0; i < m; i++)
    {
        int x;scanf("%d", &x);
        cnt[x]++;
    }
    for(int i = 1; i < maxn; i++){
        cnt[i] += cnt[i-1];
    }
    for(int i = 1; i <= (len>>1); i++){
        if(cnt[i]%2)swap(s[i-1], s[len-i]);
    }
    cout << s << endl;
    return 0;
}


#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
char str[200010];
int a[200010];
int cmp(const void *a,const void *b)
{
    return (*(int *)a)-(*(int *)b);
}
int main()
{
    int i,j,m,count,len;
    scanf("%s",str);
    len=strlen(str);
    scanf("%d",&m);
    for(i=0; i<m; i++)
    {
        scanf("%d",&a[i]);
    }
    qsort(a,m,sizeof(a[0]),cmp);
    /*for(i=0; i<m; i++)
        printf("%d  ",a[i]);
    printf("\n");*/
    int jj,n;
    char c;
    if(m%2)
    {
        for(jj=a[m-1]-1; jj<=(len-1)/2; jj++)
        {
            n=len-jj-1;
            c=str[jj];
            str[jj]=str[n];
            str[n]=c;
        }
    }
    for(i=m-1; i>0; i--)
    {
        if(i%2)
        {
            for(jj=a[i-1]-1; jj<a[i]-1; jj++)
            {
                n=len-jj-1;
                c=str[jj];
                str[jj]=str[n];
                str[n]=c;
            }
        }
    }
            puts(str);
    return 0;
}


#include <stdio.h>
#include <string.h>
int main(){
    char str[200005];
    int stri[100005]={0};
    int m,i,j,k,len;
    scanf("%s",str);
    len = strlen(str);
    scanf("%d",&m);
    for(i=0;i<m;i++){
        int fir;
        scanf("%d",&k);
        fir = k -1;
        if(stri[fir]!=0)
            stri[fir]--;
        else stri[fir]++;
    }
    int con=0;
    for(i=0;i*2<len;i++){
        if(stri[i]){
           stri[i]+=con;
           con++;
        }
        else stri[i]+=con;
        if(stri[i]%2){
            char t;
            t = str[i];
            str[i] = str[len-i-1];
            str[len-i-1] = t;
        }
    }
    printf("%s\n",str);
    return 0;
}


#include<stdio.h>
#include<string.h>
int main()
{
    char s[200005],t;
    int a[100005]={0},n,tem;
    scanf("%s",s);
    scanf("%d",&n);
    for(int i=0;i<n;i++)
    {
        scanf("%d",&tem);
        a[tem]++;
    }
    int ant = strlen(s)/2;
    for(int i=1;i<=ant;i++)
    {
        a[i]=(a[i]+a[i-1])%2;
        if(a[i]%2!=0)
        {

              t=s[i-1];
              s[i-1]=s[strlen(s)-i];
              s[strlen(s)-i]=t;

        }
    }
    printf("%s\n",s);
}


#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main()
{
   char STR[200860],str;
   int M,j,i,Len,tmp,Num,sign[200860];
   gets(STR);
   Len=strlen(STR);
   scanf("%d",&M);
   memset(sign,0,sizeof(sign));
    for(j=0;j<M;j++)
    {
        scanf("%d",&Num);
        for(i=Num;i<=Len/2;i++)
        {
            sign[i]++;
        }
    }
    for(j=1;j<=Len/2;j++)
    {
        if(sign[j]%2==1)
        {i=j-1;
        str=STR[i];
        STR[i]=STR[Len-i-1];
        STR[Len-i-1]=str;}
    }
    puts(STR);
    return 0;
}


#include <iostream>
#include <string>
#include <map>
#include <cstdio>
#include <algorithm>
using namespace std;
int main() {
    int m, a;
    string str;
    while(cin >> str >> m) {
        map <int, int> mp;
        while(m--) {
            cin >> a;
            if(!mp[a]) mp[a] = 1;
            else mp[a]++;
        }
        int sum = 0;
        int len = str.length();
        for(int i = 0; i < len / 2; i++) {
            sum += mp[i + 1];
            if(sum & 1) swap(str[i], str[len - 1 - i]);
        }
        cout << str << endl;
    }
    return 0;
}


#include<stdio.h>
#include<string.h>
char s[200005];
int m,a,len;
void change(int a,int b)
{
  char c;
  for(int i=a;i<=((a+b)>>1);i++)
  {
  	c=s[i];
  	s[i]=s[b-i+a];
  	s[b-i+a]=c;
  }
}
int main()
{
  gets(s+1);
  len=strlen(s+1);
  scanf("%d",&m);
  for(int i=1;i<=m;i++)
  {
  	scanf("%d",&a);
  	change(a,len-a+1);
  }
  puts(s+1);
  return 0;
}


#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;
const int MAX = 1e5+10;
char str[2*MAX];
int cnt[MAX];

int main()
{
    //freopen("input.txt","r",stdin);
    int n,a;
    while(~scanf("%s",str))
    {
        memset(cnt,0,sizeof(cnt));
        scanf("%d",&n);
        for(int i = 0; i<n; i++)
        {
            scanf("%d",&a);
            cnt[a]++;
        }
        int len = strlen(str);
        for(int i = 1; i<=len/2; i++)
        cnt[i] +=cnt[i-1];
        for(int i =1; i<=len/2; i++)
          if(cnt[i]%2)
           swap(str[i-1],str[len-i]);
           printf("%s\n",str);
    }
  return 0;
}


#include <bits/stdc++.h>

int main ()
{
    std::string a;
    int m;

    std::cin >> a;
    std::cin >> m;

    std::vector<int> v (a.length() / 2 + 1, 0);

    while (m--)
    {
        int temp;
        std::cin >> temp;
        ++v[temp];
    }

    int f = 0;
    int k = 1;
    for (int i = 1; i < v.size(); ++i)
    {
        if (v[i]%2 == 1)
        {
            if (f == 0)
            {
                std::swap (a[i-1], a[a.length() - i]);
                f = 1;
                k = 0;
            }

            else
            {
                f = 0;
                k = 1;
            }
        }

        else if (k == 0)
            std::swap (a[i-1], a[a.length() - i]);
    }

    std::cout << a << std::endl;
    return 0;
}


#include <bits/stdc++.h>

int main ()
{
    std::string a;
    int m;

    std::cin >> a;
    std::cin >> m;

    std::vector<int> v (a.length() / 2 + 1, 0);

    while (m--)
    {
        int temp;
        std::cin >> temp;
        ++v[temp];
    }

    int f = 0;
    int k = 1;
    for (int i = 1; i < v.size(); ++i)
    {
        if (v[i]%2 == 1)
        {
            if (f == 0)
            {
                std::swap (a[i-1], a[a.length() - i]);
                f = 1;
                k = 0;
            }

            else
                f = 0;
        }

        else if (k == 0)
            std::swap (a[i-1], a[a.length() - i]);
    }

    std::cout << a << std::endl;
    return 0;
}


#include <bits/stdc++.h>

void reverse (std::string &a, int start)
{
    for (int i = start-1, j = a.length()-start; i <= j; ++i, --j)
        std::swap (a[i], a[j]);
}

int main ()
{
    std::string a;
    int m;

    std::cin >> a;
    std::cin >> m;

    std::vector<int> v (a.length(), 0);

    while (m--)
    {
        int n;
        std::cin >> n;
        v[n]++;
    }

    for (int i = 1; i < v.size(); ++i)
    {
        if (v[i]%2 == 1)
            reverse (a, i);
        else
            continue;
    }

    std::cout << a << std::endl;
    return 0;
}


#include <bits/stdc++.h>

void reverse (std::string &a, int start)
{
    for (int i = start-1, j = a.length()-start; i <= j; ++i, --j)
        std::swap (a[i], a[j]);
}

int main ()
{
    std::string a;
    int m, n;

    std::cin >> a;
    std::cin >> m;

    while (m--)
    {
        std::cin >> n;
        reverse (a, n);
    }

    std::cout << a << std::endl;
    return 0;
}


#include <bits/stdc++.h>

void reverse (std::string &a, int start)
{
    for (int i = start-1, j = a.length()-start; i <= j; ++i, --j)
        std::swap (a[i], a[j]);
}

int main ()
{
    std::string a;
    long long m;

    std::cin >> a;
    std::cin >> m;

    std::vector<long long> v (a.length(), 0);

    while (m--)
    {
        long long n;
        std::cin >> n;
        v[n]++;
    }

    for (long long i = 1; i < v.size(); ++i)
    {
        if (v[i]%2 == 1)
            reverse (a, i);
        else
            continue;
    }

    std::cout << a << std::endl;
    return 0;
}


#include <bits/stdc++.h>

void reverse (std::string &a, int start)
{
    for (int i = start-1, j = a.length()-start; i <= j; ++i, --j)
        std::swap (a[i], a[j]);
}

int main ()
{
    std::string a;
    long long m;

    std::cin >> a;
    std::cin >> m;

    std::vector<long long> v (a.length() / 2 + 1, 0);

    while (m--)
    {
        long long n;
        std::cin >> n;
        v[n]++;
    }

    for (long long i = 1; i <= v.size() / 2; ++i)
    {
        if (v[i]%2 == 1)
            reverse (a, i);
        else
            continue;
    }

    std::cout << a << std::endl;
    return 0;
}


#include <bits/stdc++.h>

void reverse (std::string &a, int start)
{
    for (int i = start-1, j = a.length()-start; i <= j; ++i, --j)
        std::swap (a[i], a[j]);
}

int main ()
{
    std::string a;
    long long m;

    std::cin >> a;
    std::cin >> m;

    std::vector<long long> v (a.length() / 2 + 1, 0);

    while (m--)
    {
        long long n;
        std::cin >> n;
        v[n]++;
    }

    for (long long i = 1; i <= v.size(); ++i)
    {
        if (v[i]%2 == 1)
            reverse (a, i);
        else
            continue;
    }

    std::cout << a << std::endl;
    return 0;
}


# include<bits/stdc++.h>
using namespace std;
long long x[200001];
int main()
{
    long long n,i,a,m;
    string s;
    cin>>s>>n;
    m=s.size();
    s=" "+s;
    for(i=1;i<=n;i++)
    {
        cin>>a;
        x[a]++;
    }
    for(i=1;i<=m/2;i++)
    {
        x[i]=x[i-1]+x[i];
        if(x[i]%2 == 1)
        {
            swap(s[i],s[m-i+1]);
        }
    }
    for(i=1;i<=m;i++)
    {
        cout<<s[i];
    }
    return 0;
}


# include<bits/stdc++.h>
using namespace std;
long long x[200001];
int main()
{
    long long n,i,j,a,b;
    string s;
    cin>>s>>n;
    for(i=1;i<=n;i++)
    {
        cin>>a;
        b=s.size()-a;
        for(j=a-1;j<=b;j++)
        x[j]++;
    }
   long long q=s.size()-1;
    for(i=0;i<=q;i++)
    {
        if(x[i]%2==1)
        {
            for(j=q;j>=0;j--)
            {
                if(x[j]%2==1)
                {
                    swap(s[i],s[j]);
                    q=j-1;
                    j=-1;
                }
            }
        }
    }
    cout<<s;
    return 0;
}


# include<bits/stdc++.h>
using namespace std;
long long x[200001];
int main()
{
    long long n,i,a,m;
    string s;
    cin>>s>>n;
    m=s.size();
    s=" "+s;
    for(i=1;i<=n;i++)
    {
        cin>>a;
        x[a]++;
    }
    for(i=1;i<=m/2;i++)
    {
        x[i]=x[i-1]+x[i];
        if(x[i]%2 == 1)
        {
            swap(s[i],s[m-i+1]);
        }
    }
    for(i=1;i<=s.size();i++)
    {
        cout<<s[i];
    }
    return 0;
}


# include<bits/stdc++.h>
using namespace std;
long long x[200001];
int main()
{
    long long n,i,a;
    string s;
    cin>>s>>n;
    s=" "+s;
    for(i=1;i<=n;i++)
    {
        cin>>a;
        x[a]++;
    }
    for(i=1;i<=(s.size()-1)/2;i++)
    {
        x[i]=x[i-1]+x[i];
        if(x[i]%2 == 1)
        {
            swap(s[i],s[s.size()-i]);
        }
    }
    for(i=1;i<=s.size();i++)
    {
        cout<<s[i];
    }
    return 0;
}


# include<bits/stdc++.h>
using namespace std;
long long x[200001];
int main()
{
    long long n,i,a;
    string s;
    cin>>s>>n;
    s=" "+s;
    for(i=1;i<=n;i++)
    {
        cin>>a;
        x[a]++;
    }
    for(i=1;i<=(s.size()-1)/2;i++)
    {
        x[i]=x[i-1]+x[i];
        cout<<x[i]<<' '<<i<<endl;
        if(x[i]%2 == 1)
        {
            swap(s[i],s[s.size()-i]);
        }
    }
    for(i=1;i<=s.size();i++)
    {
        cout<<s[i];
    }
    return 0;
}


#include<iostream>
#include<vector>
#include<cstring>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<cstring>

using namespace std;

char s[200100];
int n;
int key[300];
int sum;
bool a[200100];
int main()
{

	scanf("%s",s);
	int l=strlen(s);
	cin>>n;
	int x;
	for(int i=0;i<n;++i)
	{
		cin>>x;
		a[x-1]^=1;
	}
	for(int i=0;i<l/2;++i)
	{
		sum^=a[i];
		if(sum){char t=s[i];
				s[i]=s[l-i-1];
				s[l-i-1]=t;}
	}
	printf("%s\n",s);

	cout<<sum<<endl;
 	return 0;
}


#include<iostream>
#include<vector>
#include<cstring>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<cstring>

using namespace std;

char s[200100];
int n;
int key[300];
int sum;
bool a[200100];
int main()
{

	scanf("%s",s);
	int l=strlen(s);
	cin>>n;
	int x;
	for(int i=0;i<n;++i)
	{
		cin>>x;
		a[x-1]^=1;
	}
	for(int i=0;i<l/2;++i)
	{
		sum^=a[i];
		if(sum){char t=s[i];
				s[i]=s[l-i-1];
				s[l-i-1]=t;}
	}
	cout<<s;

	//cout<<sum<<endl;
 	return 0;
}


#include<iostream>
#include<vector>
#include<cstring>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<cstring>

using namespace std;

char s[200100];
int n;
int key[300];
int sum;
bool a[200100];
int main()
{

	scanf("%s",s);
	int l=strlen(s);
	cin>>n;
	int x;
	for(int i=0;i<n;++i)
	{
		cin>>x;
		a[x-1]^=1;
	}
	for(int i=0;i<l/2;++i)
	{
		sum^=a[i];
		if(sum){char t=s[i];
				s[i]=s[l-i-1];
				s[l-i-1]=t;}
	}
	cout<<s<<endl;

	cout<<sum<<endl;
 	return 0;
}


#include<iostream>
#include<vector>
#include<cstring>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<cstring>

using namespace std;

char s[200100];
int n;
int key[300];
int sum;
bool a[200100];
int main()
{

	scanf("%s",s);
	int l=strlen(s);
	cin>>n;
	int x;
	for(int i=0;i<n;++i)
	{
		cin>>x;
		a[x-1]^=1;
	}
	for(int i=0;i<l/2;++i)
	{
		sum^=a[i];
		if(sum){char t=s[i];
				s[i]=s[l-i-1];
				s[l-i-1]=t;}
	}
	cout<<s<<endl;

	//cout<<sum<<endl;
 	return 0;
}


#include<iostream>
#include<vector>
#include<cstring>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<cstring>

using namespace std;

char s[200100];
int n;
int key[300];
int sum;
bool a[200100];
int main()
{

	cin>>s;
	int l=strlen(s);
	cin>>n;
	int x;
	for(int i=0;i<n;++i)
	{
		cin>>x;
		a[x-1]^=1;
	}
	for(int i=0;i<l/2;++i)
	{
		sum^=a[i];
		if(sum){char t=s[i];
				s[i]=s[l-i-1];
				s[l-i-1]=t;}
	}
	cout<<s<<endl;

	//cout<<sum<<endl;
 	return 0;
}


#include<iostream>
#include<vector>
#include<cstring>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<cstring>

using namespace std;

char s[200100];
int n;
int key[300];
int sum;
bool a[200100];
int main()
{

	scanf("%s",s);
	int l=strlen(s);
	cin>>n;
	int x;
	for(int i=0;i<n;++i)
	{
		cin>>x;
		a[x-1]^=1;
	}
	for(int i=0;i<l/2;++i)
	{
		sum^=a[i];
		if(sum){char t=s[i];
				s[i]=s[l-i-1];
				s[l-i-1]=t;}
	}
	printf("%s\n",s);

	//cout<<sum<<endl;
 	return 0;
}


#include<iostream>
#include<vector>
#include<cstring>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<cstring>

using namespace std;

char s[200100];
int n;
int key[300];
int sum;
bool a[200100];
int main()
{

	scanf("%s",s);
	int l=strlen(s);
	scanf("%d",&n);
	int x;
	for(int i=0;i<n;++i)
	{
		scanf("%d",&x);
		a[x-1]^=1;
	}
	for(int i=0;i<l/2;++i)
	{
		sum^=a[i];
		if(sum){char t=s[i];
				s[i]=s[l-i-1];
				s[l-i-1]=t;}
	}
	cout<<s<<endl;

	//cout<<sum<<endl;
 	return 0;
}


#include<bits/stdc++.h>
#define lld long long int

using namespace std;

bool chk[100003];

int main(void)
{
    string s;
    char ch;
    lld m, i, j, k, ai, l;

    cin>>s;
    cin>>m;
    l = s.size()-1;
    for(i=1; i<=m; i++)
    {
        cin>>ai;
        k = l-ai+1;
        j = ai-1;
        if(k>j)
        for(;j<k; j++, k--)
        {
          ch = s[j];
          s[j]=s[k];
          s[k]=ch;
        }
        else
         for(k;k<j; k++, j--)
        {
          ch = s[j];
          s[j]=s[k];
          s[k]=ch;
        }

    }
    cout<<s<<endl;

    return 0;
}


#include<bits/stdc++.h>
#define lld long long int

using namespace std;

int chk[100002]={0};

int main(void)
{
    string s;
    char ch;
    lld m, i, j, k, ai, l, lim;

    cin>>s;
    cin>>m;
    l = s.size()-1;
    lim = (l-1)/2;
    for(i=1; i<=m; i++)
    {
        cin>>ai;
        j = ai-1;
        for(;j<=lim; j++)
        {
          chk[j]++;
        }
    }

    for(i=0; i<=lim; i++)
    {
        if(chk[i]%2)
        {
            ch = s[i];
            s[i]=s[l-i];
            s[l-i]=ch;
        }
    }
    cout<<s<<endl;

    return 0;
}


#include<bits/stdc++.h>
#define lld long long int

using namespace std;
int main(void)
{
    char s[200004];
    lld chk[100002]={0};
    char ch;
    lld m, i, j, k, ai, l, lim;

     scanf("%s",s);
     scanf("%I64d",&m);

    l = strlen(s)-1;
    lim = (l-1)/2;

    for(i=1; i<=m; i++)
    {
        scanf("%I64d",&ai);
        chk[ai-1]++;
    }

    k=0;
    for(i=0; i<=lim; i++)
    {
        k += chk[i];
         if(k%2)
         {
            ch = s[i];
            s[i]=s[l-i];
            s[l-i]=ch;
         }
    }
     printf("%s\n",s);

    return 0;
}


#include<bits/stdc++.h>
#define lld long long int

using namespace std;
int main(void)
{
    char s[200004];
    char ch;
    lld m, i, j, k, ai, l, lim;

     scanf("%s",s);
     scanf("%I64d",&m);

    l = strlen(s)-1;
    lim = (l-1)/2;
    for(i=1; i<=m; i++)
    {
        scanf("%I64d",&ai);
        j = ai-1;
        for(;j<=lim; j++)
        {
            ch = s[j];
            s[j]=s[l-j];
            s[l-j]=ch;
        }
    }
     printf("%s\n",s);

    return 0;
}


#include<bits/stdc++.h>
#define lld long long int

using namespace std;
int main(void)
{
    string s;
    char ch;
    lld m, i, j, k, ai, l, lim;

    cin>>s;
    cin>>m;
    l = s.size()-1;
    lim = (l-1)/2;
    for(i=1; i<=m; i++)
    {
        cin>>ai;
        j = ai-1;
        for(;j<=lim; j++)
        {
            ch = s[j];
            s[j]=s[l-j];
            s[l-j]=ch;
        }
    }
    cout<<s<<endl;

    return 0;
}


#include<bits/stdc++.h>
#define lld long long int

using namespace std;

int chk[50002]={0};

int main(void)
{
    string s;
    char ch;
    lld m, i, j, k, ai, l, lim;

    cin>>s;
    cin>>m;
    l = s.size()-1;
    lim = (l-1)/2;
    for(i=1; i<=m; i++)
    {
        cin>>ai;
        k = l-ai+1;
        j = ai-1;
        for(;j<k && j<=lim; j++, k--)
        {
          chk[j]++;
        }
    }

    for(i=0; i<=lim; i++)
    {
        if(chk[i]%2)
        {
            ch = s[i];
            s[i]=s[l-i];
            s[l-i]=ch;
        }
    }
    cout<<s<<endl;

    return 0;
}


#include<bits/stdc++.h>

using namespace std;
int co[200005];
int main()
{
    string s;
    cin>>s;
    int m;
    cin>>m;
    int x;
    for(int i=0;i<m;i++)
    {
        cin>>x;
        co[x]++;
        //reverse(s.begin()+x-1,s.end()-x+1);
    }
    for(int i=2;i<s.length();i++)
    {
        co[i]+=co[i-1];
    }
    for(int i=1;i<=s.length()/2;i++)
    {
        if(co[i]%2!=0)
        {
            swap(s[i-1],s[s.length()-i]);
        }
    }
    cout<<s<<endl;
}


#include<bits/stdc++.h>

using namespace std;
int co[200005];
int main()
{
    string s;
    cin>>s;
    int m;
    cin>>m;
    int x;
    for(int i=0;i<m;i++)
    {
        cin>>x;
        co[x]++;
        //reverse(s.begin()+x-1,s.end()-x+1);
    }
    for(int i=1;i<=200005;i++)
    {
        if(co[i]%2!=0)
        {
            reverse(s.begin()+i-1,s.end()-i+1);
        }
    }
    cout<<s<<endl;
}


#include<bits/stdc++.h>

using namespace std;
int co[100005];
int main()
{
    string s;
    cin>>s;
    int m;
    cin>>m;
    int x;
    for(int i=0;i<m;i++)
    {
        cin>>x;
        co[x]++;
        //reverse(s.begin()+x-1,s.end()-x+1);
    }
    for(int i=1;i<=s.length()/2;i++)
    {
        if(co[i]%2!=0)
        {
            reverse(s.begin()+i-1,s.end()-i+1);
        }
    }
    cout<<s<<endl;
}


#include<bits/stdc++.h>

using namespace std;

int main()
{
    string s;
    cin>>s;
    int m;
    cin>>m;
    int x;
    for(int i=0;i<m;i++)
    {
        cin>>x;
        reverse(s.begin()+x-1,s.end()-x+1);
    }
    cout<<s<<endl;
}


#include<bits/stdc++.h>

using namespace std;
int co[100006];
int main()
{
    string s;
    cin>>s;
    int m;
    cin>>m;
    int x;
    for(int i=0;i<m;i++)
    {
        cin>>x;
        co[x]++;
        //reverse(s.begin()+x-1,s.end()-x+1);
    }
    for(int i=2;i<s.length();i++)
    {
        co[i]+=co[i-1];
    }
    for(int i=1;i<=s.length()/2;i++)
    {
        if(co[i]%2!=0)
        {
            swap(s[i-1],s[s.length()-i]);
        }
    }
    cout<<s<<endl;
}


#include<bits/stdc++.h>

using namespace std;
int co[100005];
int main()
{
    string s;
    cin>>s;
    int m;
    cin>>m;
    int x;
    for(int i=0;i<m;i++)
    {
        cin>>x;
        co[x]++;
        //reverse(s.begin()+x-1,s.end()-x+1);
    }
    for(int i=2;i<s.length();i++)
    {
        co[i]+=co[i-1];
    }
    for(int i=1;i<=s.length()/2;i++)
    {
        if(co[i]%2!=0)
        {
            swap(s[i-1],s[s.length()-i]);
        }
    }
    cout<<s<<endl;
}


#include<bits/stdc++.h>

using namespace std;
int co[100005];
int main()
{
    string s;
    cin>>s;
    int m;
    cin>>m;
    int x;
    for(int i=0;i<m;i++)
    {
        cin>>x;
        co[x]++;
        //reverse(s.begin()+x-1,s.end()-x+1);
    }
    for(int i=1;i<=100005;i++)
    {
        if(co[i]%2!=0)
        {
            reverse(s.begin()+i-1,s.end()-i+1);
        }
    }
    cout<<s<<endl;
}


#include<iostream>
#include<algorithm>
#include<string.h>
using namespace std;
int main()
{
    string s;
    char c;
    cin>>s;
    long long m,n,i,x=0,y=0,z=0,a[100005],b[200005]={0};
    cin>>m;
    n=s.length();
    for(i=0;i<m;i++){cin>>a[i];a[i]-=1;b[a[i]]++;}
    for(i=0;i<n;i++)
    {
        if(b[i]==0)continue;
        if((x+b[i])%2==0){x+=b[i];continue;}x+=b[i];
        for(y=i;;y++)
        {
            if(b[y]>0 && i!=y)break;
            c=s[y];s[y]=s[n-y-1];s[n-y-1]=c;z++;
            if(z>=(n-i-1)/2){z=0;break;}
        }
    }
    cout<<s;
    return 0;
}


#include<iostream>
#include<algorithm>
#include<string.h>
using namespace std;
int main()
{
    string s;
    char c;
    cin>>s;
    long long m,n,i,x=0,y=0,z=0,a[100005],b[200005]={0};
    cin>>m;
    n=s.length();
    for(i=0;i<m;i++){cin>>a[i];a[i]-=1;b[a[i]]++;}
    for(i=0;i<n;i++)
    {
        if(b[i]==0)continue;
        if((x+b[i])%2==0){x+=b[i];continue;}x+=b[i];
        z=(n-(2*i)-1)/2;
        for(y=i;y<=i+z;y++)
        {
            if(b[y]>0 && i!=y)break;
            c=s[y];s[y]=s[n-y-1];s[n-y-1]=c;
        }
    }
    cout<<s;
    return 0;
}


#include<iostream>
#include<algorithm>
#include<string.h>
using namespace std;
int main()
{
    string s;
    char c;
    cin>>s;
    long long m,n,i,x=0,y=0,z=0,a[10005],b[20005]={0};
    cin>>m;
    n=s.length();
    for(i=0;i<m;i++){cin>>a[i];a[i]-=1;b[a[i]]++;}
    for(i=0;i<n;i++)
    {
        if(b[i]==0)continue;
        if((x+b[i])%2==0){x+=b[i];continue;}x+=b[i];
        z=(n-(2*i)-1)/2;
        for(y=i;y<=i+z;y++)
        {
            if(b[y]>0 && i!=y)break;
            c=s[y];s[y]=s[n-y-1];s[n-y-1]=c;
        }
    }
    cout<<s;
    return 0;
}


#include<iostream>
#include<string.h>
using namespace std;
int main()
{
 char a[200005],temp;
 long long int m,b[100005],i,x=0,y=0,len=0,x1=0,y1=0,temp1=0,j,x2,y2,z=0;
 cin>>a;
 cin>>m;
 for(i=0;i<m;i++)
    cin>>b[i];
 len=strlen(a);
 for(i=0;i<m;i+=z)
 {
     x=b[i];
     y=len-x+1;
     x2=b[i+1];
     y2=len-x2+1;
     if(x==x2&&y==y2){z=2;continue;}
     x--;y--;
     x1=y-x+1;
     temp1=x1-1;
     y1=x1/2;
     for(j=x;j<x+y1;j++)
     {
         temp=a[j];
         a[j]=a[j+temp1];
         a[j+temp1]=temp;
         temp1-=2;
     }
     z=1;
 }
 cout<<a;
 return 0;
}


# coding: utf-8

# |a1 - a2| <= |a2 - a3| <= |a3 - a4| ....
# 를 만족시키도록 a를 정렬
# 꽤 재밌는 유형의 문제이다. 이렇게 숫자 배열을 타고 순회하는걸 oscillation이라 한다는군.
# naive하게 구성한 알고리즘은 다음과 같음
# 1. 삽입 정렬 구조를 가짐
# 2. 빈 배열에 a1 삽입
# 3. 빈 배열에 a2 삽입
# (여기까진 |a1 - a2| = |a2 - a1|이므로 큰 지장은 없음)
# 4. 빈 배열에 a3 을 넣기 위한 자리를 선택함( 전체 순회가 필요함 O(n))
# 5. 이후 a3부터 aN까지 모든 절차를 반복해야하므로 O(n^2)
# 이렇게 잡았지만 부분적으로는 해답일 수 있으나 아무래도 오답이 자꾸 나오네.
# 결국은 몇번 고민해보다가 찾은 해가 이 접근법이다.

# 일단 숫자를 모두 정렬한다. 1 2 9 5 8 8을 감소가 없는 순서대로 정렬하면,
# 1 2 5 8 8 9 이다. 이 숫자는 재밌는 성질을 갖고 있는데, 한 숫자를 기준으로
# 오른쪽은 0혹은 1이상만큼 크며 왼쪽은 0혹은 1이상만큼 작다.
# 그래서 자신에게 k 거리만큼 먼쪽일 수록 자신과의 차이가 매우 커질거란 기대를 할 수 있다.
# 자신에게 0에 가까운 거리일수록 자신과의 차이는 매우 작아진다.
# 그래서 중앙에서부터 왼쪽 절반의 제일 후미부터, 오른쪽 절반의 제일 선두부터 숫자를
# 추출하면 거리가 가까운 순서부터 먼 순서대로 뽑을 수 있다.

# 처음에 평균을 이용한 접근을 한건 평균이 중앙에 올 경우에는 성공할 수 있는 방법이지만,
# 평균값이 중앙에 있지 못한 경우에는 잘못된 동작을 할 수 있다.
# 결국 평균이 아니라 '중간값'을 찾아야하는 문제. 정렬은 이러한 방법으로 순회하기 위해
# 안정적인 전제를 제공하는 것이다.
t = gets.to_i
t.times {
    n = gets.to_i
    a = gets.split.map(&:to_i)
    a.sort!
    mid = n/2
    la, ra = a[0...mid], a[mid...n]
    b = []
    while !la.empty? || !ra.empty?
        b << ra.shift unless ra.empty?
        b << la.pop unless la.empty?
    end

    #p la
    #p ra

    puts b.join(' ')
}


t = gets.to_i
t.times do
  n = gets.to_i
  a = gets.split.map(&:to_i)
  a.sort!
  b = Array.new(n, nil)
  pos = (n - 1) / 2
  n.times do |i|
    puts pos
    b[i] = a[pos]
    if i % 2 == 0
      pos += i + 1
    else
      pos -= i + 1
    end
  end
  puts b.join(" ")
end


t = gets.to_i
t.times do
  n = gets.to_i
  a = gets.split.map(&:to_i)
  a.sort!
  b = Array.new(n, nil)
  pos = (n - 1) / 2
  n.times do |i|
    b[i] = a[pos]
    if i % 2 == 0
      pos += i + 1
    else
      pos -= i + 1
    end
  end
  puts b.join(" ")
end


a = int(input())
for i in range(a):
    b = int(input())
    q = list(map(int, raw_input().split()))
    q.sort()
    k = b / 2 - 1
    r = 0
    p = 1
    t = []
    while -1 < k < b:
        t.append(q[k])
        if r == 0:
            k += p
            r += 1
        else:
            k -= p
            r -= 1
        p += 1
    print t


a = int(input())
for i in range(a):
    b = int(input())
    q = list(map(int, raw_input().split()))
    q.sort()
    t = []
    if b % 2 == 0:
        k = b / 2 - 1
        while k >= 0:
            t.append(q[k])
            t.append(q[b-1-k])
            k -= 1
    else:
        k = b / 2
        t.append(q[k])
        k -= 1
        while k >= 0:
            t.append(q[k])
            t.append(q[b-1-k])
            k -= 1
    for k in range(b):
        print t[k],


a = int(input())
for i in range(a):
    b = int(input())
    q = list(map(int, raw_input().split()))
    q.sort()
    k = b / 2 - 1
    r = 0
    p = 1
    t = []
    while -1 < k < b:
        t.append(q[k])
        if r == 0:
            k += p
            r += 1
        else:
            k -= p
            r -= 1
        p += 1
    for k in range(b):
        print t[k],


from sys import stdin
t = int(stdin.readline())
for _ in xrange(t):
    n = int(stdin.readline())
    a = map(int,stdin.readline().split())
    a.sort()
    i = (n-1)/2
    j = i+1
    while i>=0:
        print a[i],
        i-=1
        if j<n:
            print a[j],
        j+=1
    print ""


def solve(ns):
    ns.sort()
    n = len(ns)
    res = []
    p, q = 0, n - 1
    while p <= q:
        if p <= q:
            res.append(ns[q])
            q -= 1
        if p <= q:
            res.append(ns[p])
            p += 1
    return res[::-1]

def verify(ns):
    INF = 10 ** 10
    pre = -INF
    n = len(ns)
    for i in xrange(1, n):
        assert abs(ns[i] - ns[i - 1]) >= pre
        pre = abs(ns[i] - ns[i - 1])
    return True

def test():
    from random import randint
    for i in xrange(100):
        n = randint(1, 200)
        ns = [randint(-100, 100) for i in xrange(n)]
        res = solve(ns)
        assert verify(res)

T = int(raw_input())

for case_ in xrange(T):
    n = int(raw_input())
    ns = map(int, raw_input().split())
    res = solve(ns)
    for item in res:
        print item,
    print ''


for _ in range(input()):
    n=input()
    a=[int(i) for i in raw_input().split()]
    a.sort()
    b=[]
    for i in range(n/2):
        b.append(a[n-i-1])
        b.append(a[i])
    if n%2!=0:
        b.append(a[n/2])
    b=b[::-1]
    for i in b:
        print i,
    print