#include <iostream>
#include <cstring>
#include <cmath>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <set>
#include <string>
#include <map>
#include <ctime>
#include <cstdlib>
#include <unordered_set>

typedef long long ll;

using namespace std;

const int MaxN = 1e5;
const int MaxCount = 100;

int initial_pots[MaxN];
int pots[MaxN];

long double p[MaxN][MaxCount + 1];
long double p_new[MaxCount + 1];

long double Transfer(int from, int to) {

	for (int untasted = 0; untasted <= min(pots[from], initial_pots[from]); ++untasted) {
		p_new[untasted] = p[from][untasted] * (pots[from] - untasted) / (long double)pots[from];
		if (untasted != min(pots[from], initial_pots[from]))
			p_new[untasted] += p[from][untasted + 1] * (untasted + 1) / (long double)pots[from];
	}

	long double result = -p[from][0] + p_new[0];

	for (int untasted = 0; untasted <= min(pots[from], initial_pots[from]); ++untasted)
		p[from][untasted] = p_new[untasted];

	pots[from]--;
	pots[to]++;

	return result;
}

int main() {
	int n;
	scanf ("%d", &n);
	long double result = 0;
	for (int i = 0; i < n; ++i) {
		scanf ("%d", &initial_pots[i]);
		pots[i] = initial_pots[i];
		p[i][pots[i]] = 1.0;
		if (pots[i] == 0)
			result += 1.0;
	}

	int q;
	scanf ("%d", &q);
	for (int query = 0; query < q; ++query) {
		int from, to, count;
		scanf ("%d%d%d", &from, &to, &count);
		--from, --to;
		for (int i = 0; i < count; ++i) {
			long double change = Transfer(from, to);
			result += change;
		}
		printf ("%.12Lf\n", result);
	}

	return 0;
}


#include <iostream>
#include <cstring>
#include <cmath>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <set>
#include <string>
#include <map>
#include <ctime>
#include <cstdlib>
#include <unordered_set>

typedef long long ll;

using namespace std;

const int MaxN = 1e5;
const int MaxCount = 100;

int initial_pots[MaxN];
int pots[MaxN];

long double p[MaxN][MaxCount + 1];
long double p_new[MaxCount + 1];

long double Transfer(int from, int to) {

	for (int untasted = 0; untasted <= min(pots[from], initial_pots[from]); ++untasted) {
		p_new[untasted] = p[from][untasted] * (pots[from] - untasted) / (long double)pots[from];
		if (untasted != min(pots[from], initial_pots[from]))
			p_new[untasted] += p[from][untasted + 1] * (untasted + 1) / (long double)pots[from];
	}

	long double result = -p[from][0] + p_new[0];

	for (int untasted = 0; untasted <= min(pots[from], initial_pots[from]); ++untasted)
		p[from][untasted] = p_new[untasted];

	pots[from]--;
	pots[to]++;

	return result;
}

int main() {
	int n;
	scanf ("%d", &n);
	long double result = 0;
	for (int i = 0; i < n; ++i) {
		scanf ("%d", &initial_pots[i]);
		pots[i] = initial_pots[i];
		p[i][pots[i]] = 1.0;
		if (pots[i] == 0)
			result += 1.0;
	}

	int q;
	scanf ("%d", &q);
	for (int query = 0; query < q; ++query) {

		int from, to, count;
		scanf ("%d%d%d", &from, &to, &count);

		if (query == 81)
			cout << from << " " << to << " " << count << endl;

		--from, --to;
		for (int i = 0; i < count; ++i) {
			long double change = Transfer(from, to);
			result += change;
		}
		printf ("%.12Lf\n", result);
	}

	return 0;
}


#include <iostream>
#include <cstring>
#include <cmath>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <set>
#include <string>
#include <map>
#include <ctime>
#include <cstdlib>
#include <unordered_set>

typedef long long ll;

using namespace std;

const int MaxN = 1e5;
const int MaxCount = 100;

int initial_pots[MaxN];
int pots[MaxN];

long double p[MaxN][MaxCount + 1];
long double p_new[MaxCount + 1];

long double Transfer(int from, int to) {

	for (int untasted = 0; untasted <= min(pots[from], initial_pots[from]); ++untasted) {
		p_new[untasted] = p[from][untasted] * (pots[from] - untasted) / (long double)pots[from];
		if (untasted != min(pots[from], initial_pots[from]))
			p_new[untasted] += p[from][untasted + 1] * (untasted + 1) / (long double)pots[from];
	}

	long double result = -p[from][0] + p_new[0];

	for (int untasted = 0; untasted <= min(pots[from], initial_pots[from]); ++untasted)
		p[from][untasted] = p_new[untasted];

	pots[from]--;
	pots[to]++;

	return result;
}

int main() {
	int n;
	scanf ("%d", &n);
	for (int i = 0; i < n; ++i) {
		scanf ("%d", &initial_pots[i]);
		pots[i] = initial_pots[i];
		p[i][pots[i]] = 1.0;
	}

	long double result = 0;

	int q;
	scanf ("%d", &q);
	for (int query = 0; query < q; ++query) {
		int from, to, count;
		scanf ("%d%d%d", &from, &to, &count);
		--from, --to;
		for (int i = 0; i < count; ++i) {
			long double change = Transfer(from, to);
			result += change;
		}
		printf ("%.12Lf\n", result);
	}

	return 0;
}


#include <iostream>
#include <cstring>
#include <cmath>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <set>
#include <string>
#include <map>
#include <ctime>
#include <cstdlib>
#include <unordered_set>

typedef long long ll;

using namespace std;

const int MaxN = 1e5;
const int MaxCount = 100;

int initial_pots[MaxN];
int pots[MaxN];

long double p[MaxN][MaxCount + 1];
long double p_new[MaxCount + 1];

long double Transfer(int from, int to) {

	for (int untasted = 0; untasted <= initial_pots[from]; ++untasted) {
		p_new[untasted] = p[from][untasted] * (pots[from] - untasted) / (long double)pots[from];
		if (untasted != initial_pots[from])
			p_new[untasted] += p[from][untasted + 1] * (untasted + 1) / (long double)pots[from];
	}

	long double result = -p[from][0] + p_new[0];

	for (int untasted = 0; untasted <= initial_pots[from]; ++untasted)
		p[from][untasted] = p_new[untasted];

	pots[from]--;
	pots[to]++;

	return result;
}

int main() {
	int n;
	scanf ("%d", &n);
	long double result = 0;
	for (int i = 0; i < n; ++i) {
		scanf ("%d", &initial_pots[i]);
		pots[i] = initial_pots[i];
		p[i][pots[i]] = 1.0;
		if (pots[i] == 0)
			result += 1.0;
	}

	int q;
	scanf ("%d", &q);
	for (int query = 0; query < q; ++query) {
		int from, to, count;
		scanf ("%d%d%d", &from, &to, &count);
		--from, --to;
		for (int i = 0; i < count; ++i) {
			long double change = Transfer(from, to);
			result += change;
		}
		printf ("%.12Lf\n", result);
	}

	return 0;
}


#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<string>
#include<cstring>
#include<cmath>
#include<ctime>
#include<algorithm>
#include<utility>
#include<stack>
#include<queue>
#include<vector>
#include<set>
#include<map>
#define EPS 1e-9
#define PI acos(-1.0)
#define INF 0x3f3f3f3f
#define LL long long
const int MOD = 1E9+7;
const int N =100000+5;
const int dx[] = {0,0,-1,1,-1,-1,1,1};
const int dy[] = {-1,1,0,0,-1,1,-1,1};
using namespace std;

LL n,m;
LL a[N],b[N];
LL C[1000+5][1000+5];
double dp[N][100+10];
void init() {
    C[0][0]=1;
    for(int i=1; i<=1000; i++) {
        C[i][0]=1;
        for(int j=1; j<=i; j++)
            C[i][j]=C[i-1][j-1]+C[i-1][j];
    }
}

int main() {
    scanf("%lld",&n);
    double res=0;
    for(int i=1; i<=n; i++){
        scanf("%d",&a[i]);
        b[i]=a[i];
        dp[i][a[i]]=1;
        res+=dp[i][0];
    }
    scanf("%lld",&m);
    while(m--){
        LL u,v,k;
        scanf("%lld%lld%lld",&u,&v,&k);
        res-=dp[u][0];
        for(int i=0; i<=a[u]; i++) {
            double temp=0;
            for(int j=0; j<=k; j++)
                temp+=dp[u][i+j]*C[i+j][j]*C[b[u]-i-j][k-j]/C[b[u]][k];
            dp[u][i]=temp;
        }
        b[u]-=k;
        b[v]+=k;
        res+=dp[u][0];
        printf("%.10lf\n",res);
    }
    return 0;
}


#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<string>
#include<cstring>
#include<cmath>
#include<ctime>
#include<algorithm>
#include<utility>
#include<stack>
#include<queue>
#include<vector>
#include<set>
#include<map>
#define EPS 1e-9
#define PI acos(-1.0)
#define INF 0x3f3f3f3f
#define LL long long
const int MOD = 1E9+7;
const int N =100000+5;
const int dx[] = {0,0,-1,1,-1,-1,1,1};
const int dy[] = {-1,1,0,0,-1,1,-1,1};
using namespace std;

LL n,m;
LL a[N],b[N];
LL C[1000+5][1000+5];
double dp[N][100+10];
void init() {
    C[0][0]=1;
    for(int i=1; i<=1000; i++) {
        C[i][0]=1;
        for(int j=1; j<=i; j++)
            C[i][j]=C[i-1][j-1]+C[i-1][j];
    }
}

int main() {
    scanf("%lld",&n);
    double res=0;
    for(int i=1; i<=n; i++){
        scanf("%d%d",&a[i],&b[i]);
        dp[i][a[i]]=1;
        res+=dp[i][0];
    }
    scanf("%lld",&m);
    while(m--){
        LL u,v,k;
        scanf("%lld%lld%lld",&u,&v,&k);
        res-=dp[u][0];
        for(int i=0; i<=a[u]; i++) {
            double temp=0;
            for(int j=0; j<=k; j++)
                temp+=dp[u][i+j]*C[i+j][j]*C[b[u]-i-j][k-j]/C[b[u]][k];
            dp[u][i]=temp;
        }
        b[u]-=k;
        b[v]+=k;
        res+=dp[u][0];
        printf("%.10lf\n",res);
    }
    return 0;
}


#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<string>
#include<cstring>
#include<cmath>
#include<ctime>
#include<algorithm>
#include<utility>
#include<stack>
#include<queue>
#include<vector>
#include<set>
#include<map>
#define EPS 1e-9
#define PI acos(-1.0)
#define INF 0x3f3f3f3f
#define LL long long
const int MOD = 1E9+7;
const int N =100000+5;
const int dx[] = {0,0,-1,1,-1,-1,1,1};
const int dy[] = {-1,1,0,0,-1,1,-1,1};
using namespace std;

int n,m;
int a[N],b[N];
double dp[N][100+10];
double C(int n,int m){
    if(n<m)
        return 0;
    double res=1;
    for(int i=1;i<=m;i++)
        res=res*(1.0*(n-i+1)/i);
    return res;
}

int main() {
    scanf("%d",&n);
    for(int i=1; i<=n; i++){
        scanf("%d",&a[i]);
        b[i]=a[i];
    }
    for(int i=1; i<=n; i++)
        dp[i][a[i]]=1;

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

    scanf("%d",&m);
    while(m--){
        int u,v,k;
        scanf("%d%d%d",&u,&v,&k);
        res-=dp[u][0];

        for(int i=0; i<=a[u]; i++) {
            double temp=0;
            for(LL j=0; j<=k; j++)
                temp+= dp[u][i+j]*C(i+j,j)*C(b[u]-i-j,k-j) / C(b[u],k);
            dp[u][i]=temp;
        }
        b[u]-=k;
        b[v]+=k;
        res+=dp[u][0];
        printf("%.10lf\n",res);
    }
    return 0;
}


#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
using namespace std;

#define ll long long
#define ld double
#define mem(Arr,x) memset(Arr,x,sizeof(Arr))

const int maxN=101000;
const int maxM=110;
const int inf=2147483647;

int n,m;
int Num[maxN];
ld F[maxN][maxM],G[maxM];
ld C[maxN][10];

ld GetC(int n,int m);

int main(){
	C[0][0]=1;
	for (int i=1;i<maxN;i++){
		C[i][0]=1;
		for (int j=1;j<=min(i,9);j++)
			C[i][j]=C[i-1][j]+C[i-1][j-1];
	}

	scanf("%d",&n);
	for (int i=1;i<=n;i++) scanf("%d",&Num[i]),F[i][Num[i]]=1;
	ld Ans=0;
	for (int i=1;i<=n;i++) Ans+=F[i][0];
	int Q;scanf("%d",&Q);
	while (Q--){
		int u,v,key;scanf("%d%d%d",&u,&v,&key);
		Ans-=F[u][0];//Ans-=F[v][0];
		mem(G,0);
		for (int j=0;j<=Num[u];j++)
			for (int k=0;k<=min(j,key);k++)
				G[j-k]+=F[u][j]/C[Num[u]][key]*C[j][k]*C[Num[u]-j][key-k];
		for (int j=0;j<=Num[u];j++) F[u][j]=G[j];

		Num[u]-=key;Num[v]+=key;
		Ans+=F[u][0];//Ans+=F[v][0];

		printf("%.11lf\n",Ans);
	}

	return 0;
}

/*
1
5
20
1 1 1
1 1 1
1 1 1
1 1 1
1 1 1
1 1 1
1 1 1
1 1 1
1 1 1
1 1 1
1 1 1
1 1 1
1 1 1
1 1 1
1 1 1
1 1 1
1 1 1
1 1 1
1 1 1
1 1 1
//*/


#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
using namespace std;

#define ll long long
#define ld double
#define mem(Arr,x) memset(Arr,x,sizeof(Arr))

const int maxN=101000;
const int maxM=110;
const int inf=2147483647;

int n,m;
int Num[maxN],INum[maxN];
ld F[maxN][maxM];
ld C[maxN][10];

ld GetC(int n,int m);

int main(){
	C[0][0]=1;
	for (int i=1;i<maxN;i++){
		C[i][0]=1;
		for (int j=1;j<=min(i,9);j++)
			C[i][j]=C[i-1][j]+C[i-1][j-1];
	}

	scanf("%d",&n);
	for (int i=1;i<=n;i++) scanf("%d",&Num[i]),F[i][INum[i]=Num[i]]=1;
	ld Ans=0;
	for (int i=1;i<=n;i++) Ans+=F[i][0];
	int Q;scanf("%d",&Q);
	while (Q--){
		int u,v,key;scanf("%d%d%d",&u,&v,&key);
		Ans-=F[u][0];//Ans-=F[v][0];
		for (int j=0;j<=min(INum[u],Num[u]);j++){
			ld nf=F[u][j];F[u][j]=0;
			for (int k=0;k<=min(j,key);k++)
				F[u][j-k]+=nf/C[Num[u]][key]*C[j][k]*C[Num[u]-j][key-k];
		}

		Num[u]-=key;Num[v]+=key;
		Ans+=F[u][0];//Ans+=F[v][0];

		printf("%.11lf\n",Ans);
	}

	return 0;
}

/*
1
5
20
1 1 1
1 1 1
1 1 1
1 1 1
1 1 1
1 1 1
1 1 1
1 1 1
1 1 1
1 1 1
1 1 1
1 1 1
1 1 1
1 1 1
1 1 1
1 1 1
1 1 1
1 1 1
1 1 1
1 1 1
//*/


#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
using namespace std;

#define ll long long
#define ld double
#define mem(Arr,x) memset(Arr,x,sizeof(Arr))

