#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
using namespace std;
const double eps=1e-9;
const int D=1000;
struct sl{
	int SC,LC,TS,TL;
	double p;
}a[1005];
struct csl{
	long double score,tim;
}f[1005][1561],ans;
double a1,a2,p;
int n,m,z,x,y;
inline bool cmp(sl x,sl y){
	return x.TL*x.p*(1-y.p)<y.TL*y.p*(1-x.p);
}
inline csl Max(csl x,int l,int k,int t){
	csl y;
	y.score=y.tim=0;
	if (t==1){
		y.score=f[l-1][k-a[l].TS].score+a[l].SC;
		y.tim=f[l-1][k-a[l].TS].tim+a[l].TS;
	}
	else {
		y.score=f[l-1][k-a[l].TS-a[l].TL].score+a[l].SC+a[l].LC*(1-a[l].p);
		y.tim=a[l].p*(f[l-1][k-a[l].TS-a[l].TL].tim+a[l].TS)+k*(1-a[l].p);
	}
	if (x.score+eps<y.score || (abs(x.score-y.score)<eps && x.tim>y.tim)) return y;
	else return x;
}
int main(){
	//freopen("cf277D.in","r",stdin);freopen("cf277D.out","w",stdout);
	scanf("%d%d",&n,&m);
	for (int i=1;i<=n;++i) {
		scanf("%d%d%d%d%lf",&a[i].SC,&a[i].LC,&a[i].TS,&a[i].TL,&a[i].p);
		a[i].p=p;
	}
	sort(a+1,a+n+1,cmp);
	for (int i=1;i<=n;++i){
		for (int j=0;j<=m;++j){
			f[i][j]=f[i-1][j];
			if (j>=a[i].TS) f[i][j]=Max(f[i][j],i,j,1);
			if (j>=a[i].TS+a[i].TL) f[i][j]=Max(f[i][j],i,j,2);
		}
	}
	for (int i=0;i<=m;++i)
	if (ans.score+eps<f[n][i].score || (abs(ans.score-f[n][i].score)<eps && ans.tim>f[n][i].tim)) ans=f[n][i];
	printf("%.10lf %.10lf",(double)ans.score,(double)ans.tim);
}


#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
using namespace std;
struct sl{
	int SC,LC,TS,TL;
	double p;
}a[1005];
struct csl{
	double score,tim;
}f[1005][1561],ans;
int n,m,z,x,y;
inline bool cmp(sl x,sl y){
	return x.TL*x.p/(1-x.p)<y.TL*y.p/(1-y.p);
}
inline csl Max(csl x,int l,int k,int t){
	csl y;
	y.score=y.tim=0;
	if (t==1){
		y.score=f[l-1][k-a[l].TS].score+a[l].SC;
		y.tim=f[l-1][k-a[l].TS].tim+a[l].TS;
	}
	else {
		y.score=f[l-1][k-a[l].TS-a[l].TL].score+a[l].SC+a[l].LC*(1-a[l].p);
		y.tim=a[l].p*(f[l-1][k-a[l].TS-a[l].TL].tim+a[l].TS)+k*(1-a[l].p);
	}
	if (x.score<y.score || (x.score==y.score && x.tim>y.tim)) return y;
	else return x;
}
int main(){
	//freopen("cf277D.in","r",stdin);freopen("cf277D.out","w",stdout);
	scanf("%d%d",&n,&m);
	for (int i=1;i<=n;++i) scanf("%d%d%d%d%lf",&a[i].SC,&a[i].LC,&a[i].TS,&a[i].TL,&a[i].p);
	sort(a+1,a+n+1,cmp);
	for (int i=1;i<=n;++i){
		for (int j=0;j<=m;++j){
			f[i][j]=f[i-1][j];
			if (j>=a[i].TS) f[i][j]=Max(f[i][j],i,j,1);
			if (j>=a[i].TS+a[i].TL) f[i][j]=Max(f[i][j],i,j,2);
		}
	}
	for (int i=1;i<=m;++i)
	if (ans.score<f[n][i].score || (ans.score==f[n][i].score && ans.tim>f[n][i].tim)) ans=f[n][i];
	printf("%.10lf %.10lf",ans.score,ans.tim);
}


#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
using namespace std;
struct sl{
    int SC,LC,TS,TL;
    double p;
}a[1005];
struct csl{
    double score,tim;
}f[1005][1561];
int n,m,z,x,y;
inline bool cmp(sl x,sl y){
    return x.TL*x.p/(1-x.p)<y.TL*y.p/(1-y.p);
}
inline csl Max(csl x,int l,int k,int t){
    csl y;
    y.score=y.tim=0;
    if (t==1){
        y.score=f[l-1][k-a[l].TS].score+a[l].SC;
        y.tim=f[l-1][k-a[l].TS].tim+a[l].TS;
    }
    else {
        y.score=f[l-1][k-a[l].TS-a[l].TL].score+a[l].SC+a[l].LC*(1-a[l].p);
        y.tim=a[l].p*(f[l-1][k-a[l].TS-a[l].TL].tim+a[l].TS)+(f[l-1][k-a[l].TS-a[l].TL].tim+a[l].TS+a[l].TL)*(1-a[l].p);
    }
    if (x.score<y.score || (x.score==y.score && x.tim>y.tim)) return y;
    else return y;
}
int main(){
    //freopen("cf277D.in","r",stdin);freopen("cf277D.out","w",stdout);
    scanf("%d%d",&n,&m);
    for (int i=1;i<=n;++i) scanf("%d%d%d%d%lf",&a[i].SC,&a[i].LC,&a[i].TS,&a[i].TL,&a[i].p);
    sort(a+1,a+n+1,cmp);
    for (int i=1;i<=n;++i) printf("%lf\n",a[i].p);
    for (int i=1;i<=n;++i){
        for (int j=0;j<=m;++j){
            f[i][j]=f[i-1][j];
            if (j>=a[i].TS) f[i][j]=Max(f[i][j],i,j,1);
            if (j>=a[i].TS+a[i].TL) f[i][j]=Max(f[i][j],i,j,2);
        }
    }
    printf("%.10lf %.10lf",f[n][m].score,f[n][m].tim);
}


#include <cstdio>
#include <algorithm>
const long double eps = 1e-10;
inline int sign(const long double x){return x < -eps ? -1 : x > eps;}
int n,t;
struct submit
{
	long double p;
	int ts,tl,ss,sl;
	bool operator<(const submit &o)const
	{
		return ts * p * (1 - o.p) < o.ts * o.p * (1 - p);
	}
}s[1009];
struct dp
{
	long double s,t2;
	int t1;
	bool operator<(const dp &o)const
	{
		return sign(s - o.s) < 0 || !sign(s - o.s) && t1 + t2 < o.t1 + o.t2;
	}
	void update(long double ns,int nt1,long double nt2)
	{
		if (sign(s - ns) < 0 || !sign(s - ns) && t1 + t2 > nt1 + nt2)
			s = ns,t1 = nt1,t2 = nt2;
	}
}f[2009];
int main()
{
	#ifndef ONLINE_JUDGE
	freopen("277D.in","r",stdin);
	freopen("277D.out","w",stdout);
	#endif
	scanf("%d%d",&n,&t);
	for (int i = 1; i <= n; ++i) {
		double x;
		scanf("%d%d%d%d%lf",&s[i].ss,&s[i].sl,&s[i].ts,&s[i].tl,&x);
		s[i].p = x;
	}
	std::sort(s + 1, s + 1 + n);
	for (int i = 1; i <= n; ++i)
		for (int j = t,k; j; --j) {
			if ((k = j - s[i].ts - s[i].tl) >= 0)
				f[j].update(f[k].s + s[i].ss + s[i].sl * (1 - s[i].p),f[k].t1 + s[i].ts,f[k].t2 * s[i].p + (j - s[i].ts - f[k].t1) * (1 - s[i].p));
			if ((k = j - s[i].ts) >= 0)
				f[j].update(f[k].s + s[i].ss,f[k].t1 + s[i].ts,f[k].t2);
		}
	for (int i = 0; i <= t; ++i)
		f[t + 1].update(f[i].s,f[i].t1,f[i].t2);
	printf("%.18f %.18f\n",(double)f[t + 1].s,(double)(f[t + 1].t1 + f[t + 1].t2));
}


#include <cstdio>
#include <algorithm>
const long double eps = 1e-10;
inline int sign(const long double x){return x < -eps ? -1 : x > eps;}
int n,t;
struct submit
{
    long double p;
    int ts,tl,ss,sl;
    bool operator<(const submit &o)const
    {
        return tl * p * (1 - o.p) < o.tl * o.p * (1 - p);
    }
}s[1009];
struct dp
{
    long double s,t;
    void update(long double ns,long double nt)
    {
        if (sign(s - ns) < 0 || !sign(s - ns) && t > nt)
            s = ns,t = nt;
    }
}f[2009];
int main()
{
    #ifndef ONLINE_JUDGE
    freopen("277D.in","r",stdin);
    freopen("277D.out","w",stdout);
    #endif
    scanf("%d%d",&n,&t);
    for (int i = 1; i <= n; ++i) {
        double x;
        scanf("%d%d%d%d%lf",&s[i].ss,&s[i].sl,&s[i].ts,&s[i].tl,&x);
        //x *= 1e6;
        s[i].p = x;
    }
    std::sort(s + 1, s + 1 + n);
    for (int i = 1; i <= n; ++i)
        for (int j = t,k; j; --j) {
            if ((k = j - s[i].ts - s[i].tl) >= 0)
                f[j].update(f[k].s + s[i].ss + s[i].sl * (1 - s[i].p),(f[k].t + s[i].ts) * s[i].p + j * (1 - s[i].p));
            if ((k = j - s[i].ts) >= 0)
                f[j].update(f[k].s + s[i].ss,f[k].t + s[i].ts);
        }
    for (int i = 0; i <= t; ++i)
        f[t + 1].update(f[i].s,f[i].t);
    printf("%.18f %.18f\n",(double)f[t + 1].s,(double)f[t + 1].t);
}


#include <cstdio>
#include <algorithm>
const long double eps = 1e-10;
inline int sign(const long double x){return x < -eps ? -1 : x > eps;}
int n,t;
struct submit
{
    long double p;
    int ts,tl,ss,sl;
    bool operator<(const submit &o)const
    {
        return ts * p * (1 - o.p) < o.ts * o.p * (1 - p);
    }
}s[1009];
struct dp
{
    long double s,t;
    void update(long double ns,long double nt)
    {
        if (sign(s - ns) < 0 || !sign(s - ns) && t > nt)
            s = ns,t = nt;
    }
}f[2009];
int main()
{
    #ifndef ONLINE_JUDGE
    freopen("277D.in","r",stdin);
    freopen("277D.out","w",stdout);
    #endif
    scanf("%d%d",&n,&t);
    for (int i = 1; i <= n; ++i) {
        double x;
        scanf("%d%d%d%d%lf",&s[i].ss,&s[i].sl,&s[i].ts,&s[i].tl,&x);
        //x *= 1e6;
        s[i].p = x;
    }
    std::sort(s + 1, s + 1 + n);
    for (int i = 1; i <= n; ++i)
        for (int j = t,k; j; --j) {
            if ((k = j - s[i].ts - s[i].tl) >= 0)
                f[j].update(f[k].s + s[i].ss + s[i].sl * (1 - s[i].p),(f[k].t + s[i].ts) * s[i].p + j * (1 - s[i].p));
            if ((k = j - s[i].ts) >= 0)
                f[j].update(f[k].s + s[i].ss,f[k].t + s[i].ts);
        }
    for (int i = 0; i <= t; ++i)
        f[t + 1].update(f[i].s,f[i].t);
    printf("%.18f %.18f\n",(double)f[t + 1].s,(double)f[t + 1].t);
}


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

#define PB                      push_back
#define MP                      make_pair
#define ALL(v)                  v.begin(),v.end()
#define SZ(v)                   (int)v.size()
#define CLR(v, d)               memset(v, d, sizeof(v))

const int OO = (int) 2e9;
const double EPS = 1e-6;

int dcmp(double a, double b) {
    return fabs(a - b) <= EPS ? 0 : a > b ? 1 : -1;
}

struct prob {
    int sm_s, l_s, sm_t, l_t;
    double fail;
    bool operator <(const prob & b) const {
        double x = (l_t * (1 - fail) * b.fail) + (l_t + b.l_t) * (1 - b.fail);
        double y = (b.l_t * (1 - b.fail) * fail) + (l_t + b.l_t) * (1 - fail);
        return x < y;
    }
};
int n, t;
vector<prob> v;

pair<double, double> dp[1234][1578];

pair<double, double> clc(int idx, int total) {

    if (total < 0)
        return MP(-1e100, 1e100);

    if (idx < 0)
        return total == 0 ? MP(0.0, 0.0) : MP(-1e100, 1e100);

    pair<double, double> &ans = dp[idx][total];

    if (ans == ans)
        return ans;

    ans = clc(idx - 1, total); // skip

    pair<double, double> cur = clc(idx - 1, total - v[idx].sm_t); // take small
    cur.first += v[idx].sm_s;
    cur.second += v[idx].sm_t;

    if (dcmp(cur.first, ans.first) > 0
            || (dcmp(cur.first, ans.first) == 0
                    && dcmp(cur.second, ans.second) < 0))
        ans = cur;

    // take small and large (  kolo ya waled )

    cur = clc(idx - 1, total - v[idx].sm_t - v[idx].l_t);
    cur.first += v[idx].sm_s;
    cur.second += v[idx].sm_t;

    cur.first += v[idx].l_s * (1 - v[idx].fail);

    cur.second = cur.second * v[idx].fail + total * (1 - v[idx].fail);

    if (dcmp(cur.first, ans.first) > 0
            || (dcmp(cur.first, ans.first) == 0
                    && dcmp(cur.second, ans.second) < 0))
        ans = cur;

    return ans;
}

int main() {

    cin >> n >> t;
    v.resize(n);
    for (int i = 0; i < n; i++)
    cin >> v[i].sm_s >> v[i].l_s >> v[i].sm_t >> v[i].l_t >> v[i].fail;
    sort(ALL(v));

    pair<double,double> ans = MP(0,0);

    CLR(dp,-1);
    for(int i = 1; i<=t; i++) {
        pair<double,double> cur = clc(n-1,i);
        if(dcmp(cur.first,ans.first) > 0 || (dcmp(cur.first,ans.first) ==0 && dcmp(cur.second , ans.second ) < 0 ))
            ans = cur;
    }
    printf("%.9lf %.9lf" , ans.first , ans.second);

    return 0;
}


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

#define PB                      push_back
#define MP                      make_pair
#define ALL(v)                  v.begin(),v.end()
#define SZ(v)                   (int)v.size()
#define CLR(v, d)               memset(v, d, sizeof(v))

const int OO = (int) 2e9;
const double EPS = 1e-9;

int dcmp(double a, double b) {
    return fabs(a - b) <= EPS ? 0 : a > b ? 1 : -1;
}

struct prob {
    int sm_s, l_s, sm_t, l_t;
    double fail;
    bool operator <(const prob & b) const {
        double x = (l_t * (1 - fail) * b.fail) + (l_t + b.l_t) * (1 - b.fail);
        double y = (b.l_t * (1 - b.fail) * fail) + (l_t + b.l_t) * (1 - fail);
        return x < y;
    }
};
int n, t;
vector<prob> v;

pair<long long, double> dp[1234][1578];

pair<long long, double> clc(int idx, int total) {

    if (total < 0)
        return MP(-1e18, 1e100);

    if (idx < 0)
        return total == 0 ? MP(0.0, 0.0) : MP(-1e18, 1e100);

    pair<long long, double> &ans = dp[idx][total];

    if (ans == ans)
        return ans;

    ans = clc(idx - 1, total); // skip

    pair<long long, double> cur = clc(idx - 1, total - v[idx].sm_t); // take small
    cur.first += v[idx].sm_s * (long long) 1e6;
    cur.second += v[idx].sm_t;

    if (cur.first > ans.first
            || (cur.first == ans.first && dcmp(cur.second, ans.second) < 0))
        ans = cur;

    // take small and large (  kolo ya waled )

    cur = clc(idx - 1, total - v[idx].sm_t - v[idx].l_t);
    cur.first += v[idx].sm_s * (long long) 1e6;
    cur.second += v[idx].sm_t;

    cur.first += v[idx].l_s
            * ((long long) 1e6 - (long long) (1e6 * v[idx].fail + EPS));

    cur.second = cur.second * v[idx].fail + total * (1 - v[idx].fail);

    if (cur.first > ans.first
            || (cur.first == ans.first && dcmp(cur.second, ans.second) < 0))
        ans = cur;

    return ans;
}

