#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update

using namespace std;
using namespace __gnu_pbds;

typedef tree<
int,
null_type,
less<int>,
rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;

typedef long double ld;
typedef long long ll;

const int MAX_N = 1e6+10;
const ll INF = 1000000000000000001LL;
const ll MOD = 1e9+7;

int t, n, m, cnt,verticesScc[MAX_N], degout[MAX_N];
vector<int>g[MAX_N],g1[MAX_N],scc[MAX_N], ans, ans1;
vector<int>tSort;
bool mark[MAX_N];

void topologicalSort(int v) {
    mark[v] = true;
    for(int u:g[v])
        if(!mark[u])
            topologicalSort(u);
    tSort.push_back(v);
}

void dfs(int v) {
    mark[v] = true;
    scc[cnt].push_back(v);
    verticesScc[v] = cnt;
    for(int u:g1[v])
        if(!mark[u])
            dfs(u);
}

void SCC() {
    for(int i = 1 ; i <= n ; i++)
        if(!mark[i])
            topologicalSort(i);
    reverse(tSort.begin(), tSort.end());
    for(int i = 1 ; i <= n ; i++)
        mark[i] = false;

    for(int v:tSort)
        if(!mark[v]) {
            cnt++;
            dfs(v);
        }
}

int main() {
    //ios_base::sync_with_stdio(false);
    //cin>>t;
    scanf("%d", &t);
    while(t--) {
        //cin>>n>>m;
        scanf("%d %d", &n, &m);
        for(int i = 1 ; i <= n ; i++) {
            verticesScc[i] = 0;
            g[i].clear();
            g1[i].clear();
            scc[i].clear();
            mark[i] = 0;
            degout[i] = 0;
        }
        cnt = 0;
        tSort.clear();
        ans1.clear();
        ans.clear();
        for(int i = 1 ; i <= m ; i++) {
            int a, b;
            //cin>>a>>b;
            scanf("%d %d", &a, &b);
            g[a].push_back(b);
            g1[b].push_back(a);
        }
        SCC();
        if(cnt == 1) {
            //cout<<"No"<<endl;
            printf("No\n");
            continue;
        }
        //cout<<"Yes"<<endl;
        printf("Yes\n");
        for(int i = 1 ; i <= n ; i++) {
            for(int v: g[i]) {
                if(verticesScc[i] == verticesScc[v])
                    continue;
                degout[verticesScc[i]]++;
            }
        }
        bool sw = false;
        for(int i = 1 ; i <= cnt ; i++) {
            if(degout[i] == 0 and !sw) {
                sw = true;
                for(int v: scc[i])
                    ans.push_back(v);
            }
            else {
                for(int v: scc[i])
                    ans1.push_back(v);
            }
        }
        printf("%lu %lu\n", ans.size(), ans1.size());
        //cout<<ans.size()<<" "<<ans1.size()<<endl;
        for(int v: ans)
            printf("%d ", v);
            //cout<<v<<" ";
        //cout<<endl;
        printf("\n");
        for(int v: ans1)
            printf("%d ", v);
            //cout<<v<<" ";
        //cout<<endl;
        printf("\n");

    }
}


#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update

using namespace std;
using namespace __gnu_pbds;

typedef tree<
int,
null_type,
less<int>,
rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;

typedef long double ld;
typedef long long ll;

const int MAX_N = 1e6+10;
const ll INF = 1000000000000000001LL;
const ll MOD = 1e9+7;

int t, n, m, cnt,verticesScc[MAX_N], degout[MAX_N];
vector<int>g[MAX_N],g1[MAX_N],scc[MAX_N], ans, ans1;
vector<int>tSort;
bool mark[MAX_N];

void topologicalSort(int v) {
    mark[v] = true;
    for(int u:g[v])
        if(!mark[u])
            topologicalSort(u);
    tSort.push_back(v);
}

void dfs(int v) {
    mark[v] = true;
    scc[cnt].push_back(v);
    verticesScc[v] = cnt;
    for(int u:g1[v])
        if(!mark[u])
            dfs(u);
}

void SCC() {
    for(int i = 1 ; i <= n ; i++)
        if(!mark[i])
            topologicalSort(i);
    reverse(tSort.begin(), tSort.end());
    for(int i = 1 ; i <= n ; i++)
        mark[i] = false;

    for(int v:tSort)
        if(!mark[v]) {
            cnt++;
            dfs(v);
        }
}

int main() {
    ios_base::sync_with_stdio(false);
    cin>>t;
    while(t--) {
        cin>>n>>m;
        for(int i = 1 ; i <= n ; i++) {
            verticesScc[i] = 0;
            g[i].clear();
            g1[i].clear();
            scc[i].clear();
            mark[i] = 0;
            degout[i] = 0;
        }
        cnt = 0;
        tSort.clear();
        ans1.clear();
        ans.clear();
        for(int i = 1 ; i <= m ; i++) {
            int a, b;
            cin>>a>>b;
            g[a].push_back(b);
            g1[b].push_back(a);
        }
        SCC();
        if(cnt == 1) {
            cout<<"No"<<endl;
            continue;
        }
        cout<<"Yes"<<endl;
        for(int i = 1 ; i <= n ; i++) {
            for(int v: g[i]) {
                if(verticesScc[i] == verticesScc[v])
                    continue;
                degout[verticesScc[i]]++;
            }
        }

        for(int i = 1 ; i <= cnt ; i++) {
            if(degout[i] == 0) {
                for(int v: scc[i])
                    ans.push_back(v);
            }
            else {
                for(int v: scc[i])
                    ans1.push_back(v);
            }
        }
        cout<<ans.size()<<" "<<ans1.size()<<endl;
        for(int v: ans)
            cout<<v<<" ";
        cout<<endl;
        for(int v: ans1)
            cout<<v<<" ";
        cout<<endl;

    }
}


#include <cstdio>
#include <cstring>
#include <queue>
#include <algorithm>
#include <map>
#include <iostream>
#include <cstdlib>
#include <stack>
#define inf 0x3f3f3f3f
#define LL long long
#define inf64 0x3f3f3f3f3f3f3f3f
using namespace std;
typedef long long ll;
const int maxn = 2e6 + 10;
vector<int>G[maxn];
int vis[maxn];
bool cnt[maxn];
void add(int u,int v){
	G[u].push_back(v);
}
int sum,n,m,now=0,id;
void dfs(int u,int pre){
	if(u<id) {
		sum=0;
		return ;
	}
	vis[u]=now;
	if(u<=n) sum--;
	for(int i=0;i<G[u].size();i++){
		int v=G[u][i];
		if(v==pre||vis[v]==now) continue;
		dfs(v,u);
	}
}

void dfsans(int u,int pre){
	cnt[u]=1;
	if(u<=n) printf("%d ",u);
	for(int i=0;i<G[u].size();i++){
		int v=G[u][i];
		if(v==pre||cnt[v]) continue;
		dfsans(v,u);
	}
}

int main(){
	int t;
	scanf("%d",&t);
	while(t--){
		now=0,id=0;
		scanf("%d%d",&n,&m);
		for(int i=1;i<=2*n;i++){
			G[i].clear();
			vis[i]=0;
			cnt[i]=0;
		}
		for(int i=1;i<=n;i++) add(i+n,i);
		for(int i=1;i<=m;i++){
			int u,v;
			scanf("%d%d",&u,&v);
			add(u,v+n);
		}
		int ans=0,p=0,q=0;
		for(int i=1;i<=n;i++){
			sum=n;now++;
			id=i;
			dfs(i,-1);
			if(sum>0){
				q=sum,p=n-sum,ans=i;
				break;
			}
		}
		if(ans==0){
			printf("No\n");
			continue;
		}
		printf("Yes\n");
		printf("%d %d\n",p,q);
		dfsans(ans,-1);
		printf("\n");
		for(int i=1;i<=n;i++){
			if(cnt[i]) continue;
			printf("%d ",i);
		}
		printf("\n");
	}
	return 0;
}


#include <cstdio>
#include <cstring>
#include <queue>
#include <algorithm>
#include <map>
#include <iostream>
#include <cstdlib>
#include <stack>
#define inf 0x3f3f3f3f
#define LL long long
#define inf64 0x3f3f3f3f3f3f3f3f
using namespace std;
typedef long long ll;
const int maxn = 2e6 + 10;
vector<int>G[maxn];
int vis[maxn];
bool cnt[maxn];
void add(int u,int v){
	G[u].push_back(v);
}
int sum,n,m,now=0,id;
void dfs(int u,int pre){
	if(u<id) {
		sum=0;
		return ;
	}
	vis[u]=now;
	if(u<=n) sum--;
	for(int i=0;i<G[u].size();i++){
		int v=G[u][i];
		if(v==pre||vis[v]==now) continue;
		if(v<id) return ;
		dfs(v,u);
	}
}

void dfsans(int u,int pre){
	cnt[u]=1;
	if(u<=n) printf("%d ",u);
	for(int i=0;i<G[u].size();i++){
		int v=G[u][i];
		if(v==pre||cnt[v]) continue;
		dfsans(v,u);
	}
}

int main(){
	int t;
	scanf("%d",&t);
	while(t--){
		now=0,id=0;
		scanf("%d%d",&n,&m);
		for(int i=1;i<=2*n;i++){
			G[i].clear();
			vis[i]=0;
			cnt[i]=0;
		}
		for(int i=1;i<=n;i++) add(i+n,i);
		for(int i=1;i<=m;i++){
			int u,v;
			scanf("%d%d",&u,&v);
			add(u,v+n);
		}
		int ans=0,p=0,q=0;
		for(int i=1;i<=n;i++){
			sum=n;now++;
			id=i;
			dfs(i,-1);
			if(sum>0){
				q=sum,p=n-sum,ans=i;
				break;
			}
		}
		if(ans==0){
			printf("No\n");
			continue;
		}
		printf("Yes\n");
		printf("%d %d\n",p,q);
		dfsans(ans,-1);
		printf("\n");
		for(int i=1;i<=n;i++){
			if(cnt[i]) continue;
			printf("%d ",i);
		}
		printf("\n");
	}
	return 0;
}


#include <cstdio>
#include <cstring>
#include <queue>
#include <algorithm>
#include <map>
#include <iostream>
#include <cstdlib>
#include <stack>
#define inf 0x3f3f3f3f
#define LL long long
#define inf64 0x3f3f3f3f3f3f3f3f
using namespace std;
typedef long long ll;
const int maxn = 2e6 + 10;
vector<int>G[maxn];
int vis[maxn],vss[maxn];
bool cnt[maxn];

int sum,n,m,now=0,id;
void dfs(int u,int pre){
	vis[u]=now;
	if(u<=n) sum--;
	for(int i=0;i<G[u].size();i++){
		int v=G[u][i];
		if(v-n<=id&&v>n) {
			vss[u]=1;sum=0;
			return ;
		}
		if(v==pre||vis[v]==now) continue;
		dfs(v,u);
	}
}

void dfsans(int u,int pre){
	cnt[u]=1;
	if(u<=n) printf("%d ",u);
	for(int i=0;i<G[u].size();i++){
		int v=G[u][i];
		if(v==pre||cnt[v]) continue;
		dfsans(v,u);
	}
}

int main(){
	int t;
	scanf("%d",&t);
	while(t--){
		now=0,id=0;
		scanf("%d%d",&n,&m);
		for(int i=1;i<=2*n;i++){
			G[i].clear();
			vis[i]=cnt[i]=vss[i]=0;
		}
		for(int i=1;i<=n;i++) G[i+n].push_back(i);
		for(int i=1;i<=m;i++){
			int u,v;
			scanf("%d%d",&u,&v);
			G[u].push_back(v+n);
		}
		int ans=0,p=0,q=0;
		for(int i=1;i<=n;i++){
			if(vss[i]) continue;
			sum=n;now++;id=i;
			dfs(i,0);
			if(sum>0){
				q=sum,p=n-sum,ans=i;
				break;
			}
		}
		if(ans==0){
			printf("No\n");
			continue;
		}
		printf("Yes\n");
		printf("%d %d\n",p,q);
		dfsans(ans,-1);
		printf("\n");
		for(int i=1;i<=n;i++){
			if(cnt[i]) continue;
			printf("%d ",i);
		}
		printf("\n");
	}
	return 0;
}


#include <cstdio>
#include <cstring>
#include <queue>
#include <algorithm>
#include <map>
#include <iostream>
#include <cstdlib>
#include <stack>
#define inf 0x3f3f3f3f
#define LL long long
#define inf64 0x3f3f3f3f3f3f3f3f
using namespace std;
typedef long long ll;
const int maxn = 2e6 + 10;
vector<int>G[maxn];
vector<int>E[maxn];
bool vss[maxn],cnt[maxn];
int vis[maxn];
int sum,now=0;

void dfs(int u,int pre){
	vis[u]=now;
	if(u<=n) sum--;
	for(int i=0;i<G[u].size();i++){
		int v=G[u][i];
		if(v==pre||vis[v]==now) continue;
		dfs(v,u);
	}
}

void dfs1(int u,int pre){
	vis[u]=now;
	if(u<=n) sum--;
	for(int i=0;i<E[u].size();i++){
		int v=E[u][i];
		if(v==pre||vis[v]==now) continue;
		dfs(v,u);
	}
}

void dfsans(int u,int pre){
	cnt[u]=1;
	if(u<=n) printf("%d ",u);
	for(int i=0;i<G[u].size();i++){
		int v=G[u][i];
		if(v==pre||cnt[v]) continue;
		dfsans(v,u);
	}
}

void print(int u){
	printf("Yes\n");
	printf("%d %d\n",n-sum,sum);
	dfsans(u,0);
	printf("\n");
	for(int i=1;i<=n;i++){
		if(cnt[i]) continue;
		printf("%d ",i);
	}
	printf("\n");
}

int main(){
	int t;
	scanf("%d",&t);
	while(t--){
		now=0;
		scanf("%d%d",&n,&m);
		for(int i=1;i<=2*n;i++){
			G[i].clear();E[i].clear();
			vis[i]=cnt[i]=vss[i]=0;
		}
		for(int i=1;i<=n;i++) G[i+n].push_back(i),E[i].push_back(i+n);
		for(int i=1;i<=m;i++){
			int u,v;
			scanf("%d%d",&u,&v);
			G[u].push_back(v+n);
			E[v+n].push_back(u);
		}
		sum=n;
		now++;
		dfs(1,0);
		if(sum>0) {
			print(1);
			continue;
		}
		int ans=0;
		now++;
		dfs1(1,0);
		for(int i=1;i<=n;i++){
			if(vis[i]!=now){
				ans=i;
				break;
			}
		}
		if(ans==0){
			printf("No\n");
			continue;
		}
		sum=n;now++;
		dfs(ans,0);
		print(ans);
	}
	return 0;
}


#include <cstdio>
#include <cstring>
#include <queue>
#include <algorithm>
#include <map>
#include <iostream>
#include <cstdlib>
#include <stack>
#define inf 0x3f3f3f3f
#define LL long long
#define inf64 0x3f3f3f3f3f3f3f3f
using namespace std;
typedef long long ll;
const int maxn = 2e6 + 10;
vector<int>G[maxn];
int vis[maxn];
bool cnt[maxn];
void add(int u,int v){
	G[u].push_back(v);
}
int sum,n,m,now=0;
void dfs(int u,int pre){
	vis[u]=now;
	if(u<=n) sum--;
	for(int i=0;i<G[u].size();i++){
		int v=G[u][i];
		if(v==pre||vis[v]==now) continue;
		dfs(v,u);
	}
}