const int maxN=101000;
const int maxM=110;
const int inf=2147483647;

int n,m;
int Num[maxN],INum[maxN];
ld F[maxN][maxM];
ld C[maxN][10];

ld GetC(int n,int m);

int main(){
	C[0][0]=1;
	for (int i=1;i<maxN;i++){
		C[i][0]=1;
		for (int j=1;j<=min(i,9);j++)
			C[i][j]=C[i-1][j]+C[i-1][j-1];
	}

	scanf("%d",&n);
	for (int i=1;i<=n;i++) scanf("%d",&Num[i]),F[i][INum[i]=Num[i]]=1;
	ld Ans=0;
	for (int i=1;i<=n;i++) Ans+=F[i][0];
	int Q;scanf("%d",&Q);
	while (Q--){
		int u,v,key;scanf("%d%d%d",&u,&v,&key);
		Ans-=F[u][0];//Ans-=F[v][0];
		for (int j=0;j<=min(INum[u],Num[u]);j++){
			ld nf=F[u][j];F[u][j]=0;
			for (int k=0;k<=min(j,key);k++)
				F[u][j-k]+=nf*C[j][k]*C[Num[u]-j][key-k]/C[Num[u]][key];
		}

		Num[u]-=key;Num[v]+=key;
		Ans+=F[u][0];//Ans+=F[v][0];

		printf("%.11lf\n",Ans);
	}

	return 0;
}

/*
1
5
20
1 1 1
1 1 1
1 1 1
1 1 1
1 1 1
1 1 1
1 1 1
1 1 1
1 1 1
1 1 1
1 1 1
1 1 1
1 1 1
1 1 1
1 1 1
1 1 1
1 1 1
1 1 1
1 1 1
1 1 1
//*/


#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
using namespace std;

#define ll long long
#define ld long double
#define mem(Arr,x) memset(Arr,x,sizeof(Arr))

const int maxN=101000;
const int maxM=110;
const int inf=2147483647;

int n,m;
int Num[maxN],INum[maxN];
ld F[maxN][maxM],G[maxM];
ld C[maxN][10];

ld GetC(int n,int m);

int main(){
	C[0][0]=1;
	for (int i=1;i<maxN;i++){
		C[i][0]=1;
		for (int j=1;j<=min(i,9);j++)
			C[i][j]=C[i-1][j]+C[i-1][j-1];
	}

	scanf("%d",&n);
	for (int i=1;i<=n;i++) scanf("%d",&Num[i]),F[i][Num[i]]=1,INum[i]=Num[i];
	ld Ans=0;
	for (int i=1;i<=n;i++) Ans+=F[i][0];
	int Q;scanf("%d",&Q);
	while (Q--){
		int u,v,key;scanf("%d%d%d",&u,&v,&key);
		Ans-=F[u][0];Ans-=F[v][0];
		mem(G,0);
		for (int j=0;j<=min(INum[u],Num[u]);j++)
			for (int k=0;k<=min(j,key);k++)
				G[j-k]+=F[u][j]/C[Num[u]][key]*C[j][k]*C[Num[u]-j][key-k];
		for (int j=0;j<=max(INum[u],Num[u]);j++) F[u][j]=G[j];

		Num[u]-=key;Num[v]+=key;
		Ans+=F[u][0];Ans+=F[v][0];

		printf("%.11LF\n",Ans);
	}

	return 0;
}


#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
using namespace std;

#define ll long long
#define ld double
#define mem(Arr,x) memset(Arr,x,sizeof(Arr))

const int maxN=101000;
const int maxM=110;
const int inf=2147483647;

int n,m;
int Num[maxN];
ld F[maxN][maxM],G[maxM];
ld C[maxN][10];

ld GetC(int n,int m);

int main(){
	C[0][0]=1;
	for (int i=1;i<maxN;i++){
		C[i][0]=1;
		for (int j=1;j<=min(i,9);j++)
			C[i][j]=C[i-1][j]+C[i-1][j-1];
	}

	scanf("%d",&n);
	for (int i=1;i<=n;i++) scanf("%d",&Num[i]),F[i][Num[i]]=1;
	ld Ans=0;
	for (int i=1;i<=n;i++) Ans+=F[i][0];
	int Q;scanf("%d",&Q);
	while (Q--){
		int u,v,key;scanf("%d%d%d",&u,&v,&key);
		Ans-=F[u][0];//Ans-=F[v][0];
		for (int j=0;j<=Num[u];j++){
			G[j]=0;ld nf=F[u][j];
			for (int k=0;k<=min(j,key);k++)
				G[j-k]+=nf/C[Num[u]][key]*C[j][k]*C[Num[u]-j][key-k];
		}
		for (int j=0;j<=Num[u];j++) F[u][j]=G[j];

		Num[u]-=key;Num[v]+=key;
		Ans+=F[u][0];//Ans+=F[v][0];

		printf("%.11lf\n",Ans);
	}

	return 0;
}

/*
1
5
20
1 1 1
1 1 1
1 1 1
1 1 1
1 1 1
1 1 1
1 1 1
1 1 1
1 1 1
1 1 1
1 1 1
1 1 1
1 1 1
1 1 1
1 1 1
1 1 1
1 1 1
1 1 1
1 1 1
1 1 1
//*/


#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
using namespace std;

#define ll long long
#define ld long double
#define mem(Arr,x) memset(Arr,x,sizeof(Arr))

const int maxN=101000;
const int maxM=110;
const int inf=2147483647;

int n,m;
int Num[maxN];
ld F[maxN][maxM],G[maxM];
ld C[maxN][10];

ld GetC(int n,int m);

int main(){
	C[0][0]=1;
	for (int i=1;i<maxN;i++){
		C[i][0]=1;
		for (int j=1;j<=min(i,9);j++)
			C[i][j]=C[i-1][j]+C[i-1][j-1];
	}

	scanf("%d",&n);
	for (int i=1;i<=n;i++) scanf("%d",&Num[i]),F[i][Num[i]]=1;
	ld Ans=0;
	for (int i=1;i<=n;i++) Ans+=F[i][0];
	int Q;scanf("%d",&Q);
	while (Q--){
		int u,v,key;scanf("%d%d%d",&u,&v,&key);
		Ans-=F[u][0];//Ans-=F[v][0];
		mem(G,0);
		for (int j=0;j<=Num[u];j++)
			for (int k=0;k<=min(j,key);k++)
				G[j-k]+=F[u][j]/C[Num[u]][key]*C[j][k]*C[Num[u]-j][key-k];
		for (int j=0;j<=Num[u];j++) F[u][j]=G[j];

		Num[u]-=key;Num[v]+=key;
		Ans+=F[u][0];//Ans+=F[v][0];

		printf("%.11LF\n",Ans);
	}

	return 0;
}

/*
1
5
20
1 1 1
1 1 1
1 1 1
1 1 1
1 1 1
1 1 1
1 1 1
1 1 1
1 1 1
1 1 1
1 1 1
1 1 1
1 1 1
1 1 1
1 1 1
1 1 1
1 1 1
1 1 1
1 1 1
1 1 1
//*/


#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <string.h>
#include <fstream>

using namespace std;

#define LL long long
#define N 200100
#define M 200100
#define MP make_pair
#define Pi acos(-1.0)
//#pragma comment(linker,"/STACK:1024000000,1024000000")
#define ls (rt << 1)
#define rs (ls | 1)
#define md ((ll+rr)/2)
#define lson ls,ll,md
#define rson rs,md+1,rr
#define mod 1234567891
#define inf 0x3f3f3f3f
#define sqr(x) ((x)*(x))
#define eps 1e-6
#define uLL unsigned long long
LL powmod(LL a,LL b,LL p) {LL res=1;a%=p;for(;b;b>>=1){if(b&1)res=res*a%p;a=a*a%p;}return res;}
#define F(x) ((x)/3+((x)%3 == 1 ? 0 : tb))
#define G(x) ((x)<tb ? (x)*3+1 : ((x) - tb)*3+2)
#define lowbit(x) ((x)&(-x))
#define fi first
#define se second
#define pii pair<int,int>
#define pb push_back
#define sf(n) scanf("%d", &n)

template<typename T> T gcd(T x,T y){
    while(y){
        T t = x % y;
        x = y;
        y = t;
    }
    return x;
}
template<typename T> T lsM(T x,T y) {
    return  x / gcd(x, y) * y;
}

template<typename T> inline bool chkmin(T &a, const T &b) { return a > b ? a = b, 1 : 0; }
template<typename T> inline bool chkmax(T &a, const T &b) { return a < b ? a = b, 1 : 0; }

int n, a[N];
int c[N];
long double p[N][120];

long double C(int a, int b) {
    long double ret = 1;
    for(int i = 1; i <= b; ++i)
        ret *= (a - i + 1.0) / i;
    return ret;
}

long double f(int a, int b, int c, int d) {
    if(a - b < c - d) return 0;
    if(a < b) return 0;
    return C(b, d) * C(a - b, c - d) / C(a, c);
}

int main(){
    int n;
    scanf("%d",&n);
    long double ans = 0;
    for(int i = 1; i <= n; i++){
        scanf("%d",&a[i]);
        if(a[i] == 0) ans += 1;
        c[i] = a[i];
        p[i][a[i]] = 1;
    }

    int q;
    scanf("%d",&q);
    while(q--){
        int u, v, k;
        scanf("%d%d%d",&u,&v,&k);
        ans -= p[u][0];
        for(int i = 0; i <= a[u]; i++){
            p[u][i] *= f(c[u], i, k, 0);
            for(int j = 1; i + j <= a[u] && j <= k; j++){
                p[u][i] += p[u][i+j] * f(c[u], i + j, k, j);
            }
        }

        ans += p[u][0];
        c[u] -= k, c[v] += k;
        printf("%.21lf\n",(double)ans);
    }
    return 0;
}


#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <string.h>
#include <fstream>

using namespace std;

#define LL long long
#define N 100100
#define M 200100
#define MP make_pair
#define Pi acos(-1.0)
//#pragma comment(linker,"/STACK:1024000000,1024000000")
#define ls (rt << 1)
#define rs (ls | 1)
#define md ((ll+rr)/2)
#define lson ls,ll,md
#define rson rs,md+1,rr
#define mod 1234567891
#define inf 0x3f3f3f3f
#define sqr(x) ((x)*(x))
#define eps 1e-6
#define uLL unsigned long long
LL powmod(LL a,LL b,LL p) {LL res=1;a%=p;for(;b;b>>=1){if(b&1)res=res*a%p;a=a*a%p;}return res;}
#define F(x) ((x)/3+((x)%3 == 1 ? 0 : tb))
#define G(x) ((x)<tb ? (x)*3+1 : ((x) - tb)*3+2)
#define lowbit(x) ((x)&(-x))
#define fi first
#define se second
#define pii pair<int,int>
#define pb push_back
#define sf(n) scanf("%d", &n)

template<typename T> T gcd(T x,T y){
    while(y){
        T t = x % y;
        x = y;
        y = t;
    }
    return x;
}
template<typename T> T lsM(T x,T y) {
    return  x / gcd(x, y) * y;
}

template<typename T> inline bool chkmin(T &a, const T &b) { return a > b ? a = b, 1 : 0; }
template<typename T> inline bool chkmax(T &a, const T &b) { return a < b ? a = b, 1 : 0; }

int n, a[N];
int c[N];
long double p[N][120];

long double C(int a, int b) {
    long double ret = 1;
    for(int i = 1; i <= b; ++i)
        ret *= (a - i + 1.0) / i;
    return ret;
}

long double f(int a, int b, int c, int d) {
    if(a - b < c - d) return 0;
    if(a < b) return 0;
    return C(b, d) * C(a - b, c - d) / C(a, c);
}

int main(){
    int n;
    scanf("%d",&n);
    long double ans = 0;
    for(int i = 1; i <= n; i++){
        scanf("%d",&a[i]);
        if(a[i] == 0) ans += 1;
        c[i] = a[i];
        p[i][a[i]] = 1;
    }

    int q;
    scanf("%d",&q);
    while(q--){
        int u, v, k;
        scanf("%d%d%d",&u,&v,&k);
        ans -= p[u][0];
        for(int i = 0; i <= a[u]; i++){
            p[u][i] *= f(c[u], i, k, 0);
            for(int j = 1; i + j <= a[u] && j <= k; j++){
                p[u][i] += p[u][i+j] * f(c[u], i + j, k, j);
            }
        }

        ans += p[u][0];
        c[u] -= k, c[v] += k;
        printf("%.21lf\n",(double)ans);
    }
    return 0;
}


#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#define fo(i,a,b) for(int i=a;i<=b;i++)
#define fd(i,a,b) for(int i=a;i>=b;i--)
#define maxn 100005
#define maxa 105
#define ld long double
#define db double
#define mem(a,b) memset(a,b,sizeof(a))
#define mcp(a,b) memcpy(a,b,sizeof(a))
using namespace std;

ld f[maxn][maxa];

ld g[maxa];

int n,q;

int siz[maxn],a[maxn];

db ans;

ld c[maxa],c1[maxa];

ld C(int x,int y){
	ld ret=1;
	fo(i,1,y) ret=ret*(x-i+1)/i;
	return ret;
}

void change(int x,int totsiz,int now){
	mem(g,0);
	ld tot=C(totsiz,now);
	fo(clr,0,min(a[x],siz[x])) {
		c[0]=1;
		fo(i,1,clr) c[i]=c[i-1]*(clr-i+1)/i;
		c1[0]=1;
		fo(i,1,min(now,totsiz-clr)) c1[i]=c1[i-1]*(totsiz-clr-i+1)/i;
		fo(i,0,min(clr,now)) {
			if (now-i>totsiz-clr) continue;
			g[clr-i]+=f[x][clr]*c[i]*c1[now-i]/tot;
		}
	}
	mcp(f[x],g);
}

int main(){
	scanf("%d",&n);
	fo(i,1,n) {
		scanf("%d",&a[i]);
		siz[i]=a[i];
		f[i][a[i]]=1;
		if (a[i]==0) ans++;
	}
	scanf("%d",&q);
	while (q--) {
		int x,y,num;
		scanf("%d%d%d",&x,&y,&num);
		ans-=f[x][0];
		change(x,siz[x],num);
		ans+=f[x][0];
		siz[x]-=num;
		siz[y]+=num;
		printf("%.12lf\n",ans);
	}
	return 0;
}


#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#define fo(i,a,b) for(int i=a;i<=b;i++)
#define fd(i,a,b) for(int i=a;i>=b;i--)
#define maxn 100005
#define maxa 105
#define db double
#define ld long double
#define mem(a,b) memset(a,b,sizeof(a))
#define mcp(a,b) memcpy(a,b,sizeof(a))
#define min(a,b) (((a) < (b)) ? a : b)
using namespace std;

ld f[maxn][maxa];

ld g[maxa];

int n,q;

int siz[maxn],a[maxn];

db ans;

ld c[maxa],c1[maxa];

ld C(int x,int y){
	ld ret=1;
	fo(i,1,y) ret=ret*(x-i+1)/i;
	return ret;
}

void change(int x,int totsiz,int now){
	mem(g,0);
	ld tot=C(totsiz,now);
	fo(clr,0,min(a[x],siz[x])) {
		if (f[x][clr]<1e-12) continue;
		c[0]=1;
		fo(i,1,clr) c[i]=c[i-1]*(clr-i+1)/i;
		c1[0]=1;
		fo(i,1,min(now,totsiz-clr)) c1[i]=c1[i-1]*(totsiz-clr-i+1)/i;
		fo(i,0,min(clr,now)) {
			if (now-i>totsiz-clr) continue;
			g[clr-i]+=f[x][clr]*c[i]*c1[now-i]/tot;
		}
	}
	mcp(f[x],g);
}