int main() {

    cin >> n >> t;
    v.resize(n);
    for (int i = 0; i < n; i++)
    cin >> v[i].sm_s >> v[i].l_s >> v[i].sm_t >> v[i].l_t >> v[i].fail;
    sort(ALL(v));

    pair<long long ,double> ans = MP(0,0);

    CLR(dp,-1);
    for(int i = 1; i<=t; i++) {
        pair<long long ,double> cur = clc(n-1,i);
        if(cur.first > ans.first || (cur.first == ans.first && dcmp(cur.second , ans.second ) < 0 ))
            ans = cur;
    }
    printf("%.9lf %.9lf" , ans.first / 1e6, ans.second);

    return 0;
}


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

#define PB                      push_back
#define MP                      make_pair
#define ALL(v)                  v.begin(),v.end()
#define SZ(v)                   (int)v.size()
#define CLR(v, d)               memset(v, d, sizeof(v))

const int OO = (int) 2e9;
const double EPS = 1e-9;

int dcmp(double a, double b) {
    return fabs(a - b) <= EPS ? 0 : a > b ? 1 : -1;
}

struct prob {
    int sm_s, l_s, sm_t, l_t;
    double fail;
    bool operator <(const prob & b) const {
        double x = (l_t * (1 - fail) * b.fail) + (l_t + b.l_t) * (1 - b.fail);
        double y = (b.l_t * (1 - b.fail) * fail) + (l_t + b.l_t) * (1 - fail);
        return x < y;
    }
};
int n, t;
vector<prob> v;

pair<long long, double> dp[1234][1578];

pair<long long, double> clc(int idx, int total) {

    if (total < 0)
        return MP(-1e18, 1e100);

    if (idx < 0)
        return total == 0 ? MP(0.0, 0.0) : MP(-1e18, 1e100);

    pair<long long, double> &ans = dp[idx][total];

    if (ans == ans)
        return ans;

    ans = clc(idx - 1, total); // skip

    pair<long long, double> cur = clc(idx - 1, total - v[idx].sm_t); // take small
    cur.first += v[idx].sm_s;
    cur.second += v[idx].sm_t;

    if (cur.first > ans.first
            || (cur.first == ans.first && dcmp(cur.second, ans.second) < 0))
        ans = cur;

    // take small and large (  kolo ya waled )

    cur = clc(idx - 1, total - v[idx].sm_t - v[idx].l_t);
    cur.first += v[idx].sm_s * (long long) 1e6;
    cur.second += v[idx].sm_t;

    cur.first += v[idx].l_s
            * ((long long) 1e6 - (long long) (1e6 * v[idx].fail + EPS));

    cur.second = cur.second * v[idx].fail + total * (1 - v[idx].fail);

    if (cur.first > ans.first
            || (cur.first == ans.first && dcmp(cur.second, ans.second) < 0))
        ans = cur;

    return ans;
}

int main() {

    cin >> n >> t;
    v.resize(n);
    for (int i = 0; i < n; i++)
    cin >> v[i].sm_s >> v[i].l_s >> v[i].sm_t >> v[i].l_t >> v[i].fail;
    sort(ALL(v));

    pair<long long ,double> ans = MP(0,0);

    CLR(dp,-1);
    for(int i = 1; i<=t; i++) {
        pair<long long ,double> cur = clc(n-1,i);
        if(cur.first > ans.first || (cur.first == ans.first && dcmp(cur.second , ans.second ) < 0 ))
            ans = cur;
    }
    printf("%.9lf %.9lf" , ans.first / 1e6, ans.second);

    return 0;
}


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

#define PB                      push_back
#define MP                      make_pair
#define ALL(v)                  v.begin(),v.end()
#define SZ(v)                   (int)v.size()
#define CLR(v, d)               memset(v, d, sizeof(v))

const int OO = (int) 2e9;
const double EPS = 1e-9;

int dcmp(double a, double b) {
    return fabs(a - b) <= EPS ? 0 : a > b ? 1 : -1;
}

struct prob {
    int sm_s, l_s, sm_t, l_t;
    double fail;
    bool operator <(const prob & b) const {
        double x = (l_t * (1 - fail) * b.fail) + (l_t + b.l_t) * (1 - b.fail);
        double y = (b.l_t * (1 - b.fail) * fail) + (l_t + b.l_t) * (1 - fail);
        return x < y;
    }
};
int n, t;
vector<prob> v;

pair<double, double> dp[1234][1578];

pair<double, double> clc(int idx, int total) {

    if (total < 0)
        return MP(-1e100, 1e100);

    if (idx < 0)
        return total == 0 ? MP(0.0, 0.0) : MP(-1e100, 1e100);

    pair<double, double> &ans = dp[idx][total];

    if (ans == ans)
        return ans;

    ans = clc(idx - 1, total); // skip

    pair<double, double> cur = clc(idx - 1, total - v[idx].sm_t); // take small
    cur.first += v[idx].sm_s;
    cur.second += v[idx].sm_t;

    if (dcmp(cur.first, ans.first) > 0
            || (dcmp(cur.first, ans.first) == 0
                    && dcmp(cur.second, ans.second) < 0))
        ans = cur;

    // take small and large (  kolo ya waled )

    cur = clc(idx - 1, total - v[idx].sm_t - v[idx].l_t);
    cur.first += v[idx].sm_s;
    cur.second += v[idx].sm_t;

    cur.first += v[idx].l_s * (1 - v[idx].fail);

    cur.second = cur.second * v[idx].fail + total * (1 - v[idx].fail);

    if (dcmp(cur.first, ans.first) > 0
            || (dcmp(cur.first, ans.first) == 0
                    && dcmp(cur.second, ans.second) < 0))
        ans = cur;

    return ans;
}

int main() {
    cin >> n >> t;
    v.resize(n);
    for (int i = 0; i < n; i++)
    cin >> v[i].sm_s >> v[i].l_s >> v[i].sm_t >> v[i].l_t >> v[i].fail;
    sort(ALL(v));

    pair<double,double> ans = MP(0,0);

    CLR(dp,-1);
    for(int i = 1; i<=t; i++) {
        pair<double,double> cur = clc(n-1,i);
        if(dcmp(cur.first,ans.first) > 0 || (dcmp(cur.first,ans.first) ==0 && dcmp(cur.second , ans.second ) < 0 ))
            ans = cur;
    }
    printf("%.9lf %.9lf" , ans.first , ans.second);

    return 0;
}


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

#define PB                      push_back
#define MP                      make_pair
#define ALL(v)                  v.begin(),v.end()
#define SZ(v)                   (int)v.size()
#define CLR(v, d)               memset(v, d, sizeof(v))

const int OO = (int) 1e9;
const double EPS = 1e-9;

int dcmp(double a, double b) {
    return fabs(a - b) <= EPS ? 0 : a > b ? 1 : -1;
}

struct prob {
    int sm_s, l_s, sm_t, l_t;
    double fail;
    bool operator <(const prob & b) const {
        double x = (l_t * (1 - fail) * b.fail) + (l_t + b.l_t) * (1 - b.fail);
        double y = (b.l_t * (1 - b.fail) * fail) + (l_t + b.l_t) * (1 - fail);
        return x < y;
    }
};
int n, t;
vector<prob> v;

pair<double, double> dp[1234][1578];

pair<double, double> clc(int idx, int total) {

    if (total < 0)
        return MP(-OO, OO);

    if (idx < 0)
        return total == 0 ? MP(0, 0) : MP(-OO, OO);

    pair<double, double> &ans = dp[idx][total];

    if (ans == ans)
        return ans;

    ans = clc(idx - 1, total); // skip

    pair<double, double> cur = clc(idx - 1, total - v[idx].sm_t); // take small
    cur.first += v[idx].sm_s;
    cur.second += v[idx].sm_t;

    if (dcmp(cur.first, ans.first) > 0
            || (dcmp(cur.first, ans.first) == 0
                    && dcmp(cur.second, ans.second) < 0))
        ans = cur;

    // take small and large (  kolo ya waled )

    cur = clc(idx - 1, total - v[idx].sm_t - v[idx].l_t);
    cur.first += v[idx].sm_s;
    cur.second += v[idx].sm_t;

    cur.first += v[idx].l_s * (1 - v[idx].fail);

    cur.second = cur.second * v[idx].fail + total * (1 - v[idx].fail);

    if (dcmp(cur.first, ans.first) > 0
            || (dcmp(cur.first, ans.first) == 0
                    && dcmp(cur.second, ans.second) < 0))
        ans = cur;

    return ans;
}

int main() {
    cin >> n >> t;
    v.resize(n);
    for (int i = 0; i < n; i++)
    cin >> v[i].sm_s >> v[i].l_s >> v[i].sm_t >> v[i].l_t >> v[i].fail;
    sort(ALL(v));

    pair<double,double> ans = MP(-OO,OO);

    CLR(dp,-1);
    for(int i = 1; i<=t; i++) {
        pair<double,double> cur = clc(n-1,i);
        if(dcmp(cur.first,ans.first) > 0 || (dcmp(cur.first,ans.first) ==0 && dcmp(cur.second , ans.second ) < 0 ))
            ans = cur;
    }
    printf("%.9lf %.9lf" , ans.first , ans.second);

    return 0;
}


#include<iostream>
#include<algorithm>
#include<iomanip>
#include<cstring>
#include<vector>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ld,ld> PLD;
typedef pair<int,int> PII;

#define F first
#define S second

const double ep = 1e-6;
const double INF = 1e18;
const int MUL = 1000*1000;
const int MAXN = 1000+2;
const int MAXT = 1560+10;

struct Prob{
	int ts,tl,ss,sl;
	ll s1,s2;
	double fail;
	double rate;
}p[MAXN+10];

bool cmp(Prob a,Prob b) { return a.rate<b.rate; }

PLD d[MAXN+10][MAXT+10];
int n,t;

void output();
void input();
void dyn();

vector<PII> v;

int main()
{
	input();
	sort( p , p+n , cmp );
	dyn();
	output();
	return 0;
}

void output()
{
	int best = 0;
	for(int i=1; i<=t; i++)
		if( d[n][i].F > d[n][best].F || ( d[n][i].F == d[n][best].F && d[n][i].S < d[n][best].S ) )
			best = i;
	cout << setprecision(6) << fixed << (double)d[n][best].F/MUL << " " << d[n][best].S << endl;
}

inline void update(int i,int j,PLD inp)
{
	if( j<=t )
		if( d[i][j].F < inp.F || ( d[i][j].F == inp.F && d[i][j].S > inp.S ) )
			d[i][j] = inp;
}

void dyn()
{
	for(int i=0; i<n; i++)
		for(int j=0; j<t; j++)
		{
			update( i+1 , j , d[i][j] );
			update( i+1 , j+p[i].ts , PLD( d[i][j].F + p[i].s1 , d[i][j].S + p[i].ts ) );
			update( i+1 , j+p[i].ts+p[i].tl ,
				PLD( d[i][j].F + p[i].s1 + p[i].s2 ,
				p[i].ts + (j+p[i].tl)*(1.0-p[i].fail) + d[i][j].S * p[i].fail ) );
		}
}

void input()
{
	ios::sync_with_stdio(false);
	cin >> n >> t;
	for(int i=0; i<n; i++)
	{
		cin >> p[i].ss >> p[i].sl >> p[i].ts >> p[i].tl >> p[i].fail;
		int tmp = (int)( p[i].fail * MUL + 0.5 );
		p[i].rate = ( tmp == MUL ? INF : p[i].tl * p[i].fail / ( 1.0 - p[i].fail ) );
		p[i].s1 = (ll)p[i].ss * MUL;
		p[i].s2 = (ll)p[i].sl * ( MUL - tmp );
	}
}


#include<iostream>
#include<algorithm>
#include<iomanip>
#include<cstring>
#include<vector>
using namespace std;
typedef long long ll;
typedef pair<ll,double> PLD;
typedef pair<int,int> PII;

#define F first
#define S second

const double INF = 1e60;
const int MUL = 1000*1000;
const int MAXN = 1000+2;
const int MAXT = 1560+10;

struct Prob{
	int ts,tl,ss,sl;
	double p;
}p[MAXN+10];

double Calc(Prob a) { return ( a.p == 1 ? INF : (a.tl*a.p/(1-a.p)) ); }
bool cmp(Prob a,Prob b) { return Calc(a)<Calc(b); }

PLD d[MAXN+10][MAXT+10];
int par[MAXN+10][MAXT+10];
int n,t;

void find_Par();
//void output();
void input();
void dyn();

vector<PII> v;

int main()
{
	input();
	sort( p , p+n , cmp );
	dyn();
	find_Par();
	//output();
	return 0;
}

void find_Par()
{
	int best = 0;
	for(int i=1; i<=t; i++)
		if( d[n][i].F > d[n][best].F || ( d[n][i].F == d[n][best].F && d[n][i].S < d[n][best].S ) )
			best = i;
	cout << setprecision(6) << fixed << (double)d[n][best].F/MUL << " " << d[n][best].S << endl;
	/*for(int i=n; i>0; i--)
	{
		if( par[i][best] == 1 )
		{
			best -= p[i-1].ts;
			v.push_back(PII(i-1,1));
		}
		else if( par[i][best] == 2 )
		{
			best -= p[i-1].ts + p[i-1].tl;
			v.push_back(PII(i-1,2));
		}
	}*/
}

inline void update(int pp,int i,int j,PLD inp)
{
	if( j<=t )
	{
		if( d[i][j].F < inp.F || ( d[i][j].F == inp.F && d[i][j].S > inp.S ) )
		{
			d[i][j] = inp;
			par[i][j] = pp;
		}
	}
}

void dyn()
{
	memset( par , -1 , sizeof par );
	for(int i=0; i<n; i++)
		for(int j=0; j<t; j++)
		{
			update( 0 , i+1 , j , d[i][j] );
			update( 1 , i+1 , j+p[i].ts , PLD( d[i][j].F + (ll)p[i].ss*MUL , d[i][j].S + p[i].ts ) );
			update( 2 , i+1 , j+p[i].ts+p[i].tl ,
				PLD( d[i][j].F + (ll)p[i].ss*MUL + (ll)(p[i].sl*(1-p[i].p)*MUL) ,
				p[i].ts + (j+p[i].tl)*(1-p[i].p) + d[i][j].S * p[i].p ) );
		}
}

void input()
{
	ios::sync_with_stdio(false);
	cin >> n >> t;
	for(int i=0; i<n; i++)
		cin >> p[i].ss >> p[i].sl >> p[i].ts >> p[i].tl >> p[i].p;
}


#include<iostream>
#include<algorithm>
#include<iomanip>
#include<cstring>
#include<vector>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ld,double> PLD;
typedef pair<int,int> PII;

#define F first
#define S second

const double INF = 1e60;
const int MUL = 1000*1000;
const int MAXN = 1000+2;
const int MAXT = 1560+10;

struct Prob{
	int ts,tl,ss,sl;
	double p;
}p[MAXN+10];

double Calc(Prob a) { return ( a.p == 1 ? INF : (a.tl*a.p/(1-a.p)) ); }
bool cmp(Prob a,Prob b) { return Calc(a)<Calc(b); }

PLD d[MAXN+10][MAXT+10];
int par[MAXN+10][MAXT+10];
int n,t;

void find_Par();
//void output();
void input();
void dyn();

vector<PII> v;

int main()
{
	input();
	sort( p , p+n , cmp );
	dyn();
	find_Par();
	//output();
	return 0;
}

void find_Par()
{
	int best = 0;
	for(int i=1; i<=t; i++)
		if( d[n][i].F > d[n][best].F || ( d[n][i].F == d[n][best].F && d[n][i].S < d[n][best].S ) )
			best = i;
	cout << setprecision(6) << fixed << d[n][best].F << " " << d[n][best].S << endl;
	/*for(int i=n; i>0; i--)
	{
		if( par[i][best] == 1 )
		{
			best -= p[i-1].ts;
			v.push_back(PII(i-1,1));
		}
		else if( par[i][best] == 2 )
		{
			best -= p[i-1].ts + p[i-1].tl;
			v.push_back(PII(i-1,2));
		}
	}*/
}