void dfsans(int u,int pre){
	cnt[u]=1;
	if(u<=n) printf("%d ",u);
	for(int i=0;i<G[u].size();i++){
		int v=G[u][i];
		if(v==pre||cnt[v]) continue;
		dfsans(v,u);
	}
}

int main(){
	int t;
	scanf("%d",&t);
	while(t--){
		now=0;
		scanf("%d%d",&n,&m);
		for(int i=1;i<=2*n;i++){
			G[i].clear();
			vis[i]=0;
			cnt[i]=0;
		}
		for(int i=1;i<=n;i++) add(i+n,i);
		for(int i=1;i<=m;i++){
			int u,v;
			scanf("%d%d",&u,&v);
			add(u,v+n);
		}
		int ans=0,p=0,q=0;
		for(int i=1;i<=n;i++){
			sum=n;now++;
			dfs(i,-1);
			if(sum>0){
				q=sum,p=n-sum,ans=i;
				break;
			}
		}
		if(ans==0){
			printf("No\n");
			continue;
		}
		printf("Yes\n");
		printf("%d %d\n",p,q);
		dfsans(ans,-1);
		printf("\n");
		for(int i=1;i<=n;i++){
			if(cnt[i]) continue;
			printf("%d ",i);
		}
		printf("\n");
	}
	return 0;
}


#include <cstdio>
#include <cstring>
#include <queue>
#include <algorithm>
#include <map>
#include <iostream>
#include <cstdlib>
#include <stack>
#define inf 0x3f3f3f3f
#define LL long long
#define inf64 0x3f3f3f3f3f3f3f3f
using namespace std;
typedef long long ll;
const int maxn = 2e6 + 10;
vector<int>G[maxn];
vector<int>E[maxn];
bool vss[maxn],cnt[maxn];
int vis[maxn];
int sum,now=0,n,m;

void dfs(int u,int pre){
	vis[u]=now;
	if(u<=n) sum--;
	for(int i=0;i<G[u].size();i++){
		int v=G[u][i];
		if(v==pre||vis[v]==now) continue;
		dfs(v,u);
	}
}

void dfs1(int u,int pre){
	vis[u]=now;
	if(u<=n) sum--;
	for(int i=0;i<E[u].size();i++){
		int v=E[u][i];
		if(v==pre||vis[v]==now) continue;
		dfs1(v,u);
	}
}

void dfsans(int u,int pre){
	cnt[u]=1;
	if(u<=n) printf("%d ",u);
	for(int i=0;i<G[u].size();i++){
		int v=G[u][i];
		if(v==pre||cnt[v]) continue;
		dfsans(v,u);
	}
}

void print(int u){
	printf("Yes\n");
	printf("%d %d\n",n-sum,sum);
	dfsans(u,0);
	printf("\n");
	for(int i=1;i<=n;i++){
		if(cnt[i]) continue;
		printf("%d ",i);
	}
	printf("\n");
}

int main(){
	int t;
	scanf("%d",&t);
	while(t--){
		now=0;
		scanf("%d%d",&n,&m);
		for(int i=1;i<=2*n;i++){
			G[i].clear();E[i].clear();
			vis[i]=cnt[i]=vss[i]=0;
		}
		for(int i=1;i<=n;i++) G[i+n].push_back(i),E[i].push_back(i+n);
		for(int i=1;i<=m;i++){
			int u,v;
			scanf("%d%d",&u,&v);
			G[u].push_back(v+n);
			E[v+n].push_back(u);
		}
		sum=n;
		now++;
		dfs(1,0);
		if(sum>0) {
			print(1);
			continue;
		}
		int ans=0;
		now++;
		dfs1(1,0);
		for(int i=1;i<=n;i++){
			if(vis[i]!=now){
				printf("i=%d\n",i);
				ans=i;
				break;
			}
		}
		if(ans==0){
			printf("No\n");
			continue;
		}
		sum=n;now++;
		dfs(ans,0);
		print(ans);
	}
	return 0;
}


#include <cstdio>
#include <cstring>
#include <queue>
#include <algorithm>
#include <map>
#include <iostream>
#include <cstdlib>
#include <stack>
#define inf 0x3f3f3f3f
#define LL long long
#define inf64 0x3f3f3f3f3f3f3f3f
using namespace std;
typedef long long ll;
const int maxn = 2e6 + 10;
vector<int>G[maxn];
int vis[maxn],vss[maxn];
bool cnt[maxn];

int sum,n,m,now=0,id;
void dfs(int u,int pre){
	vis[u]=now;
	if(u<=n) sum--;
	for(int i=0;i<G[u].size();i++){
		int v=G[u][i];
		if(v-n<id&&v>n) {
			vss[u]=1;sum=0;
			return ;
		}
		if(vis[v]==now&&v-n==id&&v>n) vss[u]=1;
		if(v==pre||vis[v]==now) continue;
		if(v<id) {
			sum=0;return ;
		}
		dfs(v,u);
	}
}

void dfsans(int u,int pre){
	cnt[u]=1;
	if(u<=n) printf("%d ",u);
	for(int i=0;i<G[u].size();i++){
		int v=G[u][i];
		if(v==pre||cnt[v]) continue;
		dfsans(v,u);
	}
}

int main(){
	int t;
	scanf("%d",&t);
	while(t--){
		now=0,id=0;
		scanf("%d%d",&n,&m);
		for(int i=1;i<=2*n;i++){
			G[i].clear();
			vis[i]=cnt[i]=vss[i]=0;
		}
		for(int i=1;i<=n;i++) G[i+n].push_back(i);
		for(int i=1;i<=m;i++){
			int u,v;
			scanf("%d%d",&u,&v);
			G[u].push_back(v+n);
		}
		int ans=0,p=0,q=0;
		for(int i=1;i<=n;i++){
			if(vss[i]) continue;
			sum=n;now++;id=i;
			dfs(i,0);
			if(sum>0){
				q=sum,p=n-sum,ans=i;
				break;
			}
		}
		if(ans==0){
			printf("No\n");
			continue;
		}
		printf("Yes\n");
		printf("%d %d\n",p,q);
		dfsans(ans,-1);
		printf("\n");
		for(int i=1;i<=n;i++){
			if(cnt[i]) continue;
			printf("%d ",i);
		}
		printf("\n");
	}
	return 0;
}


#include <cstdio>
#include <cstring>
#include <queue>
#include <algorithm>
#include <map>
#include <iostream>
#include <cstdlib>
#include <stack>
#define inf 0x3f3f3f3f
#define LL long long
#define inf64 0x3f3f3f3f3f3f3f3f
using namespace std;
typedef long long ll;
const int maxn = 1e6 + 10;
vector<int>a[maxn];
bool vis[maxn];

int main(){
	int t;
	scanf("%d",&t);
	while(t--){
		int n,m;
		scanf("%d%d",&n,&m);
		for(int i=1;i<=n;i++) a[i].clear(),vis[i]=0;
		for(int i=1;i<=m;i++){
			int x,y;
			scanf("%d%d",&x,&y);
			a[x].push_back(y);
		}
		int ans=0,xx=n,yy=0;
		for(int i=1;i<=n;i++){
			if(a[i].size()<n){
				ans=i;
				break;
			}
		}
		if(ans==0) {
			printf("No\n");
			continue;
		}
		printf("Yes\n");
		yy=a[ans].size();
		for(int i=0;i<a[ans].size();i++) vis[a[ans][i]]=1,xx--;
		printf("%d %d\n",xx,yy);
		for(int i=1;i<=n;i++){
			if(vis[i]) continue;
			printf("%d ",i);
		}
		printf("\n");
		for(int i=0;i<a[ans].size();i++) printf("%d ",a[ans][i]);
		printf("\n");
	}
	return 0;
}


#include <cstdio>
#include <cstring>
#include <queue>
#include <algorithm>
#include <map>
#include <iostream>
#include <cstdlib>
#include <stack>
#define inf 0x3f3f3f3f
#define LL long long
#define inf64 0x3f3f3f3f3f3f3f3f
using namespace std;
typedef long long ll;
const int maxn = 2e6 + 10;
vector<int>G[maxn];
vector<int>E[maxn];
bool vss[maxn],cnt[maxn];
int vis[maxn];
int sum,now=0,n,m;

void dfs(int u,int pre){
	vis[u]=now;
	if(u<=n) sum--;
	for(int i=0;i<G[u].size();i++){
		int v=G[u][i];
		if(v==pre||vis[v]==now) continue;
		dfs(v,u);
	}
}

void dfs1(int u,int pre){
	vis[u]=now;
	if(u<=n) sum--;
	for(int i=0;i<E[u].size();i++){
		int v=E[u][i];
		if(v==pre||vis[v]==now) continue;
		dfs(v,u);
	}
}

void dfsans(int u,int pre){
	cnt[u]=1;
	if(u<=n) printf("%d ",u);
	for(int i=0;i<G[u].size();i++){
		int v=G[u][i];
		if(v==pre||cnt[v]) continue;
		dfsans(v,u);
	}
}

void print(int u){
	printf("Yes\n");
	printf("%d %d\n",n-sum,sum);
	dfsans(u,0);
	printf("\n");
	for(int i=1;i<=n;i++){
		if(cnt[i]) continue;
		printf("%d ",i);
	}
	printf("\n");
}

int main(){
	int t;
	scanf("%d",&t);
	while(t--){
		now=0;
		scanf("%d%d",&n,&m);
		for(int i=1;i<=2*n;i++){
			G[i].clear();E[i].clear();
			vis[i]=cnt[i]=vss[i]=0;
		}
		for(int i=1;i<=n;i++) G[i+n].push_back(i),E[i].push_back(i+n);
		for(int i=1;i<=m;i++){
			int u,v;
			scanf("%d%d",&u,&v);
			G[u].push_back(v+n);
			E[v+n].push_back(u);
		}
		sum=n;
		now++;
		dfs(1,0);
		if(sum>0) {
			print(1);
			continue;
		}
		int ans=0;
		now++;
		dfs1(1,0);
		for(int i=1;i<=n;i++){
			if(vis[i]!=now){
				ans=i;
				break;
			}
		}
		if(ans==0){
			printf("No\n");
			continue;
		}
		sum=n;now++;
		dfs(ans,0);
		print(ans);
	}
	return 0;
}


#include <cstdio>
#include <cstring>
#include <queue>
#include <algorithm>
#include <map>
#include <iostream>
#include <cstdlib>
#include <stack>
#define inf 0x3f3f3f3f
#define LL long long
#define inf64 0x3f3f3f3f3f3f3f3f
using namespace std;
typedef long long ll;
const int maxn = 2e6 + 10;
vector<int>G[maxn];
int vis[maxn],vss[maxn];
bool cnt[maxn];

int sum,n,m,now=0,id;
void dfs(int u,int pre){
	vis[u]=now;
	if(u<=n) sum--;
	for(int i=0;i<G[u].size();i++){
		int v=G[u][i];
		if(v-n<id&&v>n) {
			vss[u]=1;sum=0;
			return ;
		}
		if(v-n==id&&v>n) vss[u]=1;
		if(v==pre||vis[v]==now) continue;
		if(v<id) {
			sum=0;return ;
		}
		dfs(v,u);
	}
}

void dfsans(int u,int pre){
	cnt[u]=1;
	if(u<=n) printf("%d ",u);
	for(int i=0;i<G[u].size();i++){
		int v=G[u][i];
		if(v==pre||cnt[v]) continue;
		dfsans(v,u);
	}
}

int main(){
	int t;
	scanf("%d",&t);
	while(t--){
		now=0,id=0;
		scanf("%d%d",&n,&m);
		for(int i=1;i<=2*n;i++){
			G[i].clear();
			vis[i]=cnt[i]=vss[i]=0;
		}
		for(int i=1;i<=n;i++) G[i+n].push_back(i);
		for(int i=1;i<=m;i++){
			int u,v;
			scanf("%d%d",&u,&v);
			G[u].push_back(v+n);
		}
		int ans=0,p=0,q=0;
		for(int i=1;i<=n;i++){
			if(vss[i]) continue;
			sum=n;now++;id=i;
			dfs(i,0);
			if(sum>0){
				q=sum,p=n-sum,ans=i;
				break;
			}
		}
		if(ans==0){
			printf("No\n");
			continue;
		}
		printf("Yes\n");
		printf("%d %d\n",p,q);
		dfsans(ans,-1);
		printf("\n");
		for(int i=1;i<=n;i++){
			if(cnt[i]) continue;
			printf("%d ",i);
		}
		printf("\n");
	}
	return 0;
}


#include <cstdio>
#include <cstring>
#include <queue>
#include <algorithm>
#include <map>
#include <iostream>
#include <cstdlib>
#include <stack>
#define inf 0x3f3f3f3f
#define LL long long
#define inf64 0x3f3f3f3f3f3f3f3f
using namespace std;
typedef long long ll;
const int maxn = 2e6 + 10;
vector<int>G[maxn];
vector<int>E[maxn];
bool vss[maxn],cnt[maxn];
int vis[maxn];
int sum,now=0,n,m;

void dfs(int u,int pre){
	vis[u]=now;
	if(u<=n) sum--;
	for(int i=0;i<G[u].size();i++){
		int v=G[u][i];
		if(v==pre||vis[v]==now) continue;
		dfs(v,u);
	}
}

void dfs1(int u,int pre){
	vis[u]=now;
	if(u<=n) sum--;
	for(int i=0;i<E[u].size();i++){
		int v=E[u][i];
		if(v==pre||vis[v]==now) continue;
		dfs1(v,u);
	}
}

void dfsans(int u,int pre){
	cnt[u]=1;
	if(u<=n) printf("%d ",u);
	for(int i=0;i<G[u].size();i++){
		int v=G[u][i];
		if(v==pre||cnt[v]) continue;
		dfsans(v,u);
	}
}

void print(int u){
	printf("Yes\n");
	printf("%d %d\n",n-sum,sum);
	dfsans(u,0);
	printf("\n");
	for(int i=1;i<=n;i++){
		if(cnt[i]) continue;
		printf("%d ",i);
	}
	printf("\n");
}

int main(){
	int t;
	scanf("%d",&t);
	while(t--){
		now=0;
		scanf("%d%d",&n,&m);
		for(int i=1;i<=2*n;i++){
			G[i].clear();E[i].clear();
			vis[i]=cnt[i]=vss[i]=0;
		}
		for(int i=1;i<=n;i++) G[i+n].push_back(i),E[i].push_back(i+n);
		for(int i=1;i<=m;i++){
			int u,v;
			scanf("%d%d",&u,&v);
			G[u].push_back(v+n);
			E[v+n].push_back(u);
		}
		sum=n;
		now++;
		dfs(1,0);
		if(sum>0) {
			print(1);
			continue;
		}
		int ans=0;
		now++;
		dfs1(1,0);
		for(int i=1;i<=n;i++){
			if(vis[i]!=now){
				ans=i;
				break;
			}
		}
		if(ans==0){
			printf("No\n");
			continue;
		}
		sum=n;now++;
		dfs(ans,0);
		print(ans);
	}
	return 0;
}


#include <cstdio>
#include <cstring>
#include <queue>
#include <algorithm>
#include <map>
#include <iostream>
#include <cstdlib>
#include <stack>
#define inf 0x3f3f3f3f
#define LL long long
#define inf64 0x3f3f3f3f3f3f3f3f
using namespace std;
typedef long long ll;
const int maxn = 2e6 + 10;
vector<int>G[maxn];
int vis[maxn],vss[maxn];
bool cnt[maxn];