int main(){
	scanf("%d",&n);
	fo(i,1,n) {
		scanf("%d",&a[i]);
		siz[i]=a[i];
		f[i][a[i]]=1;
		if (a[i]==0) ans++;
	}
	scanf("%d",&q);
	while (q--) {
		int x,y,num;
		scanf("%d%d%d",&x,&y,&num);
		ans-=f[x][0];
		change(x,siz[x],num);
		ans+=f[x][0];
		siz[x]-=num;
		siz[y]+=num;
		printf("%.12lf\n",ans);
	}
	return 0;
}


#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#define fo(i,a,b) for(int i=a;i<=b;i++)
#define fd(i,a,b) for(int i=a;i>=b;i--)
#define maxn 100005
#define maxa 105
#define db double
#define mem(a,b) memset(a,b,sizeof(a))
#define mcp(a,b) memcpy(a,b,sizeof(a))
#define min(a,b) (((a) < (b)) ? a : b)
using namespace std;

db f[maxn][maxa];

db g[maxa];

int n,q;

int siz[maxn],a[maxn];

db ans;

db c[maxa],c1[maxa];

db C(int x,int y){
	db ret=1;
	fo(i,1,y) ret=ret*(x-i+1)/i;
	return ret;
}

void change(int x,int totsiz,int now){
	mem(g,0);
	db tot=C(totsiz,now);
	fo(clr,0,min(a[x],siz[x])) {
		if (f[x][clr]<1e-15) continue;
		c[0]=1;
		fo(i,1,clr) c[i]=c[i-1]*(clr-i+1)/i;
		c1[0]=1;
		fo(i,1,min(now,totsiz-clr)) c1[i]=c1[i-1]*(totsiz-clr-i+1)/i;
		fo(i,0,min(clr,now)) {
			if (now-i>totsiz-clr) continue;
			g[clr-i]+=f[x][clr]*c[i]*c1[now-i]/tot;
		}
	}
	mcp(f[x],g);
}

int main(){
	scanf("%d",&n);
	fo(i,1,n) {
		scanf("%d",&a[i]);
		siz[i]=a[i];
		f[i][a[i]]=1;
		if (a[i]==0) ans++;
	}
	scanf("%d",&q);
	while (q--) {
		int x,y,num;
		scanf("%d%d%d",&x,&y,&num);
		ans-=f[x][0];
		change(x,siz[x],num);
		ans+=f[x][0];
		siz[x]-=num;
		siz[y]+=num;
		printf("%.12lf\n",ans);
	}
	return 0;
}


#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#define fo(i,a,b) for(int i=a;i<=b;i++)
#define fd(i,a,b) for(int i=a;i>=b;i--)
#define maxn 100005
#define maxa 105
#define ld long double
#define db double
#define mem(a,b) memset(a,b,sizeof(a))
#define mcp(a,b) memcpy(a,b,sizeof(a))
using namespace std;

ld f[maxn][maxa];

ld g[maxa];

int n,q;

int siz[maxn],a[maxn];

db ans;

ld c[maxa],c1[maxa];

ld C(int x,int y){
	ld ret=1;
	fo(i,1,y) ret=ret*(x-i+1)/i;
	return ret;
}

void change(int x,int totsiz,int now){
	fo(i,0,100) g[i]=0;
	ld tot=C(totsiz,now);
	fo(clr,0,min(a[x],siz[x])) {
		c[0]=1;
		fo(i,1,clr) c[i]=c[i-1]*(clr-i+1)/i;
		c1[0]=1;
		fo(i,1,min(now,totsiz-clr)) c1[i]=c1[i-1]*(totsiz-clr-i+1)/i;
		fo(i,0,min(clr,now)) {
			if (now-i>totsiz-clr) continue;
			g[clr-i]+=f[x][clr]*c[i]*c1[now-i]/tot;
		}
	}
	fo(i,0,100) f[x][i]=g[i];
}

int main(){
	scanf("%d",&n);
	fo(i,1,n) {
		scanf("%d",&a[i]);
		siz[i]=a[i];
		f[i][a[i]]=1;
		if (a[i]==0) ans++;
	}
	scanf("%d",&q);
	while (q--) {
		int x,y,num;
		scanf("%d%d%d",&x,&y,&num);
		ans-=f[x][0];
		change(x,siz[x],num);
		ans+=f[x][0];
		siz[x]-=num;
		siz[y]+=num;
		printf("%.12lf\n",ans);
	}
	return 0;
}


#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#define fo(i,a,b) for(int i=a;i<=b;i++)
#define fd(i,a,b) for(int i=a;i>=b;i--)
#define maxn 100005
#define maxa 105
#define db double
#define mem(a,b) memset(a,b,sizeof(a))
#define mcp(a,b) memcpy(a,b,sizeof(a))
using namespace std;

db f[maxn][maxa];

db g[maxa];

int n,q;

int siz[maxn],a[maxn];

db ans;

db c[maxa],c1[maxa];

db C(int x,int y){
	db ret=1;
	fo(i,1,y) ret=ret*(x-i+1)/i;
	return ret;
}

void change(int x,int totsiz,int now){
	mem(g,0);
	db tot=C(totsiz,now);
	fo(clr,0,min(a[x],siz[x])) {
		c[0]=1;
		fo(i,1,clr) c[i]=c[i-1]*(clr-i+1)/i;
		c1[0]=1;
		fo(i,1,min(now,totsiz-clr)) c1[i]=c1[i-1]*(totsiz-clr-i+1)/i;
		fo(i,0,min(clr,now)) {
			if (now-i>totsiz-clr) continue;
			g[clr-i]+=f[x][clr]*c[i]*c1[now-i]/tot;
		}
	}
	mcp(f[x],g);
}

int main(){
	scanf("%d",&n);
	fo(i,1,n) {
		scanf("%d",&a[i]);
		siz[i]=a[i];
		f[i][a[i]]=1;
		if (a[i]==0) ans++;
	}
	scanf("%d",&q);
	while (q--) {
		int x,y,num;
		scanf("%d%d%d",&x,&y,&num);
		ans-=f[x][0];
		change(x,siz[x],num);
		ans+=f[x][0];
		siz[x]-=num;
		siz[y]+=num;
		printf("%.12lf\n",ans);
	}
	return 0;
}


#include<bits/stdc++.h>
#define LL long long
#define LD long double
#define ull unsigned long long
#define fi first
#define se second
#define mk make_pair
#define PLL pair<LL, LL>
#define PLI pair<LL, int>
#define PII pair<int, int>
#define SZ(x) ((int)x.size())
#define ALL(x) (x).begin(), (x).end()
#define fio ios::sync_with_stdio(false); cin.tie(0);

using namespace std;

const int N = 1e5 + 7;
const int inf = 0x3f3f3f3f;
const LL INF = 0x3f3f3f3f3f3f3f3f;
const int mod = 998244353;
const double eps = 1e-10;
const double PI = acos(-1);

template<class T, class S> inline void add(T &a, S b) {a += b; if(a >= mod) a -= mod;}
template<class T, class S> inline void sub(T &a, S b) {a -= b; if(a < 0) a += mod;}
template<class T, class S> inline bool chkmax(T &a, S b) {return a < b ? a = b, true : false;}
template<class T, class S> inline bool chkmin(T &a, S b) {return a > b ? a = b, true : false;}

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int n, q, a[N], sum[N];
double ans, C[N][107];

double dp[N][107], f[107];

void addPot(int id, int k) {
    sum[id] += k;
}

void subPot(int id, int k) {
    double tmp = dp[id][0];
    memset(f, 0, sizeof(f));
    for(int i = 0; i <= 100; i++) {
        for(int j = 0; j <= k; j++) {
            f[i] += dp[id][i + j] * C[i + j][j] * C[sum[id] - i - j][k - j] / C[sum[id]][k];
        }
    }
    for(int i = 0; i <= 100; i++) {
        dp[id][i] = f[i];
    }
    ans += dp[id][0] - tmp;
    sum[id] -= k;
}

int main() {

    for(int i = 0; i < N; i++) {
        for(int j = C[i][0] = 1; j <= min(100, i); j++) {
            C[i][j] = C[i - 1][j - 1] + C[i - 1][j];
        }
    }

    scanf("%d", &n);

    for(int i = 1; i <= n; i++) {
        scanf("%d", &a[i]);
        sum[i] = a[i];
        dp[i][a[i]] = 1;
    }

    scanf("%d", &q);

    while(q--) {

        int u, v, k;
        scanf("%d%d%d", &u, &v, &k);

        subPot(u, k);
        addPot(v, k);

        printf("%.12f\n", ans);
    }
    return 0;
}

/*
*/


#include<bits/stdc++.h>
#define LL long long
#define LD long double
#define ull unsigned long long
#define fi first
#define se second
#define mk make_pair
#define PLL pair<LL, LL>
#define PLI pair<LL, int>
#define PII pair<int, int>
#define SZ(x) ((int)x.size())
#define ALL(x) (x).begin(), (x).end()
#define fio ios::sync_with_stdio(false); cin.tie(0);

using namespace std;

const int N = 1e5 + 7;
const int inf = 0x3f3f3f3f;
const LL INF = 0x3f3f3f3f3f3f3f3f;
const int mod = 998244353;
const double eps = 1e-10;
const double PI = acos(-1);

template<class T, class S> inline void add(T &a, S b) {a += b; if(a >= mod) a -= mod;}
template<class T, class S> inline void sub(T &a, S b) {a -= b; if(a < 0) a += mod;}
template<class T, class S> inline bool chkmax(T &a, S b) {return a < b ? a = b, true : false;}
template<class T, class S> inline bool chkmin(T &a, S b) {return a > b ? a = b, true : false;}

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int n, q, a[N], sum[N];
double ans, C[N][107];

double dp[N][107], f[107];

void addPot(int id, int k) {
    sum[id] += k;
}

void subPot(int id, int k) {
    double tmp = dp[id][0];
    memset(f, 0, sizeof(f));
    for(int i = 0; i <= 100; i++) {
        for(int j = 0; j <= k; j++) {
            f[i] += dp[id][i + j] * C[i + j][j] * C[sum[id] - i - j][k - j] / C[sum[id]][k];
        }
    }
    for(int i = 0; i <= 100; i++) {
        dp[id][i] = f[i];
    }
    ans += dp[id][0] - tmp;
    sum[id] -= k;
}

int main() {

    for(int i = 0; i < N; i++) {
        for(int j = C[i][0] = 1; j <= min(100, i); j++) {
            C[i][j] = C[i - 1][j - 1] + C[i - 1][j];
        }
    }

    scanf("%d", &n);

    for(int i = 1; i <= n; i++) {
        scanf("%d", &a[i]);
        sum[i] = a[i];
        dp[i][a[i]] = 1;
        ans += dp[i][0];
    }

    scanf("%d", &q);

    while(q--) {

        int u, v, k;
        scanf("%d%d%d", &u, &v, &k);

        subPot(u, k);
        addPot(v, k);

        printf("%.12f\n", ans);
    }
    return 0;
}

/*
*/


#include<bits/stdc++.h>
#define LL long long
#define LD long double
#define ull unsigned long long
#define fi first
#define se second
#define mk make_pair
#define PLL pair<LL, LL>
#define PLI pair<LL, int>
#define PII pair<int, int>
#define SZ(x) ((int)x.size())
#define ALL(x) (x).begin(), (x).end()
#define fio ios::sync_with_stdio(false); cin.tie(0);

using namespace std;

const int N = 1e5 + 7;
const int inf = 0x3f3f3f3f;
const LL INF = 0x3f3f3f3f3f3f3f3f;
const int mod = 998244353;
const double eps = 1e-10;
const double PI = acos(-1);

template<class T, class S> inline void add(T &a, S b) {a += b; if(a >= mod) a -= mod;}
template<class T, class S> inline void sub(T &a, S b) {a -= b; if(a < 0) a += mod;}
template<class T, class S> inline bool chkmax(T &a, S b) {return a < b ? a = b, true : false;}
template<class T, class S> inline bool chkmin(T &a, S b) {return a > b ? a = b, true : false;}

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int n, q, a[N], sum[N];
double ans, C[N][107];

double dp[N][107], f[107];

void addPot(int id, int k) {
    sum[id] += k;
}

void subPot(int id, int k) {
    double tmp = dp[id][0];
    memset(f, 0, sizeof(f));
    for(int i = 0; i <= 100; i++) {
        for(int j = 0; j <= k; j++) {
            f[i] += dp[id][i + j] * C[i + j][j] * C[sum[id] - i - j][k - j] / C[sum[id]][k];
        }
    }
    for(int i = 0; i <= 100; i++) {
        dp[id][i] = f[i];
    }
    ans += dp[id][0] - tmp;
    sum[id] -= k;
}

int main() {

    for(int i = 0; i < N; i++) {
        for(int j = C[i][0] = 1; j <= min(100, i); j++) {
            C[i][j] = C[i - 1][j - 1] + C[i - 1][j];
        }
    }

    scanf("%d", &n);

    for(int i = 1; i <= n; i++) {
        scanf("%d", &a[i]);
        sum[i] = a[i];
        dp[i][a[i]] = 1;
    }

    scanf("%d", &q);

    while(q--) {

        int u, v, k;
        scanf("%d%d%d", &u, &v, &k);

        addPot(v, k);
        subPot(u, k);

        printf("%.12f\n", ans);
    }
    return 0;
}

/*
*/


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

typedef double r32;
typedef unsigned u32;

inline int getint()
{
	static char c;
	while ((c = getchar()) < '0' || c > '9');

	int res = c - '0';
	while ((c = getchar()) >= '0' && c <= '9')
		res = res * 10 + c - '0';
	return res;
}

const int MaxN = 100005;
const int MaxM = 100005;
const int MaxP = 101;
const int MaxK = 5;

int n, m;
int pot[MaxN], cur[MaxN];
r32 pro[MaxN][MaxP + 1];
r32 outcome = 0.0;

inline void remove(int fr, int to)
{
	for (int i = 0; i <= pot[fr]; ++i)
	{
		r32 l = pro[fr][i] * (cur[fr] - i);
		r32 r = pro[fr][i + 1] * (i + 1);
		pro[fr][i] = (l + r) / cur[fr];
	}
	--cur[fr], ++cur[to];
}

int main()
{
	n = getint();
	for (int i = 1; i <= n; ++i)
	{
		pot[i] = cur[i] = getint();
		pro[i][pot[i]] = 1.0;
		outcome += pot[i] == 0;
	}

	m = getint();
	while (m--)
	{
		int u = getint(), v = getint();
		int k = getint();

		outcome -= pro[u][0];
		for (int i = 0; i < k; ++i)
			remove(u, v);
		outcome += pro[u][0];

		printf("%.16f\n", outcome);
	}

	return 0;
}


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

typedef double r32;
typedef unsigned u32;

inline int getint()
{
	static char c;
	while ((c = getchar()) < '0' || c > '9');

	int res = c - '0';
	while ((c = getchar()) >= '0' && c <= '9')
		res = res * 10 + c - '0';
	return res;
}

const int MaxN = 100005;
const int MaxM = 100005;
const int MaxP = 105;
const int MaxK = 5;

int n, m;
int pot[MaxN], cur[MaxN];
r32 pro[MaxN][MaxP];
r32 outcome = 0.0;

inline void remove(int fr, int to)
{
	for (int i = 0; i <= pot[fr]; ++i)
	{
		r32 l = pro[fr][i] * (cur[fr] - i) / cur[fr];
		r32 r = pro[fr][i + 1] * (i + 1) / cur[fr];
		pro[fr][i] = l + r;
	}
	--cur[fr], ++cur[to];
}

