#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <cmath>
#include <ctime>
#include <cassert>
#include <iostream>
#include <fstream>
#include <sstream>
#include <iomanip>
#include <complex>
#include <string>
#include <vector>
#include <list>
#include <deque>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <bitset>
#include <iterator>
#include <functional>
#include <utility>
#include <algorithm>
#include <numeric>
#include <typeinfo>

using namespace std;

#define dump(n) cerr<<"# "<<#n<<"="<<(n)<<endl
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,n) repi(i,0,n)
#define iter(c) __typeof((c).begin())
#define foreach(i,c) for(iter(c) i=(c).begin();i!=(c).end();++i)
#define allof(c) (c).begin(),(c).end()
#define mp make_pair

typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<string> vs;
typedef pair<int,int> pii;

const int MOD=100000007;

int memo[200][200];
int combi(int n,int r)
{
	if(memo[n][r]!=-1) return memo[n][r];
	if(r==0 || r==n) return memo[n][r]=1;
	else return memo[n][r]=(combi(n-1,r-1)+combi(n-1,r))%MOD;
}

void solve(vd& ps,vi& ids,vd& ws)
{
	int n=ps.size();
	vi flg(n);
	vvi loops;
	rep(i,n){
		if(flg[i]) continue;
		flg[i]=1;
		loops.push_back(vi(1,i));
		for(int j=ids[i];j!=i;j=ids[j]){
			flg[j]=1;
			loops.back().push_back(j);
		}
	}
	
	vd es(loops.size(),INT_MAX);
	vi cands(loops.size());
	rep(i,loops.size()){
		double temp=0;
		rep(j,loops[i].size())
			temp+=1.0/ws[loops[i][j]];
		vd diffs(loops[i].size());
		rep(j,loops[i].size())
			diffs[j]=-1/ws[loops[i][j]]+1/ps[loops[i][j]];
		rep(j,loops[i].size())
			es[i]=min(es[i],temp+diffs[j]);
		
		sort(allof(diffs));
		rep(j,diffs.size())
			cands[i]+=abs(diffs[j]-diffs[0])<1e-10;
	}
	
	double rese=accumulate(allof(es),0.0);
	int resp=1;
	for(int i=n,j=0;j<loops.size();i-=loops[j].size(),j++)
		resp=((ll)resp*combi(i,loops[j].size())*cands[j])%MOD;
	printf("%.10f %d\n",rese,resp);
}

int main()
{
	memset(memo,-1,sizeof(memo));
	
	for(int n;cin>>n,n;){
		vi ids(n);
		vd ps(n),ws(n);
		rep(i,n)
			cin>>ps[i]>>ids[i]>>ws[i];
		solve(ps,ids,ws);
	}
	
	return 0;
}