inline void update(int pp,int i,int j,PLD inp)
{
	if( j<=t )
	{
		if( d[i][j].F < inp.F || ( d[i][j].F == inp.F && d[i][j].S > inp.S ) )
		{
			d[i][j] = inp;
			par[i][j] = pp;
		}
	}
}

void dyn()
{
	memset( par , -1 , sizeof par );
	for(int i=0; i<n; i++)
		for(int j=0; j<t; j++)
		{
			update( 0 , i+1 , j , d[i][j] );
			update( 1 , i+1 , j+p[i].ts , PLD( d[i][j].F + p[i].ss , d[i][j].S + p[i].ts ) );
			update( 2 , i+1 , j+p[i].ts+p[i].tl ,
				PLD( d[i][j].F + p[i].ss + (p[i].sl*(1-p[i].p)) ,
				p[i].ts + (j+p[i].tl)*(1-p[i].p) + d[i][j].S * p[i].p ) );
		}
}

void input()
{
	ios::sync_with_stdio(false);
	cin >> n >> t;
	for(int i=0; i<n; i++)
		cin >> p[i].ss >> p[i].sl >> p[i].ts >> p[i].tl >> p[i].p;
}


#include<iostream>
#include<algorithm>
#include<iomanip>
#include<cstring>
#include<vector>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ld> PLD;
typedef pair<int,int> PII;

#define F first
#define S second

const double ep = 1e-6;
const double INF = 1e18;
const int MUL = 1000*1000;
const int MAXN = 1000+2;
const int MAXT = 1560+10;

struct Prob{
	int ts,tl,ss,sl;
	ll s1,s2;
	double fail;
	double rate;
}p[MAXN+10];

bool cmp(Prob a,Prob b) { return a.rate<b.rate; }

PLD d[MAXN+10][MAXT+10];
int n,t;

void output();
void input();
void dyn();

vector<PII> v;

int main()
{
	input();
	sort( p , p+n , cmp );
	dyn();
	output();
	return 0;
}

void output()
{
	int best = 0;
	for(int i=1; i<=t; i++)
		if( d[n][i].F > d[n][best].F || ( d[n][i].F == d[n][best].F && d[n][i].S < d[n][best].S ) )
			best = i;
	cout << setprecision(6) << fixed << (double)d[n][best].F/MUL << " " << d[n][best].S << endl;
}

inline void update(int i,int j,PLD inp)
{
	if( j<=t )
		if( d[i][j].F < inp.F || ( d[i][j].F == inp.F && d[i][j].S > inp.S ) )
			d[i][j] = inp;
}

void dyn()
{
	for(int i=0; i<n; i++)
		for(int j=0; j<t; j++)
		{
			update( i+1 , j , d[i][j] );
			update( i+1 , j+p[i].ts , PLD( d[i][j].F + p[i].s1 , d[i][j].S + p[i].ts ) );
			update( i+1 , j+p[i].ts+p[i].tl ,
				PLD( d[i][j].F + p[i].s1 + p[i].s2 ,
				p[i].ts + (j+p[i].tl)*(1.0-p[i].fail) + d[i][j].S * p[i].fail ) );
		}
}

void input()
{
	ios::sync_with_stdio(false);
	cin >> n >> t;
	for(int i=0; i<n; i++)
	{
		cin >> p[i].ss >> p[i].sl >> p[i].ts >> p[i].tl >> p[i].fail;
		int tmp = (int)( p[i].fail * MUL + 0.5 );
		p[i].rate = ( tmp == MUL ? INF : p[i].tl * p[i].fail / ( 1.0 - p[i].fail ) );
		p[i].s1 = (ll)p[i].ss * MUL;
		p[i].s2 = (ll)p[i].sl * ( MUL - tmp );
	}
}


#include<iostream>
#include<algorithm>
#include<iomanip>
#include<cstring>
#include<vector>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ld> PLD;
typedef pair<int,int> PII;

#define F first
#define S second

const double ep = 1e-6;
const double INF = 1e18;
const int MUL = 1000*1000;
const int MAXN = 1000+2;
const int MAXT = 1560+10;

struct Prob{
	int ts,tl,ss,sl;
	ll s1,s2;
	double fail;
	double rate;
}p[MAXN+10];

bool cmp(Prob a,Prob b) { return a.rate<b.rate; }

PLD d[MAXN+10][MAXT+10];
int n,t;

void output();
void input();
void dyn();

vector<PII> v;

int main()
{
	input();
	sort( p , p+n , cmp );
	dyn();
	output();
	return 0;
}

void output()
{
	int best = 0;
	for(int i=1; i<=t; i++)
		if( d[n][i].F > d[n][best].F || ( d[n][i].F == d[n][best].F && d[n][i].S < d[n][best].S ) )
			best = i;
	cout << setprecision(6) << fixed << (double)d[n][best].F/MUL << " " << d[n][best].S << endl;
}

inline void update(int i,int j,PLD inp)
{
	if( j<=t )
		if( d[i][j].F < inp.F || ( d[i][j].F == inp.F && d[i][j].S > inp.S ) )
			d[i][j] = inp;
}

void dyn()
{
	for(int i=0; i<=n; i++)
		for(int j=0; j<=t; j++)
			d[i][j].F = -1;
	d[0][0].F = 0;
	for(int i=0; i<n; i++)
		for(int j=0; j<t; j++)
		{
			update( i+1 , j , d[i][j] );
			update( i+1 , j+p[i].ts , PLD( d[i][j].F + p[i].s1 , d[i][j].S + p[i].ts ) );
			update( i+1 , j+p[i].ts+p[i].tl ,
				PLD( d[i][j].F + p[i].s1 + p[i].s2 ,
				p[i].ts + (j+p[i].tl)*(1.0-p[i].fail) + d[i][j].S * p[i].fail ) );
		}
}

void input()
{
	ios::sync_with_stdio(false);
	cin >> n >> t;
	for(int i=0; i<n; i++)
	{
		cin >> p[i].ss >> p[i].sl >> p[i].ts >> p[i].tl >> p[i].fail;
		int tmp = (int)( p[i].fail * MUL + 0.5 );
		p[i].rate = ( tmp == MUL ? INF : p[i].tl * p[i].fail / ( 1.0 - p[i].fail ) );
		p[i].s1 = (ll)p[i].ss * MUL;
		p[i].s2 = (ll)p[i].sl * ( MUL - tmp );
	}
}


#include<iostream>
#include<algorithm>
#include<iomanip>
#include<cstring>
#include<vector>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,double> PLD;
typedef pair<int,int> PII;

#define F first
#define S second

const double INF = 1e18;
const int MUL = 1000*1000;
const int MAXN = 1000+2;
const int MAXT = 1600+10;

struct Prob{
	int ts,tl,ss,sl;
	ll s1,s2;
	double fail;
	double rate;
}p[MAXN+10];

bool cmp(Prob a,Prob b) { return a.rate<b.rate; }

PLD d[MAXN+10][MAXT+10];
int n,t;

void output();
void input();
void dyn();

int main()
{
	input();
	sort( p , p+n , cmp );
	dyn();
	output();
	return 0;
}

void output()
{
	int best = 0;
	for(int i=1; i<=t; i++)
		if( d[n][i].F > d[n][best].F || ( d[n][i].F == d[n][best].F && d[n][i].S < d[n][best].S ) )
			best = i;
	cout << setprecision(8) << fixed << (double)d[n][best].F/MUL << " " << d[n][best].S << endl;
}

inline void update(int i,int j,PLD inp)
{
	if( j<=t )
		if( d[i][j].F < inp.F || ( d[i][j].F == inp.F && d[i][j].S > inp.S ) )
			d[i][j] = inp;
}

void dyn()
{
	for(int i=0; i<=n; i++)
		for(int j=0; j<=t; j++)
			d[i][j].F = -1;
	d[0][0].F = 0;
	for(int i=0; i<n; i++)
		for(int j=0; j<=t; j++)
		{
			update( i+1 , j , d[i][j] );
			update( i+1 , j+p[i].ts , PLD( d[i][j].F + p[i].s1 , d[i][j].S + p[i].ts ) );
			update( i+1 , j+p[i].ts+p[i].tl ,
				PLD( d[i][j].F + p[i].s1 + p[i].s2 ,
				(p[i].ts+j+p[i].tl)*(1.0-p[i].fail) + (p[i].ts+d[i][j].S) * p[i].fail ) );
		}
}

void input()
{
	ios::sync_with_stdio(false);
	cin >> n >> t;
	for(int i=0; i<n; i++)
	{
		cin >> p[i].ss >> p[i].sl >> p[i].ts >> p[i].tl >> p[i].fail;
		int tmp = (int)( p[i].fail * MUL + 0.5 );
		p[i].rate = ( tmp == MUL ? INF : p[i].tl * p[i].fail / ( 1.0 - p[i].fail ) );
		p[i].s1 = (ll)p[i].ss * (ll)MUL;
		p[i].s2 = (ll)p[i].sl * ( (ll) MUL - tmp );
	}
}


#include<iostream>
#include<algorithm>
#include<iomanip>
#include<cstring>
#include<vector>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,double> PLD;
typedef pair<int,int> PII;

#define F first
#define S second

const double INF = 1e18;
const int MUL = 1000*1000;
const int MAXN = 1000+2;
const int MAXT = 1600+10;

struct Prob{
	int ts,tl,ss,sl;
	ll s1,s2;
	double fail;
	double rate;
}p[MAXN+10];

bool cmp(Prob a,Prob b) { return a.rate<b.rate; }

PLD d[MAXN+10][MAXT+10];
int n,t;

void output();
void input();
void dyn();

int main()
{
	input();
	sort( p , p+n , cmp );
	dyn();
	output();
	return 0;
}

void output()
{
	int best = 0;
	for(int i=1; i<=t; i++)
		if( d[n][i].F > d[n][best].F || ( d[n][i].F == d[n][best].F && d[n][i].S < d[n][best].S ) )
			best = i;
	cout << setprecision(6) << fixed << (double)d[n][best].F/MUL << " " << d[n][best].S << endl;
}

inline void update(int i,int j,PLD inp)
{
	if( j<=t )
		if( d[i][j].F < inp.F || ( d[i][j].F == inp.F && d[i][j].S > inp.S ) )
			d[i][j] = inp;
}

void dyn()
{
	for(int i=0; i<=n; i++)
		for(int j=0; j<=t; j++)
			d[i][j].F = -1;
	d[0][0].F = 0;
	for(int i=0; i<n; i++)
		for(int j=0; j<=t; j++)
		{
			update( i+1 , j , d[i][j] );
			update( i+1 , j+p[i].ts , PLD( d[i][j].F + p[i].s1 , d[i][j].S + p[i].ts ) );
			update( i+1 , j+p[i].ts+p[i].tl ,
				PLD( d[i][j].F + p[i].s1 + p[i].s2 ,
				(p[i].ts+j+p[i].tl)*(1.0-p[i].fail) + ( p[i].ts+d[i][j].S) * p[i].fail ) );
		}
}

void input()
{
	ios::sync_with_stdio(false);
	cin >> n >> t;
	for(int i=0; i<n; i++)
	{
		cin >> p[i].ss >> p[i].sl >> p[i].ts >> p[i].tl >> p[i].fail;
		int tmp = (int)( p[i].fail * MUL + 0.5 );
		p[i].rate = ( tmp == MUL ? INF : p[i].tl * p[i].fail / ( 1.0 - p[i].fail ) );
		p[i].s1 = (ll)p[i].ss * (ll)MUL;
		p[i].s2 = (ll)p[i].sl * ( (ll) MUL - tmp );
	}
}


#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<vector>
#include<deque>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<algorithm>
#include<functional>
#include<utility>
#include<bitset>
#include<cmath>
#include<cstdlib>
#include<ctime>
#include<cstdio>
using namespace std;
#define REP(i,n) for((i)=0;(i)<(int)(n);(i)++)
#define snuke(c,itr) for(__typeof((c).begin()) itr=(c).begin();itr!=(c).end();itr++)
typedef long long ll;
struct problem {int score1,score2; int time1,time2; double fail; ll expscore1,expscore2; double ratio;};
int N,T;
problem P[1010];
ll dpscore[1010][1600];
double dppenal[1010][1600];
void update(int n, int t, ll score, double penal){
    if(n <= N && t <= T && (score > dpscore[n][t] || (score == dpscore[n][t] && penal < dppenal[n][t]))){
        dpscore[n][t] = score;
        dppenal[n][t] = penal;
    }
}
int main(){
    int i,j;
    cin >> N >> T;
    REP(i,N){
        cin >> P[i].score1 >> P[i].score2 >> P[i].time1 >> P[i].time2 >> P[i].fail;
        P[i].expscore1 = (ll)P[i].score1 * (ll)1000000000;
        ll tmp =(P[i].fail * 1000000000);
        P[i].expscore2 = (ll)P[i].score2 * (ll)(1000000000 - tmp);
        P[i].ratio = ((tmp == 1000000000) ? (1.0E+18) : (P[i].time2 * P[i].fail / (1.0 - P[i].fail)));
    }
    REP(i,N+5) REP(j,N-1) if(P[j].ratio > P[j+1].ratio) swap(P[j], P[j+1]);
    REP(i,N+1) REP(j,T+1) dpscore[i][j] = -1;
    dpscore[0][0] = 0;
    REP(i,N) REP(j,T+1) if(dpscore[i][j] != -1){
        ll score = dpscore[i][j];
        double penal = dppenal[i][j];
        // solve 0
        update(i+1, j, score, penal);
        // solve 1
        update(i+1, j + P[i].time1, score + P[i].expscore1, penal + P[i].time1);
        // solve 2
        double fail_penalty = penal + P[i].time1;
        double ac_penalty = j + P[i].time1 + P[i].time2;
        update(i+1, j + P[i].time1 + P[i].time2, score + P[i].expscore1 + P[i].expscore2, fail_penalty * P[i].fail + ac_penalty * (1.0 - P[i].fail));
    }
    ll score = 0;
    double penal = 0.0;
    REP(i,T+1){
        ll score2 = dpscore[N][i];
        double penal2 = dppenal[N][i];
        if(score2 > score || (score2 == score && penal2 < penal)){
            score = score2;
            penal = penal2;
        }
    }
    printf("%.12f %.12f\n", score / 1000000000.0, penal);
    return 0;
}


#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<vector>
#include<deque>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<algorithm>
#include<functional>
#include<utility>
#include<bitset>
#include<cmath>
#include<cstdlib>
#include<ctime>
#include<cstdio>
using namespace std;
#define REP(i,n) for((i)=0;(i)<(int)(n);(i)++)
#define snuke(c,itr) for(__typeof((c).begin()) itr=(c).begin();itr!=(c).end();itr++)
typedef long long ll;
struct problem {int score1,score2; int time1,time2; double fail; ll expscore1,expscore2; double ratio;};
int N,T;
problem P[1010];
ll dpscore[1010][1600];
double dppenal[1010][1600];
void update(int n, int t, ll score, double penal){
    if(n <= N && t <= T && (score > dpscore[n][t] || (score == dpscore[n][t] && penal < dppenal[n][t]))){
        dpscore[n][t] = score;
        dppenal[n][t] = penal;
    }
}
int main(){
    int i,j;
    cin >> N >> T;
    REP(i,N){
        cin >> P[i].score1 >> P[i].score2 >> P[i].time1 >> P[i].time2 >> P[i].fail;
        P[i].expscore1 = (ll)P[i].score1 * (ll)1000000;
        int tmp = (floor)(P[i].fail * 1000000);
        P[i].expscore2 = (ll)P[i].score2 * (ll)(1000000 - tmp);
        P[i].ratio = ((tmp == 1000000) ? (1.0E+18) : (P[i].time2 * P[i].fail / (1.0 - P[i].fail)));
    }
    REP(i,N+5) REP(j,N-1) if(P[j].ratio > P[j+1].ratio) swap(P[j], P[j+1]);
    REP(i,N+1) REP(j,T+1) dpscore[i][j] = -1;
    dpscore[0][0] = 0;
    REP(i,N) REP(j,T+1) if(dpscore[i][j] != -1){
        ll score = dpscore[i][j];
        double penal = dppenal[i][j];
        // solve 0
        update(i+1, j, score, penal);
        // solve 1
        update(i+1, j + P[i].time1, score + P[i].expscore1, penal + P[i].time1);
        // solve 2
        double fail_penalty = penal + P[i].time1;
        double ac_penalty = j + P[i].time1 + P[i].time2;
        update(i+1, j + P[i].time1 + P[i].time2, score + P[i].expscore1 + P[i].expscore2, fail_penalty * P[i].fail + ac_penalty * (1.0 - P[i].fail));
    }
    ll score = 0;
    double penal = 0.0;
    REP(i,T+1){
        ll score2 = dpscore[N][i];
        double penal2 = dppenal[N][i];
        if(score2 > score || (score2 == score && penal2 < penal)){
            score = score2;
            penal = penal2;
        }
    }
    printf("%.12f %.12f\n", score / 1000000.0, penal);
    return 0;
}