int main()
{
	n = getint();
	for (int i = 1; i <= n; ++i)
	{
		pot[i] = cur[i] = getint();
		pro[i][pot[i]] = 1.0;
		outcome += pot[i] == 0;
	}

	m = getint();
	while (m--)
	{
		int u = getint(), v = getint();
		int k = getint();

		outcome -= pro[u][0];
		for (int i = 0; i < k; ++i)
			remove(u, v);
		outcome += pro[u][0];

		printf("%.16f\n", outcome);
	}

	return 0;
}


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

typedef double r32;
typedef unsigned u32;

inline int getint()
{
	static char c;
	while ((c = getchar()) < '0' || c > '9');

	int res = c - '0';
	while ((c = getchar()) >= '0' && c <= '9')
		res = res * 10 + c - '0';
	return res;
}

const int MaxN = 100005;
const int MaxM = 100005;
const int MaxP = 105;
const int MaxK = 5;

int n, m;
int pot[MaxN], cur[MaxN];
r32 pro[MaxN][MaxP];
r32 outcome = 0.0;

inline void remove(int fr, int to)
{
	int k = cur[fr];
	for (int i = 0; i <= pot[fr]; ++i)
		pro[fr][i] = pro[fr][i] * (k - i) / k + pro[fr][i + 1] * (i + 1) / k;
	--cur[fr];
}

int main()
{
	n = getint();
	for (int i = 1; i <= n; ++i)
	{
		pot[i] = cur[i] = getint();
		pro[i][pot[i]] = 1.0;
		outcome += pot[i] == 0;
	}

	m = getint();
	while (m--)
	{
		int u = getint(), v = getint();
		int k = getint();

		outcome -= pro[u][0];
		for (int i = 0; i < k; ++i)
			remove(u, v);
		outcome += pro[u][0];
		cur[v] += k;

		printf("%.16f\n", outcome);
	}

	return 0;
}


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

typedef double r32;
typedef unsigned u32;

inline int getint()
{
	static char c;
	while ((c = getchar()) < '0' || c > '9');

	int res = c - '0';
	while ((c = getchar()) >= '0' && c <= '9')
		res = res * 10 + c - '0';
	return res;
}

const int MaxN = 100005;
const int MaxM = 100005;
const int MaxP = 101;
const int MaxK = 7;

int n, m;
int pot[MaxN], cur[MaxN];
r32 pro[MaxN][MaxP];
r32 outcome = 0.0;

u32 binom[MaxP][MaxK];

inline void init_binom(int n)
{
	for (int i = 0; i <= n; ++i)
	{
		binom[i][0] = 1;
		for (int j = 1; j <= min(i, 5); ++j)
			binom[i][j] = binom[i - 1][j] + binom[i - 1][j - 1];
	}
}

int main()
{
	n = getint();
	for (int i = 1; i <= n; ++i)
	{
		pot[i] = cur[i] = getint();
		pro[i][pot[i]] = 1.0;
		outcome += pot[i] == 0;
	}

	init_binom(*max_element(pot + 1, pot + n + 1));

	m = getint();
	while (m--)
	{
		int u = getint(), v = getint(), k = getint();
		int t = cur[u], s = binom[t][k];
		outcome -= pro[u][0];

		int up = min(pot[u], cur[u]);
		for (int i = 0; i <= up; ++i)
		{
			r32 res = 0.0;
			for (int j = 0; i + j <= t && j <= k; ++j)
			{
				r32 p = (r32)binom[i + j][j] / (r32)s * (r32)binom[t - i - j][k - j];
				res += pro[u][i + j] * p;
			}
			pro[u][i] = res;
		}

		printf("%.16f\n", outcome += pro[u][0]);

		cur[u] -= k;
		cur[v] += k;
	}

	return 0;
}


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

typedef double r32;
typedef unsigned u32;

inline int getint()
{
	static char c;
	while ((c = getchar()) < '0' || c > '9');

	int res = c - '0';
	while ((c = getchar()) >= '0' && c <= '9')
		res = res * 10 + c - '0';
	return res;
}

const int MaxN = 100005;
const int MaxM = 100005;
const int MaxP = 101;
const int MaxK = 5;

int n, m;
int pot[MaxN], cur[MaxN];
r32 pro[MaxN][MaxP + 1];
r32 outcome = 0.0;

r32 binom[MaxM * MaxK][MaxK + 1];

inline void init_binom(int n)
{
	for (int i = 0; i <= n; ++i)
	{
		binom[i][0] = 1.0;
		for (int j = 1; j <= min(i, 5); ++j)
			binom[i][j] = binom[i - 1][j] + binom[i - 1][j - 1];
	}
}

int main()
{
	n = getint();
	for (int i = 1; i <= n; ++i)
	{
		pot[i] = cur[i] = getint();
		pro[i][pot[i]] = 1.0;
		outcome += pot[i] == 0;
	}

	init_binom((m = getint()) * 5);

	while (m--)
	{
		int u = getint(), v = getint(), k = getint();
		int t = cur[u];
		r32 s = binom[t][k];
		outcome -= pro[u][0];

		int up = min(pot[u], cur[u]);
		for (int i = 0; i <= up; ++i)
		{
			r32 res = 0.0;
			for (int j = 0; i + j <= t && j <= k; ++j)
			{
				r32 p = binom[i + j][j] / s * binom[t - i - j][k - j];
				res += pro[u][i + j] * p;
			}
			pro[u][i] = res;
		}

		printf("%.16f\n", outcome += pro[u][0]);

		cur[u] -= k;
		cur[v] += k;
	}

	return 0;
}


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

typedef double r32;
typedef unsigned u32;

inline int getint()
{
	static char c;
	while ((c = getchar()) < '0' || c > '9');

	int res = c - '0';
	while ((c = getchar()) >= '0' && c <= '9')
		res = res * 10 + c - '0';
	return res;
}

const int MaxN = 100005;
const int MaxM = 100005;
const int MaxP = 105;
const int MaxK = 5;

int n, m;
int pot[MaxN], cur[MaxN];
r32 pro[MaxN][MaxP];
r32 outcome = 0.0;

inline void remove(int fr, int to)
{
	int k = cur[fr];
	for (int i = 0; i <= pot[fr]; ++i)
		pro[fr][i] = pro[fr][i] * (k - i) / k + pro[fr][i + 1] * (i + 1) / k;
	--cur[fr], ++cur[to];
}

int main()
{
	n = getint();
	for (int i = 1; i <= n; ++i)
	{
		pot[i] = cur[i] = getint();
		pro[i][pot[i]] = 1.0;
		outcome += pot[i] == 0;
	}

	m = getint();
	while (m--)
	{
		int u = getint(), v = getint();
		int k = getint();

		outcome -= pro[u][0];
		for (int i = 0; i < k; ++i)
			remove(u, v);
		outcome += pro[u][0];

		printf("%.16lf\n", outcome);
	}

	return 0;
}


#include<cstdio>
#define Int register int
const int MAXN = 100005;
int n, q, A[MAXN], B[MAXN];
double ans, f[MAXN][105];

int main() {
	scanf("%d", &n);
	for(Int i = 1; i <= n; ++i) scanf("%d", A+i), f[i][B[i] = A[i]] = 1, ans += f[i][0];
	scanf("%d", &q);
	Int u, v, k;
	while(q--) {
		scanf("%d%d%d", &u, &v, &k);
		ans -= f[u][0];

		for(Int i = 1; i <= k; ++i)
			for(Int j = 0; j <= A[u]; ++j)
				f[u][j] = f[u][j] * (B[u] - i + 1 - j) / (B[u] - i + 1) + f[u][j + 1] * (j + 1) / (B[u] - i + 1);

		ans += f[u][0]+1;
		B[u] -= k; B[v] += k;
		printf("%.12lf\n", ans);
	}
	return 0;
}


#include<cstdio>
#define Int register int
const int MAXN = 100005;
int n, q, A[MAXN], B[MAXN];
double ans, f[MAXN][105];

int main() {
	scanf("%d", &n);
	for(Int i = 1; i <= n; ++i) scanf("%d", A+i), f[i][B[i] = A[i]] = 1, ans += f[i][0];
	scanf("%d", &q);
	Int u, v, k;
	while(q--) {
		scanf("%d%d%d", &u, &v, &k);
		ans -= f[u][0];

		for(Int i = 1; i <= k; ++i)
			for(Int j = 0; j <= A[u]; ++j)
				f[u][j] = f[u][j] * (B[u] - i + 1 - j) / (B[u] - i + 1) + f[u][j + 1] * (j + 1) / (B[u] - i + 1);

		ans += f[u][0]+8;
		B[u] -= k; B[v] += k;
		printf("%.12lf\n", ans);
	}
	return 0;
}


#include<cstdio>
#define Int register int
const int MAXN = 100005;
int n, q, A[MAXN], B[MAXN];
double ans, f[MAXN][105];

int main() {
	scanf("%d", &n);
	for(Int i = 1; i <= n; ++i) scanf("%d", A+i), f[i][B[i] = A[i]] = 1, ans += f[i][0];
	scanf("%d", &q);
	Int u, v, k;
	while(q--) {
		scanf("%d%d%d", &u, &v, &k);
		ans -= f[u][0];

		for(Int i = 1; i <= k; ++i)
			for(Int j = 0; j <= A[u]; ++j)
				f[u][j] = f[u][j] * (B[u] - i + 1 - j) / (B[u] - i + 1) + f[u][j + 1] * (j + 1) / (B[u] - i + 1);

		ans += f[u][0];
		B[u] -= k; B[v] += k;
		printf("%.12lf\n", ans);
	}
	return 0;
}


#include<cstdio>
#define Int register int
const int MAXN = 100005;
int n, q, A[MAXN], B[MAXN];
double ans, f[MAXN][105];

int main() {
	scanf("%d", &n);
	for(Int i = 1; i <= n; ++i) scanf("%d", A+i), f[i][B[i] = A[i]] = 1, ans += f[i][0];
	scanf("%d", &q);
	Int u, v, k;
	while(q--) {
		scanf("%d%d%d", &u, &v, &k);
		ans -= f[u][0];

		for(Int i = 1; i <= k; ++i)
			for(Int j = 0; j <= A[u]; ++j)
				f[u][j] = f[u][j] * (B[u] - i + 1 - j) / (B[u] - i + 1) + f[u][j + 1] * (j + 1) / (B[u] - i + 1);

		ans += f[u][0]+9;
		B[u] -= k; B[v] += k;
		printf("%.12lf\n", ans);
	}
	return 0;
}


#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<cmath>
#include<queue>
#include<stack>
#include<set>
#include<map>
using namespace std;
#define ll long long
#define REP(i,a,b) for(int i=(a),_end_=(b);i<=_end_;i++)
#define DREP(i,a,b) for(int i=(a),_end_=(b);i>=_end_;i--)
#define EREP(i,a) for(int i=start[(a)];i;i=e[i].next)
inline int read()
{
	int sum=0,p=1;char ch=getchar();
	while(!(('0'<=ch && ch<='9') || ch=='-'))ch=getchar();
	if(ch=='-')p=-1,ch=getchar();
	while('0'<=ch && ch<='9')sum=sum*10+ch-48,ch=getchar();
	return sum*p;
}

const int maxn=1e5+20;

int n;
double f[maxn][120];
int a[maxn],b[maxn];

inline void init()
{
	n=read();
	REP(i,1,n)b[i]=a[i]=read(),f[i][a[i]]=1;
}

inline double C(int n,int m){ if(n<m || m<0)return 0;double res=1;REP(i,1,m)res*=(double)(n-i+1)/i;return res;}

inline void doing()
{
	int q=read();
	double res=0;
	REP(i,1,n)res+=f[i][0];
	while(q--)
	{
		int u=read(),v=read(),k=read();
		res-=f[u][0];
		REP(j,0,min(a[u],b[u]))
		{
			double tmp=f[u][j];f[u][j]=0;
			REP(i,0,min(k,j))
				f[u][j-i]+=tmp*C(j,i)*C(b[u]-j,k-i)/C(b[u],k);
		}
		b[v]+=k;b[u]-=k;
		res+=f[u][0];
		printf("%.10lf\n",res);
	}
	REP(i,1,n)
	{
		double res=0;
		//REP(j,1,a[i])res+=j*f[i][j];
		//printf("%.10lf\n",res);
	}
}

int main()
{
#ifndef ONLINE_JUDGE
	freopen("honey.in","r",stdin);
	freopen("honey.out","w",stdout);
#endif
	init();
	doing();
	return 0;
}


#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<cmath>
#include<queue>
#include<stack>
#include<set>
#include<map>
using namespace std;
#define ll long long
#define REP(i,a,b) for(int i=(a),_end_=(b);i<=_end_;i++)
#define DREP(i,a,b) for(int i=(a),_end_=(b);i>=_end_;i--)
#define EREP(i,a) for(int i=start[(a)];i;i=e[i].next)
inline int read()
{
	int sum=0,p=1;char ch=getchar();
	while(!(('0'<=ch && ch<='9') || ch=='-'))ch=getchar();
	if(ch=='-')p=-1,ch=getchar();
	while('0'<=ch && ch<='9')sum=sum*10+ch-48,ch=getchar();
	return sum*p;
}

const int maxn=1e5+20;

int n;
double f[maxn][120];
int a[maxn],b[maxn];

inline void init()
{
	n=read();
	REP(i,1,n)b[i]=a[i]=read(),f[i][a[i]]=1;
}

inline double C(int n,int m){ if(n<m || m<0)return 0;double res=1;REP(i,1,m)res*=(double)(n-i+1)/i;return res;}

inline void doing()
{
	int q=read();
	double res=0;
	while(q--)
	{
		int u=read(),v=read(),k=read();
		res-=f[u][0];
		REP(j,0,min(a[u],b[u]))
		{
			double tmp=f[u][j];f[u][j]=0;
			REP(i,0,min(k,j))
				f[u][j-i]+=tmp*C(j,i)*C(b[u]-j,k-i)/C(b[u],i);
		}
		b[v]+=k;b[u]-=k;
		res+=f[u][0];
		printf("%.10lf\n",res);
	}
	REP(i,1,n)
	{
		double res=0;
		//REP(j,1,a[i])res+=j*f[i][j];
		//printf("%.10lf\n",res);
	}
}

int main()
{
#ifndef ONLINE_JUDGE
	freopen("honey.in","r",stdin);
	freopen("honey.out","w",stdout);
#endif
	init();
	doing();
	return 0;
}


#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<cmath>
#include<queue>
#include<stack>
#include<set>
#include<map>
using namespace std;
#define ll long long
#define REP(i,a,b) for(int i=(a),_end_=(b);i<=_end_;i++)
#define DREP(i,a,b) for(int i=(a),_end_=(b);i>=_end_;i--)
#define EREP(i,a) for(int i=start[(a)];i;i=e[i].next)
inline int read()
{
	int sum=0,p=1;char ch=getchar();
	while(!(('0'<=ch && ch<='9') || ch=='-'))ch=getchar();
	if(ch=='-')p=-1,ch=getchar();
	while('0'<=ch && ch<='9')sum=sum*10+ch-48,ch=getchar();
	return sum*p;
}

const int maxn=1e5+20;

int n;
double f[maxn][120];
int a[maxn],b[maxn];

inline void init()
{
	n=read();
	REP(i,1,n)b[i]=a[i]=read(),f[i][a[i]]=1;
}

inline double C(int n,int m){ if(n<m || m<0)return 0;double res=1;REP(i,1,m)res*=(double)(n-i+1)/i;return res;}