int sum,n,m,now=0,id;
void dfs(int u,int pre){
	vis[u]=now;
	if(u<=n) sum--;
	for(int i=0;i<G[u].size();i++){
		int v=G[u][i];
		if(v-n<id&&v>n) {
			vss[u]=1;sum=0;
			return ;
		}
		if(v-n==id&&v>n) vss[u]=1;
		if(v==pre||vis[v]==now) continue;
		if(v<id) {
			sum=0;return ;
		}
		dfs(v,u);
	}
}

void dfsans(int u,int pre){
	cnt[u]=1;
	if(u<=n) printf("%d ",u);
	for(int i=0;i<G[u].size();i++){
		int v=G[u][i];
		if(v==pre||cnt[v]) continue;
		dfsans(v,u);
	}
}

int main(){
	int t;
	scanf("%d",&t);
	while(t--){
		now=0,id=0;
		scanf("%d%d",&n,&m);
		for(int i=1;i<=2*n;i++){
			G[i].clear();
			vis[i]=cnt[i]=vss[i]=0;
		}
		for(int i=1;i<=n;i++) G[i+n].push_back(i);
		if(n==452308) printf("sss\n");
		for(int i=1;i<=m;i++){
			int u,v;
			scanf("%d%d",&u,&v);
			G[u].push_back(v+n);
		}
		for(int i=1;i<=2*n;i++) sort(G[i].begin(),G[i].end());
		int ans=0,p=0,q=0;
		for(int i=1;i<=n;i++){
			if(vss[i]) continue;
			sum=n;now++;id=i;
			dfs(i,0);
			if(sum>0){
				q=sum,p=n-sum,ans=i;
				break;
			}
		}
		if(ans==0){
			printf("No\n");
			continue;
		}
		printf("Yes\n");
		printf("%d %d\n",p,q);
		dfsans(ans,-1);
		printf("\n");
		for(int i=1;i<=n;i++){
			if(cnt[i]) continue;
			printf("%d ",i);
		}
		printf("\n");
	}
	return 0;
}


#include <cstdio>
#include <cstring>
#include <queue>
#include <algorithm>
#include <map>
#include <iostream>
#include <cstdlib>
#include <stack>
#define inf 0x3f3f3f3f
#define LL long long
#define inf64 0x3f3f3f3f3f3f3f3f
using namespace std;
typedef long long ll;
const int maxn = 2e6 + 10;
vector<int>G[maxn];
int vis[maxn];
bool cnt[maxn];
void add(int u,int v){
	G[u].push_back(v);
}
int sum,n,m,now=0,id;
void dfs(int u,int pre){
	if(u<id) {
		sum=0;
		return ;
	}
	vis[u]=now;
	if(u<=n) sum--;
	for(int i=0;i<G[u].size();i++){
		int v=G[u][i];
		if(v==pre||vis[v]==now) continue;
		if(v<id) {
			sum=0;
			return ;
		}
		dfs(v,u);
	}
}

void dfsans(int u,int pre){
	cnt[u]=1;
	if(u<=n) printf("%d ",u);
	for(int i=0;i<G[u].size();i++){
		int v=G[u][i];
		if(v==pre||cnt[v]) continue;
		dfsans(v,u);
	}
}

int main(){
	int t;
	scanf("%d",&t);
	while(t--){
		now=0,id=0;
		scanf("%d%d",&n,&m);
		for(int i=1;i<=2*n;i++){
			G[i].clear();
			vis[i]=0;
			cnt[i]=0;
		}
		for(int i=1;i<=n;i++) add(i+n,i);
		for(int i=1;i<=m;i++){
			int u,v;
			scanf("%d%d",&u,&v);
			add(u,v+n);
		}
		int ans=0,p=0,q=0;
		for(int i=1;i<=n;i++){
			sum=n;now++;
			id=i;
			dfs(i,-1);
			if(sum>0){
				q=sum,p=n-sum,ans=i;
				break;
			}
		}
		if(ans==0){
			printf("No\n");
			continue;
		}
		printf("Yes\n");
		printf("%d %d\n",p,q);
		dfsans(ans,-1);
		printf("\n");
		for(int i=1;i<=n;i++){
			if(cnt[i]) continue;
			printf("%d ",i);
		}
		printf("\n");
	}
	return 0;
}


#include <cstdio>
#include <cstring>
#include <queue>
#include <algorithm>
#include <map>
#include <iostream>
#include <cstdlib>
#include <stack>
#define inf 0x3f3f3f3f
#define LL long long
#define inf64 0x3f3f3f3f3f3f3f3f
using namespace std;
typedef long long ll;
const int maxn = 2e6 + 10;
vector<int>G[maxn];
int vis[maxn],vss[maxn];
bool cnt[maxn];

int sum,n,m,now=0,id;
void dfs(int u,int pre){
	vis[u]=now;
	if(u<=n) sum--;
	for(int i=0;i<G[u].size();i++){
		int v=G[u][i];
		if(v-n<id&&v>n) {
			vss[u]=1;sum=0;
			return ;
		}
		if(v-n==id&&v>n) vss[u]=1;
		if(v==pre||vis[v]==now) continue;
		dfs(v,u);
	}
}

void dfsans(int u,int pre){
	cnt[u]=1;
	if(u<=n) printf("%d ",u);
	for(int i=0;i<G[u].size();i++){
		int v=G[u][i];
		if(v==pre||cnt[v]) continue;
		dfsans(v,u);
	}
}

int main(){
	int t;
	scanf("%d",&t);
	while(t--){
		now=0,id=0;
		scanf("%d%d",&n,&m);
		for(int i=1;i<=2*n;i++){
			G[i].clear();
			vis[i]=cnt[i]=vss[i]=0;
		}
		for(int i=1;i<=n;i++) G[i+n].push_back(i);
		for(int i=1;i<=m;i++){
			int u,v;
			scanf("%d%d",&u,&v);
			G[u].push_back(v+n);
		}
		int ans=0,p=0,q=0;
		sum=n;now++;id=1;
		dfs(1,-1);
		for(int i=1;i<=n;i++){
			if(vss[i]) continue;
			sum=n;now++;id=i;
			dfs(i,0);
			if(sum>0){
				q=sum,p=n-sum,ans=i;
				break;
			}
		}
		if(ans==0){
			printf("No\n");
			continue;
		}
		printf("Yes\n");
		printf("%d %d\n",p,q);
		dfsans(ans,-1);
		printf("\n");
		for(int i=1;i<=n;i++){
			if(cnt[i]) continue;
			printf("%d ",i);
		}
		printf("\n");
	}
	return 0;
}


#include <cstdio>
#include <cstring>
#include <queue>
#include <algorithm>
#include <map>
#include <iostream>
#include <cstdlib>
#include <stack>
#define inf 0x3f3f3f3f
#define LL long long
#define inf64 0x3f3f3f3f3f3f3f3f
using namespace std;
typedef long long ll;
const int maxn = 2e6 + 10;
vector<int>G[maxn];
int vis[maxn],vss[maxn];
bool cnt[maxn];

int sum,n,m,now=0,id;
void dfs(int u,int pre){
	vis[u]=now;
	if(u<=n) sum--;
	for(int i=0;i<G[u].size();i++){
		int v=G[u][i];
		if(v-n<id&&v>n) {
			vss[u]=1;sum=0;
			return ;
		}
		if(v-n==id&&v>n) vss[u]=1;
		if(v==pre||vis[v]==now) continue;
		if(v<id) {
			sum=0;return ;
		}
		dfs(v,u);
	}
}

void dfsans(int u,int pre){
	cnt[u]=1;
	if(u<=n) printf("%d ",u);
	for(int i=0;i<G[u].size();i++){
		int v=G[u][i];
		if(v==pre||cnt[v]) continue;
		dfsans(v,u);
	}
}

int main(){
	int t;
	scanf("%d",&t);
	while(t--){
		now=0,id=0;
		scanf("%d%d",&n,&m);
		for(int i=1;i<=2*n;i++){
			G[i].clear();
			vis[i]=cnt[i]=vss[i]=0;
		}
		for(int i=1;i<=n;i++) G[i+n].push_back(i);
		for(int i=1;i<=m;i++){
			int u,v;
			scanf("%d%d",&u,&v);
			G[u].push_back(v+n);
		}
		for(int i=1;i<=2*n;i++) sort(G[i].begin(),G[i].end());
		int ans=0,p=0,q=0;
		for(int i=1;i<=n;i++){
			if(vss[i]) continue;
			sum=n;now++;id=i;
			dfs(i,0);
			if(sum>0){
				q=sum,p=n-sum,ans=i;
				break;
			}
		}
		if(ans==0){
			printf("No\n");
			continue;
		}
		printf("Yes\n");
		printf("%d %d\n",p,q);
		dfsans(ans,-1);
		printf("\n");
		for(int i=1;i<=n;i++){
			if(cnt[i]) continue;
			printf("%d ",i);
		}
		printf("\n");
	}
	return 0;
}


#include <cstdio>
#include <cstring>
#include <queue>
#include <algorithm>
#include <map>
#include <iostream>
#include <cstdlib>
#include <stack>
#define inf 0x3f3f3f3f
#define LL long long
#define inf64 0x3f3f3f3f3f3f3f3f
using namespace std;
typedef long long ll;
const int maxn = 2e6 + 10;
vector<int>G[maxn];
int vis[maxn],vss[maxn];
bool cnt[maxn];
void add(int u,int v){
	G[u].push_back(v);
}
int sum,n,m,now=0,id;
void dfs(int u,int pre){
	if(u<id) {
		sum=0;
		return ;
	}
	vis[u]=now;
	if(u<=n) sum--;
	for(int i=0;i<G[u].size();i++){
		int v=G[u][i];
		if(vis[v]==now&&v-n<=id&&v>n) vss[u]=1;
		if(v==pre||vis[v]==now) continue;
		if(v<id) {
			sum=0;
			return ;
		}
		dfs(v,u);
	}
}

void dfsans(int u,int pre){
	cnt[u]=1;
	if(u<=n) printf("%d ",u);
	for(int i=0;i<G[u].size();i++){
		int v=G[u][i];
		if(v==pre||cnt[v]) continue;
		dfsans(v,u);
	}
}

int main(){
	int t;
	scanf("%d",&t);
	while(t--){
		now=0,id=0;
		scanf("%d%d",&n,&m);
		for(int i=1;i<=2*n;i++){
			G[i].clear();
			vis[i]=cnt[i]=vss[i]=0;
		}
		for(int i=1;i<=n;i++) add(i+n,i);
		for(int i=1;i<=m;i++){
			int u,v;
			scanf("%d%d",&u,&v);
			add(u,v+n);
		}
		int ans=0,p=0,q=0;
		for(int i=1;i<=n;i++){
			if(vss[i]) continue;
			sum=n;now++;id=i;
			dfs(i,0);
			if(sum>0){
				q=sum,p=n-sum,ans=i;
				break;
			}
		}
		if(ans==0){
			printf("No\n");
			continue;
		}
		printf("Yes\n");
		printf("%d %d\n",p,q);
		dfsans(ans,-1);
		printf("\n");
		for(int i=1;i<=n;i++){
			if(cnt[i]) continue;
			printf("%d ",i);
		}
		printf("\n");
	}
	return 0;
}


#include <cstdio>
#include <cstring>
#include <queue>
#include <algorithm>
#include <map>
#include <iostream>
#include <cstdlib>
#include <stack>
#define inf 0x3f3f3f3f
#define LL long long
#define inf64 0x3f3f3f3f3f3f3f3f
using namespace std;
typedef long long ll;
const int maxn = 2e6 + 10;
vector<int>G[maxn];
int vis[maxn],vss[maxn];
bool cnt[maxn];
void add(int u,int v){
	G[u].push_back(v);
}
int sum,n,m,now=0,id;
void dfs(int u,int pre){
	if(u<id) {
		sum=0;
		return ;
	}
	vis[u]=now;
	if(u<=n) sum--;
	for(int i=0;i<G[u].size();i++){
		int v=G[u][i];
		if(vis[v]==now&&v-n==id) vss[u]=1;
		if(v==pre||vis[v]==now) continue;
		if(v<id) {
			sum=0;
			return ;
		}
		dfs(v,u);
	}
}

void dfsans(int u,int pre){
	cnt[u]=1;
	if(u<=n) printf("%d ",u);
	for(int i=0;i<G[u].size();i++){
		int v=G[u][i];
		if(v==pre||cnt[v]) continue;
		dfsans(v,u);
	}
}

int main(){
	int t;
	scanf("%d",&t);
	while(t--){
		now=0,id=0;
		scanf("%d%d",&n,&m);
		for(int i=1;i<=2*n;i++){
			G[i].clear();
			vis[i]=cnt[i]=vss[i]=0;
		}
		for(int i=1;i<=n;i++) add(i+n,i);
		for(int i=1;i<=m;i++){
			int u,v;
			scanf("%d%d",&u,&v);
			add(u,v+n);
		}
		int ans=0,p=0,q=0;
		for(int i=1;i<=n;i++){
			if(vss[i]) continue;
			sum=n;now++;
			id=i;
			dfs(i,0);
			if(sum>0){
				q=sum,p=n-sum,ans=i;
				break;
			}
		}
		if(ans==0){
			printf("No\n");
			continue;
		}
		printf("Yes\n");
		printf("%d %d\n",p,q);
		dfsans(ans,-1);
		printf("\n");
		for(int i=1;i<=n;i++){
			if(cnt[i]) continue;
			printf("%d ",i);
		}
		printf("\n");
	}
	return 0;
}


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

const int N = 100005 , M = 107;

#define fo(i , st , en) for (int i = st; i <= en; i++)
#define Me(x , y) memset(x , y , sizeof(x))

double f[N][M];
int n , q;
int a[N] , cur[N];

void Read(int &x){
    char c;
    while (c = getchar() , c < '0' || c > '9');
    x = c - '0';
    while (c = getchar() , c >= '0' && c <= '9') x = x * 10 + c - '0';
}

double C(int x , int y){
    double sum = 1;
    fo (i , x - y + 1 , x) sum *= i;
    fo (i , 2 , y) sum /= i;
    return sum;
}

void Init(){
    Read(n); Me(f , 0);
    fo (i , 1 , n){
        Read(a[i]); cur[i] = a[i]; f[i][a[i]] = 1;
    }
}

void Work(){
    Read(q); int u , v , k; double ans = 0;
    fo (i , 1 , n)
        if (!a[i]) ans += 1;
    fo (i , 1 , q){
        Read(u); Read(v); Read(k); ans -= f[u][0]; double tt = 1 / C(cur[u] , k);
        fo (j , 0 , a[u]){
            if (cur[u] >= j){
                fo (l , 1 , k)
                    if (j >= l && cur[u] - j >= k - l) f[u][j - l] += f[u][j] * C(j , l) * C(cur[u] - j , k - l) * tt;
                if (cur[u] - j >= k)
                    f[u][j] *= C(cur[u] - j , k) * tt;
                else
                    f[u][j] = 0;
            }
        }
        cur[u] -= k; cur[v] += k; ans += f[u][0]; printf("%.10lf\n" , ans);
    }

}

int main(){
    Init();
    Work();
    return 0;
}


