#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>

using namespace std;

const int mod = 100000007;

long long modpow(long long a, long long p){
	if(p==0) return 1;
	long long res = modpow(a, p/2);
	res = (res*res)%mod;
	if(p%2==1) res = (res*a)%mod;
	return res;
}

int main(){
	int n;
	double p[100], w[100];
	int nxt[100];
	double exp[100];
	bool visit[100];
	while(cin >> n, n){
		for(int i=0;i<n;i++) cin >> p[i] >> nxt[i] >> w[i];
		for(int i=0;i<n;i++){
			visit[i] = false;
			exp[i] = 1 + (1-p[i])/p[i];
			for(int j=nxt[i];j!=i;j=nxt[j])
				exp[i] += 1 + (1-w[j])/w[j];
		}
		double res = 0.0;
		long long pat = 1;
		int lest = n;
		for(int i=0;i<n;i++){
			int cnt = 0;
			int mul = 1;
			double mx = 1e12;
			if(visit[i]) continue;
			for(int j=i;!visit[j];j=nxt[j]){
				cnt++;
				visit[j] = true;
				if(mx > exp[j]) mul = 0, mx = exp[j];
				if(abs(mx-exp[j]) < 1e-9) mul++;
			}
			res += mx;
			long long add = mul;
			for(int j=0;j<cnt;j++) add = (add*(lest-j))%mod;
			for(int j=0;j<cnt;j++) add = (add*modpow(j+1, mod-2))%mod;
			pat = (pat*add)%mod;
			lest -= cnt;
		}
		printf("%.10lf %d\n", res, pat);
	}
	return 0;
}