inline void doing()
{
	int q=read();
	double res=0;
	while(q--)
	{
		int u=read(),v=read(),k=read();
		res-=f[u][0];
		REP(j,0,min(a[u],b[u]))
		{
			double tmp=f[u][j];f[u][j]=0;
			REP(i,0,min(k,j))
				f[u][j-i]+=tmp*C(j,i)*C(b[u]-j,k-i)/C(b[u],k);
		}
		b[v]+=k;b[u]-=k;
		res+=f[u][0];
		printf("%.10lf\n",res);
	}
	REP(i,1,n)
	{
		double res=0;
		//REP(j,1,a[i])res+=j*f[i][j];
		//printf("%.10lf\n",res);
	}
}

int main()
{
#ifndef ONLINE_JUDGE
	freopen("honey.in","r",stdin);
	freopen("honey.out","w",stdout);
#endif
	init();
	doing();
	return 0;
}


#include <iostream>
#include <cstring>
#include <cstdio>

using namespace std;

bool map1[20][20][20];
int ans=0;
int k1[10]={-1,1,0,0,0,0};
int n1[10]={0,0,1,0,-1,0};
int m1[10]={0,0,0,1,0,-1};
bool used[15][15][15];
int k,n,m;

bool isin(int tmpk,int tmpn,int tmpm)
{
    if(tmpk>=0&&tmpk<k&&tmpn>=0&&tmpn<n&&tmpm>=0&&tmpm<m)
        return true;
    else
        return false;
}
void dfs(int nowk,int nown,int nowm)
{
    int tmpk,tmpn,tmpm;
    used[nowk][nown][nowm]=1;
        ans++;
        for(int i=0;i<6;i++)
        {
            tmpk=nowk+k1[i];
            tmpn=nown+n1[i];
            tmpm=nowm+m1[i];
            if(isin(tmpk,tmpn,tmpm)&&!map1[tmpk][tmpn][tmpm]&&!used[tmpk][tmpn][tmpm])
            {
                dfs(tmpk,tmpn,tmpm);
            }
        }

}
int main()
{
    cin>>k>>n>>m;
    memset(map1,0,sizeof(map1));
    memset(used,0,sizeof(used));
    string s;
    for(int t=0;t<k;t++)
        for(int i=0;i<m;i++)
        {
            cin>>s;
//            cout<<s<<endl;
           for(int j=0;j<n;j++)
           {
                if(s[j]=='.')
                    map1[t][i][j]=0;
                else
                    map1[t][i][j]=1;
           }
        }
    int x,y;
    cin>>x>>y;
    x--;y--;
    ans=0;
    dfs(0,x,y);
    printf("%d\n",ans);
     return 0;
}


#include <iostream>
#include <cstring>
#include <cstdio>

using namespace std;

bool map1[20][20][20];
int ans=0;
int k1[10]={-1,1,0,0,0,0};
int n1[10]={0,0,1,0,-1,0};
int m1[10]={0,0,0,1,0,-1};
bool used[15][15][15];
int k,n,m;

bool isin(int tmpk,int tmpn,int tmpm)
{
    if(tmpk>=0&&tmpk<k&&tmpn>=0&&tmpn<n&&tmpm>=0&&tmpm<m)
        return true;
    else
        return false;
}
void dfs(int nowk,int nown,int nowm)
{
    int tmpk,tmpn,tmpm;
    used[nowk][nown][nowm]=1;
        ans++;
        for(int i=0;i<6;i++)
        {
            tmpk=nowk+k1[i];
            tmpn=nown+n1[i];
            tmpm=nowm+m1[i];
            if(isin(tmpk,tmpn,tmpm)&&!map1[tmpk][tmpn][tmpm]&&!used[tmpk][tmpn][tmpm])
            {
                dfs(tmpk,tmpn,tmpm);
            }
        }

}
int main()
{
    cin>>k>>n>>m;
    memset(map1,0,sizeof(map1));
    memset(used,0,sizeof(used));
    string s;
    for(int t=0;t<k;t++)
        for(int i=0;i<n;i++)
        {
            cin>>s;

           for(int j=0;j<m;j++)
           {
                if(s[j]=='.')
                    map1[t][i][j]=0;
                else
                    map1[t][i][j]=1;
           }
        }
    int x,y;
    cin>>x>>y;
    x--;y--;
    ans=0;
    dfs(0,x,y);
    printf("%d\n",ans);
     return 0;
}


#include <iostream>
#include <cstring>
#include <cstdio>

using namespace std;

bool map1[15][15][15];
int ans=0;
int k1[10]={-1,1,0,0,0,0};
int n1[10]={0,0,1,0,-1,0};
int m1[10]={0,0,0,1,0,-1};
bool used[15][15][15];
int k,n,m;

bool isin(int tmpk,int tmpn,int tmpm)
{
    if(tmpk>=0&&tmpk<k&&tmpn>=0&&tmpn<n&&tmpm>=0&&tmpm<m)
        return true;
    else
        return false;
}
void dfs(int nowk,int nown,int nowm)
{
    int tmpk,tmpn,tmpm;

    if(used[nowk][nown][nowm])
    {
        return ;
    }
    used[nowk][nown][nowm]=1;
        ans++;
        for(int i=0;i<6;i++)
        {
            tmpk=nowk+k1[i];
            tmpn=nown+n1[i];
            tmpm=nowm+m1[i];
            if(isin(tmpk,tmpn,tmpm)&&!map1[tmpk][tmpn][tmpm])
            {
                dfs(tmpk,tmpn,tmpm);
            }
        }

}
int main()
{
    cin>>k>>n>>m;
    memset(map1,0,sizeof(map1));
    memset(used,0,sizeof(used));
    string s;
    for(int t=0;t<k;t++)
        for(int i=0;i<m;i++)
        {
            cin>>s;
//            cout<<s<<endl;
           for(int j=0;j<n;j++)
           {
                if(s[j]=='.')
                    map1[t][i][j]=0;
                else
                    map1[t][i][j]=1;
           }
        }
    int x,y;
    scanf("%d%d",&x,&y);
    x--;y--;
    ans=0;
    dfs(0,x,y);
    printf("%d\n",ans);
     return 0;
}


#include <iostream>
#include <string>
#include <vector>
#include <queue>

using namespace std;

typedef vector<string> Layer;
typedef struct Vec3d {
    int x, y, z;
} Vec3d;

inline bool isValid(const Vec3d &pos, int n, int m, int k){
    if(pos.x < 0){ return false; }
    if(pos.x >= m){ return false; }
    if(pos.y < 0){ return false; }
    if(pos.y >= n){ return false; }
    if(pos.z < 0){ return false; }
    if(pos.z >= k){ return false; }
    return true;
}

int main(){
    int n, m, k;
    cin >> k >> n >> m;
    vector<Layer> plate;
    for(int i = 0; i < k; ++i){
        Layer layer(n);
        for(int j = 0; j < n; ++j){
            cin >> layer[j];
        }
        plate.push_back(layer);
    }
    int x, y, answer = 0;
    cin >> x >> y;
    Vec3d init = { x - 1, y - 1, 0 };
    plate[init.z][init.y][init.x] = '#';
    queue<Vec3d> q;
    q.push(init);
    while(!q.empty()){
        Vec3d pos = q.front(); q.pop();
        ++answer;
        {
            Vec3d next = { pos.x - 1, pos.y, pos.z };
            if(isValid(next, n, m, k) && plate[next.z][next.y][next.x] == '.'){
                plate[next.z][next.y][next.x] = '#';
                q.push(next);
            }
        }
        {
            Vec3d next = { pos.x + 1, pos.y, pos.z };
            if(isValid(next, n, m, k) && plate[next.z][next.y][next.x] == '.'){
                plate[next.z][next.y][next.x] = '#';
                q.push(next);
            }
        }
        {
            Vec3d next = { pos.x, pos.y - 1, pos.z };
            if(isValid(next, n, m, k) && plate[next.z][next.y][next.x] == '.'){
                plate[next.z][next.y][next.x] = '#';
                q.push(next);
            }
        }
        {
            Vec3d next = { pos.x, pos.y + 1, pos.z };
            if(isValid(next, n, m, k) && plate[next.z][next.y][next.x] == '.'){
                plate[next.z][next.y][next.x] = '#';
                q.push(next);
            }
        }
        {
            Vec3d next = { pos.x, pos.y, pos.z - 1 };
            if(isValid(next, n, m, k) && plate[next.z][next.y][next.x] == '.'){
                plate[next.z][next.y][next.x] = '#';
                q.push(next);
            }
        }
        {
            Vec3d next = { pos.x, pos.y, pos.z + 1 };
            if(isValid(next, n, m, k) && plate[next.z][next.y][next.x] == '.'){
                plate[next.z][next.y][next.x] = '#';
                q.push(next);
            }
        }
    }
    cout << answer << endl;
    return 0;
}


#include <iostream>
#include <string>
#include <vector>
#include <queue>

using namespace std;

typedef vector<string> Layer;
typedef struct Vec3d {
    int x, y, z;
} Vec3d;

inline bool isValid(const Vec3d &pos, int n, int m, int k){
    if(pos.x < 0){ return false; }
    if(pos.x >= n){ return false; }
    if(pos.y < 0){ return false; }
    if(pos.y >= m){ return false; }
    if(pos.z < 0){ return false; }
    if(pos.z >= k){ return false; }
    return true;
}

int main(){
    int n, m, k;
    cin >> k >> n >> m;
    vector<Layer> plate;
    for(int i = 0; i < k; ++i){
        Layer layer(n);
        for(int j = 0; j < n; ++j){
            cin >> layer[j];
        }
        plate.push_back(layer);
    }
    int x, y, answer = 0;
    cin >> x >> y;
    Vec3d init = { x - 1, y - 1, 0 };
    plate[init.z][init.x][init.y] = '#';
    queue<Vec3d> q;
    q.push(init);
    while(!q.empty()){
        Vec3d pos = q.front(); q.pop();
        ++answer;
        {
            Vec3d next = { pos.x - 1, pos.y, pos.z };
            if(isValid(next, n, m, k) && plate[next.z][next.x][next.y] == '.'){
                plate[next.z][next.x][next.y] = '#';
                q.push(next);
            }
        }
        {
            Vec3d next = { pos.x + 1, pos.y, pos.z };
            if(isValid(next, n, m, k) && plate[next.z][next.x][next.y] == '.'){
                plate[next.z][next.x][next.y] = '#';
                q.push(next);
            }
        }
        {
            Vec3d next = { pos.x, pos.y - 1, pos.z };
            if(isValid(next, n, m, k) && plate[next.z][next.x][next.y] == '.'){
                plate[next.z][next.x][next.y] = '#';
                q.push(next);
            }
        }
        {
            Vec3d next = { pos.x, pos.y + 1, pos.z };
            if(isValid(next, n, m, k) && plate[next.z][next.x][next.y] == '.'){
                plate[next.z][next.x][next.y] = '#';
                q.push(next);
            }
        }
        {
            Vec3d next = { pos.x, pos.y, pos.z - 1 };
            if(isValid(next, n, m, k) && plate[next.z][next.x][next.y] == '.'){
                plate[next.z][next.x][next.y] = '#';
                q.push(next);
            }
        }
        {
            Vec3d next = { pos.x, pos.y, pos.z + 1 };
            if(isValid(next, n, m, k) && plate[next.z][next.x][next.y] == '.'){
                plate[next.z][next.x][next.y] = '#';
                q.push(next);
            }
        }
    }
    cout << answer << endl;
    return 0;
}


#include <iostream>
#include <string>
#include <vector>
#include <queue>

using namespace std;

typedef vector<string> Layer;
typedef struct Vec3d {
    int x, y, z;
} Vec3d;

inline bool isValid(const Vec3d &pos, int n, int m, int k){
    if(pos.x < 0){ return false; }
    if(pos.x >= n){ return false; }
    if(pos.y < 0){ return false; }
    if(pos.y >= m){ return false; }
    if(pos.z < 0){ return false; }
    if(pos.z >= k){ return false; }
    return true;
}

int main(){
    int n, m, k;
    cin >> k >> n >> m;
    vector<Layer> plate;
    for(int i = 0; i < k; ++i){
        Layer layer(m);
        for(int j = 0; j < m; ++j){
            cin >> layer[j];
        }
        plate.push_back(layer);
    }
    int x, y, answer = 0;
    cin >> y >> x;
    Vec3d init = { x - 1, y - 1, 0 };
    queue<Vec3d> q;
    q.push(init);
    while(!q.empty()){
        Vec3d pos = q.front(); q.pop();
        if(plate[pos.z][pos.y][pos.x] == '#'){ continue; }
        ++answer;
        plate[pos.z][pos.y][pos.x] = '#';
        {
            Vec3d next = { pos.x - 1, pos.y, pos.z };
            if(isValid(next, n, m, k) && plate[next.z][next.y][next.x] == '.'){ q.push(next); }
        }
        {
            Vec3d next = { pos.x + 1, pos.y, pos.z };
            if(isValid(next, n, m, k) && plate[next.z][next.y][next.x] == '.'){ q.push(next); }
        }
        {
            Vec3d next = { pos.x, pos.y - 1, pos.z };
            if(isValid(next, n, m, k) && plate[next.z][next.y][next.x] == '.'){ q.push(next); }
        }
        {
            Vec3d next = { pos.x, pos.y + 1, pos.z };
            if(isValid(next, n, m, k) && plate[next.z][next.y][next.x] == '.'){ q.push(next); }
        }
        {
            Vec3d next = { pos.x, pos.y, pos.z - 1 };
            if(isValid(next, n, m, k) && plate[next.z][next.y][next.x] == '.'){ q.push(next); }
        }
        {
            Vec3d next = { pos.x, pos.y, pos.z + 1 };
            if(isValid(next, n, m, k) && plate[next.z][next.y][next.x] == '.'){ q.push(next); }
        }
    }
    cout << answer << endl;
    return 0;
}


#include <iostream>
#include <string>
#include <vector>
#include <queue>

using namespace std;

typedef vector<string> Layer;
typedef struct Vec3d {
    int x, y, z;
} Vec3d;

inline bool isValid(const Vec3d &pos, int n, int m, int k){
    if(pos.x < 0){ return false; }
    if(pos.x >= m){ return false; }
    if(pos.y < 0){ return false; }
    if(pos.y >= n){ return false; }
    if(pos.z < 0){ return false; }
    if(pos.z >= k){ return false; }
    return true;
}

int main(){
    int n, m, k;
    cin >> k >> n >> m;
    vector<Layer> plate;
    for(int i = 0; i < k; ++i){
        Layer layer(n);
        for(int j = 0; j < n; ++j){
            cin >> layer[j];
        }
        plate.push_back(layer);
    }
    int x, y, answer = 0;
    cin >> x >> y;
    Vec3d init = { x - 1, y - 1, 0 };
    plate[init.z][init.x][init.y] = '#';
    queue<Vec3d> q;
    q.push(init);
    while(!q.empty()){
        Vec3d pos = q.front(); q.pop();
        ++answer;
        {
            Vec3d next = { pos.x - 1, pos.y, pos.z };
            if(isValid(next, n, m, k) && plate[next.z][next.x][next.y] == '.'){
                plate[next.z][next.x][next.y] = '#';
                q.push(next);
            }
        }
        {
            Vec3d next = { pos.x + 1, pos.y, pos.z };
            if(isValid(next, n, m, k) && plate[next.z][next.x][next.y] == '.'){
                plate[next.z][next.x][next.y] = '#';
                q.push(next);
            }
        }
        {
            Vec3d next = { pos.x, pos.y - 1, pos.z };
            if(isValid(next, n, m, k) && plate[next.z][next.x][next.y] == '.'){
                plate[next.z][next.x][next.y] = '#';
                q.push(next);
            }
        }
        {
            Vec3d next = { pos.x, pos.y + 1, pos.z };
            if(isValid(next, n, m, k) && plate[next.z][next.x][next.y] == '.'){
                plate[next.z][next.x][next.y] = '#';
                q.push(next);
            }
        }
        {
            Vec3d next = { pos.x, pos.y, pos.z - 1 };
            if(isValid(next, n, m, k) && plate[next.z][next.x][next.y] == '.'){
                plate[next.z][next.x][next.y] = '#';
                q.push(next);
            }
        }
        {
            Vec3d next = { pos.x, pos.y, pos.z + 1 };
            if(isValid(next, n, m, k) && plate[next.z][next.x][next.y] == '.'){
                plate[next.z][next.x][next.y] = '#';
                q.push(next);
            }
        }
    }
    cout << answer << endl;
    return 0;
}