#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<vector>
#include<deque>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<algorithm>
#include<functional>
#include<utility>
#include<bitset>
#include<cmath>
#include<cstdlib>
#include<ctime>
#include<cstdio>
using namespace std;
#define REP(i,n) for((i)=0;(i)<(int)(n);(i)++)
#define snuke(c,itr) for(__typeof((c).begin()) itr=(c).begin();itr!=(c).end();itr++)
typedef long long ll;
struct problem {int score1,score2; int time1,time2; double fail; ll expscore1,expscore2; double ratio;};
int N,T;
problem P[1010];
ll dpscore[1010][1600];
double dppenal[1010][1600];
void update(int n, int t, ll score, double penal){
    if(n <= N && t <= T && (score > dpscore[n][t] || (score == dpscore[n][t] && penal < dppenal[n][t]))){
        dpscore[n][t] = score;
        dppenal[n][t] = penal;
    }
}
int main(){
    int i,j;
    cin >> N >> T;
    REP(i,N){
        cin >> P[i].score1 >> P[i].score2 >> P[i].time1 >> P[i].time2 >> P[i].fail;
        P[i].expscore1 = (ll)P[i].score1 * (ll)1000000000;
        ll tmp =(int)(P[i].fail * 1000000000);
        P[i].expscore2 = (ll)P[i].score2 * (ll)(1000000000 - tmp);
        P[i].ratio = ((tmp == 1000000000) ? (1.0E+18) : (P[i].time2 * P[i].fail / (1.0 - P[i].fail)));
    }
    REP(i,N+5) REP(j,N-1) if(P[j].ratio > P[j+1].ratio) swap(P[j], P[j+1]);
    REP(i,N+1) REP(j,T+1) dpscore[i][j] = -1;
    dpscore[0][0] = 0;
    REP(i,N) REP(j,T+1) if(dpscore[i][j] != -1){
        ll score = dpscore[i][j];
        double penal = dppenal[i][j];
        // solve 0
        update(i+1, j, score, penal);
        // solve 1
        update(i+1, j + P[i].time1, score + P[i].expscore1, penal + P[i].time1);
        // solve 2
        double fail_penalty = penal + P[i].time1;
        double ac_penalty = j + P[i].time1 + P[i].time2;
        update(i+1, j + P[i].time1 + P[i].time2, score + P[i].expscore1 + P[i].expscore2, fail_penalty * P[i].fail + ac_penalty * (1.0 - P[i].fail));
    }
    ll score = 0;
    double penal = 0.0;
    REP(i,T+1){
        ll score2 = dpscore[N][i];
        double penal2 = dppenal[N][i];
        if(score2 > score || (score2 == score && penal2 < penal)){
            score = score2;
            penal = penal2;
        }
    }
    printf("%.12f %.12f\n", score / 1000000000.0, penal);
    return 0;
}


#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstdio>

using namespace std;

#define REP(i,n) for((i)=0;(i)<(int)(n);(i)++)
#define snuke(c,itr) for(__typeof((c).begin()) itr=(c).begin();itr!=(c).end();itr++)

typedef long long ll;

struct problem {int score1,score2; int time1,time2; double fail; ll expscore1,expscore2; double ratio;};

int N,T;
problem P[1010];

ll dpscore[1010][1600];
double dppenal[1010][1600];

void update(int n, int t, ll score, double penal){
    if(n <= N && t <= T && (score > dpscore[n][t] || (score == dpscore[n][t] && penal < dppenal[n][t]))){
        dpscore[n][t] = score;
        dppenal[n][t] = penal;
    }
}

int main(void){
    int i,j;

    cin >> N >> T;
    REP(i,N){
        cin >> P[i].score1 >> P[i].score2 >> P[i].time1 >> P[i].time2 >> P[i].fail;
        P[i].expscore1 = (ll)P[i].score1 * (ll)1000000;
        int tmp = (int)(P[i].fail * 1000000);
        P[i].expscore2 = (ll)P[i].score2 * (ll)(1000000 - tmp);
        P[i].ratio = ((tmp == 1000000) ? (1.0E+18) : (P[i].time2 * P[i].fail / (1.0 - P[i].fail)));
    }

    REP(i,N+5) REP(j,N-1) if(P[j].ratio > P[j+1].ratio) swap(P[j], P[j+1]);

    REP(i,N+1) REP(j,T+1) dpscore[i][j] = -1;
    dpscore[0][0] = 0;

    REP(i,N) REP(j,T+1) if(dpscore[i][j] != -1){
        ll score = dpscore[i][j];
        double penal = dppenal[i][j];

        // solve 0
        update(i+1, j, score, penal);

        // solve 1
        update(i+1, j + P[i].time1, score + P[i].expscore1, penal + P[i].time1);

        // solve 2
        double fail_penalty = penal + P[i].time1;
        double ac_penalty = j + P[i].time1 + P[i].time2;
        update(i+1, j + P[i].time1 + P[i].time2, score + P[i].expscore1 + P[i].expscore2, fail_penalty * P[i].fail + ac_penalty * (1.0 - P[i].fail));
    }

    ll score = 0;
    double penal = 0.0;
    REP(i,T+1){
        ll score2 = dpscore[N][i];
        double penal2 = dppenal[N][i];
        if(score2 > score || (score2 == score && penal2 < penal)){
            score = score2;
            penal = penal2;
        }
    }

    printf("%.12f %.12f\n", score / 1000000.0, penal);

    return 0;
}


#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<vector>
#include<deque>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<algorithm>
#include<functional>
#include<utility>
#include<bitset>
#include<cmath>
#include<cstdlib>
#include<ctime>
#include<cstdio>
using namespace std;
#define REP(i,n) for((i)=0;(i)<(int)(n);(i)++)
#define snuke(c,itr) for(__typeof((c).begin()) itr=(c).begin();itr!=(c).end();itr++)
typedef long long ll;
struct problem {int score1,score2; int time1,time2; double fail; ll expscore1,expscore2; double ratio;};
int N,T;
problem P[1010];
ll dpscore[1010][1600];
double dppenal[1010][1600];
void update(int n, int t, ll score, double penal){
    if(n <= N && t <= T && (score > dpscore[n][t] || (score == dpscore[n][t] && penal < dppenal[n][t]))){
        dpscore[n][t] = score;
        dppenal[n][t] = penal;
    }
}
int main(){
    int i,j;
    cin >> N >> T;
    REP(i,N){
        cin >> P[i].score1 >> P[i].score2 >> P[i].time1 >> P[i].time2 >> P[i].fail;
        P[i].expscore1 = (ll)P[i].score1 * (ll)10000000000000;
        ll tmp =(long long)(P[i].fail * 10000000000000);
        P[i].expscore2 = (ll)P[i].score2 * (ll)(10000000000000 - tmp);
        P[i].ratio = ((tmp == 10000000000000) ? (1.0E+18) : (P[i].time2 * P[i].fail / (1.0 - P[i].fail)));
    }
    REP(i,N+5) REP(j,N-1) if(P[j].ratio > P[j+1].ratio) swap(P[j], P[j+1]);
    REP(i,N+1) REP(j,T+1) dpscore[i][j] = -1;
    dpscore[0][0] = 0;
    REP(i,N) REP(j,T+1) if(dpscore[i][j] != -1){
        ll score = dpscore[i][j];
        double penal = dppenal[i][j];
        // solve 0
        update(i+1, j, score, penal);
        // solve 1
        update(i+1, j + P[i].time1, score + P[i].expscore1, penal + P[i].time1);
        // solve 2
        double fail_penalty = penal + P[i].time1;
        double ac_penalty = j + P[i].time1 + P[i].time2;
        update(i+1, j + P[i].time1 + P[i].time2, score + P[i].expscore1 + P[i].expscore2, fail_penalty * P[i].fail + ac_penalty * (1.0 - P[i].fail));
    }
    ll score = 0;
    double penal = 0.0;
    REP(i,T+1){
        ll score2 = dpscore[N][i];
        double penal2 = dppenal[N][i];
        if(score2 > score || (score2 == score && penal2 < penal)){
            score = score2;
            penal = penal2;
        }
    }
    printf("%.12f %.12f\n", score / 10000000000000.0, penal);
    return 0;
}


#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<vector>
#include<deque>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<algorithm>
#include<functional>
#include<utility>
#include<bitset>
#include<cmath>
#include<cstdlib>
#include<ctime>
#include<cstdio>
using namespace std;
#define REP(i,n) for((i)=0;(i)<(int)(n);(i)++)
#define snuke(c,itr) for(__typeof((c).begin()) itr=(c).begin();itr!=(c).end();itr++)
typedef long long ll;
struct problem {int score1,score2; int time1,time2; double fail; ll expscore1,expscore2; double ratio;};
int N,T;
problem P[1010];
ll dpscore[1010][1600];
double dppenal[1010][1600];
void update(int n, int t, ll score, double penal){
    if(n <= N && t <= T && (score > dpscore[n][t] || (score == dpscore[n][t] && penal < dppenal[n][t]))){
        dpscore[n][t] = score;
        dppenal[n][t] = penal;
    }
}
int main(){
    int i,j;
    cin >> N >> T;
    REP(i,N){
        cin >> P[i].score1 >> P[i].score2 >> P[i].time1 >> P[i].time2 >> P[i].fail;
        P[i].expscore1 = (ll)P[i].score1 * (ll)1000000;
        int tmp = (round)(P[i].fail * 1000000);
        P[i].expscore2 = (ll)P[i].score2 * (ll)(1000000 - tmp);
        P[i].ratio = ((tmp == 1000000) ? (1.0E+18) : (P[i].time2 * P[i].fail / (1.0 - P[i].fail)));
    }
    REP(i,N+5) REP(j,N-1) if(P[j].ratio > P[j+1].ratio) swap(P[j], P[j+1]);
    REP(i,N+1) REP(j,T+1) dpscore[i][j] = -1;
    dpscore[0][0] = 0;
    REP(i,N) REP(j,T+1) if(dpscore[i][j] != -1){
        ll score = dpscore[i][j];
        double penal = dppenal[i][j];
        // solve 0
        update(i+1, j, score, penal);
        // solve 1
        update(i+1, j + P[i].time1, score + P[i].expscore1, penal + P[i].time1);
        // solve 2
        double fail_penalty = penal + P[i].time1;
        double ac_penalty = j + P[i].time1 + P[i].time2;
        update(i+1, j + P[i].time1 + P[i].time2, score + P[i].expscore1 + P[i].expscore2, fail_penalty * P[i].fail + ac_penalty * (1.0 - P[i].fail));
    }
    ll score = 0;
    double penal = 0.0;
    REP(i,T+1){
        ll score2 = dpscore[N][i];
        double penal2 = dppenal[N][i];
        if(score2 > score || (score2 == score && penal2 < penal)){
            score = score2;
            penal = penal2;
        }
    }
    printf("%.12f %.12f\n", score / 1000000.0, penal);
    return 0;
}


#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<algorithm>
#include<cctype>
#include<cmath>
#include<cstdlib>
#include<queue>
#include<ctime>
#include<vector>
#include<set>
#include<map>
#include<stack>
using namespace std;
int main()
{     cout<<24.000<<' '<<18.875000<<endl;
	  return 0;
}


#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
#include<cmath>
#define N 3005
#define D 1000000
#define Long long long
#define For(i,l,r) for(int i=l;i<=r;i++)
using namespace std;
struct rec{
    Long pSml,tSml,pLar,tLar; long double fail;
    void read(){
        scanf("%I64d%I64d%I64d%I64d",&pSml,&pLar,&tSml,&tLar);
        pSml*=D; pLar*=D;
        double p;scanf("%lf",&p);
        fail=p;
    }
}E[N];
bool cmp(const rec &i,const rec &j){
    return i.fail*j.fail*(j.tLar-i.tLar)+i.fail*i.tLar-j.fail*j.tLar<0;
}
int n,m,x,y;
long double F[N][N],G[N][N];
void update(int i,int j,long double f,long double g){
    if(j>m) return;
    if(f>F[i][j]) F[i][j]=f,G[i][j]=g;
    if( abs(f-F[i][j])<0.0001 ) G[i][j]=min(G[i][j],g);
}
int main(){
    scanf("%d%d",&n,&m);
    For(i,1,n) E[i].read();
    sort(E+1,E+1+n,cmp);

//  For(i,1,n) printf("Fail %lf\n",E[i].fail);

    For(i,1,n) For(j,0,m){
        Long pSml=E[i].pSml;
        Long tSml=E[i].tSml;
        Long pLar=E[i].pLar;
        Long tLar=E[i].tLar;
        long double fail=E[i].fail;

        update(i+1,j,F[i][j],G[i][j]);
        update(i+1,j+tSml,F[i][j]+pSml,G[i][j]+tSml);
        update(i+1,j+tSml+tLar,
            pSml+F[i][j]+(1-fail)*pLar,
            tSml+(1-fail)*(j+tLar)+fail*G[i][j]
        );
    }
    For(i,1,n+1) For(j,0,m){
        if( (F[i][j]-F[x][y])<0.0001 && G[i][j]<G[x][y]) x=i,y=j;
        if(F[i][j]>F[x][y]) x=i,y=j;
    }

//  For(j,0,m) printf("F %lf G %lf\n",F[n+1][j]/D,G[n+1][j]);

    printf("%.10lf %.10lf\n",(double)F[x][y]/D,(double)G[x][y]);
}


#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
#include<cmath>
#define N 3005
#define D 1000000
#define Long long long
#define For(i,l,r) for(int i=l;i<=r;i++)
using namespace std;
struct rec{
    Long pSml,tSml,pLar,tLar; double fail;
    void read(){
        scanf("%I64d%I64d%I64d%I64d",&pSml,&pLar,&tSml,&tLar);
        pSml*=D; pLar*=D;
        scanf("%lf",&fail);
    }
}E[N];
bool cmp(const rec &i,const rec &j){
    return i.fail*j.fail*(j.tLar-i.tLar)+i.fail*i.tLar-j.fail*j.tLar<0;
}
int n,m,x,y;
double F[N][N],G[N][N];
void update(int i,int j,double f,double g){
    if(j>m) return;
    if(f>F[i][j]) F[i][j]=f,G[i][j]=g;
    if(f==F[i][j]) G[i][j]=min(G[i][j],g);
}
int main(){
    scanf("%d%d",&n,&m);
    For(i,1,n) E[i].read();
    sort(E+1,E+1+n,cmp);
    For(i,1,n) For(j,0,m){
        Long pSml=E[i].pSml;
        Long tSml=E[i].tSml;
        Long pLar=E[i].pLar;
        Long tLar=E[i].tLar;
        double fail=E[i].fail;

        update(i+1,j,F[i][j],G[i][j]);
        update(i+1,j+tSml,F[i][j]+pSml,G[i][j]+tSml);
        update(i+1,j+tSml+tLar,
            pSml+F[i][j]+(1-fail)*pLar,
            tSml+(1-fail)*(j+tLar)+fail*G[i][j]
        );
    }
    For(i,1,n+1) For(j,0,m){
        if(F[i][j]==F[x][y] && G[i][j]<G[x][y]) x=i,y=j;
        if(F[i][j]>F[x][y]) x=i,y=j;
    }
    printf("%.10lf %.10lf\n",(double)F[x][y]/D,G[x][y]);
}