#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
const int M=(int)1e5+5;
int n,m;
int a[M],tot[M];
double dp[M][105],p;
int main(){
	scanf("%d",&n);
	double ans=0;
	for(int i=1;i<=n;i++)scanf("%d",&a[i]),dp[i][a[i]]=1,tot[i]=a[i],ans+=dp[i][0];
	scanf("%d",&m);
	for(int i=1,x,y,v;i<=m;i++){
		scanf("%d %d %d",&x,&y,&v);
		ans-=dp[x][0];
		for(int j=1;j<=v;j++){
			for(int k=1;k<=a[x];k++){
				p=(double)k/tot[x];
				dp[x][k-1]+=dp[x][k]*p;
				dp[x][k]*=(1-p);
			}
			tot[x]--;
		}
		tot[y]+=v;
		ans+=dp[x][0];
		printf("%.12f\n",ans);
	}
	return 0;
}


#include <bits/stdc++.h>
//Damned if I don't take what I want.

using namespace std;

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

double calc(int a, int b, int x, int y){ // not tasted, tasted, from not tasted, from tasted
	if (x > a || y > b || x < 0 || y < 0) return 0;
	double ans = 1;

	for (int i = 0; i < x + y; i++){
		if (i < x) ans *= a - i, ans /= i + 1;
		if (i < y) ans *= b - i, ans /= i + 1;
		ans *= i + 1;
		ans /= a + b - i;
	}

	return ans;
}

const int MAXN = 1e5 + 100, MAXA = 110;

double dp[MAXN][MAXA], tmp[MAXA];
int a[MAXN];

int main(){
	ios::sync_with_stdio( false );
	cout.tie(0); cin.tie(0);

	cout << fixed << setprecision(10);

	int n; cin >> n;

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

	int q; cin >> q;
	while(q--){
		int u, v, k;
		cin >> u >> v >> k; u--; v--;
		ans -= dp[u][0];

		memcpy(tmp, dp[u], sizeof dp[u]);
		memset(dp[u], 0, sizeof dp[u]);

		for (int i = 0; i < MAXA; i++)
			for (int x = 0; x <= k && x <= i; x++) if(tmp[i]){
				int a = i, b = ::a[u] - a, y = k - x;
				//cerr << a << ", " << b << ", " << x << ", " << y << " : " << calc(a, b, x, y) << endl;
				dp[u][i - x] += tmp[i] * calc(a, b, x, y);
			}

		ans += dp[u][0];

		a[u] -= k;
		a[v] += k;
		cout << ans << "\n";

		/*for (int i = 0; i < n; i++, cerr << endl)
			for (int j = 0; j < MAXA; j++)
				cerr << dp[i][j] << ", ";
		cerr << endl;*/
	}

}


#include <bits/stdc++.h>
//Damned if I don't take what I want.

using namespace std;

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

double calc(int a, int b, int x, int y){ // not tasted, tasted, from not tasted, from tasted
	if (x > a || y > b || x < 0 || y < 0) return 0;
	double ans = 1;

	for (int i = 0; i < x + y; i++){
		if (i < x) ans *= a - i, ans /= i + 1;
		if (i < y) ans *= b - i, ans /= i + 1;
		ans *= i + 1;
		ans /= a + b - i;
	}

	return ans;
}

const int MAXN = 1e5 + 100, MAXA = 4;

double dp[MAXN][MAXA], tmp[MAXA];
int a[MAXN];

int main(){
	ios::sync_with_stdio( false );
	cout.tie(0); cin.tie(0);

	cout << fixed << setprecision(10);

	int n; cin >> n;

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

	int q; cin >> q;
	while(q--){
		int u, v, k;
		cin >> u >> v >> k; u--; v--;
		ans -= dp[u][0];

		memcpy(tmp, dp[u], sizeof dp[u]);
		memset(dp[u], 0, sizeof dp[u]);

		for (int i = 0; i < MAXA; i++)
			for (int x = 0; x <= k && x <= i; x++) if(tmp[i]){
				int a = i, b = ::a[u] - a, y = k - x;
				//cerr << a << ", " << b << ", " << x << ", " << y << " : " << calc(a, b, x, y) << endl;
				dp[u][i - x] += tmp[i] * calc(a, b, x, y);
			}

		ans += dp[u][0];

		a[u] -= k;
		a[v] += k;
		cout << ans << "\n";

		/*for (int i = 0; i < n; i++, cerr << endl)
			for (int j = 0; j < MAXA; j++)
				cerr << dp[i][j] << ", ";
		cerr << endl;*/
	}

}


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

double a[100010][101];
long long c[1000010][6];
int s[100010];
double b[101];

void doit(int u,int v,int k)
{
    memset(b,0,sizeof(b));
    for (int i=0;i<=100;i++)
        for (int j=0;j<=min(i,k);j++)
            b[i-j]+=a[u][i]*c[i][j]*c[s[u]-i][k-j]/c[s[u]][k];
    //k=j; N=s[u]; m=i; n=k;
    for (int i=0;i<=100;i++)
        a[u][i]=b[i];
    s[u]-=k;
    s[v]+=k;
}

int main()
{
    memset(c,0,sizeof(c));
    c[0][0]=1;
    for (int i=1;i<=1000000;i++)
        for (int j=0;j<=min(5,i);j++)
            if (j==0 || j==i) c[i][j]=1;
            else c[i][j]=c[i-1][j-1]+c[i-1][j];

    int n;
    scanf("%d",&n);
    for (int i=0;i<n;i++)
        scanf("%d",&s[i]);
    memset(a,0,sizeof(a));
    for (int i=0;i<n;i++)
        a[i][s[i]]=1;
    int q;
    scanf("%d",&q);
    double ans=0;
    for (int i=0;i<n;i++)
        ans+=a[i][0];
    for (int i=0;i<q;i++)
    {
        int u,v,k;
        scanf("%d%d%d",&u,&v,&k);
        u--,v--;
        double tmp=a[u][0];
        doit(u,v,k);
        ans+=a[u][0]-tmp;
        printf("%.12lf\n",ans);
        /*
        for (int i=0;i<n;i++)
            for (int j=0;j<=2;j++)
                printf("%d %d: %.12lf\n",i,j,a[i][j]);
        printf("\n");
        */
    }

    //system("pause");
    return 0;
}


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

#define N 100100
#define NN 5*N+10000
#define eps (1e-11)

int num[N];//sheng xia d panzi shu
long double lef[N][110];//sheng xia de ganjingpanzi  gailv
int n, q;

long double mid[110];
long double c[NN][6];

void pre()
{
	for(int i=0; i<NN; i++){
		c[i][0] = 1.0;
		for(int j=1; j<=min(i, 5); j++){
			c[i][j] = c[i][j-1]*(1.0*(i-j+1))/(1.0*j);
		}
	}
}

int main()
{
//	freopen("in.txt", "r", stdin);
//	freopen("out.txt", "w" ,stdout);
	pre();
	while(scanf("%d", &n)!=EOF){
		for(int i=0; i<n; i++)
			scanf("%d", &num[i]);
		for(int i=0; i<n; i++){
			for(int j=0; j<num[i] ;j++)
				lef[i][j] = 0.0;
			lef[i][num[i]] = 1.0;
		}
		long double ans = 0.0;
		scanf("%d", &q);
		int u, v, k;
		for(int i=0; i<q; i++){
			scanf("%d%d%d", &u, &v, &k);
			u--, v--;
			for(int j=0; j<=100; j++)
				mid[j] = 0.0;
			for(int l = 0; l<=100; l++){
				if(lef[u][l]<eps) continue;
				for(int chu = max(0, k-(num[u]-l)); chu<=min(k, l); chu++){
					mid[l-chu] += lef[u][l]*c[l][chu]*c[num[u]-l][k-chu]/c[num[u]][k];
				}
			}

			ans += mid[0]-lef[u][0];
			num[u]-=k;num[v]+=k;
			for(int j=0; j<=100; j++)
				lef[u][j] = mid[j];

			printf("%.11Lf\n", ans);//cout<<endl;
		}
	}
}


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

#define N 100100
#define NN 5*N+10000
#define eps (1e-11)

int num[N];//sheng xia d panzi shu
long double lef[N][110];//sheng xia de ganjingpanzi  gailv
int n, q;

long double mid[110];
long double c[NN][6];

void pre()
{
	for(int i=0; i<NN; i++){
		c[i][0] = 1.0;
		for(int j=1; j<=min(i, 5); j++){
			c[i][j] = c[i][j-1]*(1.0*(i-j+1))/(1.0*j);
		}
	}
}

int main()
{
//	freopen("in.txt", "r", stdin);
//	freopen("out.txt", "w" ,stdout);
	pre();
	while(scanf("%d", &n)!=EOF){
		for(int i=0; i<n; i++)
			scanf("%d", &num[i]);
		for(int i=0; i<n; i++){
			for(int j=0; j<num[i] ;j++)
				lef[i][j] = 0.0;
			lef[i][num[i]] = 1.0;
		}
		long double ans = 0.0;
		scanf("%d", &q);
		int u, v, k;
		for(int i=0; i<q; i++){
			scanf("%d%d%d", &u, &v, &k);
			u--, v--;
			for(int j=0; j<=100; j++)
				mid[j] = 0.0;
			for(int l = 0; l<=100; l++){
				if(lef[u][l]<eps) continue;
				for(int chu = max(0, k-(num[u]-l)); chu<=min(k, l); chu++){
					mid[l-chu] += lef[u][l]*c[l][chu]*c[num[u]-l][k-chu]/c[num[u]][k];
				}
			}

			ans += mid[0]-lef[u][0];
			num[u]-=k;num[v]+=k;
			for(int j=0; j<=100; j++)
				lef[u][j] = mid[j];

			printf("%.11llf\n", ans);//cout<<endl;
		}
	}
}


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

#define N 100100
#define NN 5*N+10000
#define eps (1e-11)

int num[N];//sheng xia d panzi shu
double lef[N][110];//sheng xia de ganjingpanzi  gailv
int n, q;

double mid[110];
double c[NN][6];

void pre()
{
	for(int i=0; i<NN; i++){
		c[i][0] = 1.0;
		for(int j=1; j<=min(i, 5); j++){
			c[i][j] = c[i][j-1]*(1.0*(i-j+1))/(1.0*j);
		}
	}
}

int main()
{
//	freopen("in.txt", "r", stdin);
//	freopen("out.txt", "w" ,stdout);
	pre();
	while(scanf("%d", &n)!=EOF){
		for(int i=0; i<n; i++)
			scanf("%d", &num[i]);
		for(int i=0; i<n; i++){
			for(int j=0; j<num[i] ;j++)
				lef[i][j] = 0.0;
			lef[i][num[i]] = 1.0;
		}
		/*for(int i=0; i<n; i++)
			{
				cout<<num[i]<<endl;
				for(int j=0; j<=num[i]; j++)
					cout<<lef[i][j]<<' ';
					cout<<endl;
			}*/
		double ans = 0.0;
		scanf("%d", &q);
		int u, v, k;
		//cout<<"hehe\n";
		for(int i=0; i<q; i++){
			scanf("%d%d%d", &u, &v, &k);
			u--, v--;
			//for(int j=0; j<6; j++)
			//	cout<<lef[u][j]<<' ';cout<<endl;
			for(int j=0; j<=100; j++)
				mid[j] = 0.0;
			for(int l = 0; l<=100; l++){
				if(lef[u][l]<eps) continue;
				for(int chu = max(0, k-(num[u]-l)); chu<=min(k, l); chu++){
					mid[l-chu] += lef[u][l]*c[l][chu]*c[num[u]-l][k-chu]/c[num[u]][k];
				}
			}

			ans += mid[0]-lef[u][0];
			//cout<<"hehe "<<mid[0]<<' '<<lef[u][0]<<' '<<ans<<endl;
			num[u]-=k;num[v]+=k;
			for(int j=0; j<=100; j++)
				lef[u][j] = mid[j];

			//for(int j=0; j<6; j++)
			//	cout<<lef[u][j]<<' ';cout<<endl;
			printf("%.11lf\n", ans);//cout<<endl;
		}
	}
}


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

#define N 100100
#define NN 5*N+10000
#define eps (1e-11)

int num[N];//sheng xia d panzi shu
long double lef[N][110];//sheng xia de ganjingpanzi  gailv
int n, q;

long double mid[110];
long double c[NN][6];

void pre()
{
	for(int i=0; i<NN; i++){
		c[i][0] = 1.0;
		for(int j=1; j<=min(i, 5); j++){
			c[i][j] = c[i][j-1]*(1.0*(i-j+1))/(1.0*j);
		}
	}
}

int main()
{
//	freopen("in.txt", "r", stdin);
//	freopen("out.txt", "w" ,stdout);
	pre();
	while(scanf("%d", &n)!=EOF){
		for(int i=0; i<n; i++)
			scanf("%d", &num[i]);
		for(int i=0; i<n; i++){
			for(int j=0; j<num[i] ;j++)
				lef[i][j] = 0.0;
			lef[i][num[i]] = 1.0;
		}
		double ans = 0.0;
		for(int i=0; i<n; i++)
			ans+=(num[i]==0);
		scanf("%d", &q);
		int u, v, k;
		for(int i=0; i<q; i++){
			scanf("%d%d%d", &u, &v, &k);
			u--, v--;
			for(int j=0; j<=100; j++)
				mid[j] = 0.0;
			for(int l = 0; l<=100; l++){
				if(lef[u][l]<eps) continue;
				for(int chu = max(0, k-(num[u]-l)); chu<=min(k, l); chu++){
					mid[l-chu] += lef[u][l]*c[l][chu]*c[num[u]-l][k-chu]/c[num[u]][k];
				}
			}

			ans += mid[0]-lef[u][0];
			num[u]-=k;num[v]+=k;
			for(int j=0; j<=100; j++)
				lef[u][j] = mid[j];
			if(ans<eps)printf("0.0000000000\n");
			else	printf("%.11lf\n", ans);//cout<<endl;
		}
	}
}


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

#define N 100100
#define NN 5*N+10000
#define eps (1e-11)

int num[N];//sheng xia d panzi shu
long double lef[N][110];//sheng xia de ganjingpanzi  gailv
int n, q;

long double mid[110];
long double c[NN][6];

void pre()
{
	for(int i=0; i<NN; i++){
		c[i][0] = 1.0;
		for(int j=1; j<=min(i, 5); j++){
			c[i][j] = c[i][j-1]*(1.0*(i-j+1))/(1.0*j);
		}
	}
}

int main()
{
//	freopen("in.txt", "r", stdin);
//	freopen("out.txt", "w" ,stdout);
	pre();
	while(scanf("%d", &n)!=EOF){
		for(int i=0; i<n; i++)
			scanf("%d", &num[i]);
		for(int i=0; i<n; i++){
			for(int j=0; j<num[i] ;j++)
				lef[i][j] = 0.0;
			lef[i][num[i]] = 1.0;
		}
		double ans = 0.0;
		scanf("%d", &q);
		int u, v, k;
		for(int i=0; i<q; i++){
			scanf("%d%d%d", &u, &v, &k);
			u--, v--;
			for(int j=0; j<=100; j++)
				mid[j] = 0.0;
			for(int l = 0; l<=100; l++){
				if(lef[u][l]<eps) continue;
				for(int chu = max(0, k-(num[u]-l)); chu<=min(k, l); chu++){
					mid[l-chu] += lef[u][l]*c[l][chu]*c[num[u]-l][k-chu]/c[num[u]][k];
				}
			}

			ans += mid[0]-lef[u][0];
			num[u]-=k;num[v]+=k;
			for(int j=0; j<=100; j++)
				lef[u][j] = mid[j];
			if(ans<eps)printf("0.0000000000\n");
			else	printf("%.11lf\n", ans);//cout<<endl;
		}
	}
}


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