#include <iostream>
#include <string>
#include <vector>
#include <queue>

using namespace std;

typedef vector<string> Layer;
typedef struct Vec3d {
    int x, y, z;
} Vec3d;

inline bool isValid(const Vec3d &pos, int n, int m, int k){
    if(pos.x < 0){ return false; }
    if(pos.x >= n){ return false; }
    if(pos.y < 0){ return false; }
    if(pos.y >= m){ return false; }
    if(pos.z < 0){ return false; }
    if(pos.z >= k){ return false; }
    return true;
}

int main(){
    int n, m, k;
    cin >> k >> n >> m;
    vector<Layer> plate;
    for(int i = 0; i < k; ++i){
        Layer layer(m);
        for(int j = 0; j < m; ++j){
            cin >> layer[j];
        }
        plate.push_back(layer);
    }
    int x, y, answer = 0;
    cin >> y >> x;
    Vec3d init = { x - 1, y - 1, 0 };
    plate[init.z][init.y][init.x] = '#';
    queue<Vec3d> q;
    q.push(init);
    while(!q.empty()){
        Vec3d pos = q.front(); q.pop();
        ++answer;
        {
            Vec3d next = { pos.x - 1, pos.y, pos.z };
            if(isValid(next, n, m, k) && plate[next.z][next.y][next.x] == '.'){
                plate[next.z][next.y][next.x] = '#';
                q.push(next);
            }
        }
        {
            Vec3d next = { pos.x + 1, pos.y, pos.z };
            if(isValid(next, n, m, k) && plate[next.z][next.y][next.x] == '.'){
                plate[next.z][next.y][next.x] = '#';
                q.push(next);
            }
        }
        {
            Vec3d next = { pos.x, pos.y - 1, pos.z };
            if(isValid(next, n, m, k) && plate[next.z][next.y][next.x] == '.'){
                plate[next.z][next.y][next.x] = '#';
                q.push(next);
            }
        }
        {
            Vec3d next = { pos.x, pos.y + 1, pos.z };
            if(isValid(next, n, m, k) && plate[next.z][next.y][next.x] == '.'){
                plate[next.z][next.y][next.x] = '#';
                q.push(next);
            }
        }
        {
            Vec3d next = { pos.x, pos.y, pos.z - 1 };
            if(isValid(next, n, m, k) && plate[next.z][next.y][next.x] == '.'){
                plate[next.z][next.y][next.x] = '#';
                q.push(next);
            }
        }
        {
            Vec3d next = { pos.x, pos.y, pos.z + 1 };
            if(isValid(next, n, m, k) && plate[next.z][next.y][next.x] == '.'){
                plate[next.z][next.y][next.x] = '#';
                q.push(next);
            }
        }
    }
    cout << answer << endl;
    return 0;
}


#include <iostream>
#include <string>
#include <queue>
#include <stack>
#include <algorithm>
#include <cstdio>
#include <map>
#include <set>
#include <vector>
#include <cctype>
#include <sstream>
using namespace std;
#define oo (1<<31-1)
#define INFI (1e31)
#define ll long long
#define ull unsigned long long
int dx[]={-1,1,0,0,0,0};
int dy[]={0,0,-1,1,0,};
int dz[]={0,0,0,0,1,-1};
	int ans;
bool P[11][11][11],V[11][11][11];
void bfs(int,int);
int I,J,K;
void solve();
int main(){
	cin>>I>>J>>K;
	solve();
return 0;}
void solve(){
	for(int i=0;i<I;i++){
		for(int j=0;j<J;j++){
			string temp;
			cin>>temp;
			for(int k=0;k<K;k++){
				P[i][j][k]=!(temp[k]=='#');
				V[i][j][k]=false;
			}

		}
	}
	ans=0;
	int A,B;
	cin>>A>>B;
		V[0][A-1][B-1]=true;
		ans++;
		bfs(A-1,B-1);

	cout<<ans<<endl;
}
void bfs(int a,int b){
	pair<pair<int,int>,int> T;
	(T.first).first=0;
	(T.first).second=a;
	T.second=b;
	queue<pair<pair<int,int>,int> > Q;
	Q.push(T);
	int X,Y,Z;
	int xt,yt,zt;
	while(!Q.empty()){
		T=Q.front(); Q.pop();
		xt=(T.first).first;
		yt=(T.first).second;
		zt=T.second;
		for(int m=0;m<6;m++){
			X=xt+dx[m];
			Y=yt+dy[m];
			Z=zt+dz[m];
			if(X>=0&&X<I&&Y>=0&&Y<J&&Z>=0&&Z<K&&P[X][Y][Z]&&!V[X][Y][Z]){
				V[X][Y][Z]=true;
				ans++;
				pair<pair<int,int>,int> W;
					(W.first).first=X;
					(W.first).second=Y;
					W.second=Z;
				Q.push(W);
			}
		}
	}
}


#include <iostream>
#include <string>
#include <queue>
#include <stack>
#include <algorithm>
#include <cstdio>
#include <map>
#include <set>
#include <vector>
#include <cctype>
#include <sstream>
using namespace std;
#define oo (1<<31-1)
#define INFI (1e31)
#define ll long long
#define ull unsigned long long
int dx[]={-1,1,0,0,0,0};
int dy[]={0,0,-1,1,0,0};
int dz[]={0,0,0,0,1,-1};
	int ans;
bool P[11][11][11],V[11][11][11];
void bfs(int,int);
int I,J,K;
void solve();
int main(){
	cin>>I>>J>>K;
	solve();
return 0;}
void solve(){
	for(int i=0;i<I;i++){
		for(int j=0;j<J;j++){
			string temp;
			cin>>temp;
			for(int k=0;k<K;k++){
				if(temp[k]=='.')
				P[i][j][k]=true;
				else P[i][j][k]=false;

				V[i][j][k]=false;
			}

		}
	}
	ans=0;
	int A,B;
	cin>>A>>B;
		V[0][A-1][B-1]=true;
		ans++;
		bfs(A-1,B-1);

	cout<<ans<<endl;
}
void bfs(int a,int b){

	int Q[10*10*10+1][3];
	int indice=0;
	Q[indice][0]=0;
	Q[indice][1]=a;
	Q[indice][2]=b;
	int X,Y,Z;
	int xt,yt,zt;
	while(indice>=0){
		xt=Q[indice][0];
		yt=Q[indice][1];
		zt=Q[indice][2];
		indice--;
		for(int m=0;m<6;m++){
			X=xt+dx[m];
			Y=yt+dy[m];
			Z=zt+dz[m];
			if(X>=0&&X<I&&Y>=0&&Y<J&&Z>=0&&Z<K&&P[X][Y][Z]&&!V[X][Y][Z]){
				V[X][Y][Z]=true;
				ans++;
				indice++;
				Q[indice][0]=X;
				Q[indice][1]=Y;
				Q[indice][2]=Z;

			}
		}
	}
}


#include <iostream>
#include <string>
#include <queue>
#include <stack>
#include <algorithm>
#include <cstdio>
#include <map>
#include <set>
#include <vector>
#include <cctype>
#include <sstream>
using namespace std;
#define oo (1<<31-1)
#define INFI (1e31)
#define ll long long
#define ull unsigned long long
int dx[]={-1,1,0,0,0,0};
int dy[]={0,0,-1,1,0,};
int dz[]={0,0,0,0,1,-1};
	int ans;
bool P[11][11][11],V[11][11][11];
void bfs(int,int);
int I,J,K;
void solve();
int main(){
	cin>>I>>J>>K;
	solve();
return 0;}
void solve(){
	for(int i=0;i<I;i++){
		for(int j=0;j<J;j++){
			string temp;
			cin>>temp;
			for(int k=0;k<K;k++){
				if(temp[k]=='.')
				P[i][j][k]=true;
				else P[i][j][k]=false;

				V[i][j][k]=false;
			}

		}
	}
	ans=0;
	int A,B;
	cin>>A>>B;
		V[0][A-1][B-1]=true;
		ans++;
		bfs(A-1,B-1);

	cout<<ans<<endl;
}
void bfs(int a,int b){
	pair<pair<int,int>,int> T;
	(T.first).first=0;
	(T.first).second=a;
	T.second=b;
	queue<pair<pair<int,int>,int> > Q;
	Q.push(T);
	int X,Y,Z;
	int xt,yt,zt;
	while(!Q.empty()){
		T=Q.front(); Q.pop();
		xt=(T.first).first;
		yt=(T.first).second;
		zt=T.second;
		for(int m=0;m<6;m++){
			X=xt+dx[m];
			Y=yt+dy[m];
			Z=zt+dz[m];
			if(X>=0&&X<I&&Y>=0&&Y<J&&Z>=0&&Z<K&&P[X][Y][Z]&&!V[X][Y][Z]){
				V[X][Y][Z]=true;
				ans++;
				pair<pair<int,int>,int> W;
					(W.first).first=X;
					(W.first).second=Y;
					W.second=Z;
				Q.push(W);
			}
		}
	}
}


#include <iostream>
#include <string>
#include <queue>
#include <stack>
#include <algorithm>
#include <cstdio>
#include <map>
#include <set>
#include <vector>
#include <cctype>
#include <sstream>
using namespace std;
#define oo (1<<31-1)
#define INFI (1e31)
#define ll long long
#define ull unsigned long long
int dx[]={-1,1,0,0,0,0};
int dy[]={0,0,-1,1,0,};
int dz[]={0,0,0,0,1,-1};
	int ans;
bool P[11][11][11],V[11][11][11];
void bfs(int,int);
int I,J,K;
void solve();
int main(){
	cin>>I>>J>>K;
	solve();
return 0;}
void solve(){
	for(int i=0;i<I;i++){
		for(int j=0;j<J;j++){
			string temp;
			cin>>temp;
			for(int k=0;k<K;k++){
				if(temp[k]=='.')
				P[i][j][k]=true;
				else P[i][j][k]=false;

				V[i][j][k]=false;
			}

		}
	}
	ans=0;
	int A,B;
	cin>>A>>B;
		V[0][A-1][B-1]=true;
		ans++;
		bfs(A-1,B-1);

	cout<<ans<<endl;
}
void bfs(int a,int b){

	int Q[10*10*10+1][3];
	int indice=0;
	Q[indice][0]=0;
	Q[indice][1]=a;
	Q[indice][2]=b;
	int X,Y,Z;
	int xt,yt,zt;
	while(indice>=0){
		xt=Q[indice][0];
		yt=Q[indice][1];
		zt=Q[indice][2];
		indice--;
		for(int m=0;m<6;m++){
			X=xt+dx[m];
			Y=yt+dy[m];
			Z=zt+dz[m];
			if(X>=0&&X<I&&Y>=0&&Y<J&&Z>=0&&Z<K&&P[X][Y][Z]&&!V[X][Y][Z]){
				V[X][Y][Z]=true;
				ans++;
				indice++;
				Q[indice][0]=X;
				Q[indice][1]=Y;
				Q[indice][2]=Z;

			}
		}
	}
}


#include <iostream>
#include <string>
#include <queue>
#include <stack>
#include <algorithm>
#include <cstdio>
#include <map>
#include <set>
#include <vector>
#include <cctype>
#include <sstream>
using namespace std;
#define oo (1<<31-1)
#define INFI (1e31)
#define ll long long
#define ull unsigned long long
int dx[]={-1,1,0,0,0,0};
int dy[]={0,0,-1,1,0,};
int dz[]={0,0,0,0,1,-1};
	int ans;
bool P[11][11][11],V[11][11][11];
struct terna{
	int x,y,z;
};
void bfs(int,int);
int I,J,K;
void solve();
int main(){
	cin>>I>>J>>K;
	solve();
return 0;}
void solve(){
	for(int i=0;i<I;i++){
		for(int j=0;j<J;j++){
			string temp;
			cin>>temp;
			for(int k=0;k<K;k++){
				P[i][j][k]=(temp[k]=='.');
				V[i][j][k]=false;
			}

		}
	}
	ans=0;
	int A,B;
	cin>>A>>B;
		V[0][A-1][B-1]=true;
		ans++;
		bfs(A-1,B-1);

	cout<<ans<<endl;
}
void bfs(int a,int b){
	terna T;
	T.x=0;
	T.y=a;
	T.z=b;
	queue<terna> Q;
	Q.push(T);
	int X,Y,Z;
	int xt,yt,zt;
	while(!Q.empty()){
		T=Q.front(); Q.pop();
		xt=T.x;
		yt=T.y;
		zt=T.z;
		for(int m=0;m<6;m++){
			X=xt+dx[m];
			Y=yt+dy[m];
			Z=zt+dz[m];
			if(X>=0&&X<I&&Y>=0&&Y<J&&Z>=0&&Z<K&&P[X][Y][Z]&&!V[X][Y][Z]){
				V[X][Y][Z]=true;
				ans++;
				T.x=X;
				T.y=Y;
				T.z=Z;
				Q.push(T);
			}
		}
	}
}


#include <iostream>
#include <string>
#include <queue>
#include <stack>
#include <algorithm>
#include <cstdio>
#include <map>
#include <set>
#include <vector>
#include <cctype>
#include <sstream>
using namespace std;
#define oo (1<<31-1)
#define INFI (1e31)
#define ll long long
#define ull unsigned long long
int dx[]={-1,1,0,0,0,0};
int dy[]={0,0,-1,1,0,};
int dz[]={0,0,0,0,1,-1};
	int ans;
bool P[11][11][11],V[11][11][11];
struct terna{
	int x,y,z;
};
void bfs(int,int);
int I,J,K;
void solve();
int main(){
	cin>>I>>J>>K;
	solve();
return 0;}
void solve(){
	for(int i=0;i<I;i++){
		for(int j=0;j<J;j++){
			string temp;
			cin>>temp;
			for(int k=0;k<K;k++){
				P[i][j][k]=!(temp[k]=='#');
				V[i][j][k]=false;
			}

		}
	}
	ans=0;
	int A,B;
	cin>>A>>B;
		V[0][A-1][B-1]=true;
		ans++;
		bfs(A-1,B-1);

	cout<<ans<<endl;
}
void bfs(int a,int b){
	terna T;
	T.x=0;
	T.y=a;
	T.z=b;
	queue<terna> Q;
	Q.push(T);
	int X,Y,Z;
	int xt,yt,zt;
	while(!Q.empty()){
		T=Q.front(); Q.pop();
		xt=T.x;
		yt=T.y;
		zt=T.z;
		for(int m=0;m<6;m++){
			X=xt+dx[m];
			Y=yt+dy[m];
			Z=zt+dz[m];
			if(X>=0&&X<I&&Y>=0&&Y<J&&Z>=0&&Z<K&&P[X][Y][Z]&&!V[X][Y][Z]){
				V[X][Y][Z]=true;
				ans++;
				T.x=X;
				T.y=Y;
				T.z=Z;
				Q.push(T);
			}
		}
	}
}


#include <iostream>
#include <cstdio>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <list>
#include <string>
#include <cstring>
#include <cmath>
#include <algorithm>

using namespace std;

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

ll total=0;
char x[12][12][12];
int km,mm,nm;