#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
#include<cmath>
#define sqr(x) (x)*(x)
#define N 250000
#define inf 1000000000
#define For(i,l,r) for(int i=l;i<=r;i++)
using namespace std;
struct rec{int x,y;}E[N];
double dist(int i,int j){return sqrt( sqr(E[i].x-E[j].x) + sqr(E[i].y-E[j].y) );}
int n,S,T;
struct network{
	int next[N],son[N],ed[N],cap[N],q[N],from[N]; double co[N],dis[N];
	int cnt,st,en; bool inq[N];
	void link(int x,int y,int z,double c){
		next[++cnt]=son[x]; son[x]=cnt; ed[cnt]=y; cap[cnt]=z; co[cnt]=c;
		next[++cnt]=son[y]; son[y]=cnt; ed[cnt]=x; cap[cnt]=0; co[cnt]=-c;
	}
	bool SPFA(){
		st=en=0; For(i,1,T) dis[i]=inf;
		q[++en]=S; dis[S]=0;
		while(st<en){
			int u=q[++st]; inq[u]=0;
			for(int i=son[u];i;i=next[i]){
				int v=ed[i];
				if(dis[v]>dis[u]+co[i] && cap[i]){
					dis[v]=dis[u]+co[i]; from[v]=i;
					if(!inq[v]) q[++en]=v,inq[v]=1;
				}
			}
		}
		if(dis[T]>=inf) return 0;
		return 1;
	}
	void costflow(){
		double cost=0; int flow=0;
		while(SPFA()){
			int ret=inf;
			for(int now=T;now!=S;now=ed[now^1]){
				now=from[now],ret=min(ret,cap[now]);
			}
			for(int now=T;now!=S;now=ed[now^1]){
				now=from[now];
				cost+=ret*co[now];
				cap[now]-=ret;
				cap[now^1]+=ret;
			}
			flow+=ret;
		}
		if(flow==n-1) printf("%.8lf\n",cost);
		else printf("-1\n");
	}
}Network;
int main(){
	scanf("%d",&n); Network.cnt=1;
	For(i,1,n) scanf("%d%d",&E[i].x,&E[i].y);
	For(i,1,n) For(j,1,n) if(E[i].y>E[j].y) Network.link(i,j+n,1,dist(i,j));
	S=2*n+1; T=2*n+2;
	For(i,1,n) Network.link(S,i,2,0);
	For(i,1,n) Network.link(i+n,T,1,0);
	Network.costflow();
}


#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
#include<cmath>
#define N 3005
#define D 1000000
#define Long long long
#define For(i,l,r) for(int i=l;i<=r;i++)
using namespace std;
struct rec{
    Long pSml,tSml,pLar,tLar; double fail;
    void read(){
        scanf("%I64d%I64d%I64d%I64d",&pSml,&pLar,&tSml,&tLar);
        pSml*=D; pLar*=D;
        scanf("%lf",&fail);
    }
}E[N];
bool cmp(const rec &i,const rec &j){
    return i.fail*j.fail*(j.tLar-i.tLar)+i.fail*i.tLar-j.fail*j.tLar<0;
}
int n,m,x,y;
double F[N][N],G[N][N];
void update(int i,int j,double f,double g){
    if(j>m) return;
    if(f>F[i][j]) F[i][j]=f,G[i][j]=g;
    if( abs(f-F[i][j])<0.0001 ) G[i][j]=min(G[i][j],g);
}
int main(){
    scanf("%d%d",&n,&m);
    For(i,1,n) E[i].read();
    sort(E+1,E+1+n,cmp);
    For(i,1,n) For(j,0,m){
        Long pSml=E[i].pSml;
        Long tSml=E[i].tSml;
        Long pLar=E[i].pLar;
        Long tLar=E[i].tLar;
        double fail=E[i].fail;

        update(i+1,j,F[i][j],G[i][j]);
        update(i+1,j+tSml,F[i][j]+pSml,G[i][j]+tSml);
        update(i+1,j+tSml+tLar,
            pSml+F[i][j]+(1-fail)*pLar,
            tSml+(1-fail)*(j+tLar)+fail*G[i][j]
        );
    }
    For(i,1,n+1) For(j,0,m){
        if( (F[i][j]-F[x][y])<0.0001 && G[i][j]<G[x][y]) x=i,y=j;
        if(F[i][j]>F[x][y]) x=i,y=j;
    }
    printf("%.10lf %.10lf\n",(double)F[x][y]/D,G[x][y]);
}


#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <iostream>
#include <algorithm>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <vector>
#include <bitset>
#include <functional>
using namespace std;
const long long mod = 1e9 + 7;
const int maxn = 100005;
const double eps = 1e-15;
inline int read ()
{
	int res, ok = 1;
	char ch;
	for (ch = getchar (); ch < '0' || ch > '9'; ch = getchar ())
	if (ch == '-')
	ok = -1;
	res = ch - '0';
	for (ch = getchar (); ch >= '0' && ch <= '9'; ch = getchar ())
	res = res * 10 + ch - '0';
	return res * ok;
}
int n, t;
struct node
{
	int ssc, lsc, st, lt;
	double p;
	bool operator < (const node& b) const
	{
		return p * lt * (1 - b.p) < b.p * b.lt * (1 - p);
	}
}a[1005];
struct point
{
	double sc, t;
	point small (double sci, double ti)
	{
		return (point) {sc + sci, t + ti};
	}
	point large (double ssc, double lsc, double st, double lt, double p, int x)
	{
		return (point) {sc + ssc + (1 - p) * lsc, st + p * t + (1 - p) * (x + lt)};
	}
}f[2005];
inline point max (const point& a, const point& b)
{
	if (fabs (a.sc - b.sc) < eps)
	return (point) {a.sc, min (a.t, b.t)};
	if (a.sc > b.sc)
	return a;
	return b;
}
int main ()
{
	n = read();
	t = read();
	for (int i = 1; i <= n; i++)
	{
		double p;
		a[i].ssc = read();
		a[i].lsc = read();
		a[i].st = read();
		a[i].lt = read();
		scanf ("%lf", &p);
		a[i].p = p;
	}
	sort (a + 1, a + 1 + n);
	for (int i = 1; i <= n; i++)
	for (int j = t; j >= 0; j--)
	{
		if (j >= a[i].st)
		f[j] = max (f[j], f[j - a[i].st].small(a[i].ssc, a[i].st));
		if (j >= a[i].st + a[i].lt)
		f[j] = max (f[j], f[j - a[i].st - a[i].lt].large(a[i].ssc, a[i].lsc, a[i].st, a[i].lt, a[i].p, j - a[i].lt - a[i].st));
	}
	point ans = (point) {0, 0};
	for (int i = t; i >= 0; i--)
	ans = max (ans, f[i]);
	printf ("%.10lf %.10lf\n", ans.sc, ans.t);
	return 0;
}


#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <iostream>
#include <algorithm>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <vector>
#include <bitset>
#include <functional>
using namespace std;
const long long mod = 1e9 + 7;
const int maxn = 100005;
const double eps = 1e-8;
inline int read ()
{
	int res, ok = 1;
	char ch;
	for (ch = getchar (); ch < '0' || ch > '9'; ch = getchar ())
	if (ch == '-')
	ok = -1;
	res = ch - '0';
	for (ch = getchar (); ch >= '0' && ch <= '9'; ch = getchar ())
	res = res * 10 + ch - '0';
	return res * ok;
}
int n, t;
struct node
{
	int ssc, lsc, st, lt;
	double p;
	bool operator < (const node& b) const
	{
		return p * lt * (1 - b.p) < b.p * b.lt * (1 - p);
	}
}a[1005];
struct point
{
	double sc, t;
	point small (double sci, double ti)
	{
		return (point) {sc + sci, t + ti};
	}
	point large (double ssc, double lsc, double st, double lt, double p, int x)
	{
		return (point) {sc + ssc + (1 - p) * lsc, st + p * x + (1 - p) * (x + lt)};
	}
}f[2005];
inline point max (const point& a, const point& b)
{
	if (fabs (a.sc - b.sc) < eps)
	return (point) {a.sc, min (a.t, b.t)};
	if (a.sc > b.sc)
	return a;
	return b;
}
int main ()
{
	n = read();
	t = read();
	for (int i = 1; i <= n; i++)
	{
		double p;
		a[i].ssc = read();
		a[i].lsc = read();
		a[i].st = read();
		a[i].lt = read();
		scanf ("%lf", &p);
		a[i].p = p;
	}
	sort (a + 1, a + 1 + n);
	for (int i = 1; i <= n; i++)
	for (int j = t; j >= 0; j--)
	{
		if (j >= a[i].st)
		f[j] = max (f[j], f[j - a[i].st].small(a[i].ssc, a[i].st));
		if (j >= a[i].st + a[i].lt)
		f[j] = max (f[j], f[j - a[i].st - a[i].lt].large(a[i].ssc, a[i].lsc, a[i].st, a[i].lt, a[i].p, j - a[i].lt - a[i].st));
	}
	point ans = (point) {0, 0};
	for (int i = t; i >= 0; i--)
	ans = max (ans, f[i]);
	printf ("%.10lf %.10lf\n", ans.sc, ans.t);
	return 0;
}


#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <iostream>
#include <algorithm>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <vector>
#include <bitset>
#include <functional>
using namespace std;
const long long mod = 1e9 + 7;
const int maxn = 100005;
const double eps = 1e-8;
inline int read ()
{
	int res, ok = 1;
	char ch;
	for (ch = getchar (); ch < '0' || ch > '9'; ch = getchar ())
	if (ch == '-')
	ok = -1;
	res = ch - '0';
	for (ch = getchar (); ch >= '0' && ch <= '9'; ch = getchar ())
	res = res * 10 + ch - '0';
	return res * ok;
}
int n, t;
struct node
{
	int ssc, lsc, st, lt;
	long double p;
	bool operator < (const node& b) const
	{
		return p * lt * (1 - b.p) < b.p * b.lt * (1 - p);
	}
}a[1005];
struct point
{
	long double sc, t;
	point small (long double sci, long double ti)
	{
		return (point) {sc + sci, t + ti};
	}
	point large (long double ssc, long double lsc, long double st, long double lt, long double p, int x)
	{
		return (point) {sc + ssc + (1 - p) * lsc, st + p * t + (1 - p) * (x + lt)};
	}
}f[2005];
inline point max (const point& a, const point& b)
{
	if (fabs (a.sc - b.sc) < eps)
	return (point) {a.sc, min (a.t, b.t)};
	if (a.sc > b.sc)
	return a;
	return b;
}
int main ()
{
	n = read();
	t = read();
	for (int i = 1; i <= n; i++)
	{
		double p;
		a[i].ssc = read();
		a[i].lsc = read();
		a[i].st = read();
		a[i].lt = read();
		scanf ("%lf", &p);
		a[i].p = p;
	}
	sort (a + 1, a + 1 + n);
	for (int i = 1; i <= n; i++)
	for (int j = t; j >= 0; j--)
	{
		if (j >= a[i].st)
		f[j] = max (f[j], f[j - a[i].st].small(a[i].ssc, a[i].st));
		if (j >= a[i].st + a[i].lt)
		f[j] = max (f[j], f[j - a[i].st - a[i].lt].large(a[i].ssc, a[i].lsc, a[i].st, a[i].lt, a[i].p, j - a[i].lt - a[i].st));
	}
	point ans = (point) {0, 0};
	for (int i = t; i >= 0; i--)
	ans = max (ans, f[i]);
	printf ("%.10lf %.10lf\n", (double)ans.sc, (double)ans.t);
	return 0;
}


#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <iostream>
#include <algorithm>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <vector>
#include <bitset>
#include <functional>
using namespace std;
const long long mod = 1e9 + 7;
const int maxn = 100005;
const double eps = 1e-8;
inline int read ()
{
	int res, ok = 1;
	char ch;
	for (ch = getchar (); ch < '0' || ch > '9'; ch = getchar ())
	if (ch == '-')
	ok = -1;
	res = ch - '0';
	for (ch = getchar (); ch >= '0' && ch <= '9'; ch = getchar ())
	res = res * 10 + ch - '0';
	return res * ok;
}
int n, t;
struct node
{
	int ssc, lsc, st, lt;
	double p;
	bool operator < (const node& b) const
	{
		return p * lt * (1 - b.p) < b.p * b.lt * (1 - p);
	}
}a[1005];
struct point
{
	double sc, t;
	point small (double sci, double ti)
	{
		return (point) {sc + sci, t + ti};
	}
	point large (double ssc, double lsc, double st, double lt, double p, int x)
	{
		return (point) {sc + ssc + (1 - p) * lsc, st + p * t + (1 - p) * (x + lt)};
	}
}f[2005];
inline point max (const point& a, const point& b)
{
	if (fabs (a.sc - b.sc) < eps)
	return (point) {a.sc, min (a.t, b.t)};
	if (a.sc > b.sc)
	return a;
	return b;
}
int main ()
{
	n = read();
	t = read();
	for (int i = 1; i <= n; i++)
	{
		double x;
		a[i].ssc = read();
		a[i].lsc = read();
		a[i].st = read();
		a[i].lt = read();
		scanf ("%lf", &x);
		a[i].p = x;
	}
	sort (a + 1, a + 1 + n);
	for (int i = 1; i <= n; i++)
	for (int j = t; j >= 0; j--)
	{
		if (j >= a[i].st)
		f[j] = max (f[j], f[j - a[i].st].small(a[i].ssc, a[i].st));
		if (j >= a[i].st + a[i].lt)
		f[j] = max (f[j], f[j - a[i].st - a[i].lt].large(a[i].ssc, a[i].lsc, a[i].st, a[i].lt, a[i].p, j - a[i].lt - a[i].st));
	}
	point ans = (point) {0, 0};
	for (int j = t; j >= 0; j--)
	ans = max (ans, f[j]);
	cout << ans.sc << " " << ans.t << endl;
	return 0;
}


#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <iostream>
#include <algorithm>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <vector>
#include <bitset>
#include <functional>
using namespace std;
const long long mod = 1e9 + 7;
const int maxn = 100005;
const double eps = 1e-8;
inline int read ()
{
	int res, ok = 1;
	char ch;
	for (ch = getchar (); ch < '0' || ch > '9'; ch = getchar ())
	if (ch == '-')
	ok = -1;
	res = ch - '0';
	for (ch = getchar (); ch >= '0' && ch <= '9'; ch = getchar ())
	res = res * 10 + ch - '0';
	return res * ok;
}
int n, t;
struct node
{
	int ssc, lsc, st, lt;
	double p;
	bool operator < (const node& b) const
	{
		return p * lt * (1 - b.p) < b.p * b.lt * (1 - p);
	}
}a[1005];
struct point
{
	double sc, t;
	point small (double sci, double ti)
	{
		return (point) {sc + sci, t + ti};
	}
	point large (double ssc, double lsc, double st, double lt, double p, int x)
	{
		return (point) {sc + ssc + (1 - p) * lsc, st + p * t + (1 - p) * (x + lt)};
	}
}f[2005];
inline point max (const point& a, const point& b)
{
	if (fabs (a.sc - b.sc) < eps)
	return (point) {a.sc, min (a.t, b.t)};
	if (a.sc > b.sc)
	return a;
	return b;
}
int main ()
{
	n = read();
	t = read();
	for (int i = 1; i <= n; i++)
	{
		double x;
		a[i].ssc = read();
		a[i].lsc = read();
		a[i].st = read();
		a[i].lt = read();
		scanf ("%lf", &x);
		a[i].p = x;
	}
	sort (a + 1, a + 1 + n);
	for (int i = 1; i <= n; i++)
	for (int j = t; j >= 0; j--)
	{
		if (j >= a[i].st)
		f[j] = max (f[j], f[j - a[i].st].small(a[i].ssc, a[i].st));
		if (j >= a[i].st + a[i].lt)
		f[j] = max (f[j], f[j - a[i].st - a[i].lt].large(a[i].ssc, a[i].lsc, a[i].st, a[i].lt, a[i].p, j - a[i].lt - a[i].st));
	}
	point ans = (point) {0, 0};
	for (int j = t; j >= 0; j--)
	ans = max (ans, f[j]);
	printf ("%.10lf %.10lf\n", ans.sc, ans.t);
	return 0;
}