#define N 100100
#define NN 5*N+10000
#define eps (1e-11)

int num[N];//sheng xia d panzi shu
long double lef[N][110];//sheng xia de ganjingpanzi  gailv
int n, q;

long double mid[110];
long double c[NN][6];

void pre()
{
	for(int i=0; i<NN; i++){
		c[i][0] = 1.0;
		for(int j=1; j<=min(i, 5); j++){
			c[i][j] = c[i][j-1]*(1.0*(i-j+1))/(1.0*j);
		}
	}
}

int main()
{
//	freopen("in.txt", "r", stdin);
//	freopen("out.txt", "w" ,stdout);
	pre();
	while(scanf("%d", &n)!=EOF){
		for(int i=0; i<n; i++)
			scanf("%d", &num[i]);
		for(int i=0; i<n; i++){
			for(int j=0; j<num[i] ;j++)
				lef[i][j] = 0.0;
			lef[i][num[i]] = 1.0;
		}
		/*for(int i=0; i<n; i++)
			{
				cout<<num[i]<<endl;
				for(int j=0; j<=num[i]; j++)
					cout<<lef[i][j]<<' ';
					cout<<endl;
			}*/
		double ans = 0.0;
		scanf("%d", &q);
		int u, v, k;
		//cout<<"hehe\n";
		for(int i=0; i<q; i++){
			scanf("%d%d%d", &u, &v, &k);
			u--, v--;
			//for(int j=0; j<6; j++)
			//	cout<<lef[u][j]<<' ';cout<<endl;
			for(int j=0; j<=100; j++)
				mid[j] = 0.0;
			for(int l = 0; l<=100; l++){
				if(lef[u][l]<eps) continue;
				for(int chu = max(0, k-(num[u]-l)); chu<=min(k, l); chu++){
					mid[l-chu] += lef[u][l]*c[l][chu]*c[num[u]-l][k-chu]/c[num[u]][k];
				}
			}

			ans += mid[0]-lef[u][0];
			//cout<<"hehe "<<mid[0]<<' '<<lef[u][0]<<' '<<ans<<endl;
			num[u]-=k;num[v]+=k;
			for(int j=0; j<=100; j++)
				lef[u][j] = mid[j];

			//for(int j=0; j<6; j++)
			//	cout<<lef[u][j]<<' ';cout<<endl;
			printf("%.11lf\n", ans);//cout<<endl;
		}
	}
}


#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <iostream>
using namespace std;

const int MAXN = 101010;

int n;
int q;
int a[MAXN];
int u, v, k;
double f[MAXN][111], ans = 0;
int g[MAXN];
double c[501010][6];
double cur[111];

void pre()
{
	c[0][0] = 1;
	for(int i = 1; i <= 500000; ++i)
	{
		c[i][0] = 1;
		for(int j = 1; j <= 5; ++j)
			c[i][j] = c[i - 1][j - 1] + c[i - 1][j];
	}
}

int main()
{
	pre();
	scanf("%d", &n);
	for(int i = 1; i <= n; ++i)
	{
		scanf("%d", &a[i]);
		f[i][a[i]] = 1;
		g[i] = a[i];
	}
	scanf("%d", &q);
	for(int i = 1; i <= n; ++i)
	{
		ans += f[i][0];
	}

	for(int i = 1; i <= q; ++i)
	{
		scanf("%d%d%d", &u, &v, &k);
		memset(cur, 0, sizeof(cur));
		int maxto = min(a[u], g[u]);

		for(int j = 0; j <= maxto; ++j)
		{
			for(int p = 0; p <= k; ++p)
			{
				if(j >= p)
					cur[j - p] += f[u][j] * c[j][p] * c[g[u] - j][k - p] / c[g[u]][k];
			}
		}
		ans += cur[0] - f[u][0];
		for(int j = 0; j <= 100; ++j)
		{
			f[u][j] = cur[j];
		//	cout<<cur[j]<<" ";
		}
		//cout<<endl;
		g[u] -= k;
		g[v] += k;
		printf("%.12lf\n", ans);
	}

	return 0;
}


#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <iostream>
using namespace std;

const int MAXN = 101010;

int n;
int q;
int a[MAXN];
int u, v, k;
double f[MAXN][111], ans = 0;
int g[MAXN];
double c[501010][6];
double cur[111];

void pre()
{
	c[0][0] = 1;
	for(int i = 1; i <= 500000; ++i)
	{
		c[i][0] = 1;
		for(int j = 1; j <= 5; ++j)
			c[i][j] = c[i - 1][j - 1] + c[i - 1][j];
	}
}

int main()
{
	pre();
	scanf("%d", &n);
	for(int i = 1; i <= n; ++i)
	{
		scanf("%d", &a[i]);
		f[i][a[i]] = 1;
		g[i] = a[i];
	}
	scanf("%d", &q);
	for(int i = 1; i <= n; ++i)
	{
		ans += f[i][0];
	}

	for(int i = 1; i <= q; ++i)
	{
		scanf("%d%d%d", &u, &v, &k);
		memset(cur, 0, sizeof(cur));
		for(int j = 0; j <= a[u]; ++j)
		{
			for(int p = 0; p <= k; ++p)
			{
				if(j >= p)
					cur[j - p] += f[u][j] * c[j][p] * c[g[u] - j][k - p] / c[g[u]][k];
			}
		}
		ans += cur[0] - f[u][0];
		for(int j = 0; j <= 100; ++j)
		{
			f[u][j] = cur[j];
		//	cout<<cur[j]<<" ";
		}
		//cout<<endl;
		g[u] -= k;
		g[v] += k;
		printf("%.12lf\n", ans);
	}

	return 0;
}


#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <iostream>
using namespace std;

const int MAXN = 101010;

int n;
int q;
int a[MAXN];
int u, v, k;
long double f[MAXN][111], ans = 0;
int g[MAXN];
long double c[501010][6];
long double cur[111];

void pre()
{
	c[0][0] = 1;
	for(int i = 1; i <= 500000; ++i)
	{
		c[i][0] = 1;
		for(int j = 1; j <= 5; ++j)
			c[i][j] = c[i - 1][j - 1] + c[i - 1][j];
	}
}

int main()
{
	pre();
	scanf("%d", &n);
	for(int i = 1; i <= n; ++i)
	{
		scanf("%d", &a[i]);
		f[i][a[i]] = 1;
		g[i] = a[i];
	}
	scanf("%d", &q);
	for(int i = 1; i <= n; ++i)
	{
		ans += f[i][0];
	}

	for(int i = 1; i <= q; ++i)
	{
		scanf("%d%d%d", &u, &v, &k);
		memset(cur, 0, sizeof(cur));
		for(int j = 0; j <= a[u]; ++j)
		{
			for(int p = 0; p <= k; ++p)
			{
				if(j >= p)
					cur[j - p] += f[u][j] * c[j][p] * c[g[u] - j][k - p] / c[g[u]][k];
			}
		}
		ans += cur[0] - f[u][0];
		for(int j = 0; j <= 100; ++j)
		{
			f[u][j] = cur[j];
		//	cout<<cur[j]<<" ";
		}
		//cout<<endl;
		g[u] -= k;
		g[v] += k;
		printf("%.12lf\n", (double)ans);
	}

	return 0;
}


#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <iostream>
using namespace std;

const int MAXN = 101010;

int n;
int q;
int a[MAXN];
int u, v, k;
long double f[MAXN][111], ans = 0;
int g[MAXN];
int c[501010][6];
long double cur[111];

void pre()
{
	c[0][0] = 1;
	for(int i = 1; i <= 500000; ++i)
	{
		c[i][0] = 1;
		for(int j = 1; j <= 5; ++j)
			c[i][j] = c[i - 1][j - 1] + c[i - 1][j];
	}
}

int main()
{
	pre();
	scanf("%d", &n);
	for(int i = 1; i <= n; ++i)
	{
		scanf("%d", &a[i]);
		f[i][a[i]] = 1;
		g[i] = a[i];
	}
	scanf("%d", &q);
	for(int i = 1; i <= n; ++i)
	{
		ans += f[i][0];
	}

	for(int i = 1; i <= q; ++i)
	{
		scanf("%d%d%d", &u, &v, &k);
		memset(cur, 0, sizeof(cur));
		for(int j = 0; j <= a[u]; ++j)
		{
			for(int p = 0; p <= k; ++p)
			{
				if(j >= p)
					cur[j - p] += f[u][j] * c[j][p] * c[g[u] - j][k - p] / c[g[u]][k];
			}
		}
		ans += cur[0] - f[u][0];
		for(int j = 0; j <= 100; ++j)
		{
			f[u][j] = cur[j];
		//	cout<<cur[j]<<" ";
		}
		//cout<<endl;
		g[u] -= k;
		g[v] += k;
		printf("%.12lf\n", (double)ans);
	}

	return 0;
}


#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
using namespace std;
#define ll long long
#define MAX 100100
inline int read()
{
	int x=0;bool t=false;char ch=getchar();
    while((ch<'0'||ch>'9')&&ch!='-')ch=getchar();
    if(ch=='-')t=true,ch=getchar();
    while(ch<='9'&&ch>='0')x=x*10+ch-48,ch=getchar();
    return t?-x:x;
}
double f[MAX][111],ans;
int n,q,a[MAX],b[MAX];
double C(int n,int m)
{
	if(n<m)return 0;
	double ret=1;
	for(int i=1;i<=m;++i)ret=ret*(1.0*(n-i+1)/i);
	return ret;
}
int main()
{
	n=read();
	for(int i=1;i<=n;++i)a[i]=b[i]=read();
	for(int i=1;i<=n;++i)f[i][a[i]]=1;
	for(int i=1;i<=n;++i)ans+=f[i][0];
	q=read();
	for(int i=1;i<=q;++i)
	{
		int u=read(),v=read(),K=read();ans-=f[u][0];
		for(int j=0;j<=a[u];++j)
		{
			double g=0,tt=C(b[u],K);
			for(int k=0;k<=K;++k)g+=f[u][j+k]*C(j+k,k)*C(b[u]-j-k,K-k)/tt;
			f[u][j]=g;
		}
		b[u]-=K;b[v]+=K;ans+=f[u][0];
		printf("%.10lf\n",ans);
	}
	return 0;
}


#include<stdio.h>
#include<string.h>
#include<math.h>
#include<iostream>
#include<algorithm>
#include<vector>
#include<map>
#include<set>
#include<queue>
using namespace std;
typedef long long lld;
int sum[100010];
double dp[100010][110];
double c(int x,int y)
{
	if(x < y)
		return 0;
	double tmp=1.0;
	while(y > 0)
	{
		tmp*=1.0*x;
		tmp/=1.0*y;
		x--;
		y--;
	}
	return tmp;
}
double mark[110];
int main()
{
	int n;
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
		scanf("%d",&sum[i]);
	memset(dp,0,sizeof(dp));
	for(int i=1;i<=n;i++)
		dp[i][sum[i]]=1.0;
	double ans=0;
	int Q;
	scanf("%d",&Q);
	while(Q--)
	{
		int x,y,s;
		scanf("%d %d %d",&x,&y,&s);
		ans-=dp[x][0];
		memset(mark,0,sizeof(mark));
		for(int i=0;i<110;i++)
		{
			if(dp[x][i] == 0)
				continue;
			int j=sum[x]-i;
			for(int k=0;k<=s;k++)
			{
				int ai=k;
				int aj=s-k;
				if(ai > i || aj > j)
					continue;
				double p=c(i,ai)*c(j,aj)/c(sum[x],k);
				p*=dp[x][i];
				mark[i-ai]+=p;
			}
		}
		for(int i=0;i<110;i++)
			dp[x][i]=mark[i];
		ans+=dp[x][0];
		sum[x]-=s;
		sum[y]+=s;
		printf("%.12f\n",ans);
	}
	return 0;
}


#include<stdio.h>
#include<string.h>
#include<math.h>
#include<iostream>
#include<algorithm>
#include<vector>
#include<map>
#include<set>
#include<queue>
using namespace std;
typedef long long lld;
int sum[100010];
double dp[100010][110];
double c(int x,int y)
{
    if(x < y)
        return 0;
    if(y == 0)
        return 1.0;
    double tmp=1.0;
    while(y > 0)
    {
        tmp*=1.0*x;
        tmp/=1.0*y;
        x--;
        y--;
    }
    return tmp;
}
double mark[110];
int main()
{
    int n;
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
        scanf("%d",&sum[i]);
    memset(dp,0,sizeof(dp));
    for(int i=1;i<=n;i++)
        dp[i][sum[i]]=1.0;
    double ans=0;
    int Q;
    scanf("%d",&Q);
    while(Q--)
    {
        int x,y,s;
        scanf("%d %d %d",&x,&y,&s);
        ans-=dp[x][0];
        memset(mark,0,sizeof(mark));
        for(int i=0;i<110;i++)
        {
            if(dp[x][i] == 0)
                continue;
            int j=sum[x]-i;
            for(int k=0;k<=s;k++)
            {
                int ai=k;
                int aj=s-k;
                if(ai > i || aj > j)
                    continue;
                double p=c(i,ai)*c(j,aj)/c(sum[x],s);
                p*=dp[x][i];
                mark[i-ai]+=p;
            }
        }
        for(int i=0;i<110;i++)
            dp[x][i]=mark[i];
        ans+=dp[x][0];
        sum[x]-=s;
        sum[y]+=s;
        printf("%.12f\n",ans);
    }
    return 0;
}


#include<stdio.h>
#include<string.h>
#include<math.h>
#include<iostream>
#include<algorithm>
#include<vector>
#include<map>
#include<set>
#include<queue>
using namespace std;
typedef long long lld;
int sum[100010];
double dp[100010][110];
double c(int x,int y)
{
    if(x < y)
        return 0;
    if(y == 0)
        return 1.0;
    double tmp=1.0;
    while(y > 0)
    {
        tmp*=1.0*x;
        tmp/=1.0*y;
        x--;
        y--;
    }
    return tmp;
}
double mark[110];
int main()
{
    int n;
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
        scanf("%d",&sum[i]);
    memset(dp,0,sizeof(dp));
    double ans=0;
    for(int i=1;i<=n;i++)
    {
        dp[i][sum[i]]=1.0;
        if(sum[i] == 0)
            ans+=1.0;
    }
    int Q;
    scanf("%d",&Q);
    while(Q--)
    {
        int x,y,s;
        scanf("%d %d %d",&x,&y,&s);
        ans-=dp[x][0];
        memset(mark,0,sizeof(mark));
        for(int i=0;i<110;i++)
        {
            if(dp[x][i] == 0)
                continue;
            int j=sum[x]-i;
            for(int k=0;k<=s;k++)
            {
                int ai=k;
                int aj=s-k;
                if(ai > i || aj > j)
                    continue;
                double p=c(i,ai)*c(j,aj)/c(sum[x],s);
                p*=dp[x][i];
                mark[i-ai]+=p;
            }
        }
        for(int i=0;i<110;i++)
            dp[x][i]=mark[i];
        ans+=dp[x][0];
        sum[x]-=s;
        sum[y]+=s;
        printf("%.12f\n",ans);
    }
    return 0;
}


#include<cstdio>
#include<cstdlib>
#include<algorithm>
#define foru(i,a,b) for(int i=a;i<=b;++i)
#define S(a) scanf("%d",&a)