void traverse(int tinggi,int panjang,int lebar){
	if (tinggi<1 || tinggi>=km || panjang<1 || panjang>=mm || lebar<1 || lebar>=nm) return;
	else if (x[tinggi][panjang][lebar]=='.'){
		x[tinggi][panjang][lebar]='#';
		total++;
		traverse(tinggi,panjang+1,lebar);
		traverse(tinggi,panjang-1,lebar);
		traverse(tinggi,panjang,lebar+1);
		traverse(tinggi,panjang,lebar-1);
		traverse(tinggi+1,panjang,lebar);
		traverse(tinggi-1,panjang,lebar);
	}
}

int main()
{
	memset(x,'#',sizeof x);
	int k,m,n;
	scanf("%d%d%d",&k,&m,&n);
	km=k+1;mm=m+1;nm=n+1;
	for (int i=1;i<=k;i++)
		for (int j=1;j<=m;j++)
			for (int l=1;l<=n;l++)
				cin >> x[i][j][l];
	traverse(1,1,1);
	cout << total << endl;
	return 0;
}


#include <iostream>
#include <cstdio>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <list>
#include <string>
#include <cstring>
#include <cmath>
#include <algorithm>

using namespace std;

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

ll total=0;
char x[12][12][12];
int km,mm,nm;

void traverse(int tinggi,int panjang,int lebar){
	if (tinggi<1 || tinggi>=km || panjang<1 || panjang>=mm || lebar<1 || lebar>=nm) return;
	else if (x[tinggi][panjang][lebar]=='.'){
		x[tinggi][panjang][lebar]='#';
		total++;
		traverse(tinggi,panjang+1,lebar);
		traverse(tinggi,panjang-1,lebar);
		traverse(tinggi,panjang,lebar+1);
		traverse(tinggi,panjang,lebar-1);
		traverse(tinggi+1,panjang,lebar);
		traverse(tinggi-1,panjang,lebar);
	}
}

int main()
{
	memset(x,'#',sizeof x);
	int k,m,n;
	scanf("%d%d%d",&k,&m,&n);
	km=k+1;mm=m+1;nm=n+1;
	for (int i=1;i<=k;i++)
		for (int j=1;j<=m;j++)
			for (int l=1;l<=n;l++)
				cin >> x[i][j][l];
	int x1,x2;
	scanf("%d%d",&x1,&x2);
	traverse(1,x1,x2);
	cout << total << endl;
	return 0;
}


#include <iostream>
#include <cstdio>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <list>
#include <string>
#include <cstring>
#include <cmath>
#include <algorithm>

using namespace std;

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

ll total=0;
char x[12][12][12];
int km,mm,nm;

void traverse(int tinggi,int panjang,int lebar){
	if (tinggi<1 || tinggi>=km || panjang<1 || panjang>=mm || lebar<1 || lebar>=nm || x[tinggi][panjang][lebar]=='#') return;
	else if (x[tinggi][panjang][lebar]=='.'){
		x[tinggi][panjang][lebar]='#';
		total++;
		traverse(tinggi,panjang+1,lebar);
		traverse(tinggi,panjang-1,lebar);
		traverse(tinggi,panjang,lebar+1);
		traverse(tinggi,panjang,lebar-1);
		traverse(tinggi+1,panjang,lebar);
		traverse(tinggi-1,panjang,lebar);
	}
}

int main()
{
	memset(x,'#',sizeof x);
	int k,m,n;
	scanf("%d%d%d",&k,&m,&n);
	km=k+1;mm=m+1;nm=n+1;
	for (int i=1;i<=k;i++)
		for (int j=1;j<=m;j++)
			for (int l=1;l<=n;l++)
				cin >> x[i][j][l];
	int x1,x2;
	scanf("%d%d",&x1,&x2);
	traverse(1,x1,x2);
	cout << total << endl;
	return 0;
}


#include <iostream>
#include <cstdio>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <list>
#include <string>
#include <cstring>
#include <cmath>
#include <algorithm>

using namespace std;

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

ll total=0;
char x[12][12][12];
int km,mm,nm;

void traverse(int tinggi,int panjang,int lebar){
	if (tinggi<1 || tinggi>=km || panjang<1 || panjang>=mm || lebar<1 || lebar>=nm) return;
	else if (x[tinggi][panjang][lebar]=='.'){
		x[tinggi][panjang][lebar]='#';
		total++;
		traverse(tinggi,panjang+1,lebar);
		traverse(tinggi,panjang-1,lebar);
		traverse(tinggi,panjang,lebar+1);
		traverse(tinggi,panjang,lebar-1);
		traverse(tinggi+1,panjang,lebar);
		traverse(tinggi-1,panjang,lebar);
	}
}

int main()
{
	memset(x,'#',sizeof x);
	int k,m,n;
	scanf("%d%d%d",&k,&m,&n);
	km=k+1;mm=m+1;nm=n+1;
	for (int i=1;i<=k;i++)
		for (int j=1;j<=m;j++)
			for (int l=1;l<=n;l++)
				cin >> x[i][j][l];
	for (int i=1;i<=m;i++)
		for (int j=1;j<=n;j++){
			if (x[1][i][j]=='.') traverse(1,i,j);
		}
	cout << total << endl;
	return 0;
}


#include<cstdio>
#include<queue>
#include<vector>
#include<iostream>

using namespace std;

vector<vector<string> > vs;
    int k,n,m,x,y;

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

struct trio
{
    int z,x,y;
    trio(int zz, int xx,int yy)
    {
        x=xx;
        y=yy;
        z=zz;
    }
    trio(){}
};

bool isvalid(int z,int x,int y)
{
    return (x>=0 && y>=0 && z>=0 && x<m && y<n && z<k && vs[z][x][y]=='.');
}

int bfs(int a,int b)
{
    queue<trio> Q;
    Q.push(trio(0,a,b));
    int x,y,z,cont=1;
    vs[0][a][b]='#';
    while(!Q.empty())
    {
        x=Q.front().x;
        y=Q.front().y;
        z=Q.front().z;
        Q.pop();
        //printf("-> %d %d %d  = %c\n",x,y,z,vs[z][x][y]);
        for(int i=0;i<6;i++)
        {
            if(isvalid(z+dz[i],x+dx[i],y+dy[i]) )
            {
                Q.push(trio(z+dz[i],x+dx[i],y+dy[i]));
                vs[z+dz[i]][x+dx[i]][y+dy[i]]='#';
                cont++;
            }
        }
    }
    return cont;
}

int main()
{
    string s;
    scanf("%d%d%d",&k,&n,&m);
    for(int i=0;i<k;i++)
    {
        vector<string> tmp;
        for(int j=0;j<n;j++)
        {
            cin>>s;
            tmp.push_back(s);
        }
        vs.push_back(tmp);
    }

    scanf("%d%d",&x,&y);
    printf("%d\n",bfs(x-1,y-1));
}


#include<cstdio>
#include<queue>
#include<vector>
#include<iostream>

using namespace std;

vector<vector<string> > vs;
    int k,n,m,x,y;

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

struct trio
{
    int z,x,y;
    trio(int zz, int xx,int yy)
    {
        x=xx;
        y=yy;
        z=zz;
    }
    trio(){}
};

bool isvalid(int z,int x,int y)
{
    return (x>=0 && y>=0 && z>=0 && x<n && y<m && z<k && vs[z][x][y]=='.');
}

int bfs(int a,int b)
{
    queue<trio> Q;
    Q.push(trio(0,a,b));
    int x,y,z,cont=1;
    vs[0][a][b]='#';
    while(!Q.empty())
    {
        x=Q.front().x;
        y=Q.front().y;
        z=Q.front().z;
        Q.pop();
        printf("-> %d %d %d  = %c\n",x,y,z,vs[z][x][y]);
        for(int i=0;i<6;i++)
        {
            if(isvalid(z+dz[i],x+dx[i],y+dy[i]) )
            {
                Q.push(trio(z+dz[i],x+dx[i],y+dy[i]));
                vs[z+dz[i]][x+dx[i]][y+dy[i]]='#';
                cont++;
            }
        }
    }
    return cont;
}

int main()
{
    string s;
    scanf("%d%d%d",&k,&n,&m);
    for(int i=0;i<k;i++)
    {
        vector<string> tmp;
        for(int j=0;j<n;j++)
        {
            cin>>s;
            tmp.push_back(s);
        }
        vs.push_back(tmp);
    }
    scanf("%d%d",&x,&y);
    printf("%d\n",bfs(x-1,y-1));
}


#include<cstdio>
#include<queue>
#include<vector>
#include<iostream>

using namespace std;

vector<vector<string> > vs;
    int k,n,m,x,y;

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

struct trio
{
    int z,x,y;
    trio(int zz, int xx,int yy)
    {
        x=xx;
        y=yy;
        z=zz;
    }
    trio(){}
};

bool isvalid(int z,int x,int y)
{
    return (x>=0 && y>=0 && z>=0 && x<n && y<m && z<k && vs[z][x][y]=='.');
}

int bfs(int a,int b)
{
    queue<trio> Q;
    Q.push(trio(0,a,b));
    int x,y,z,cont=1;
    vs[0][a][b]='#';
    while(!Q.empty())
    {
        x=Q.front().x;
        y=Q.front().y;
        z=Q.front().z;
        Q.pop();
        //printf("-> %d %d %d  = %c\n",x,y,z,vs[z][x][y]);
        for(int i=0;i<6;i++)
        {
            if(isvalid(z+dz[i],x+dx[i],y+dy[i]) )
            {
                Q.push(trio(z+dz[i],x+dx[i],y+dy[i]));
                vs[z+dz[i]][x+dx[i]][y+dy[i]]='#';
                cont++;
            }
        }
    }
    return cont;
}

int main()
{
    string s;
    scanf("%d%d%d",&k,&n,&m);
    for(int i=0;i<k;i++)
    {
        vector<string> tmp;
        for(int j=0;j<n;j++)
        {
            cin>>s;
            tmp.push_back(s);
        }
        vs.push_back(tmp);
    }
    scanf("%d%d",&x,&y);
    printf("%d\n",bfs(x-1,y-1));
}


#include <algorithm>
#include <string>
#include <vector>
#include <queue>
#include <iostream>
#include <cmath>
#include <sstream>
#include <map>
#include <set>
#include <numeric>
#include <memory.h>
#include <stdio.h>

using namespace std;

#define pb push_back
#define INF 1000000000
#define L(s) (int)((s).size())
#define FOR(i,a,b) for (int _n(b), i(a); i < _n; i++)
#define rep(i,n) FOR(i,0,n)
#define ford(i,a,b) for(int i=(a),_b=(b);i>=_b;--i)
#define ll long long
#define VI vector<int>
#define mp make_pair
#define all(c) (c).begin(), (c).end()
#define SORT(c) sort(all(c))

char cell[16][16][16];
char used[16][16][16];
int K,N,M;
int X,Y;
int counter;

bool ok(int x, int y, int k)
{
    return !(x<0 || x>N || y < 0 || y > M || k < 0 || k > K);
}

void dfs(int x, int y, int k)
{
    if(used[k][x][y]) return;
    used[k][x][y] = true;
    ++counter;

    for(int dx = -1; dx <= 1; ++dx)
        for(int dy = -1; dy <= 1; ++dy)
            for(int dk = -1; dk <= 1; ++dk)
                if(dx*dx + dy*dy + dk*dk == 1)
                {
                    int xx = x + dx, yy = y + dy, kk = k + dk;
                    if(ok(xx,yy,kk) && cell[kk][xx][yy] == '.')
                    {
                        dfs(xx,yy,kk);
                    }
                }
}

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

    memset(used,0,sizeof(used));
    counter = 0;

    cin >> K >> N >> M;

    rep(k,K) rep(n,N) rep (m,M) cin >> cell[k][n][m];

    cin >> X >> Y;

    --X, --Y;

    dfs(X,Y,0);

    cout << counter << endl;

	return 0;
}


#include <algorithm>
#include <string>
#include <vector>
#include <queue>
#include <iostream>
#include <cmath>
#include <sstream>
#include <map>
#include <set>
#include <numeric>
#include <memory.h>
#include <stdio.h>

using namespace std;

#define pb push_back
#define INF 1000000000
#define L(s) (int)((s).size())
#define FOR(i,a,b) for (int _n(b), i(a); i < _n; i++)
#define rep(i,n) FOR(i,0,n)
#define ford(i,a,b) for(int i=(a),_b=(b);i>=_b;--i)
#define VI vector<int>
#define mp make_pair
#define all(c) (c).begin(), (c).end()
#define SORT(c) sort(all(c))
#define mp make_pair
#define X first
#define Y second

typedef long long ll;
typedef pair<ll,int> pil;

ll gcd(ll x, ll y)
{
    while(x && y)
        if(x>=y)
            x %= y;
        else
            y %= x;

    return x + y;
}

bool isSq(ll x)
{
    ll r = ll(ceil(sqrt(1.0*x)));
    return r * r == x;
}

bool ok(ll a, ll b, ll c)
{
    if(a <= 0 || b <= 0 || c <= 0) return false;

    if(!isSq(a) || !isSq(b) || !isSq(c)) return false;

    if(gcd(a,b) != 1 || gcd(b,c) != 1 || gcd(a,c) != 1) return false;

    return a + b == c;
}

bool good(ll x, ll y)
{
    ll xx = x*x, yy = y*y;

    return ok(xx,yy,xx+yy) || ok(abs(xx-yy),min(xx,yy),max(xx,yy)) || ok(min(xx,yy),abs(xx-yy), max(xx,yy));
}

int N;
pil a[1000000];

int p[1000000];
int rank[1000000];

int find(ll x)
{
    return x == p[x] ? x : p[x] = find(p[x]);
}

void _union(ll x, ll y)
{
    x = find(x), y = find(y);

    if(x == y) return;

    if(rank[x] > rank[y])
    {
        p[y] = x;
    }
    else
    {
        if(rank[x]==rank[y]) rank[y]++;
        p[x] = y;
    }
}

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

    memset(rank,0,sizeof(rank));

    cin >> N;
    ll ta;

    rep(i,N) p[i]=i;

    rep(i,N)
    {
        cin >> ta;
        a[i] = mp(ta,i);
    }

    sort(a,a+N);

    rep(i,N)
    {
        ll sq = ll(sqrt(1.0*a[i].X) + 0.5);
        ll low = max(1LL*0,a[i].X-sq);
        ll up = min(a[i].X+sq,1LL*10000000);

        for(int k = i; k < N && a[k].X <= up; ++k)
            if(good(a[i].X, a[k].X))
            {
                 _union(a[i].Y, a[k].Y);
            }
    }

    set<ll> coutTheComponents(p,p+N);

    cout << L(coutTheComponents) << endl;

        return 0;
}


#include <algorithm>
#include <string>
#include <vector>
#include <queue>
#include <iostream>
#include <cmath>
#include <sstream>
#include <map>
#include <set>
#include <numeric>
#include <memory.h>
#include <stdio.h>

using namespace std;

#define FOR(i,a,b) for (int _n(b), i(a); i < _n; i++)
#define rep(i,n) FOR(i,0,n)

char cell[16][16][16];
char used[16][16][16];
int K,N,M;
int X,Y;
int counter;

bool ok(int x, int y, int k)
{
    return !(x<0 || x>N || y < 0 || y > M || k < 0 || k > K);
}

void dfs(int x, int y, int k)
{
    if(used[k][x][y]) return;
    used[k][x][y] = true;
    ++counter;

    for(int dx = -1; dx <= 1; ++dx)
        for(int dy = -1; dy <= 1; ++dy)
            for(int dk = -1; dk <= 1; ++dk)
                if(dx*dx + dy*dy + dk*dk == 1)
                {
                    int xx = x + dx, yy = y + dy, kk = k + dk;
                    if(ok(xx,yy,kk) && cell[kk][xx][yy] == '.')
                    {
                        dfs(xx,yy,kk);
                    }
                }
}

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

    memset(used,0,sizeof(used));
    counter = 0;

    cin >> K >> N >> M;

    rep(k,K) rep(n,N) rep (m,M) cin >> cell[k][n][m];

    cin >> X >> Y;

    --X, --Y;

    dfs(X,Y,0);

    cout << counter << endl;

        return 0;
}