#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <iostream>
#include <algorithm>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <vector>
#include <bitset>
#include <functional>
using namespace std;
const long long mod = 1e9 + 7;
const int maxn = 100005;
const double eps = 1e-8;
inline int read ()
{
	int res, ok = 1;
	char ch;
	for (ch = getchar (); ch < '0' || ch > '9'; ch = getchar ())
	if (ch == '-')
	ok = -1;
	res = ch - '0';
	for (ch = getchar (); ch >= '0' && ch <= '9'; ch = getchar ())
	res = res * 10 + ch - '0';
	return res * ok;
}
int n, t;
struct node
{
	int ssc, lsc, st, lt;
	long double p;
	bool operator < (const node& b) const
	{
		return p * lt * (1 - b.p) < b.p * b.lt * (1 - p);
	}
}a[1005];
struct point
{
	double sc, t;
	point small (long double sci, long double ti)
	{
		return (point) {sc + sci, t + ti};
	}
	point large (long double ssc, long double lsc, long double st, long double lt, long double p, int x)
	{
		return (point) {sc + ssc + (1 - p) * lsc, st + p * t + (1 - p) * (x + lt)};
	}
}f[2005];
inline point max (const point& a, const point& b)
{
	if (fabs (a.sc - b.sc) < eps)
	return (point) {a.sc, min (a.t, b.t)};
	if (a.sc > b.sc)
	return a;
	return b;
}
int main ()
{
	n = read();
	t = read();
	for (int i = 1; i <= n; i++)
	{
		double p;
		a[i].ssc = read();
		a[i].lsc = read();
		a[i].st = read();
		a[i].lt = read();
		scanf ("%lf", &p);
		a[i].p = p;
	}
	sort (a + 1, a + 1 + n);
	for (int i = 1; i <= n; i++)
	for (int j = t; j >= 0; j--)
	{
		if (j >= a[i].st)
		f[j] = max (f[j], f[j - a[i].st].small(a[i].ssc, a[i].st));
		if (j >= a[i].st + a[i].lt)
		f[j] = max (f[j], f[j - a[i].st - a[i].lt].large(a[i].ssc, a[i].lsc, a[i].st, a[i].lt, a[i].p, j - a[i].lt - a[i].st));
	}
	point ans = (point) {0, 0};
	for (int i = t; i >= 0; i--)
	ans = max (ans, f[i]);
	printf ("%.10lf %.10lf\n", (double)ans.sc, (double)ans.t);
	return 0;
}


#include<bits/stdc++.h>
#define db long double
#define For(i,j,k) for (int i=(j);i<=(int)k;i++)
#define Rep(i,j,k) for (int i=(j);i>=(int)k;i++)
using namespace std;
struct prob
{
	int ssc,lsc,st,lt;
	db pos;
};
bool cmp(const prob &a,const prob &b)
{
	return a.pos*a.lt*(1-b.pos)<b.pos*b.lt*(1-a.pos);
}
prob a[2005];
struct State
{
	db pts,times;
	State small(prob a)
	 {
		return (State){pts+a.ssc,times+a.st};
	 }
	State large(prob a,int T)
	 {
		return (State){pts+a.ssc+(1-a.pos)*a.lsc,a.st+a.pos*times+(1-a.pos)*(a.lt+T)};
	 }
	int operator <(const State &a)const
	 {
		if (fabs(pts-a.pts)>1e-8)return pts<a.pts;
		return times>a.times;
	 }
};
State f[2000];
int n,t;
int main()
{
	scanf("%d%d",&n,&t);
	For(i,1,n)
	 {
		double tmp;
		scanf("%d%d",&a[i].ssc,&a[i].lsc),
		scanf("%d%d%lf",&a[i].st,&a[i].lt,&tmp);
		a[i].pos=tmp;
	 }
	sort(a+1,a+n+1,cmp);
	For(i,1,n)
	 for (int j=t;j>=0;j--)
	  {
		if (j>=a[i].st) f[j]=max(f[j],f[j-a[i].st].small(a[i]));
		if (j>=a[i].st+a[i].lt) f[j]=max(f[j],f[j-a[i].st-a[i].lt].large(a[i],j-a[i].st-a[i].lt));
	  }
	State ans=(State){0,0};
	For(j,0,t) ans=max(ans,f[j]);
	printf("%.15lf %.15lf",(double)ans.pts,(double)ans.times);
}


#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
#include<iostream>
#include<fstream>
#include<map>
#include<ctime>
#include<set>
#include<queue>
#include<cmath>
#include<vector>
#include<bitset>
#include<functional>
#define x first
#define y second
#define mp make_pair
#define pb push_back
#define REP(i,l,r) for((i)=(l);(i)<=(r);++(i))
#define REP2(i,l,r) for((i)=(l);(i)!=(r);++(i))
using namespace std;

typedef long long LL;
typedef double ld;

const int MAX=2000+10;
const ld One=1e6;
ld EPS=1e-9;

struct pro
{
	int sp,bp,st,bt;
	ld failp;
}d[MAX];

struct Case
{
	ld point,penalty;
	Case()
	{
		point=-1e10;
		penalty=1e10;
	}
	Case(ld a,ld b)
	{
		point=a;
		penalty=b;
	}
}f[MAX][MAX];

int operator < (const Case& a,const Case& b)
{
	if(abs(a.point-b.point)>EPS)
		return a.point<b.point;
	else return a.penalty>b.penalty;
}

int operator < (const pro& a,const pro& b)
{
	return a.bt*(1-a.failp)*b.failp+(a.bt+b.bt)*(1-b.failp)<b.bt*(1-b.failp)*a.failp+(a.bt+b.bt)*(1-a.failp);
}

int n,t;

int main()
{
#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#endif
	int i,j;
	scanf("%d%d",&n,&t);
	REP(i,1,n)
		scanf("%d%d%d%d%lf",&d[i].sp,&d[i].bp,&d[i].st,&d[i].bt,&d[i].failp);
	sort(d+1,d+n+1);
	f[0][0]=Case(0,0);
	Case ans;
	for(i=1;i<=n;++i)
		for(j=0;j<=t;++j)
		{
			f[i][j]=max(f[i][j],f[i-1][j]);
			if(j+d[i].st>t)continue;
			f[i][j+d[i].st]=max(f[i][j+d[i].st],
					Case(f[i-1][j].point+d[i].sp*One,f[i-1][j].penalty+d[i].st*One));
			if(j+d[i].st+d[i].bt>t)continue;
			f[i][j+d[i].st+d[i].bt]
				=max(f[i][j+d[i].st+d[i].bt],
						Case( f[i-1][j].point+d[i].sp*One+d[i].bp*One*(1-d[i].failp),
							f[i-1][j].penalty*d[i].failp+d[i].st*One+(j+d[i].bt)*One*(1-d[i].failp) ) );
		}
	for(j=0;j<=t;++j)
		ans=max(ans,f[n][j]);
	printf("%.9lf %.9lf\n",ans.point/One,ans.penalty/One);
	return 0;
}


#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
#include<iostream>
#include<fstream>
#include<map>
#include<ctime>
#include<set>
#include<queue>
#include<cmath>
#include<vector>
#include<bitset>
#include<functional>
#define x first
#define y second
#define mp make_pair
#define pb push_back
#define REP(i,l,r) for((i)=(l);(i)<=(r);++(i))
#define REP2(i,l,r) for((i)=(l);(i)!=(r);++(i))
using namespace std;

typedef long long LL;
typedef long double ld;

const int MAX=2000+10;
const ld One=1e6;
ld EPS=1e-9;

struct pro
{
	int sp,bp,st,bt;
	ld failp;
}d[MAX];

struct Case
{
	ld point,penalty;
	Case()
	{
		point=-1e10;
		penalty=1e10;
	}
	Case(ld a,ld b)
	{
		point=a;
		penalty=b;
	}
}f[MAX][MAX];

int operator < (const Case& a,const Case& b)
{
	if(abs(a.point-b.point)>EPS)
		return a.point<b.point;
	else return a.penalty>b.penalty;
}

int operator < (const pro& a,const pro& b)
{
	return a.bt*(1-a.failp)*b.failp+(a.bt+b.bt)*(1-b.failp)<b.bt*(1-b.failp)*a.failp+(a.bt+b.bt)*(1-a.failp);
}

int n,t;

int main()
{
#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#endif
	int i,j;
	scanf("%d%d",&n,&t);
	REP(i,1,n)
		scanf("%d%d%d%d%Lf",&d[i].sp,&d[i].bp,&d[i].st,&d[i].bt,&d[i].failp);
	sort(d+1,d+n+1);
	f[0][0]=Case(0,0);
	Case ans;
	for(i=1;i<=n;++i)
		for(j=0;j<=t;++j)
		{
			f[i][j]=max(f[i][j],f[i-1][j]);
			if(j+d[i].st>t)continue;
			f[i][j+d[i].st]=max(f[i][j+d[i].st],
					Case(f[i-1][j].point+d[i].sp*One,f[i-1][j].penalty+d[i].st*One));
			if(j+d[i].st+d[i].bt>t)continue;
			f[i][j+d[i].st+d[i].bt]
				=max(f[i][j+d[i].st+d[i].bt],
						Case( f[i-1][j].point+d[i].sp*One+d[i].bp*One*(1-d[i].failp),
							f[i-1][j].penalty*d[i].failp+d[i].st*One+(j+d[i].bt)*One*(1-d[i].failp) ) );
		}
	for(j=0;j<=t;++j)
		ans=max(ans,f[n][j]);
	printf("%Lf %Lf\n",ans.point/One,ans.penalty/One);
	return 0;
}


#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
#include<iostream>
#include<fstream>
#include<map>
#include<ctime>
#include<set>
#include<queue>
#include<cmath>
#include<vector>
#include<bitset>
#include<functional>
#define x first
#define y second
#define mp make_pair
#define pb push_back
#define REP(i,l,r) for((i)=(l);(i)<=(r);++(i))
#define REP2(i,l,r) for((i)=(l);(i)!=(r);++(i))
using namespace std;

typedef long long LL;
typedef double ld;

const int MAX=2000+10;
const ld One=1e6;
ld EPS=1e-9;

struct pro
{
	int sp,bp,st,bt;
	ld failp;
}d[MAX];

struct Case
{
	ld point,penalty;
	Case()
	{
		point=-1e10;
		penalty=1e10;
	}
	Case(ld a,ld b)
	{
		point=a;
		penalty=b;
	}
}f[MAX][MAX];

int operator < (const Case& a,const Case& b)
{
	if(abs(a.point-b.point)>EPS)
		return a.point<b.point;
	else return a.penalty>b.penalty;
}

int operator < (const pro& a,const pro& b)
{
	return a.bt*(1-a.failp)*b.failp+(a.bt+b.bt)*(1-b.failp)<b.bt*(1-b.failp)*a.failp+(a.bt+b.bt)*(1-a.failp);
}

int n,t;

int main()
{
#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#endif
	int i,j;
	scanf("%d%d",&n,&t);
	REP(i,1,n)
		scanf("%d%d%d%d%lf",&d[i].sp,&d[i].bp,&d[i].st,&d[i].bt,&d[i].failp);
	sort(d+1,d+n+1);
	f[0][0]=Case(0,0);
	Case ans;
	for(i=1;i<=n;++i)
		for(j=0;j<=t;++j)
		{
			f[i][j]=max(f[i][j],f[i-1][j]);
			if(j+d[i].st>t)continue;
			f[i][j+d[i].st]=max(f[i][j+d[i].st],
					Case(f[i-1][j].point+d[i].sp,f[i-1][j].penalty+d[i].st));
			if(j+d[i].st+d[i].bt>t)continue;
			f[i][j+d[i].st+d[i].bt]
				=max(f[i][j+d[i].st+d[i].bt],
						Case( f[i-1][j].point+d[i].sp+d[i].bp*(1-d[i].failp),
							f[i-1][j].penalty*d[i].failp+d[i].st+(j+d[i].bt)*(1-d[i].failp) ) );
		}
	for(j=0;j<=t;++j)
		ans=max(ans,f[n][j]);
	printf("%.9lf %.9lf\n",ans.point,ans.penalty);
	return 0;
}


#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
#include<iostream>
#include<fstream>
#include<map>
#include<ctime>
#include<set>
#include<queue>
#include<cmath>
#include<vector>
#include<bitset>
#include<functional>
#define x first
#define y second
#define mp make_pair
#define pb push_back
#define REP(i,l,r) for((i)=(l);(i)<=(r);++(i))
#define REP2(i,l,r) for((i)=(l);(i)!=(r);++(i))
using namespace std;

typedef long long LL;
typedef long double ld;

const int MAX=2000+10;
const ld One=1e6;
ld EPS=1e-9;

struct pro
{
	int sp,bp,st,bt;
	ld failp;
}d[MAX];

struct Case
{
	ld point,penalty;
	Case()
	{
		point=-1e10;
		penalty=1e10;
	}
	Case(ld a,ld b)
	{
		point=a;
		penalty=b;
	}
}f[MAX][MAX];

int operator < (const Case& a,const Case& b)
{
	if(abs(a.point-b.point)>EPS)
		return a.point<b.point;
	else return a.penalty>b.penalty;
}

int operator < (const pro& a,const pro& b)
{
	return a.bt*(1-a.failp)*b.failp+(a.bt+b.bt)*(1-b.failp)<b.bt*(1-b.failp)*a.failp+(a.bt+b.bt)*(1-a.failp);
}

int n,t;

int main()
{
#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#endif
	int i,j;
	scanf("%d%d",&n,&t);
	REP(i,1,n)
		scanf("%d%d%d%d%Lf",&d[i].sp,&d[i].bp,&d[i].st,&d[i].bt,&d[i].failp);
	sort(d+1,d+n+1);
	f[0][0]=Case(0,0);
	Case ans;
	for(i=1;i<=n;++i)
		for(j=0;j<=t;++j)
		{
			f[i][j]=max(f[i][j],f[i-1][j]);
			if(j+d[i].st>t)continue;
			f[i][j+d[i].st]=max(f[i][j+d[i].st],
					Case(f[i-1][j].point+d[i].sp,f[i-1][j].penalty+d[i].st));
			if(j+d[i].st+d[i].bt>t)continue;
			f[i][j+d[i].st+d[i].bt]
				=max(f[i][j+d[i].st+d[i].bt],
						Case( f[i-1][j].point+d[i].sp+d[i].bp*(1-d[i].failp),
							f[i-1][j].penalty*d[i].failp+d[i].st+(j+d[i].bt)*(1-d[i].failp) ) );
		}
	for(j=0;j<=t;++j)
		ans=max(ans,f[n][j]);
	cout<<ans.point<<" "<<ans.penalty<<endl;
	return 0;
}


#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
#include<iostream>
#include<fstream>
#include<map>
#include<ctime>
#include<set>
#include<queue>
#include<cmath>
#include<vector>
#include<bitset>
#include<functional>
#include<iomanip>
#define x first
#define y second
#define mp make_pair
#define pb push_back
#define REP(i,l,r) for((i)=(l);(i)<=(r);++(i))
#define REP2(i,l,r) for((i)=(l);(i)!=(r);++(i))
using namespace std;

typedef long long LL;
typedef long double ld;

const int MAX=2000+10;
const ld One=1e6;
ld EPS=1e-9;

struct pro
{
	int sp,bp,st,bt;
	ld failp;
}d[MAX];

struct Case
{
	ld point,penalty;
	Case()
	{
		point=-1e10;
		penalty=1e10;
	}
	Case(ld a,ld b)
	{
		point=a;
		penalty=b;
	}
}f[MAX][MAX];

int operator < (const Case& a,const Case& b)
{
	if(abs(a.point-b.point)>EPS)
		return a.point<b.point;
	else return a.penalty>b.penalty;
}

int operator < (const pro& a,const pro& b)
{
	return a.bt*(1-a.failp)*b.failp+(a.bt+b.bt)*(1-b.failp)<b.bt*(1-b.failp)*a.failp+(a.bt+b.bt)*(1-a.failp);
}

int n,t;

int main()
{
#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#endif
	int i,j;
	scanf("%d%d",&n,&t);
	REP(i,1,n)
		scanf("%d%d%d%d",&d[i].sp,&d[i].bp,&d[i].st,&d[i].bt),cin>>d[i].failp;
	sort(d+1,d+n+1);
	f[0][0]=Case(0,0);
	Case ans;
	for(i=1;i<=n;++i)
		for(j=0;j<=t;++j)
		{
			f[i][j]=max(f[i][j],f[i-1][j]);
			if(j+d[i].st>t)continue;
			f[i][j+d[i].st]=max(f[i][j+d[i].st],
					Case(f[i-1][j].point+d[i].sp,f[i-1][j].penalty+d[i].st));
			if(j+d[i].st+d[i].bt>t)continue;
			f[i][j+d[i].st+d[i].bt]
				=max(f[i][j+d[i].st+d[i].bt],
						Case( f[i-1][j].point+d[i].sp+d[i].bp*(1-d[i].failp),
							f[i-1][j].penalty*d[i].failp+d[i].st+(j+d[i].bt)*(1-d[i].failp) ) );
		}
	for(j=0;j<=t;++j)
		ans=max(ans,f[n][j]);
	cout.setf(ios::fixed);
	cout<<setprecision(9)<<ans.point<<" "<<ans.penalty<<endl;
	return 0;
}