using namespace std;
double ans,f[100001][101],g[101],q[6],p[6];
int n,m,a[100001],b[100001],c[6][6],aa,bb,cc;
int min(int a,int b){return a<b?a:b;}
int main()
{
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	S(n);
	foru(i,1,n) S(a[i]),f[i][a[i]]=1,b[i]=a[i],ans+=!a[i];
	S(m); c[0][0]=1;
	foru(i,1,5) c[i][0]=1;
	foru(i,1,5)
	  foru(j,1,i) c[i][j]=c[i-1][j]+c[i-1][j-1];
	while(m--)
	{
		S(aa),S(bb),S(cc);
		foru(i,0,min(a[aa],b[aa])) g[i]=0;
		foru(i,0,min(a[aa],b[aa]))
		{

			q[0]=1; foru(j,1,5) q[j]=q[j-1]*(i-j+1);
			p[0]=1; foru(j,1,5) p[j]=p[j-1]*(a[aa]-i-j+1);
			double x=1; foru(j,1,cc) x*=(a[aa]-j+1);
			foru(j,0,min(cc,i))
			  if(cc-j<=a[aa]-i) g[i-j]+=f[aa][i]*c[cc][j]*q[j]*p[cc-j]/x;
		}
		ans+=g[0]-f[aa][0]; a[aa]-=cc; a[bb]+=cc;
		foru(j,0,b[aa]) f[aa][j]=g[j];
		printf("%.9lf\n",ans);
	}
	return 0;
}


#include<cstdio>
#include<cstdlib>
#include<algorithm>
#define foru(i,a,b) for(int i=a;i<=b;++i)
#define S(a) scanf("%d",&a)

using namespace std;
double ans,f[100001][101];
int n,m,a[100001],b[100001],aa,bb,cc;
int min(int a,int b){return a<b?a:b;}
int main()
{
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	S(n);
	foru(i,1,n) S(a[i]),f[i][a[i]]=1,b[i]=a[i],ans+=!a[i];
	S(m);
	while(m--)
	{
		S(aa),S(bb),S(cc);
		ans-=f[aa][0];
		foru(i,1,cc)
		{
			foru(j,0,min(b[aa],a[aa]))	f[aa][j]=(f[aa][j]*(a[aa]-j)+f[aa][j+1]*(j+1))/a[aa];
			--a[aa];
		}
		//printf("%lf\n",f[aa][0]);
		ans+=f[aa][0]; a[bb]+=cc;
		printf("%.10lf\n",ans);
	}
	return 0;
}


#include<cstdio>
#include<cstdlib>
#include<algorithm>
#define foru(i,a,b) for(int i=a;i<=b;++i)
#define S(a) scanf("%d",&a)

using namespace std;
double ans,f[100001][101],g[101],q[6],p[6];
int n,m,a[100001],b[100001],c[6][6],aa,bb,cc;
int min(int a,int b){return a<b?a:b;}
int main()
{
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	S(n);
	foru(i,1,n) S(a[i]),f[i][a[i]]=1,b[i]=a[i],ans+=!a[i];
	S(m); c[0][0]=1;
	foru(i,1,5) c[i][0]=1;
	foru(i,1,5)
	  foru(j,1,i) c[i][j]=c[i-1][j]+c[i-1][j-1];
	ans=0;
	while(m--)
	{
		S(aa),S(bb),S(cc);
		foru(i,0,min(a[aa],b[aa])) g[i]=0;
		foru(i,0,min(a[aa],b[aa]))
		{

			q[0]=1; foru(j,1,5) q[j]=q[j-1]*(i-j+1);
			p[0]=1; foru(j,1,5) p[j]=p[j-1]*(a[aa]-i-j+1);
			double x=1; foru(j,1,cc) x*=(a[aa]-j+1);
			foru(j,0,min(cc,i))
			  if(cc-j<=a[aa]-i) g[i-j]+=f[aa][i]*c[cc][j]*q[j]*p[cc-j]/x;
		}
		ans+=g[0]-f[aa][0]; a[aa]-=cc; a[bb]+=cc;
		foru(j,0,b[aa]) f[aa][j]=g[j];
		printf("%.9lf\n",ans);
	}
	return 0;
}


#include<cstdio>
#include<cstdlib>
#include<algorithm>
#define foru(i,a,b) for(int i=a;i<=b;++i)
#define S(a) scanf("%d",&a)

using namespace std;
double ans,f[100001][101];
int n,m,a[100001],b[100001],aa,bb,cc;
int min(int a,int b){return a<b?a:b;}
int main()
{
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	S(n);
	foru(i,1,n) S(a[i]),f[i][a[i]]=1,b[i]=a[i],ans+=!a[i];
	S(m);
	while(m--)
	{
		S(aa),S(bb),S(cc);
		ans-=f[aa][0];
		foru(i,1,cc)
		{
			foru(j,0,min(b[aa],a[aa]))	f[aa][j]=f[aa][j]*(a[aa]-j)/a[aa]+f[aa][j+1]*(j+1)/a[aa];
			--a[aa];
		}
		//printf("%lf\n",f[aa][0]);
		ans+=f[aa][0]; a[bb]+=cc;
		printf("%.10lf\n",ans);
	}
	return 0;
}


#include<cstdio>
#include<cstdlib>
#include<algorithm>
#define foru(i,a,b) for(int i=a;i<=b;++i)
#define S(a) scanf("%d",&a)

using namespace std;
double ans,f[100001][101],g[101],q[6],p[6];
int n,m,a[100001],b[100001],c[6][6],aa,bb,cc;
int min(int a,int b){return a<b?a:b;}
int main()
{
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	S(n);
	foru(i,1,n) S(a[i]),f[i][a[i]]=1,b[i]=a[i];
	S(m); c[0][0]=1;
	foru(i,1,5) c[i][0]=1;
	foru(i,1,5)
	  foru(j,1,i) c[i][j]=c[i-1][j]+c[i-1][j-1];
	ans=0;
	while(m--)
	{
		S(aa),S(bb),S(cc);
		foru(i,0,min(a[aa],b[aa])) g[i]=0;
		foru(i,0,min(a[aa],b[aa]))
		{

			q[0]=1; foru(j,1,5) q[j]=q[j-1]*(i-j+1);
			p[0]=1; foru(j,1,5) p[j]=p[j-1]*(a[aa]-i-j+1);
			double x=1; foru(j,1,cc) x*=(a[aa]-j+1);
			foru(j,0,min(cc,i))
			  if(cc-j<=a[aa]-i) g[i-j]+=f[aa][i]*c[cc][j]*q[j]*p[cc-j]/x;
		}
		ans+=g[0]-f[aa][0]; a[aa]-=cc; a[bb]+=cc;
		foru(j,0,b[aa]) f[aa][j]=g[j];
		printf("%.9lf\n",ans);
	}
	return 0;
}


#include<cstdio>
#include<cstdlib>
#include<algorithm>
#define foru(i,a,b) for(int i=a;i<=b;++i)
#define S(a) scanf("%d",&a)

using namespace std;
double ans,f[100010][110];
int n,m,a[100010],b[100010],aa,bb,cc;
int min(int a,int b){return a<b?a:b;}
int main()
{
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	S(n);
	foru(i,1,n) S(a[i]),f[i][a[i]]=1,b[i]=a[i],ans+=!a[i];
	S(m);
	while(m--)
	{
		S(aa),S(bb),S(cc);

		foru(i,1,cc)
		{
			ans-=f[aa][0];
			foru(j,0,min(b[aa],a[aa])) f[aa][j]=(f[aa][j]*(a[aa]-j)+f[aa][j+1]*(j+1))/a[aa];
			--a[aa];
			ans+=f[aa][0];
		}
		//printf("%lf\n",f[aa][0]);
		 a[bb]+=cc;
		printf("%.10lf\n",ans);
	}
	return 0;
}


#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <cstring>
using namespace std;
int get()
{
	int f=0,v=0;char ch;
	while(!isdigit(ch=getchar()))if(ch=='-')break;
	if(ch=='-')f=1;else v=ch-'0';
	while(isdigit(ch=getchar()))v=v*10+ch-'0';
	if(f)return -v;else return v;
}
const int maxn=100003,maxk=103;
double p[maxn][maxk],ans=0;
int n,T,a[maxn];
int main()
{
	n=get();
	for(int i=1;i<=n;i++)p[i][a[i]=get()]=1,ans+=(!a[i]);
	T=get();
	while(T--)
	{
		int x=get(),y=get(),k=get();
		ans-=p[x][0];
		for(int j=1;j<=k;j++)
		{
			for(int i=0;i<a[x];i++)
				p[x][i]=p[x][i]*(a[x]-i)/a[x]+p[x][i+1]*(i+1)/a[x];
			p[x][a[x]--]=0;
		}
		a[y]+=k;
		printf("%.10lf\n",ans+=p[x][0]);
	}
	return 0;
}


#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <cstring>
using namespace std;
int get()
{
	int f=0,v=0;char ch;
	while(!isdigit(ch=getchar()))if(ch=='-')break;
	if(ch=='-')f=1;else v=ch-'0';
	while(isdigit(ch=getchar()))v=v*10+ch-'0';
	if(f)return -v;else return v;
}
const int maxn=100003,maxk=103;
double p[maxn][maxk],ans=0;
int n,T,a[maxn],b[maxn];
int main()
{
	n=get();
	for(int i=1;i<=n;i++)p[i][b[i]=a[i]=get()]=1,ans+=(!a[i]);
	T=get();
	while(T--)
	{
		int x=get(),y=get(),k=get();
		ans-=p[x][0];
		for(int j=1;j<=k;j++)
		{
			for(int i=0;i<=b[x];i++)
				p[x][i]=p[x][i]*(a[x]-i)/a[x]+p[x][i+1]*(i+1)/a[x];
			a[x]--;
			//p[x][a[x]--]=0;
		}
		a[y]+=k;
		printf("%.10lf\n",ans+=p[x][0]);
	}
	return 0;
}


#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <cstring>
using namespace std;
int get()
{
	int f=0,v=0;char ch;
	while(!isdigit(ch=getchar()))if(ch=='-')break;
	if(ch=='-')f=1;else v=ch-'0';
	while(isdigit(ch=getchar()))v=v*10+ch-'0';
	if(f)return -v;else return v;
}
const int maxn=100003,maxk=103;
double p[maxn][maxk],ans=0;
int n,T,a[maxn],b[maxn];
int main()
{
	n=get();
	for(int i=1;i<=n;i++)p[i][b[i]=a[i]=get()]=1,ans+=(!a[i]);
	T=get();
	while(T--)
	{
		int x=get(),y=get(),k=get(),t=a[x];
		ans-=p[x][0];
		for(int j=1;j<=k;j++,t--)
			for(int i=0;i<=b[x];i++)
				p[x][i]=p[x][i]*(t-i)/t+p[x][i+1]*(i+1)/t;
		b[x]-=max(k-(a[x]-b[x]),0);
		a[x]-=k,a[y]+=k;
		printf("%.10lf\n",ans+=p[x][0]);
	}
	return 0;
}


#include <bits/stdc++.h>
#define forup(i,a,b) for(int i=(a);i<=(b);i++)
#define fordown(i,a,b) for(int i=(a);i>=(b);i--)
#define maxn 100005
using namespace std;
typedef long long ll;
typedef unsigned long long ull;

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


#include <map>
#include <set>
#include <cmath>
#include <stack>
#include <queue>
#include <string>
#include <vector>
#include <bitset>
#include <fstream>
#include <sstream>
#include <stdio.h>
#include <ctype.h>
#include <string.h>
#include <iostream>
#include <algorithm>
using namespace std;
#define li        long long int
#define rep(i,to) for(li i=0;i<((li)(to));++i)
#define pb        push_back
#define sz(v)     ((li)(v).size())
#define bit(n)    (1ll<<(li)(n))
#define all(vec)  (vec).begin(),(vec).end()
#define each(i,c) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();i++)
#define MP        make_pair
#define F         first
#define S         second

#define M 105
#define MAX 100500
li a[MAX];
double tmp[M];
double d[MAX][M];
double sum = 0;

double memo[MAX * 6][7];
double C(li n, li m)
{
	if(n < m) return 0.0;
	return memo[n][m];
}

int main()
{
	rep(i, MAX * 6) memo[i][0] = 1.0;
	rep(i, 7) memo[i][i] = 1.0;
	rep(i, MAX * 6)rep(j, min(7ll, i))if(j) memo[i][j] = memo[i - 1][j - 1] + memo[i- 1][j];

	li n;
	cin >> n;
	rep(i, n){
		cin >> a[i];
		d[i][a[i]] = 1.0;
		if(a[i] == 0) sum += 1.0;
	}
	li q;
	cin >> q;
	rep(i, q){
		li u, v, k;
		cin >> u >> v >> k;
		u--;
		v--;
		rep(j, M) tmp[j] = 0.0;
		rep(rem, M)if(d[u][rem] != 0.0)for(li eat = 0; eat <= min(k, rem); eat++){
			if(a[u] - rem < 0) continue;
			if(a[u] < k) continue;
			tmp[rem - eat] += d[u][rem] * C(rem, eat) * C(a[u] - rem, k - eat) / C(a[u], k);
		}
		sum -= d[u][0];
		rep(j, M) d[u][j]= tmp[j];
		sum += d[u][0];

		a[u] -= k;
		a[v] += k;
		printf("%0.20lf\n", sum);
	}
}


#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<algorithm>
using namespace std;
const int mm=100010;
double f[mm][110],ans;
int a[mm],b[mm],x,y,k,i,j,l,n,m;
int main(){
	scanf("%d",&n);
	for(i=1;i<=n;++i)scanf("%d",&a[i]),f[i][b[i]=a[i]]=1,ans+=f[i][0];
	scanf("%d",&m);
	for(i=1;i<=m;++i){
		scanf("%d%d%d",&x,&y,&k);
		ans-=f[x][0];
		for(j=1;j<=k;++j){
			for(l=1;l<=b[x];++l){
				f[x][l-1]+=f[x][l]*l/a[x];
				f[x][l]*=1.0*(a[x]-l)/a[x];
			}
			a[x]--;
		}
		a[y]+=k;
		ans+=f[x][0];
		printf("%.10lf\n",ans);
	}
}