#include <algorithm>
#include <string>
#include <vector>
#include <queue>
#include <iostream>
#include <cmath>
#include <sstream>
#include <map>
#include <set>
#include <numeric>
#include <memory.h>
#include <stdio.h>

using namespace std;

#define FOR(i,a,b) for (int _n(b), i(a); i < _n; i++)
#define rep(i,n) FOR(i,0,n)

char cell[16][16][16];
char used[16][16][16];
int K,N,M;
int X,Y;
int counter;

bool ok(int x, int y, int k)
{
    return !(x<0 || x>N || y < 0 || y > M || k < 0 || k > K);
}

void dfs(int x, int y, int k)
{
    if(used[k][x][y]) return;
    used[k][x][y] = true;
    ++counter;

    for(int dx = -1; dx <= 1; ++dx)
        for(int dy = -1; dy <= 1; ++dy)
            for(int dk = -1; dk <= 1; ++dk)
                if(dx*dx + dy*dy + dk*dk == 1)
                {
                    int xx = x + dx, yy = y + dy, kk = k + dk;
                    if(ok(xx,yy,kk) && cell[kk][xx][yy] == '.')
                    {
                        dfs(xx,yy,kk);
                    }
                }
}

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

    memset(used,0,sizeof(used));
    counter = 0;

    cin >> K >> N >> M;

    rep(k,K) rep(n,N) rep (m,M) cin >> cell[k][n][m];

    cin >> X >> Y;

    --X, --Y;

    dfs(X,Y,0);

    cout << counter << endl;

	return 0;
}


#include <algorithm>
#include <string>
#include <vector>
#include <queue>
#include <iostream>
#include <cmath>
#include <sstream>
#include <map>
#include <set>
#include <numeric>
#include <memory.h>
#include <stdio.h>

using namespace std;

#define FOR(i,a,b) for (int _n(b), i(a); i < _n; i++)
#define rep(i,n) FOR(i,0,n)

char cell[16][16][16];
char used[16][16][16];
int K,N,M;
int X,Y;
int counter;

bool ok(int x, int y, int k)
{
    return !(x<0 || x>N || y < 0 || y > M || k < 0 || k > K);
}

void dfs(int x, int y, int k)
{
    if(used[k][x][y]) return;
    used[k][x][y] = true;
    ++counter;

    for(int dx = -1; dx <= 1; ++dx)
        for(int dy = -1; dy <= 1; ++dy)
            for(int dk = -1; dk <= 1; ++dk)
                if(dx*dx + dy*dy + dk*dk == 1)
                {
                    int xx = x + dx, yy = y + dy, kk = k + dk;
                    if(ok(xx,yy,kk) && cell[kk][xx][yy] == '.')
                    {
                        dfs(xx,yy,kk);
                    }
                }
}

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

    memset(used,0,sizeof(used));
    counter = 0;

    cin >> K >> N >> M;

    rep(k,K) rep(n,N) rep (m,M) cin >> cell[k][n][m];

    cin >> X >> Y;

    --X, --Y;

    dfs(X,Y,0);

    cout << counter << endl;

	return 0;
}


#include <iostream>
#include <cstdio>

using namespace std;

char mapa[13][13][13];
int k, n, m, x, y, res;

void explore(int x, int y, int z)
{
    if(x < 0 or x >= k or y < 0 or y >= n or z < 0 or z >= m or mapa[x][y][z] == '#')
        return;
    res++;
    mapa[x][y][z] = '#';
    explore(x - 1, y, z);
    explore(x + 1, y, z);
    explore(x, y - 1, z);
    explore(x, y + 1, z);
    explore(x, y, z - 1);
    explore(x, y, z + 1);
    return;
}

int main()
{
    scanf("%d%d%d", &k, &n, &m);
    for(int i = 0; i < k; i++)
        for(int j = 0; j < n; j++)
            scanf("%s", mapa[i][j]);
    scanf("%d%d", &x, &y);
    explore(0, x - 1, y - 1);
    printf("%d\n", res);
	return 0;
}


#include <iostream>
#include <cstdio>
#include <queue>
#include <cstring>

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

int k, n, m, a, b, odg;
char mapa[15][15];
bool state[15][15];
queue <int> qx;
queue <int> qy;

int main()
{
    scanf("%d%d%d", &k, &n, &m);
    for(int z = 0; z < k; z++)
    {
        for(int i = 1; i <= n; i++)
            scanf("%s", mapa[i] + 1);
        for(int i = 1; i <= n; i++)
            for(int j = 1; j <= m; j++)
                if(state[i][j] == false and mapa[i][j] == '.')
                {
                    state[i][j] = 1;
                    qx.push(i), qy.push(j);
                    while(!qx.empty())
                    {
                        int xx = qx.front(); qx.pop();
                        int yy = qy.front(); qy.pop();
                        if(mapa[xx][yy] == '.')
                            odg++;
                        for(int g = 0; g < 4; g++)
                            if(state[g + dx[k]][g + dy[k]] == false and mapa[g + dx[k]][g + dy[k]] != 0)
                            {
                                state[g + dx[k]][g + dy[k]] = true;
                                qx.push(g + dx[k]); qy.push(g + dy[k]);
                            }
                    }
                }
        memset(state, 0, sizeof state);
    }
    scanf("%d%d", &a, &b);
    printf("%d\n", odg - 1);
	return 0;
}


#include <iostream>
#include <cstdio>
#include <queue>
#include <cstring>

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

int k, n, m, a, b, odg;
char mapa[15][15];
bool state[15][15];
queue <int> qx;
queue <int> qy;

int main()
{
    scanf("%d%d%d", &k, &n, &m);
    for(int z = 0; z < k; z++)
    {
        for(int i = 1; i <= n; i++)
            scanf("%s", mapa[i] + 1);
        for(int i = 1; i <= n; i++)
            for(int j = 1; j <= m; j++)
                if(state[i][j] == false and mapa[i][j] == '.')
                {
                    state[i][j] = 1;
                    qx.push(i), qy.push(j);
                    odg++;
                    while(!qx.empty())
                    {
                        int xx = qx.front(); qx.pop();
                        int yy = qy.front(); qy.pop();
                        if(mapa[xx][yy] == '.')
                            odg++;
                        for(int g = 0; g < 4; g++)
                            if(state[g + dx[k]][g + dy[k]] == false and mapa[g + dx[k]][g + dy[k]] != 0)
                            {
                                state[g + dx[k]][g + dy[k]] = true;
                                qx.push(g + dx[k]); qy.push(g + dy[k]);
                            }
                    }
                }
    }
    scanf("%d%d", &a, &b);
    printf("%d\n", odg - 1);
	return 0;
}


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

char c[10][101];
int b[10][101];
int dx[4]= {-1,0,1,0},dy[4]= {0,-1,0,1};
int ans,k,n,m,x,y;

void bfs(int x,int y)
{
    int nx,ny;
    b[x][y]=1;
    ans++;
    for(int i=0; i<4; i++)
    {
        nx=x+dx[i];
        ny=y+dy[i];
        if(nx>=0&&ny>=0&&nx<k&&ny<n*m&&c[nx][ny]=='.'&&b[nx][ny]==0)
            bfs(nx,ny);
    }
    return;
}

int main()
{
    cin>>k>>n>>m;
    memset(b,sizeof(b),0);
    getchar();
    for(int i=0; i<k; i++)
    {
        int k=1;
        for(int j=0; j<n*m; j++)
        {
            cin>>c[i][j];
            if(k==m)
            {
                getchar();
                k=0;
            }
            k++;
        }
        getchar();
    }

    cin>>x>>y;
    //       for(int j=0;j<k;j++)
    // {for(int k=0;k<n*m;k++)
    //    cout<<c[j][k];
    //    cout<<endl;
    // }
    ans=0;
    int q=0,w=(x-1)*m+y-1;
    bfs(q,w);
    cout<<ans<<endl;
    return 0;
}


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

char c[105][15];
int b[105][15];
int dx[4]= {-1,0,1,0},dy[4]= {0,-1,0,1};
int ans,k,n,m,x,y,key;

void bfs(int key,int x,int y)
{
    int nx,ny;
    int t;
    b[x][y]=1;
    ans++;
    for(int i=0; i<4; i++)
    {
        nx=x+dx[i];
        ny=y+dy[i];
        if(nx>(key-1)*n&&ny>0&&nx<=key*n&&ny<=m&&c[nx][ny]=='.'&&b[nx][ny]==0)
        {
            bfs(key,nx,ny);
        }
    }
    if(key+1<=k&&c[x+n][y]=='.'&&b[x+n][y]==0)
    {
        t=key+1;
        x+=n;
        bfs(t,x,y);
    }
    if(key-1>=1&&c[x-n][y]=='.'&&b[x-n][y]==0)
    {
        x-=n;
        t=key-1;
        bfs(t,x,y);
    }
    return;
}

int main()
{
    cin>>k>>n>>m;
    memset(b,sizeof(b),0);
    getchar();
    for(int i=1; i<=n*k; i++)
    {
        for(int j=1; j<=m; j++)
        {
            cin>>c[i][j];
        }
        getchar();
    }
    getchar();
    cin>>x>>y;

    ans=0;
    key=1;
    bfs(key,x,y);
    cout<<ans<<endl;

    return 0;
}


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

char c[10][101];
int b[10][101];
int dx[4]= {-1,0,1,0},dy[4]= {0,-1,0,1};
int ans,k,n,m,x,y;

void bfs(int x,int y)
{
    int nx,ny;
    b[x][y]=1;
    ans++;
    for(int i=0; i<4; i++)
    {
        nx=x+dx[i];
        ny=y+dy[i];
        if(nx>=0&&ny>=0&&nx<k&&ny<n*m&&c[nx][ny]=='.'&&b[nx][ny]==0)
            bfs(nx,ny);
    }
    return;
}

int main()
{
    cin>>k>>n>>m;
    memset(b,sizeof(b),0);
    getchar();
    for(int i=0; i<k; i++)
    {
        int k=1;
        for(int j=0; j<n*m; j++)
        {
            cin>>c[i][j];
            if(k==m)
            {
                getchar();
                k=0;
            }
            k++;
        }
        getchar();
    }

    cin>>x>>y;
    //       for(int j=0;j<k;j++)
    // {for(int k=0;k<n*m;k++)
    //    cout<<c[j][k];
    //    cout<<endl;
    // }
    ans=0;
    int q=0,w=x*y-1;
    bfs(q,w);
    cout<<ans<<endl;
    return 0;
}


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

char c[105][15];
int b[105][15];
int dx[4]= {-1,0,1,0},dy[4]= {0,-1,0,1};
int ans,k,n,m,x,y,key;

void bfs(int key,int x,int y)
{
    int nx,ny;
    int t;
    b[x][y]=1;
    ans++;
    for(int i=0; i<4; i++)
    {
        nx=x+dx[i];
        ny=y+dy[i];
        if(nx>(key-1)*n&&ny>0&&nx<=key*n&&ny<=m&&c[nx][ny]=='.'&&b[nx][ny]==0)
        {
            bfs(key,nx,ny);
        }
    }
    if(key+1<=k&&c[x+n][y]=='.'&&b[x+n][y]==0)
    {
        t=key+1;
        bfs(t,x+n,y);
    }
    if(key-1>=1&&c[x-n][y]=='.'&&b[x-n][y]==0)
    {
        t=key-1;
        bfs(t,x-n,y);
    }
    return;
}

int main()
{
    cin>>k>>n>>m;
    memset(b,sizeof(b),0);
    getchar();
    for(int i=1; i<=n*k; i++)
    {
        for(int j=1; j<=m; j++)
        {
            cin>>c[i][j];
        }
        getchar();
    }
    getchar();
    cin>>x>>y;

    ans=0;
    key=1;
    bfs(key,x,y);
    cout<<ans<<endl;

    return 0;
}


#include <cstdio>
#include <cstring>
#include <queue>
using namespace std;
int di[6][3] = {{0,1,0},{1,0,0},{0,-1,0},{-1,0,0},{0,0,1},{0,0,-1}};
struct Node{
    int x,y,z;
    Node(){}
    Node(int _x,int _y,int _z):x(_x),y(_y),z(_z){}
};

queue<Node>Q;
int a[11][11][11];
char map[11][11];
int k,m,n,sx,sy;

int BFS(Node s){
    while(!Q.empty())Q.pop();
    Q.push(s);
    a[s.x][s.y][s.z] = 1;
    int res = 0;
    while(!Q.empty()){
        res ++;
        Node tmp = Q.front();
        Q.pop();
        int tz,tx,ty;
        for(int w = 0; w < 6; ++w){
            tx = tmp.x + di[w][0];
            ty = tmp.y + di[w][1];
            tz = tmp.z + di[w][2];
            if(tx > m || tx < 1 || ty > n || ty < 1 || tz > k || tz < 1)continue;
            if(a[tx][ty][tz] == 0){
                Q.push(Node(tx,ty,tz));
                a[tx][ty][tz] = 1;
            }
        }
    }
    return res;
}

int main(){
    while(scanf("%d%d%d",&k,&m,&n)!=EOF){
    memset(a,0,sizeof(a));
    for(int i = 1; i <= k; ++i){
        for(int j = 1; j <= m; ++j){
            scanf(" %s",map[j]+1);
            for(int t = 1; t <= n; ++t){
                if(map[j][t] != '.')//a[j][t][i] = 0;
                 a[j][t][i] = 1;
            }
        }
    }
    scanf("%d%d",&sx,&sy);
    int ans = BFS(Node(sx,sy,1));
    printf("%d\n",ans);}

}


#include <cstdio>
#include <cstring>
#include <queue>
using namespace std;
int di[6][3] = {{0,1,0},{1,0,0},{0,-1,0},{-1,0,0},{0,0,1},{0,0,-1}};
struct Node{
    int x,y,z;
    Node(){}
    Node(int _x,int _y,int _z):x(_x),y(_y),z(_z){}
};

queue<Node>Q;
int a[11][11][11];
char map[11][11];
int k,m,n,sx,sy;

int BFS(Node s){
    while(!Q.empty())Q.pop();
    Q.push(s);
    a[s.x][s.y][s.z] = 1;
    int res = 0;
    while(!Q.empty()){
        res ++;
        Node tmp = Q.front();
        Q.pop();
        int tz,tx,ty;
        for(int w = 0; w < 6; ++w){
            tx = tmp.x + di[w][0];
            ty = tmp.y + di[w][1];
            tz = tmp.z + di[w][2];
            if(tx > m || tx < 1 || ty > n || ty < 1 || tz > k || tz < 1)continue;
            if(a[tx][ty][tz] == 0){
                Q.push(Node(tx,ty,tz));
                a[tx][ty][tz] = 1;
            }
        }
    }
    return res;
}

int main(){
    scanf("%d%d%d",&k,&m,&n);
    //memset(a,0,sizeof(a));
    for(int i = 1; i <= k; ++i){
        for(int j = 1; j <= m; ++j){
            scanf(" %s",map[j]+1);
            for(int t = 1; t <= n; ++t){
                if(map[j][t] == '.')a[j][t][i] = 0;
                else a[j][t][i] = 1;
            }
        }
    }
    scanf("%d%d",&sx,&sy);
    int ans = BFS(Node(sx,sy,1));
    printf("%d\n",ans);

}