#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
#include<iostream>
#include<fstream>
#include<map>
#include<ctime>
#include<set>
#include<queue>
#include<cmath>
#include<vector>
#include<bitset>
#include<functional>
#define x first
#define y second
#define mp make_pair
#define pb push_back
#define REP(i,l,r) for((i)=(l);(i)<=(r);++(i))
#define REP2(i,l,r) for((i)=(l);(i)!=(r);++(i))
using namespace std;

typedef long long LL;
typedef long double ld;

const int MAX=2000+10;
const ld One=1e6;
ld EPS=1e-9;

struct pro
{
	int sp,bp,st,bt;
	ld failp;
}d[MAX];

struct Case
{
	ld point,penalty;
	Case()
	{
		point=-1e10;
		penalty=1e10;
	}
	Case(ld a,ld b)
	{
		point=a;
		penalty=b;
	}
}f[MAX][MAX];

int operator < (const Case& a,const Case& b)
{
	if(abs(a.point-b.point)>EPS)
		return a.point<b.point;
	else return a.penalty>b.penalty;
}

int operator < (const pro& a,const pro& b)
{
	return a.bt*(1-a.failp)*b.failp+(a.bt+b.bt)*(1-b.failp)<b.bt*(1-b.failp)*a.failp+(a.bt+b.bt)*(1-a.failp);
}

int n,t;

int main()
{
#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#endif
	int i,j;
	scanf("%d%d",&n,&t);
	REP(i,1,n)
		scanf("%d%d%d%d%Lf",&d[i].sp,&d[i].bp,&d[i].st,&d[i].bt,&d[i].failp);
	sort(d+1,d+n+1);
	f[0][0]=Case(0,0);
	Case ans;
	for(i=1;i<=n;++i)
		for(j=0;j<=t;++j)
		{
			f[i][j]=max(f[i][j],f[i-1][j]);
			if(j+d[i].st>t)continue;
			f[i][j+d[i].st]=max(f[i][j+d[i].st],
					Case(f[i-1][j].point+d[i].sp*One,f[i-1][j].penalty+d[i].st*One));
			if(j+d[i].st+d[i].bt>t)continue;
			f[i][j+d[i].st+d[i].bt]
				=max(f[i][j+d[i].st+d[i].bt],
						Case( f[i-1][j].point+d[i].sp*One+d[i].bp*One*(1-d[i].failp),
							f[i-1][j].penalty*d[i].failp+d[i].st*One+(j+d[i].bt)*One*(1-d[i].failp) ) );
		}
	for(j=0;j<=t;++j)
		ans=max(ans,f[n][j]);
	printf("%.9Lf %.9Lf\n",ans.point/One,ans.penalty/One);
	return 0;
}


#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
#include<iostream>
#include<fstream>
#include<map>
#include<ctime>
#include<set>
#include<queue>
#include<cmath>
#include<vector>
#include<bitset>
#include<functional>
#define x first
#define y second
#define mp make_pair
#define pb push_back
#define REP(i,l,r) for((i)=(l);(i)<=(r);++(i))
#define REP2(i,l,r) for((i)=(l);(i)!=(r);++(i))
using namespace std;

typedef long long LL;
typedef long double ld;

const int MAX=2000+10;
const ld One=1e6;
ld EPS=1e-9;

struct pro
{
	int sp,bp,st,bt;
	ld failp;
}d[MAX];

struct Case
{
	ld point,penalty;
	Case()
	{
		point=-1e10;
		penalty=1e10;
	}
	Case(ld a,ld b)
	{
		point=a;
		penalty=b;
	}
}f[MAX][MAX];

int operator < (const Case& a,const Case& b)
{
	if(abs(a.point-b.point)>EPS)
		return a.point<b.point;
	else return a.penalty>b.penalty;
}

int operator < (const pro& a,const pro& b)
{
	return a.bt*(1-a.failp)*b.failp+(a.bt+b.bt)*(1-b.failp)<b.bt*(1-b.failp)*a.failp+(a.bt+b.bt)*(1-a.failp);
}

int n,t;

int main()
{
#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#endif
	int i,j;
	scanf("%d%d",&n,&t);
	REP(i,1,n)
		scanf("%d%d%d%d",&d[i].sp,&d[i].bp,&d[i].st,&d[i].bt),cin>>d[i].failp;
	sort(d+1,d+n+1);
	f[0][0]=Case(0,0);
	Case ans;
	for(i=1;i<=n;++i)
		for(j=0;j<=t;++j)
		{
			f[i][j]=max(f[i][j],f[i-1][j]);
			if(j+d[i].st>t)continue;
			f[i][j+d[i].st]=max(f[i][j+d[i].st],
					Case(f[i-1][j].point+d[i].sp,f[i-1][j].penalty+d[i].st));
			if(j+d[i].st+d[i].bt>t)continue;
			f[i][j+d[i].st+d[i].bt]
				=max(f[i][j+d[i].st+d[i].bt],
						Case( f[i-1][j].point+d[i].sp+d[i].bp*(1-d[i].failp),
							f[i-1][j].penalty*d[i].failp+d[i].st+(j+d[i].bt)*(1-d[i].failp) ) );
		}
	for(j=0;j<=t;++j)
		ans=max(ans,f[n][j]);
	cout<<ans.point<<" "<<ans.penalty<<endl;
	return 0;
}


#include <cstdio>
#include <iostream>
#include <algorithm>

typedef long double double64;
typedef std :: pair <double64, double64> pdd;

inline int Get() {
	char ch;
	while ((ch = getchar()) < '0' || ch > '9');
	int Num = ch - '0';
	while ((ch = getchar()) >= '0' && ch <= '9')
		Num = (Num << 3) + (Num << 1) + ch - '0';
	return Num;
}

const int N = 1e3 + 5;
const int M = 1600;
int n, m, gA[N], gB[N], tA[N], tB[N], id[N];
double64 prob[N];
pdd dp[N][M];

inline bool cmp(const int &a, const int &b) {
	return (prob[id[a]] - 1) * prob[id[b]] * tB[id[b]] < (prob[id[b]] - 1) * prob[id[a]] * tB[id[a]];
}

int main() {
	n = Get(), m = Get();
	for (int i = 1; i <= n; ++i) {
		gA[i] = Get(), gB[i] = Get(), tA[i] = Get(), tB[i] = Get();
		double res; scanf("%lf", &res); prob[i] = res;
	}

	for (int i = 1; i <= n; ++i) id[i] = i;
	std :: sort(id + 1, id + n + 1, cmp);

	for (int i = 1, k; k = id[i], i <= n; ++i)
		for (int j = m; j >= 0; --j) {
			pdd nxt; dp[i][j] = dp[i - 1][j];
			if (j >= tA[k]) {
				nxt = std :: make_pair(dp[i - 1][j - tA[k]].first + gA[k], dp[i - 1][j - tA[k]].second - tA[k]);
				dp[i][j] = std :: max(dp[i][j], nxt);
			}
			if (j >= tA[k] + tB[k]) {
				nxt.first = dp[i - 1][j - tA[k] - tB[k]].first + gA[k] + (1 - prob[k]) * gB[k];
				nxt.second = (double64)-tA[k] + prob[k] * dp[i - 1][j - tA[k] - tB[k]].second - (1 - prob[k]) * (j - tA[k]);
				dp[i][j] = std :: max(dp[i][j], nxt);
			}
		}

	pdd ans = std :: make_pair(0, 0);
	for (int j = 0; j <= m; ++j) ans = std :: max(ans, dp[n][j]);

	printf("%lf %lf\n", (double)ans.first, -(double)ans.second);
}


#include <cstdio>
#include <iostream>
#include <algorithm>

typedef long double double64;
typedef std :: pair <double64, double64> pdd;

inline int Get() {
	char ch;
	while ((ch = getchar()) < '0' || ch > '9');
	int Num = ch - '0';
	while ((ch = getchar()) >= '0' && ch <= '9')
		Num = (Num << 3) + (Num << 1) + ch - '0';
	return Num;
}

const int N = 1e3 + 5;
const int M = 1600;
int n, m, gA[N], gB[N], tA[N], tB[N], id[N];
double64 prob[N];
pdd dp[N][M];

inline bool cmp(const int &a, const int &b) {
	return (prob[id[a]] - 1) * prob[id[b]] * tB[id[b]] < (prob[id[b]] - 1) * prob[id[a]] * tB[id[a]];
}

int main() {
	n = Get(), m = Get();
	for (int i = 1; i <= n; ++i) {
		gA[i] = Get(), gB[i] = Get(), tA[i] = Get(), tB[i] = Get();
		double res; scanf("%lf", &res); prob[i] = res;
	}

	for (int i = 1; i <= n; ++i) id[i] = i;
	std :: sort(id + 1, id + n + 1, cmp);

	for (int i = 1, k; k = id[i], i <= n; ++i)
		for (int j = m; j >= 0; --j) {
			pdd nxt; dp[i][j] = dp[i - 1][j];
			if (j >= tA[k]) {
				nxt = std :: make_pair(dp[i - 1][j - tA[k]].first + gA[k], dp[i - 1][j - tA[k]].second - tA[k]);
				dp[i][j] = std :: max(dp[i][j], nxt);
			}
			if (j >= tA[k] + tB[k]) {
				nxt.first = dp[i - 1][j - tA[k] - tB[k]].first + gA[k] + (1 - prob[k]) * gB[k];
				nxt.second = prob[k] * dp[i - 1][j - tA[k] - tB[k]].second - (1 - prob[k]) * (j - tA[k]) - tA[k];
				dp[i][j] = std :: max(dp[i][j], nxt);
			}
		}

	pdd ans = std :: make_pair(0, 0);
	for (int j = 0; j <= m; ++j) ans = std :: max(ans, dp[n][j]);

	printf("%.10lf %.10lf\n", (double)ans.first, -(double)ans.second);
}


#include <cstdio>
#include <iostream>
#include <algorithm>

typedef long double double64;
typedef std :: pair <double64, double64> pdd;

inline int Get() {
	char ch;
	while ((ch = getchar()) < '0' || ch > '9');
	int Num = ch - '0';
	while ((ch = getchar()) >= '0' && ch <= '9')
		Num = (Num << 3) + (Num << 1) + ch - '0';
	return Num;
}

const int N = 1e3 + 5;
const int M = 1600;
int n, m, gA[N], gB[N], tA[N], tB[N], id[N];
double64 prob[N];
pdd dp[N][M];

inline bool cmp(const int &a, const int &b) {
	return (prob[id[a]] - 1) * prob[id[b]] * tB[id[b]] < (prob[id[b]] - 1) * prob[id[a]] * tB[id[a]];
}

int main() {
	n = Get(), m = Get();
	for (int i = 1; i <= n; ++i) {
		gA[i] = Get(), gB[i] = Get(), tA[i] = Get(), tB[i] = Get();
		double res; scanf("%lf", &res); prob[i] = res;
	}

	for (int i = 1; i <= n; ++i) id[i] = i;
	std :: sort(id + 1, id + n + 1, cmp);

	for (int i = 1, k; k = id[i], i <= n; ++i)
		for (int j = m; j >= 0; --j) {
			pdd nxt; dp[i][j] = dp[i - 1][j];
			if (j >= tA[k]) {
				nxt = std :: make_pair(dp[i - 1][j - tA[k]].first + gA[k], dp[i - 1][j - tA[k]].second - tA[k]);
				dp[i][j] = std :: max(dp[i][j], nxt);
			}
			if (j >= tA[k] + tB[k]) {
				nxt.first = dp[i - 1][j - tA[k] - tB[k]].first + gA[k] + (1 - prob[k]) * gB[k];
				nxt.second = prob[k] * dp[i - 1][j - tA[k] - tB[k]].second - (1 - prob[k]) * (j - tA[k]) - tA[k];
				dp[i][j] = std :: max(dp[i][j], nxt);
			}
		}

	pdd ans = std :: make_pair(0, 0);
	for (int j = 0; j <= m; ++j) ans = std :: max(ans, dp[n][j]);

	printf("%lf %lf\n", (double)ans.first, -(double)ans.second);
}


#include<bits/stdc++.h>
#define ll long long
#define ull unsigned ll
#define uint ungigned
#define db long double
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pli pair<ll,int>
#define vi vector<int>
#define vpi vector<pii >
#define IT iterator

#define PB push_back
#define MK make_pair
#define LB lower_bound
#define UB upper_bound
#define BG begin
#define ED end

#define For(i,j,k) for (int i=(j);i<=(int)k;i++)
#define Rep(i,j,k) for (int i=(j);i>=(int)k;i++)
#define UPD(x,y) (((x)+=(y))>=mo?x-=mo:233)
#define CLR(a,v) memset(a,v,sizeof(a));
#define CPY(a,b) memcpy(a,b,sizeof(a));

#define LS3 k*2,l,mid
#define RS3 k*2+1,mid+1,r
#define LS5 k*2,l,mid,x,yb
#define RS5 k*2+1,mid+1,r,x,y
#define GET pushdown(k);int mid=(l+r)/2
using namespace std;

struct prob{
	int ssc,lsc,st,lt;
	db pos;
};
bool cmp(const prob &a,const prob &b){
	return a.pos*a.lt*(1-b.pos)<b.pos*b.lt*(1-a.pos);
}
prob a[2005];

struct State{
	db pts,times;
	State small(prob a){
		return (State){pts+a.ssc,times+a.st};
	}
	State large(prob a,int T){
		return (State){pts+a.ssc+(1-a.pos)*a.lsc,a.st+a.pos*times+(1-a.pos)*(a.lt+T)};
	}
	bool operator <(const State &a)const{
		if (fabs(pts-a.pts)>1e-8)
			return pts<a.pts;
		return times>a.times;
	}
};
State f[2000];

int n,t;

int main(){
	scanf("%d%d",&n,&t);
	For(i,1,n)
		scanf("%d%d",&a[i].ssc,&a[i].lsc),
		scanf("%d%d%lf",&a[i].st,&a[i].lt,&a[i].pos);
	sort(a+1,a+n+1,cmp);
	For(i,1,n) for (int j=t;j>=0;j--){
		if (j>=a[i].st) f[j]=max(f[j],f[j-a[i].st].small(a[i]));
		if (j>=a[i].st+a[i].lt) f[j]=max(f[j],f[j-a[i].st-a[i].lt].large(a[i],j-a[i].st-a[i].lt));
	}
	State ans=(State){0,0};
	For(j,0,t) ans=max(ans,f[j]);
	printf("%.15lf %.15lf",ans.pts,ans.times);
}


#include<bits/stdc++.h>
#define ll long long
#define ull unsigned ll
#define uint ungigned
#define db long double
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pli pair<ll,int>
#define vi vector<int>
#define vpi vector<pii >
#define IT iterator

#define PB push_back
#define MK make_pair
#define LB lower_bound
#define UB upper_bound
#define BG begin
#define ED end

#define For(i,j,k) for (int i=(j);i<=(int)k;i++)
#define Rep(i,j,k) for (int i=(j);i>=(int)k;i++)
#define UPD(x,y) (((x)+=(y))>=mo?x-=mo:233)
#define CLR(a,v) memset(a,v,sizeof(a));
#define CPY(a,b) memcpy(a,b,sizeof(a));

#define LS3 k*2,l,mid
#define RS3 k*2+1,mid+1,r
#define LS5 k*2,l,mid,x,yb
#define RS5 k*2+1,mid+1,r,x,y
#define GET pushdown(k);int mid=(l+r)/2
using namespace std;

struct prob{
	int ssc,lsc,st,lt;
	db pos;
};
bool cmp(const prob &a,const prob &b){
	return a.pos*a.lt*(1-b.pos)<b.pos*b.lt*(1-a.pos);
}
prob a[2005];

struct State{
	db pts,times;
	State small(prob a){
		return (State){pts+a.ssc,times+a.st};
	}
	State large(prob a,int T){
		return (State){pts+a.ssc+(1-a.pos)*a.lsc,a.st+a.pos*times+(1-a.pos)*(a.lt+T)};
	}
	bool operator <(const State &a)const{
		if (fabs(pts-a.pts)>1e-8)
			return pts<a.pts;
		return times>a.times;
	}
};
State f[2000];

int n,t;

int main(){
	scanf("%d%d",&n,&t);
	For(i,1,n)
		scanf("%d%d",&a[i].ssc,&a[i].lsc),
		scanf("%d%d%lf",&a[i].st,&a[i].lt,&a[i].pos);
	sort(a+1,a+n+1,cmp);
	For(i,1,n) for (int j=t;j>=0;j--){
		if (j>=a[i].st) f[j]=max(f[j],f[j-a[i].st].small(a[i]));
		if (j>=a[i].st+a[i].lt) f[j]=max(f[j],f[j-a[i].st-a[i].lt].large(a[i],j-a[i].st-a[i].lt));
	}
	State ans=(State){0,0};
	For(j,0,t) ans=max(ans,f[j]);
	printf("%.15lf %.15lf",(double)ans.pts,(double)ans.times);
}