#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define fi first
#define se second
typedef vector<int> VI;
typedef long long ll;
typedef pair<int,int> PII;
const ll mod=1000000007;
ll powmod(ll a,ll b) {ll res=1;a%=mod;for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
// head

const int N=101000;
int n,q,u,v,k,a[N],cur[N];
double dp[N][110],ret;
int main() {
	scanf("%d",&n);
	rep(i,1,n+1) {
		scanf("%d",a+i);
		cur[i]=a[i];
		dp[i][cur[i]]=1;
	}
	ret=0;
	scanf("%d",&q);
	rep(i,0,q) {
		scanf("%d%d%d",&u,&v,&k);
		ret-=dp[u][0];
		rep(j,0,k) {
			rep(s,0,a[u]+1) {
				if (s>0) dp[u][s-1]+=dp[u][s]*s/cur[u];
				dp[u][s]=dp[u][s]*(cur[u]-s)/cur[u];
			}
			--cur[u];
		}
		ret+=dp[u][0];
		printf("%.10f\n",ret);
		cur[v]+=k;
	}
}


#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define fi first
#define se second
typedef vector<int> VI;
typedef long long ll;
typedef pair<int,int> PII;
const ll mod=1000000007;
ll powmod(ll a,ll b) {ll res=1;a%=mod;for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
// head

const int N=101000;
int n,q,u,v,k,a[N],cur[N];
double dp[N][110],ret;
int main() {
	scanf("%d",&n);
	rep(i,1,n+1) {
		scanf("%d",a+i);
		cur[i]=a[i];
		dp[i][cur[i]]=1;
		ret+=(cur[i]==0);
	}
	ret=0;
	scanf("%d",&q);
	rep(i,0,q) {
		scanf("%d%d%d",&u,&v,&k);
		ret-=dp[u][0];
		rep(j,0,k) {
			rep(s,0,a[u]+1) {
				if (s>0) dp[u][s-1]+=dp[u][s]*s/cur[u];
				dp[u][s]=dp[u][s]*(cur[u]-s)/cur[u];
			}
			--cur[u];
		}
		ret+=dp[u][0];
		printf("%.10f\n",ret);
		cur[v]+=k;
	}
}


#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define fi first
#define se second
typedef vector<int> VI;
typedef long long ll;
typedef pair<int,int> PII;
const ll mod=1000000007;
ll powmod(ll a,ll b) {ll res=1;a%=mod;for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
// head

const int N=101000;
int n,q,u,v,k,a[N],cur[N];
double dp[N][110],ret;
int main() {
	scanf("%d",&n);
	rep(i,1,n+1) {
		scanf("%d",a+i);
		cur[i]=a[i];
		dp[i][cur[i]]=1;
		ret+=(cur[i]==0);
	}
	scanf("%d",&q);
	rep(i,0,q) {
		scanf("%d%d%d",&u,&v,&k);
		ret-=dp[u][0];
		rep(j,0,k) {
			rep(s,0,a[u]+1) {
				if (s>0) dp[u][s-1]+=dp[u][s]*s/cur[u];
				dp[u][s]=dp[u][s]*(cur[u]-s)/cur[u];
			}
			--cur[u];
		}
		ret+=dp[u][0];
		printf("%.10f\n",ret);
		cur[v]+=k;
	}
}


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

const int N=100010, M=105;
int  n, m, x, y, z, a[N], In[N];
double res=0, nCr[M][M], dp[N][M];

void First()
{
    for(int i=0;i<M;i++)
    {
        nCr[i][0]=1.0;
        for(int j=1;j<=i;j++)
            nCr[i][j]=(nCr[i-1][j-1]+nCr[i-1][j]);
    }
}

int main()
{
   //freopen("r.txt","r",stdin);
   First();
   cin>>n;
   for(int i=0;i<n;i++)
   {
       cin>>a[i];
       In[i]=a[i];
       dp[i][a[i]]=1.0;
       if(a[i]==0)
          res++;
   }
   cin>>m;
   for(int i=0;i<m;i++)
   {
       cin>>x>>y>>z;
       x--, y--;
       double before=dp[x][0];
       for(int t=0;t<=In[x];t++)
       {
           int nt=In[x]-t;
           for(int take=1;take<=min(z, t);take++)
               dp[x][t-take] += dp[x][t]*nCr[t][take]*nCr[nt][z-take]/nCr[In[x]][z];
           dp[x][t] *= nCr[nt][z]/nCr[In[x]][z];
       }
       In[x]-=z, In[y]+=z;
       res-=before, res+=dp[x][0];
       printf("%.12lf\n", res);
   }

    return 0;
}


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

const int N=100010, M=105;
int  n, m, x, y, z, a[N], In[N];
double res=0, nCr[M][M], dp[N][M];

double NcR(int n, int r)
{
    if(n<r)
        return 0.0;
    double ret=1.0;
    for(int i=0;i<r;i++)
        ret*=(n-i);
    for(int i=1;i<=r;i++)
        ret/=i;
    return (ret);
}

int main()
{
   //freopen("r.txt","r",stdin);
   scanf("%d",&n);
   for(int i=0;i<n;i++)
   {
       scanf("%d",&a[i]);
       In[i]=a[i];
       dp[i][a[i]]=1.0;
       if(a[i]==0)
          res++;
   }
   scanf("%d",&m);
   for(int i=0;i<m;i++)
   {
       scanf("%d %d %d",&x, &y, &z);
       x--, y--;
       double before=dp[x][0];
       for(int t=0;t<=a[x];t++)
       {
           int nt=In[x]-t;
           for(int take=1;take<=min(z, t);take++)
               dp[x][t-take] += dp[x][t]*NcR(t, take)*NcR(nt, z-take)/NcR(In[x], z);
           dp[x][t] *= NcR(nt, z)/NcR(In[x], z);
       }
       In[x]-=z, In[y]+=z;
       res-=before, res+=dp[x][0];
       printf("%.12lf\n", res);
   }

    return 0;
}


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

const int N=100010, M=105;
int  n, m, x, y, z, a[N], In[N];
double res=0, nCr[M][M], dp[N][M];

void First()
{
    for(int i=0;i<M;i++)
    {
        nCr[i][0]=1.0;
        for(int j=1;j<=i;j++)
            nCr[i][j]=(nCr[i-1][j-1]+nCr[i-1][j]);
    }
}

int main()
{
   //freopen("r.txt","r",stdin);
   First();
   scanf("%d",&n);
   for(int i=0;i<n;i++)
   {
       scanf("%d",&a[i]);
       In[i]=a[i];
       dp[i][a[i]]=1.0;
       if(a[i]==0)
          res++;
   }
   scanf("%d",&m);
   for(int i=0;i<m;i++)
   {
       scanf("%d %d %d",&x, &y, &z);
       x--, y--;
       double before=dp[x][0];
       for(int t=0;t<=In[x];t++)
       {
           int nt=In[x]-t;
           for(int take=1;take<=min(z, t);take++)
               dp[x][t-take] += dp[x][t]*nCr[t][take]*nCr[nt][z-take]/nCr[In[x]][z];
           dp[x][t] *= nCr[nt][z]/nCr[In[x]][z];
       }
       In[x]-=z, In[y]+=z;
       res-=before, res+=dp[x][0];
       printf("%.12lf\n", res);
   }

    return 0;
}


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

const int N=100010, M=105;
int  n, m, x, y, z, a[N], In[N];
double res=0, nCr[M][M], dp[N][M];

double NcR(int n, int r)
{
    if(n<r)
        return 0.0;
    if(n==r || r==0)
        return 1.0;
    if(r==1)
        return n;
    return (NcR(n-1, r)+NcR(n-1, r-1));
}

int main()
{
   //freopen("r.txt","r",stdin);
   scanf("%d",&n);
   for(int i=0;i<n;i++)
   {
       scanf("%d",&a[i]);
       In[i]=a[i];
       dp[i][a[i]]=1.0;
       if(a[i]==0)
          res++;
   }
   scanf("%d",&m);
   for(int i=0;i<m;i++)
   {
       scanf("%d %d %d",&x, &y, &z);
       x--, y--;
       double before=dp[x][0];
       for(int t=0;t<=In[x];t++)
       {
           int nt=In[x]-t;
           for(int take=1;take<=min(z, t);take++)
               dp[x][t-take] += dp[x][t]*NcR(t, take)*NcR(nt, z-take)/NcR(In[x], z);
           dp[x][t] *= NcR(nt, z)/NcR(In[x], z);
       }
       In[x]-=z, In[y]+=z;
       res-=before, res+=dp[x][0];
       printf("%.12lf\n", res);
   }

    return 0;
}


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

const int N=100010, M=105;
int  n, m, x, y, z, a[N], In[N];
double res=0, nCr[M][M], dp[N][M];

void First()
{
    for(int i=0;i<M;i++)
    {
        nCr[i][0]=1.0;
        for(int j=1;j<=i;j++)
            nCr[i][j]=(nCr[i-1][j-1]+nCr[i-1][j]);
    }
}

int main()
{
   //freopen("r.txt","r",stdin);
   First();
   scanf("%d",&n);
   for(int i=0;i<n;i++)
   {
       scanf("%d",&a[i]);
       In[i]=a[i];
       dp[i][a[i]]=1.0;
       if(a[i]==0)
          res++;
   }
   scanf("%d",&m);
   for(int i=0;i<m;i++)
   {
       scanf("%d %d %d",&x, &y, &z);
       x--, y--;
       double before=dp[x][0];
       for(int t=0;t<=a[x];t++)
       {
           int nt=In[x]-t;
           for(int take=1;take<=min(z, t);take++)
               dp[x][t-take] += dp[x][t]*nCr[t][take]*nCr[nt][z-take]/nCr[In[x]][z];
           dp[x][t] *= nCr[nt][z]/nCr[In[x]][z];
       }
       In[x]-=z, In[y]+=z;
       res-=before, res+=dp[x][0];
       printf("%.12lf\n", res);
   }

    return 0;
}


#include <cmath>
#include <map>
#include <vector>
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <set>
#include <bitset>
#include <memory.h>
#include <functional>
#include <queue>
#include <fstream>
#include <ctime>
#include <deque>
#include <utility>
#include <stack>
#include <sstream>
#include <list>
#include <cctype>
#include <numeric>
#include <iomanip>
#include <assert.h>
using namespace std;
#define sqr(_) ((_)*(_))

typedef pair<int, int> Pii;
#define x first
#define y second
#define mp make_pair
#define pb push_back
#define SZ(x) ((int)(x).size())

typedef long long LL;

const int MAXN = (int)1e5 + 10, MAXM = (int)1e6 + 10, MAXA = 100 + 10;

double lfac[MAXM], p[MAXN][MAXA], Tohka;
int n, m, a[MAXN];

double C(int n, int k)
{
	return lfac[n] - lfac[k] - lfac[n - k];
}
double Calc(int n, int k, int a, int b)
{
	if (n - a < k - b) return 0;
	return exp(C(a, b) + C(n - a, k - b) - C(n, k));
}
void Work(int x, int k)
{
	Tohka -= p[x][0];
	for (int i = 1; i <= a[x]; ++i)
		if (p[x][i])
		{
			double P = p[x][i];
			p[x][i] = 0;
			for (int j = 0; j <= min(i, k); ++j)
			{
				double s = P * Calc(a[x], k, i, j);
				p[x][i - j] += s;
			}
		}
	Tohka += p[x][0];
}
int main()
{
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin), freopen("output.txt", "w", stdout);
#endif

	scanf("%d", &n);
	for (int i = 1; i <= n; ++i)
		scanf("%d", &a[i]), p[i][a[i]] = 1, Tohka += p[i][0];
	scanf("%d", &m);
	for (int i = 1; i <= m * 5; ++i)
		lfac[i] = lfac[i - 1] + log((double)i);
	for (int i = 1; i <= m; ++i)
	{
		int x, y, k;
		scanf("%d%d%d", &x, &y, &k);
		Work(x, k);
		a[x] -= k, a[y] += k;
		printf("%.10lf\n", Tohka);
	}

	fclose(stdin);
	fclose(stdout);
	return 0;
}


#include <cmath>
#include <map>
#include <vector>
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <set>
#include <bitset>
#include <memory.h>
#include <functional>
#include <queue>
#include <fstream>
#include <ctime>
#include <deque>
#include <utility>
#include <stack>
#include <sstream>
#include <list>
#include <cctype>
#include <numeric>
#include <iomanip>
#include <assert.h>
using namespace std;
#define sqr(_) ((_)*(_))

typedef pair<int, int> Pii;
#define x first
#define y second
#define mp make_pair
#define pb push_back
#define SZ(x) ((int)(x).size())

typedef long long LL;

const int MAXN = (int)1e5 + 10, MAXM = (int)1e6 + 10, MAXA = 100 + 10;

double lfac[MAXM], p[MAXN][MAXA], Tohka;
int n, m, a[MAXN];

double C(int n, int k)
{
	return lfac[n] - lfac[k] - lfac[n - k];
}
double Calc(int n, int k, int a, int b)
{
	if (n - a < k - b) return 0;
	return exp(C(a, b) + C(n - a, k - b) - C(n, k));
}
void Work(int x, int k)
{
	Tohka -= p[x][0];
	for (int i = 1; i <= a[x]; ++i)
		if (p[x][i])
		{
			double P = p[x][i];
			p[x][i] = 0;
			for (int j = 0; j <= min(i, k); ++j)
			{
				double s = P * Calc(a[x], k, i, j);
//				cout << Calc(a[x], k, i, j) << " " << a[x] << " " << k << " " << i << " " << j << endl;
				p[x][i - j] += s;
			}
//			cout << endl;
		}
	Tohka += p[x][0];
}
int main()
{
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin), freopen("output.txt", "w", stdout);
#endif

	scanf("%d", &n);
	for (int i = 1; i <= n; ++i)
		scanf("%d", &a[i]), p[i][a[i]] = 1;
	scanf("%d", &m);
	for (int i = 1; i <= m * 5; ++i)
		lfac[i] = lfac[i - 1] + log((double)i);
	for (int i = 1; i <= m; ++i)
	{
		int x, y, k;
		scanf("%d%d%d", &x, &y, &k);
		Work(x, k);
		a[x] -= k, a[y] += k;
		printf("%.10lf\n", Tohka);
	}

	fclose(stdin);
	fclose(stdout);
	return 0;
}


#include <cmath>
#include <map>
#include <vector>
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <set>
#include <bitset>
#include <memory.h>
#include <functional>
#include <queue>
#include <fstream>
#include <ctime>
#include <deque>
#include <utility>
#include <stack>
#include <sstream>
#include <list>
#include <cctype>
#include <numeric>
#include <iomanip>
#include <assert.h>
using namespace std;
#define sqr(_) ((_)*(_))

typedef pair<int, int> Pii;
typedef long double ld;
#define x first
#define y second
#define mp make_pair
#define pb push_back
#define SZ(x) ((int)(x).size())

typedef long long LL;

const int MAXN = (int)1e5 + 10, MAXM = (int)1e6 + 10, MAXA = 100 + 10;

ld lfac[MAXM], p[MAXN][MAXA], Tohka;
int n, m, a[MAXN], b[MAXN];

ld C(int n, int k)
{
	return lfac[n] - lfac[k] - lfac[n - k];
}
ld Calc(int n, int k, int a, int b)
{
	if (n - a < k - b) return 0;
	return exp(C(a, b) + C(n - a, k - b) - C(n, k));
}
void Work(int x, int k)
{
	Tohka -= p[x][0];
	for (int i = 1; i <= b[x]; ++i)
		if (p[x][i])
		{
			ld P = p[x][i];
			p[x][i] = 0;
			for (int j = 0; j <= min(i, k); ++j)
			{
				ld s = P * Calc(a[x], k, i, j);
				p[x][i - j] += s;
			}
		}
	Tohka += p[x][0];
}
int main()
{
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin), freopen("output.txt", "w", stdout);
#endif

	scanf("%d", &n);
	for (int i = 1; i <= n; ++i)
		scanf("%d", &a[i]), p[i][a[i]] = 1, Tohka += p[i][0], b[i] = a[i];
	scanf("%d", &m);
	for (int i = 1; i <= m * 5; ++i)
		lfac[i] = lfac[i - 1] + log((ld)i);
	cout << setprecision(10);
	for (int i = 1; i <= m; ++i)
	{
		int x, y, k;
		scanf("%d%d%d", &x, &y, &k);
		Work(x, k);
		a[x] -= k, a[y] += k;
		cout << fixed << Tohka << endl;
	}

	fclose(stdin);
	fclose(stdout);
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
const double eps =  1e-10;
typedef long double Ld;

const int N = 100010;
Ld f[N],p[N][101],tmp[101];
int n,a[N],u,v,k,q,b[N];
Ld cal(int n,int k,int i,int j){
	if(n-i-k+j<0) return 0.0;
	Ld ret=1.0;
	for(int w=i-j+1;w<=i;w++) ret*=w;
	for(int w=1;w<=j;w++) ret/=w;
	for(int w=n-i-k+j+1;w<=n-i;w++) ret*=w;
	for(int w=1;w<=k-j;w++) ret/=w;
	for(int w=1;w<=k;w++) ret*=w;
	for(int w=n-k+1;w<=n;w++) ret/=w;
	return ret;
}
int dcmp(double x){
	if(fabs(x)<eps) return 0;
	if(x>=eps) return 1;
	return -1;
}
int main(){
	//cout<<cal(4,2,2,0)<<endl;
	scanf("%d",&n);
	for	(int i=1;i<=n;i++) scanf("%d",a+i);
	double ans=0.0;
	for(int i=1;i<=n;i++){
		b[i]=a[i];
		for(int j=0;j<a[i];j++) p[i][j]=0.0;
		p[i][a[i]]=1.0;
		if(a[i]==0) ans+=1.0;

	}
	scanf("%d",&q);

	while(q--){
		scanf("%d%d%d",&u,&v,&k);
		ans-=p[u][0];
		for(int i=0;i<101;i++) tmp[i]=0.0;
		for(int i=0;i<=a[u] && i<101;i++)if(dcmp(p[u][i])!=0){
			for(int j=0;j<=k && j<=i;j++){
				tmp[i-j]+=1.0*p[u][i]*cal(a[u],k,i,j);
			}
		}
		memcpy(p[u],tmp,sizeof(tmp));
		a[u]-=k;
		a[v]+=k;
		ans+=p[u][0];
		printf("%.12lf\n",ans);
	}
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
const double eps =  1e-10;
typedef long double Ld;

const int N = 100010;
Ld f[N],p[N][101],tmp[101];
int n,a[N],u,v,k,q,b[N];
Ld cal(int n,int k,int i,int j){
	if(n-i-k+j<0) return 0.0;
	Ld ret=1.0;
	for(int w=i-j+1;w<=i;w++) ret*=w;
	for(int w=1;w<=j;w++) ret/=w;
	for(int w=n-i-k+j+1;w<=n-i;w++) ret*=w;
	for(int w=1;w<=k-j;w++) ret/=w;
	for(int w=1;w<=k;w++) ret*=w;
	for(int w=n-k+1;w<=n;w++) ret/=w;
	return ret;
}
int dcmp(double x){
	if(fabs(x)<eps) return 0;
	if(x>=eps) return 1;
	return -1;
}
int main(){
	//cout<<cal(4,2,2,0)<<endl;
	scanf("%d",&n);
	for	(int i=1;i<=n;i++) scanf("%d",a+i);
	for(int i=1;i<=n;i++){
		b[i]=a[i];
		for(int j=0;j<a[i];j++) p[i][j]=0.0;
		p[i][a[i]]=1.0;
	}
	scanf("%d",&q);
	double ans=0.0;
	while(q--){
		scanf("%d%d%d",&u,&v,&k);
		ans-=p[u][0];
		for(int i=0;i<101;i++) tmp[i]=0.0;
		for(int i=0;i<=a[u] && i<101;i++)if(dcmp(p[u][i])!=0){
			for(int j=0;j<=k && j<=i;j++){
				tmp[i-j]+=1.0*p[u][i]*cal(a[u],k,i,j);
			}
		}
		memcpy(p[u],tmp,sizeof(tmp));
		a[u]-=k;
		a[v]+=k;
		ans+=p[u][0];
		printf("%.12lf\n",ans);
	}
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
const double eps =  1e-10;
typedef long double Ld;

const int N = 100010;
Ld f[N],p[N][101],tmp[101],fac[10];
int n,a[N],u,v,k,q,b[N];
Ld cal(int n,int k,int i,int j){
	if(n-i-k+j<0) return 0.0;
	Ld ret=1.0;
	for(int w=i-j+1;w<=i;w++) ret*=w;
	ret/=fac[j]; //for(int w=1;w<=j;w++) ret/=w;
	for(int w=n-i-k+j+1;w<=n-i;w++) ret*=w;
	ret/=fac[k-j]; //for(int w=1;w<=k-j;w++) ret/=w;
	ret*=fac[k]; //for(int w=1;w<=k;w++) ret*=w;
	for(int w=n-k+1;w<=n;w++) ret/=w;
	return ret;
}
/*
int dcmp(double x){
	if(fabs(x)<eps) return 0;
	if(x>=eps) return 1;
	return -1;
}*/
int main(){
	//cout<<cal(4,2,2,0)<<endl;
	fac[0]=1.0;
	for(int i=1;i<10;i++) fac[i]=i*fac[i-1];
	scanf("%d",&n);
	for	(int i=1;i<=n;i++) scanf("%d",a+i);
	double ans=0.0;
	for(int i=1;i<=n;i++){
		b[i]=a[i];
		for(int j=0;j<a[i];j++) p[i][j]=0.0;
		p[i][a[i]]=1.0;
		if(a[i]==0) ans+=1.0;
	}
	scanf("%d",&q);

	while(q--){
		scanf("%d%d%d",&u,&v,&k);
		ans-=p[u][0];
		for(int i=0;i<101;i++) tmp[i]=0.0;
		for(int i=0;i<=a[u] && i<101 && i<=b[u];i++){
			for(int j=0;j<=k && j<=i;j++){
				tmp[i-j]+=1.0*p[u][i]*cal(a[u],k,i,j);
			}
		}
		memcpy(p[u],tmp,sizeof(tmp));
		a[u]-=k;
		a[v]+=k;
		ans+=p[u][0];
		printf("%.12lf\n",ans);
	}
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
const double eps =  1e-10;
typedef long double Ld;

const int N = 100010;
Ld f[N],p[N][101],tmp[101];
int n,a[N],u,v,k,q,b[N];
Ld cal(int n,int k,int i,int j){
	if(n-i-k+j<0) return 0.0;
	Ld ret=1.0;
	for(int w=i-j+1;w<=i;w++) ret*=w;
	for(int w=1;w<=j;w++) ret/=w;
	for(int w=n-i-k+j+1;w<=n-i;w++) ret*=w;
	for(int w=1;w<=k-j;w++) ret/=w;
	for(int w=1;w<=k;w++) ret*=w;
	for(int w=n-k+1;w<=n;w++) ret/=w;
	return ret;
}
int dcmp(double x){
	if(fabs(x)<eps) return 0;
	if(x>=eps) return 1;
	return -1;
}
int main(){
	//cout<<cal(4,2,2,0)<<endl;
	scanf("%d",&n);
	for	(int i=1;i<=n;i++) scanf("%d",a+i);
	double ans=0.0;
	for(int i=1;i<=n;i++){
		b[i]=a[i];
		for(int j=0;j<a[i];j++) p[i][j]=0.0;
		p[i][a[i]]=1.0;
		if(a[i]==0) ans+=1.0;

	}
	scanf("%d",&q);

	while(q--){
		scanf("%d%d%d",&u,&v,&k);
		ans-=p[u][0];
		for(int i=0;i<101;i++) tmp[i]=0.0;
		for(int i=0;i<=a[u] && i<101;i++){
			for(int j=0;j<=k && j<=i;j++){
				tmp[i-j]+=1.0*p[u][i]*cal(a[u],k,i,j);
			}
		}
		memcpy(p[u],tmp,sizeof(tmp));
		a[u]-=k;
		a[v]+=k;
		ans+=p[u][0];
		printf("%.12lf\n",ans);
	}
	return 0;
}


#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<algorithm>
using namespace std;
const int mm=100010;
double f[mm][110],ans;
int a[mm],b[mm],x,y,k,i,j,l,n,m;
int main(){
	scanf("%d",&n);
	for(i=1;i<=n;++i)scanf("%d",&a[i]),f[i][b[i]=a[i]]=1,ans+=f[i][0];
	scanf("%d",&m);
	for(i=1;i<=m;++i){
		scanf("%d%d%d",&x,&y,&k);
		ans-=f[x][0];
		for(j=1;j<=k;++j){
			if(a[x]==0)break;
			for(l=1;l<=b[x];++l){
				f[x][l-1]+=f[x][l]*l/a[x];
				f[x][l]*=1.0*(a[x]-l)/a[x];
			}
			a[x]--;
			a[y]++;
		}
		ans+=f[x][0];
		printf("%.10lf\n",ans);
	}
}


#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<algorithm>
using namespace std;
const int mm=100010;
double f[mm][110],ans;
int a[mm],b[mm],x,y,k,i,j,l,n,m;
int main(){
//	freopen("1.in","r",stdin);
//	freopen("1.out","w",stdout);
	scanf("%d",&n);
	for(i=1;i<=n;++i)scanf("%d",&a[i]),f[i][b[i]=a[i]]=1,ans+=f[i][0];
	scanf("%d",&m);
	for(i=1;i<=m;++i){
		scanf("%d%d%d",&x,&y,&k);
		ans-=f[x][0];
		for(j=1;j<=k;++j){
			if(a[x]==0)break;
			for(l=1;l<=b[x] && l<=a[x];++l){
				f[x][l-1]+=f[x][l]*l/a[x];
				f[x][l]*=1.0*(a[x]-l)/a[x];
			}
			a[x]--;
			a[y]++;
		}
		ans+=f[x][0];
		printf("%.10lf\n",ans);
	}
}


#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<algorithm>
using namespace std;
const int mm=100010;
double f[mm][110],ans;
int a[mm],b[mm],x,y,k,i,j,l,n,m;
int main(){
	scanf("%d",&n);
	for(i=1;i<=n;++i)scanf("%d",&a[i]),f[i][b[i]=a[i]]=1,ans+=f[i][0];
	scanf("%d",&m);
	for(i=1;i<=m;++i){
		scanf("%d%d%d",&x,&y,&k);
		ans-=f[x][0];
		for(j=1;j<=k;++j){
			for(l=1;l<=b[x];++l){
				f[x][l-1]+=f[x][l]*l/a[x];
				f[x][l]*=1.0*(a[x]-l)/a[x];
			}
			a[x]--;
		}
		a[y]+=k;
		ans+=f[x][0];
		printf("%.10lf\n",ans);
	}
}


#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<algorithm>
using namespace std;
const int mm=100010;
double f[mm][110],ans;
int a[mm],b[mm],x,y,k,i,j,l,n,m;
int main(){
	scanf("%d",&n);
	for(i=1;i<=n;++i)scanf("%d",&a[i]),f[i][b[i]=a[i]]=1;
	scanf("%d",&m);
	for(i=1;i<=m;++i){
		scanf("%d%d%d",&x,&y,&k);
		ans-=f[x][0];
		for(j=1;j<=k;++j){
			if(a[x]==0)break;
			for(l=1;l<=b[x];++l){
				f[x][l-1]+=f[x][l]*l/a[x];
				f[x][l]*=1.0*(a[x]-l)/a[x];
			}
			a[x]--;
			a[y]++;
		}
		ans+=f[x][0];
		printf("%.10lf\n",ans);
	}
}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
void read(int &digit)
{
	digit=0;
	char c;
	for (c=getchar();(c<'0' || c>'9') && c!='-';c=getchar());
	bool type=false;
	if (c=='-')
		type=true,c=getchar();
	for (;c>='0' && c<='9';digit=digit*10+c-'0',c=getchar());
	if (type==true)
		digit=-digit;
}

#define maxn 100010
map<int,double>	f[maxn];
pair<int,double>	qaq[maxn];
int a[maxn];
int n,m;
typedef map<int,double>::iterator zxo;
ll c[100010][6];
double mjy;

int main()
{
	//freopen("248E.in","r",stdin);
	read(n);
	for (int i=1;i<=n;i++)	read(a[i]);
	for (int i=1;i<=n;i++)
	{
		f[i][a[i]]=1;
		if (a[i]==0)	mjy+=1;
	}
	c[0][0]=1;
	for (int i=1;i<=100000;i++)
	{
		c[i][0]=1;
		for (int j=1;j<=i && j<=5;j++)	c[i][j]=c[i-1][j-1]+c[i-1][j];
	}
	read(m);
	while (m--)
	{
		int u,v,k;
		read(u),read(v),read(k);
		int cnt=0;
		mjy-=f[u][0];
		for (zxo it=f[u].begin();it!=f[u].end();it++)
		{
			for (int l=0;l<=k;l++)
			if (it->first>=l && a[u]-(it->first)>=k-l)
			{
				double num=c[it->first][l];
				num*=c[a[u]-it->first][k-l];
				num/=c[a[u]][k];
				num*=it->second;
				qaq[++cnt]=make_pair(it->first-l,num);
			}
		}
		f[u].clear();
		for (int i=1;i<=cnt;i++)	f[u][qaq[i].first]+=qaq[i].second;
		a[u]-=k;
		a[v]+=k;
		mjy+=f[u][0];
		printf("%.10lf\n",mjy);
	}
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
void read(int &digit)
{
	digit=0;
	char c;
	for (c=getchar();(c<'0' || c>'9') && c!='-';c=getchar());
	bool type=false;
	if (c=='-')
		type=true,c=getchar();
	for (;c>='0' && c<='9';digit=digit*10+c-'0',c=getchar());
	if (type==true)
		digit=-digit;
}

#define maxn 100010
map<int,double>	f[maxn];
pair<int,double>	qaq[maxn];
int a[maxn];
int n,m;
typedef map<int,double>::iterator zxo;
int c[110][6];
double mjy;

int main()
{
	read(n);
	for (int i=1;i<=n;i++)	read(a[i]);
	for (int i=1;i<=n;i++)
	{
		f[i][a[i]]=1;
		if (a[i]==0)	mjy+=1;
	}
	c[0][0]=1;
	for (int i=1;i<=100;i++)
	{
		c[i][0]=1;
		for (int j=1;j<=i && j<=5;j++)	c[i][j]=c[i-1][j-1]+c[i-1][j];
	}
	read(m);
	while (m--)
	{
		int u,v,k;
		read(u),read(v),read(k);
		int cnt=0;
		mjy-=f[u][0];
		for (zxo it=f[u].begin();it!=f[u].end();it++)
		{
			for (int l=0;l<=k;l++)
			if (it->first>=l && a[u]-(it->first)>=k-l)
			{
				double num=c[it->first][l];
				num*=c[a[u]-it->first][k-l];
				num/=c[a[u]][k];
				num*=it->second;
				qaq[++cnt]=make_pair(it->first-l,num);
			}
		}
		f[u].clear();
		for (int i=1;i<=cnt;i++)	f[u][qaq[i].first]+=qaq[i].second;
		a[u]-=k;
		a[v]+=k;
		mjy+=f[u][0];
		printf("%.10lf\n",mjy);
	}
	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) / (double)pots[from];
		if (untasted != min(pots[from], initial_pots[from]))
			p_new[untasted] += p[from][untasted + 1] * (untasted + 1) / (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]--;

	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;
		}

		pots[to] += count;
		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 << to + 1 << 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 <= 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 <= 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]--;

	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;

		if (from == to)
			while (true);
		for (int i = 0; i < count; ++i) {
			long double change = Transfer(from, to);
			result += change;
		}

		pots[to] += count;
		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] * (double)(pots[from] - untasted) / (long double)pots[from];
		if (untasted != initial_pots[from])
			p_new[untasted] += p[from][untasted + 1] * (double)(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 <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];

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

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) / (double)pots[from];
		if (untasted != min(pots[from], initial_pots[from]))
			p_new[untasted] += p[from][untasted + 1] * (untasted + 1) / (double)pots[from];
	}

	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);
	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) {
			double change = Transfer(from, to);
			result += change;
		}
		printf ("%.12f\n", result);
	}

	return 0;
}