#include <cstdio>
#include <iostream>
#include <algorithm>

typedef long double double64;
typedef std :: pair <double64, double64> pdd;

inline int Get() {
	char ch;
	while ((ch = getchar()) < '0' || ch > '9');
	int Num = ch - '0';
	while ((ch = getchar()) >= '0' && ch <= '9')
		Num = (Num << 3) + (Num << 1) + ch - '0';
	return Num;
}

const int N = 1e3 + 5;
const int M = 1600;
int n, m, gA[N], gB[N], tA[N], tB[N], id[N];
double64 prob[N];
pdd dp[N][M];

inline bool cmp(const int &a, const int &b) {
	return (1 - prob[b]) * prob[a] * tB[a] < (1 - prob[a]) * prob[b] * tB[b];
}

int main() {
	n = Get(), m = Get();
	for (int i = 1; i <= n; ++i) {
		gA[i] = Get(), gB[i] = Get(), tA[i] = Get(), tB[i] = Get();
		double res; scanf("%lf", &res); prob[i] = res;
	}

	for (int i = 1; i <= n; ++i) id[i] = i;
	std :: sort(id + 1, id + n + 1, cmp);
	for (int i = 1, k; k = id[i], i <= n; ++i)
		for (int j = m; j >= 0; --j) {
			pdd nxt; dp[i][j] = dp[i - 1][j];
			if (j >= tA[k]) {
				nxt = std :: make_pair(dp[i - 1][j - tA[k]].first + gA[k], dp[i - 1][j - tA[k]].second - tA[k]);
				dp[i][j] = std :: max(dp[i][j], nxt);
			}
			if (j >= tA[k] + tB[k]) {
				nxt.first = dp[i - 1][j - tA[k] - tB[k]].first + gA[k] + (1 - prob[k]) * gB[k];
				nxt.second = prob[k] * dp[i - 1][j - tA[k] - tB[k]].second - (1 - prob[k]) * (j - tA[k]) - tA[k];
				dp[i][j] = std :: max(dp[i][j], nxt);
			}
		}
	pdd ans = std :: make_pair(0, 0);
	for (int j = 0; j <= m; ++j) ans = std :: max(ans, dp[n][j]);

	printf("%.10lf %.10lf\n", (double)ans.first, -(double)ans.second);
}


#include<bits/stdc++.h>
#define ll long long
#define ull unsigned ll
#define uint ungigned
#define db long double
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pli pair<ll,int>
#define vi vector<int>
#define vpi vector<pii >
#define IT iterator

#define PB push_back
#define MK make_pair
#define LB lower_bound
#define UB upper_bound
#define BG begin
#define ED end

#define For(i,j,k) for (int i=(j);i<=(int)k;i++)
#define Rep(i,j,k) for (int i=(j);i>=(int)k;i++)
#define UPD(x,y) (((x)+=(y))>=mo?x-=mo:233)
#define CLR(a,v) memset(a,v,sizeof(a));
#define CPY(a,b) memcpy(a,b,sizeof(a));

#define LS3 k*2,l,mid
#define RS3 k*2+1,mid+1,r
#define LS5 k*2,l,mid,x,yb
#define RS5 k*2+1,mid+1,r,x,y
#define GET pushdown(k);int mid=(l+r)/2
using namespace std;

struct prob{
	int ssc,lsc,st,lt;
	db pos;
};
bool cmp(const prob &a,const prob &b){
	return a.pos*a.lt*(1-b.pos)<b.pos*b.lt*(1-a.pos);
}
prob a[2005];

struct State{
	db pts,times;
	State small(prob a){
		return (State){pts+a.ssc,times+a.st};
	}
	State large(prob a,int T){
		return (State){pts+a.ssc+(1-a.pos)*a.lsc,a.st+a.pos*times+(1-a.pos)*(a.lt+T)};
	}
	bool operator <(const State &a)const{
		if (fabs(pts-a.pts)>1e-8)
			return pts<a.pts;
		return times>a.times;
	}
};
State f[2000];

int n,t;

int main(){
	scanf("%d%d",&n,&t);
	For(i,1,n) {
		double res;
		scanf("%d%d",&a[i].ssc,&a[i].lsc),
		scanf("%d%d%lf",&a[i].st,&a[i].lt,&res);
		a[i].pos = res;
	}
	sort(a+1,a+n+1,cmp);
	For(i,1,n) for (int j=t;j>=0;j--){
		if (j>=a[i].st) f[j]=max(f[j],f[j-a[i].st].small(a[i]));
		if (j>=a[i].st+a[i].lt) f[j]=max(f[j],f[j-a[i].st-a[i].lt].large(a[i],j-a[i].st-a[i].lt));
	}
	State ans=(State){0,0};
	For(j,0,t) ans=max(ans,f[j]);
	printf("%.15lf %.15lf",(double)ans.pts,(double)ans.times);
}


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

typedef long long s64;

const int MaxN = 1000;
const int MaxT = 1560;

template <class T>
inline void relax(T &a, const T &b)
{
	if (b > a)
		a = b;
}

struct task
{
	int a, b;
	int s, t;
	double p;

	friend inline bool operator<(const task &lhs, const task &rhs)
	{
		return lhs.t * lhs.p * (1 - rhs.p) < rhs.t * rhs.p * (1 - lhs.p);
	}
};

struct f_t
{
	s64 score;
	double time;

	friend inline bool operator>(const f_t &lhs, const f_t &rhs)
	{
		if (lhs.score != rhs.score)
			return lhs.score > rhs.score;
		return lhs.time < rhs.time;
	}
};

int main()
{
	int n, totT;
	static task a[MaxN];

	cin >> n >> totT;
	for (int i = 0; i < n; i++)
		scanf("%d %d %d %d %lf", &a[i].a, &a[i].b, &a[i].s, &a[i].t, &a[i].p);

	sort(a, a + n);

	const int B = 1000000;

	static f_t f[MaxT + 1];
	for (int i = 0; i < n; i++)
		for (int j = totT; j >= 0; j--)
		{
			if (j >= a[i].s)
			{
				f_t cur = f[j - a[i].s];
				cur.score += (s64)a[i].a * B;
				cur.time += a[i].s;
				relax(f[j], cur);
			}
			if (j >= a[i].s + a[i].t)
			{
				f_t cur = f[j - a[i].s - a[i].t];
				cur.score += (s64)a[i].a * B + a[i].b * (s64)((1 - a[i].p) * B);
				cur.time = (a[i].s + cur.time) * a[i].p + j * (1 - a[i].p);
				relax(f[j], cur);
			}
		}

	f_t res = f[0];
	for (int j = 1; j <= totT; j++)
		relax(res, f[j]);
	printf("%.10f %.10f\n", (double)res.score / B, res.time);

	return 0;
}


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

typedef long long s64;

const int MaxN = 50000;

int n;
char s[MaxN + 1];

const int H = 1000000007;
int h[MaxN + 1];
int hpow[MaxN + 1];
void init_hash()
{
	h[0] = 0;
	for (int i = 0; i < n; i++)
		h[i + 1] = (h[i] + (s64)(s[i] - 'a') * hpow[i]) % H;
}

bool is_same(int l, int i, int j)
{
	return (s64)(h[i + l] + H - h[i]) * hpow[j - i] % H == (h[j + l] + H - h[j]) % H;
}

int getlcp(int i, int j)
{
	int le = 1, ri = i + 2;
	while (le != ri)
	{
		int mid = (le + ri) / 2;
		if (is_same(mid, i - mid + 1, j - mid + 1))
			le = mid + 1;
		else
			ri = mid;
	}
	return le - 1;
}
int getlcs(int i, int j)
{
	int le = 1, ri = n - j + 1;
	while (le != ri)
	{
		int mid = (le + ri) / 2;
		if (is_same(mid, i, j))
			le = mid + 1;
		else
			ri = mid;
	}
	return le - 1;
}

bool check(int l)
{
	for (int i = l; i + l <= n; i += l)
		if (getlcp(i - 1, i + l - 1) + getlcs(i, i + l) >= l)
			return true;
	return false;
}

int main()
{
	scanf("%s", s);
	n = strlen(s);

	hpow[0] = 1;
	for (int i = 1; i <= n; i++)
		hpow[i] = (s64)hpow[i - 1] * 31 % H;

	init_hash();
	for (int l = 1; l <= n; l++)
		if (check(l))
		{
			int c = 0;
			int new_n = l;
			for (int i = l; i < n; i++)
			{
				if (s[i] == s[i - l])
				{
					c++;
					if (c == l)
					{
						new_n -= l;
						c = 0;
					}
				}
				else
					c = 0;
				s[new_n++] = s[i];
			}
			n = new_n;
			s[n] = '\0';

			init_hash();
		}

	cout << s << endl;

	return 0;
}


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

const int MaxN = 1000;
const int MaxT = 1560;

template <class T>
inline void relax(T &a, const T &b)
{
	if (b > a)
		a = b;
}

struct task
{
	int a, b;
	int s, t;
	double p;

	friend inline bool operator<(const task &lhs, const task &rhs)
	{
		return lhs.t * lhs.p / (1 - lhs.p) < rhs.t * rhs.p / (1 - rhs.p);
	}
};

struct f_t
{
	double score;
	double time;

	friend inline bool operator>(const f_t &lhs, const f_t &rhs)
	{
		const double EPS = 1e-9;
		if (abs(lhs.score - rhs.score) > EPS)
			return lhs.score > rhs.score;
		return lhs.time < rhs.time;
	}
};

int main()
{
	int n, totT;
	static task a[MaxN];

	cin >> n >> totT;
	for (int i = 0; i < n; i++)
		scanf("%d %d %d %d %lf", &a[i].a, &a[i].b, &a[i].s, &a[i].t, &a[i].p);

	sort(a, a + n);

	static f_t f[MaxT + 1];
	for (int i = 0; i < n; i++)
		for (int j = totT; j >= 0; j--)
		{
			if (j >= a[i].s)
			{
				f_t cur = f[j - a[i].s];
				cur.score += a[i].a;
				cur.time += a[i].s;
				relax(f[j], cur);
			}
			if (j >= a[i].s + a[i].t)
			{
				f_t cur = f[j - a[i].s - a[i].t];
				cur.score += a[i].a + a[i].b * (1 - a[i].p);
				cur.time = (a[i].s + cur.time) * a[i].p + j * (1 - a[i].p);
				relax(f[j], cur);
			}
		}

	f_t res = f[0];
	for (int j = 1; j <= totT; j++)
		relax(res, f[j]);
	printf("%.10f %.10f\n", res.score, res.time);

	return 0;
}


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

const int MaxN = 1000;
const int MaxT = 1560;

template <class T>
inline void relax(T &a, const T &b)
{
	if (b > a)
		a = b;
}

struct task
{
	int a, b;
	int s, t;
	double p;

	friend inline bool operator<(const task &lhs, const task &rhs)
	{
		return lhs.t * lhs.p * (1 - rhs.p) < rhs.t * rhs.p * (1 - lhs.p);
	}
};

struct f_t
{
	double score;
	double time;

	friend inline bool operator>(const f_t &lhs, const f_t &rhs)
	{
		const double EPS = 1e-7;
		if (abs(lhs.score - rhs.score) > EPS)
			return lhs.score > rhs.score;
		return lhs.time < rhs.time;
	}
};

int main()
{
	int n, totT;
	static task a[MaxN];

	cin >> n >> totT;
	for (int i = 0; i < n; i++)
		scanf("%d %d %d %d %lf", &a[i].a, &a[i].b, &a[i].s, &a[i].t, &a[i].p);

	sort(a, a + n);

	static f_t f[MaxT + 1];
	for (int i = 0; i < n; i++)
		for (int j = totT; j >= 0; j--)
		{
			if (j >= a[i].s)
			{
				f_t cur = f[j - a[i].s];
				cur.score += a[i].a;
				cur.time += a[i].s;
				relax(f[j], cur);
			}
			if (j >= a[i].s + a[i].t)
			{
				f_t cur = f[j - a[i].s - a[i].t];
				cur.score += a[i].a + a[i].b * (1 - a[i].p);
				cur.time = (a[i].s + cur.time) * a[i].p + j * (1 - a[i].p);
				relax(f[j], cur);
			}
		}

	f_t res = f[0];
	for (int j = 1; j <= totT; j++)
		relax(res, f[j]);
	printf("%.10f %.10f\n", res.score, res.time);

	return 0;
}


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

typedef long long s64;

const int MaxN = 1000;
const int MaxT = 1560;

template <class T>
inline void relax(T &a, const T &b)
{
	if (b > a)
		a = b;
}

struct task
{
	int a, b;
	int s, t;
	double p;

	friend inline bool operator<(const task &lhs, const task &rhs)
	{
		return lhs.t * lhs.p * (1 - rhs.p) < rhs.t * rhs.p * (1 - lhs.p);
	}
};

struct f_t
{
	s64 score;
	double time;

	friend inline bool operator>(const f_t &lhs, const f_t &rhs)
	{
		if (lhs.score != rhs.score)
			return lhs.score > rhs.score;
		return lhs.time < rhs.time;
	}
};

int main()
{
	int n, totT;
	static task a[MaxN];

	cin >> n >> totT;
	for (int i = 0; i < n; i++)
		scanf("%d %d %d %d %lf", &a[i].a, &a[i].b, &a[i].s, &a[i].t, &a[i].p);

	sort(a, a + n);

	const int B = 1000000;

	static f_t f[MaxT + 1];
	for (int i = 0; i < n; i++)
		for (int j = totT; j >= 0; j--)
		{
			if (j >= a[i].s)
			{
				f_t cur = f[j - a[i].s];
				cur.score += (s64)a[i].a * B;
				cur.time += a[i].s;
				relax(f[j], cur);
			}
			if (j >= a[i].s + a[i].t)
			{
				f_t cur = f[j - a[i].s - a[i].t];
				cur.score += (s64)a[i].a * B + a[i].b * (s64)floor((1 - a[i].p) * B + 0.5);
				cur.time = (a[i].s + cur.time) * a[i].p + j * (1 - a[i].p);
				relax(f[j], cur);
			}
		}

	f_t res = f[0];
	for (int j = 1; j <= totT; j++)
		relax(res, f[j]);
	printf("%.10f %.10f\n", (double)res.score / B, res.time);

	return 0;
}


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

const int MaxN = 1000;
const int MaxT = 1560;

template <class T>
inline void relax(T &a, const T &b)
{
	if (b > a)
		a = b;
}

struct task
{
	int a, b;
	int s, t;
	double p;

	friend inline bool operator<(const task &lhs, const task &rhs)
	{
		return lhs.t * lhs.p * (1 - rhs.p) < rhs.t * rhs.p * (1 - lhs.p);
	}
};

struct f_t
{
	double score;
	double time;

	friend inline bool operator>(const f_t &lhs, const f_t &rhs)
	{
		const double EPS = 1e-9;
		if (abs(lhs.score - rhs.score) > EPS)
			return lhs.score > rhs.score;
		return lhs.time < rhs.time;
	}
};

int main()
{
	int n, totT;
	static task a[MaxN];

	cin >> n >> totT;
	for (int i = 0; i < n; i++)
		scanf("%d %d %d %d %lf", &a[i].a, &a[i].b, &a[i].s, &a[i].t, &a[i].p);

	sort(a, a + n);

	static f_t f[MaxT + 1];
	for (int i = 0; i < n; i++)
		for (int j = totT; j >= 0; j--)
		{
			if (j >= a[i].s)
			{
				f_t cur = f[j - a[i].s];
				cur.score += a[i].a;
				cur.time += a[i].s;
				relax(f[j], cur);
			}
			if (j >= a[i].s + a[i].t)
			{
				f_t cur = f[j - a[i].s - a[i].t];
				cur.score += a[i].a + a[i].b * (1 - a[i].p);
				cur.time = (a[i].s + cur.time) * a[i].p + j * (1 - a[i].p);
				relax(f[j], cur);
			}
		}

	f_t res = f[0];
	for (int j = 1; j <= totT; j++)
		relax(res, f[j]);
	printf("%.10f %.10f\n", res.score, res.time);

	return 0;
}