#include <bits/stdc++.h>
#define _CRT_SECURE_NO_WAENINGS
#define Mapogo ios_base::sync_with_stdio(false);cout.tie(NULL);cin.tie(NULL);
typedef long long ll;
#define sortt(a) sort(a.begin(),a.end())
#define r(i,x,n) (ll i=x;i<n;i++)
#define i(n) (int i=0;i<n;i++)
#define j(n) (int j=0;j<n;j++)
#define yes cout<<"yes\n"
#define no cout<<"no\n"
#define YES cout<<"YES\n"
#define NO cout<<"NO\n"
#define Yes cout<<"Yes\n"
#define No cout<<"No\n"
#define endl "\n"
#define Pi 3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679
using namespace std;
//============== GCD ==================//
//long long gcd(long long a, long long b)
//{
//	if (b == 0)
//		return a;
//	return gcd(b, a % b);
//}
//============== LCM ================       ==//
//int lcm(int a, int b)
//{
//    return (a * b) / gcd(a, b);
//}
//============ Plaindrome =============//
//bool plaindrome(string s) {
//	for (int i = 0, j = s.size() - 1; i < s.size() / 2; i++, j--) {
//		if (s[i] != s[j])
//			return false;
//	}
//	return true;
//}
//============ in/out file ============//
//void file() {
//	freopen("input.txt", "r", stdin);
//	freopen("output.txt","w",stdout);
//}
//============== Prime ===============//
//bool prime(ll n) {
//	if (n == 1)return false;
//	if (n == 2)return true;
//	for (ll i = 2; i*i <= n; i++)
//        if (n % i == 0) return false;
//	return true;
//}
//bool oneway(ll x1, ll y1, ll x2, ll y2, ll x3, ll y3) {
//	ll a = x1 * (y2 - y3) + x2 * (y3 - y1) + x3 * (y1 - y2);
//	if (a == 0)return true;
//	return false;
//}
int dx[4] = { -1,0,1,0 };
int dy[4] = { 0,1,0,-1 };
int main()
{
	Mapogo;
	int n, x;
	cin >> n >> x;
	map <int, int> m;
	vector <int> v;
	for i(n) {
		int a;
		cin >> a;
		v.push_back(a);
		m[a]++;
	}
	int ans = 0;
	for i(v.size()) {
		if (m[(v[i] ^ x)] >= 1) {
			/*cout << m[v[i]] << " " << m[(v[i] ^ x)] << endl;*/
			ans++;
			m[v[i]]--;
			m[(v[i] ^ x)]--;
		}
	}
	cout << ans;
	return 0;
}


#include <bits/stdc++.h>
#define _CRT_SECURE_NO_WAENINGS
#define Mapogo ios_base::sync_with_stdio(false);cout.tie(NULL);cin.tie(NULL);
typedef long long ll;
#define sortt(a) sort(a.begin(),a.end())
#define r(i,x,n) (ll i=x;i<n;i++)
#define i(n) (int i=0;i<n;i++)
#define j(n) (int j=0;j<n;j++)
#define yes cout<<"yes\n"
#define no cout<<"no\n"
#define YES cout<<"YES\n"
#define NO cout<<"NO\n"
#define Yes cout<<"Yes\n"
#define No cout<<"No\n"
#define endl "\n"
#define Pi 3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679
using namespace std;
//============== GCD ==================//
//long long gcd(long long a, long long b)
//{
//	if (b == 0)
//		return a;
//	return gcd(b, a % b);
//}
//============== LCM ================       ==//
//int lcm(int a, int b)
//{
//    return (a * b) / gcd(a, b);
//}
//============ Plaindrome =============//
//bool plaindrome(string s) {
//	for (int i = 0, j = s.size() - 1; i < s.size() / 2; i++, j--) {
//		if (s[i] != s[j])
//			return false;
//	}
//	return true;
//}
//============ in/out file ============//
//void file() {
//	freopen("input.txt", "r", stdin);
//	freopen("output.txt","w",stdout);
//}
//============== Prime ===============//
//bool prime(ll n) {
//	if (n == 1)return false;
//	if (n == 2)return true;
//	for (ll i = 2; i*i <= n; i++)
//        if (n % i == 0) return false;
//	return true;
//}
//bool oneway(ll x1, ll y1, ll x2, ll y2, ll x3, ll y3) {
//	ll a = x1 * (y2 - y3) + x2 * (y3 - y1) + x3 * (y1 - y2);
//	if (a == 0)return true;
//	return false;
//}
int dx[4] = { -1,0,1,0 };
int dy[4] = { 0,1,0,-1 };
int main()
{
	Mapogo;
	int n, x;
	cin >> n >> x;
	map <int, int> m;
	vector <int> v;
	for i(n) {
		int a;
		cin >> a;
		v.push_back(a);
		m[a]++;
	}
	int ans = 0;
	for i(v.size()) {
		if (m[(v[i] ^ x)] >= 1) {
			/*cout << m[v[i]] << " " << m[(v[i] ^ x)] << endl;*/
			ans += m[(v[i] ^ x)];
			m[v[i]]--;
			/*m[(v[i] ^ x)]--;*/
		}
	}
	cout << ans;
	return 0;
}


#include <bits/stdc++.h>
#define _CRT_SECURE_NO_WAENINGS
#define Mapogo ios_base::sync_with_stdio(false);cout.tie(NULL);cin.tie(NULL);
typedef long long ll;
#define sortt(a) sort(a.begin(),a.end())
#define r(i,x,n) (ll i=x;i<n;i++)
#define i(n) (int i=0;i<n;i++)
#define j(n) (int j=0;j<n;j++)
#define yes cout<<"yes\n"
#define no cout<<"no\n"
#define YES cout<<"YES\n"
#define NO cout<<"NO\n"
#define Yes cout<<"Yes\n"
#define No cout<<"No\n"
#define endl "\n"
#define Pi 3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679
using namespace std;
//============== GCD ==================//
//long long gcd(long long a, long long b)
//{
//	if (b == 0)
//		return a;
//	return gcd(b, a % b);
//}
//============== LCM ================       ==//
//int lcm(int a, int b)
//{
//    return (a * b) / gcd(a, b);
//}
//============ Plaindrome =============//
//bool plaindrome(string s) {
//	for (int i = 0, j = s.size() - 1; i < s.size() / 2; i++, j--) {
//		if (s[i] != s[j])
//			return false;
//	}
//	return true;
//}
//============ in/out file ============//
//void file() {
//	freopen("input.txt", "r", stdin);
//	freopen("output.txt","w",stdout);
//}
//============== Prime ===============//
//bool prime(ll n) {
//	if (n == 1)return false;
//	if (n == 2)return true;
//	for (ll i = 2; i*i <= n; i++)
//        if (n % i == 0) return false;
//	return true;
//}
//bool oneway(ll x1, ll y1, ll x2, ll y2, ll x3, ll y3) {
//	ll a = x1 * (y2 - y3) + x2 * (y3 - y1) + x3 * (y1 - y2);
//	if (a == 0)return true;
//	return false;
//}
int dx[4] = { -1,0,1,0 };
int dy[4] = { 0,1,0,-1 };
int main()
{
	Mapogo;
	int n, x;
	cin >> n >> x;
	map <int, int> m;
	vector <int> v;
	for i(n) {
		int a;
		cin >> a;
		v.push_back(a);
		m[a]++;
	}
	ll ans = 0;
	for i(v.size()) {
		if (m[(v[i] ^ x)] >= 1) {
			/*cout << m[v[i]] << " " << m[(v[i] ^ x)] << endl;*/
			ans += m[(v[i] ^ x)];
			m[v[i]]--;
			/*m[(v[i] ^ x)]--;*/
		}
	}
	cout << ans;
	return 0;
}


#include <bits/stdc++.h>
#define _CRT_SECURE_NO_WAENINGS
#define Mapogo ios_base::sync_with_stdio(false);cout.tie(NULL);cin.tie(NULL);
typedef long long ll;
#define sortt(a) sort(a.begin(),a.end())
#define r(i,x,n) (ll i=x;i<n;i++)
#define i(n) (int i=0;i<n;i++)
#define j(n) (int j=0;j<n;j++)
#define yes cout<<"yes\n"
#define no cout<<"no\n"
#define YES cout<<"YES\n"
#define NO cout<<"NO\n"
#define Yes cout<<"Yes\n"
#define No cout<<"No\n"
#define endl "\n"
#define Pi 3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679
using namespace std;
//============== GCD ==================//
//long long gcd(long long a, long long b)
//{
//	if (b == 0)
//		return a;
//	return gcd(b, a % b);
//}
//============== LCM ================       ==//
//int lcm(int a, int b)
//{
//    return (a * b) / gcd(a, b);
//}
//============ Plaindrome =============//
//bool plaindrome(string s) {
//	for (int i = 0, j = s.size() - 1; i < s.size() / 2; i++, j--) {
//		if (s[i] != s[j])
//			return false;
//	}
//	return true;
//}
//============ in/out file ============//
//void file() {
//	freopen("input.txt", "r", stdin);
//	freopen("output.txt","w",stdout);
//}
//============== Prime ===============//
//bool prime(ll n) {
//	if (n == 1)return false;
//	if (n == 2)return true;
//	for (ll i = 2; i*i <= n; i++)
//        if (n % i == 0) return false;
//	return true;
//}
//bool oneway(ll x1, ll y1, ll x2, ll y2, ll x3, ll y3) {
//	ll a = x1 * (y2 - y3) + x2 * (y3 - y1) + x3 * (y1 - y2);
//	if (a == 0)return true;
//	return false;
//}
int dx[4] = { -1,0,1,0 };
int dy[4] = { 0,1,0,-1 };
int main()
{
	Mapogo;
	int n, x;
	cin >> n >> x;
	map <int, int> m;
	vector <int> v;
	for i(n) {
		int a;
		cin >> a;
		if (m[a] == 0) v.push_back(a);
		m[a]++;
	}
	ll ans = 0;
	if (x == 0) {
		for (auto i : m) {
			ans += i.second * (i.second * (i.second - 1));
		}
		return cout << ans, 0;
	}
	for i(v.size()) {
		for r(j, i + 1, v.size()) {
			if ((v[i] ^ v[j]) == x) {
				ans += m[v[i]] * m[v[j]];
			}
		}
	}
	cout << ans;
	return 0;
}


#include <bits/stdc++.h>
#define _CRT_SECURE_NO_WAENINGS
#define Mapogo ios_base::sync_with_stdio(false);cout.tie(NULL);cin.tie(NULL);
typedef long long ll;
#define sortt(a) sort(a.begin(),a.end())
#define r(i,x,n) (ll i=x;i<n;i++)
#define i(n) (int i=0;i<n;i++)
#define j(n) (int j=0;j<n;j++)
#define yes cout<<"yes\n"
#define no cout<<"no\n"
#define YES cout<<"YES\n"
#define NO cout<<"NO\n"
#define Yes cout<<"Yes\n"
#define No cout<<"No\n"
#define endl "\n"
#define Pi 3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679
using namespace std;
//============== GCD ==================//
//long long gcd(long long a, long long b)
//{
//	if (b == 0)
//		return a;
//	return gcd(b, a % b);
//}
//============== LCM ================       ==//
//int lcm(int a, int b)
//{
//    return (a * b) / gcd(a, b);
//}
//============ Plaindrome =============//
//bool plaindrome(string s) {
//	for (int i = 0, j = s.size() - 1; i < s.size() / 2; i++, j--) {
//		if (s[i] != s[j])
//			return false;
//	}
//	return true;
//}
//============ in/out file ============//
//void file() {
//	freopen("input.txt", "r", stdin);
//	freopen("output.txt","w",stdout);
//}
//============== Prime ===============//
//bool prime(ll n) {
//	if (n == 1)return false;
//	if (n == 2)return true;
//	for (ll i = 2; i*i <= n; i++)
//        if (n % i == 0) return false;
//	return true;
//}
//bool oneway(ll x1, ll y1, ll x2, ll y2, ll x3, ll y3) {
//	ll a = x1 * (y2 - y3) + x2 * (y3 - y1) + x3 * (y1 - y2);
//	if (a == 0)return true;
//	return false;
//}
int dx[4] = { -1,0,1,0 };
int dy[4] = { 0,1,0,-1 };
int main()
{
	Mapogo;
	int n, x;
	cin >> n >> x;
	vector <int> v(n);
	for i(n) cin >> v[i];
	int ans = 0;
	for i(n) {
		for r(j, i + 1, n) {
			if ((v[i] ^ v[j]) == x)ans++;
		}
	}
	cout << ans;
	return 0;
}


#include <bits/stdc++.h>
#define _CRT_SECURE_NO_WAENINGS
#define Mapogo ios_base::sync_with_stdio(false);cout.tie(NULL);cin.tie(NULL);
typedef long long ll;
#define sortt(a) sort(a.begin(),a.end())
#define r(i,x,n) (ll i=x;i<n;i++)
#define i(n) (int i=0;i<n;i++)
#define j(n) (int j=0;j<n;j++)
#define yes cout<<"yes\n"
#define no cout<<"no\n"
#define YES cout<<"YES\n"
#define NO cout<<"NO\n"
#define Yes cout<<"Yes\n"
#define No cout<<"No\n"
#define endl "\n"
#define Pi 3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679
using namespace std;
//============== GCD ==================//
//long long gcd(long long a, long long b)
//{
//	if (b == 0)
//		return a;
//	return gcd(b, a % b);
//}
//============== LCM ================       ==//
//int lcm(int a, int b)
//{
//    return (a * b) / gcd(a, b);
//}
//============ Plaindrome =============//
//bool plaindrome(string s) {
//	for (int i = 0, j = s.size() - 1; i < s.size() / 2; i++, j--) {
//		if (s[i] != s[j])
//			return false;
//	}
//	return true;
//}
//============ in/out file ============//
//void file() {
//	freopen("input.txt", "r", stdin);
//	freopen("output.txt","w",stdout);
//}
//============== Prime ===============//
//bool prime(ll n) {
//	if (n == 1)return false;
//	if (n == 2)return true;
//	for (ll i = 2; i*i <= n; i++)
//        if (n % i == 0) return false;
//	return true;
//}
//bool oneway(ll x1, ll y1, ll x2, ll y2, ll x3, ll y3) {
//	ll a = x1 * (y2 - y3) + x2 * (y3 - y1) + x3 * (y1 - y2);
//	if (a == 0)return true;
//	return false;
//}
int dx[4] = { -1,0,1,0 };
int dy[4] = { 0,1,0,-1 };
int main()
{
	Mapogo;
	int n, x;
	cin >> n >> x;
	map <int, int> m;
	vector <int> v;
	for i(n) {
		int a;
		cin >> a;
		if (m[a] == 0) v.push_back(a);
		m[a]++;
	}
	int ans = 0;
	for i(v.size()) {
		for r(j, i + 1, v.size()) {
			if ((v[i] ^ v[j]) == x) {
				ans += m[v[i]] * m[v[j]];
			}
		}
	}
	cout << ans;
	return 0;
}


#include <bits/stdc++.h>
#define _CRT_SECURE_NO_WAENINGS
#define Mapogo ios_base::sync_with_stdio(false);cout.tie(NULL);cin.tie(NULL);
typedef long long ll;
#define sortt(a) sort(a.begin(),a.end())
#define r(i,x,n) (ll i=x;i<n;i++)
#define i(n) (int i=0;i<n;i++)
#define j(n) (int j=0;j<n;j++)
#define yes cout<<"yes\n"
#define no cout<<"no\n"
#define YES cout<<"YES\n"
#define NO cout<<"NO\n"
#define Yes cout<<"Yes\n"
#define No cout<<"No\n"
#define endl "\n"
#define Pi 3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679
using namespace std;
//============== GCD ==================//
//long long gcd(long long a, long long b)
//{
//	if (b == 0)
//		return a;
//	return gcd(b, a % b);
//}
//============== LCM ================       ==//
//int lcm(int a, int b)
//{
//    return (a * b) / gcd(a, b);
//}
//============ Plaindrome =============//
//bool plaindrome(string s) {
//	for (int i = 0, j = s.size() - 1; i < s.size() / 2; i++, j--) {
//		if (s[i] != s[j])
//			return false;
//	}
//	return true;
//}
//============ in/out file ============//
//void file() {
//	freopen("input.txt", "r", stdin);
//	freopen("output.txt","w",stdout);
//}
//============== Prime ===============//
//bool prime(ll n) {
//	if (n == 1)return false;
//	if (n == 2)return true;
//	for (ll i = 2; i*i <= n; i++)
//        if (n % i == 0) return false;
//	return true;
//}
//bool oneway(ll x1, ll y1, ll x2, ll y2, ll x3, ll y3) {
//	ll a = x1 * (y2 - y3) + x2 * (y3 - y1) + x3 * (y1 - y2);
//	if (a == 0)return true;
//	return false;
//}
int dx[4] = { -1,0,1,0 };
int dy[4] = { 0,1,0,-1 };
int main()
{
	Mapogo;
	int n, x;
	cin >> n >> x;
	map <int, int> m;
	vector <int> v;
	for i(n) {
		int a;
		cin >> a;
		if (m[a] == 0) v.push_back(a);
		m[a]++;
	}
	ll ans = 0;
	if (x == 0) {
		for (auto i : m) {
			ll num = i.second;
			ans += num * (num - 1);
		}
		ans /= 2;
		return cout << ans, 0;
	}
	for i(v.size()) {
		/*for r(j, i + 1, v.size()) {
			if ((v[i] ^ v[j]) == x) {
				ans += m[v[i]] * m[v[j]];
			}
		}*/
		if (m[(v[i] ^ x)] >= 1) {
			ll f = m[v[i]], s = m[(v[i] ^ x)];
			f = f * s;
			ans += f;
		}
	}
	ans /= 2;
	cout << ans;
	return 0;
}


#include<bits/stdc++.h>
#define forn(i, n) for (int i = 1; i <= (int)(n); ++i)
#define sqr(x) ((x)*(x))
#define pb push_back
#define mp make_pair
#define se second
#define fi first
#define sz(x) ((int)(x.size()))
#define y1 asdfghjkl
#define int long long

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
const int mod = 1e9 + 7;
const ll N = 2e6 + 500;
const ll INF = 1e18 + 7;

using namespace std;

void boost() {
     ios_base :: sync_with_stdio(false);
     cin.tie(0);
     cout.tie(0);
}

ll fast_pow(ll a, ll b){
	ll res = a, ret = 1;
	while(b){
		if(b&1)
			ret = (ret*res)%mod;
		res = (res*res)%mod;
		b>>=1;
	}
	return ret;
}

int n, x, a[N], cnt[N], ans;

main()
{
	scanf("%lld %lld", &n, &x);
	for(int i = 0; i < n; ++i)
	{
		scanf("%lld", a+i);
		cnt[a[i]]++;
	}
	for(int i = 0; i < n; ++i)
	{
		int b = (a[i] ^ x);
		if(a[i] == b)
			ans+=b-1;
		else ans+=cnt[b];
	}
	printf("%lld", ans/2);
}


#include<bits/stdc++.h>
#define forn(i, n) for (int i = 1; i <= (int)(n); ++i)
#define sqr(x) ((x)*(x))
#define pb push_back
#define mp make_pair
#define se second
#define fi first
#define sz(x) ((int)(x.size()))
#define y1 asdfghjkl
#define int long long

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
const int mod = 1e9 + 7;
const ll N = 2e6 + 500;
const ll INF = 1e18 + 7;

using namespace std;

void boost() {
     ios_base :: sync_with_stdio(false);
     cin.tie(0);
     cout.tie(0);
}

ll fast_pow(ll a, ll b){
	ll res = a, ret = 1;
	while(b){
		if(b&1)
			ret = (ret*res)%mod;
		res = (res*res)%mod;
		b>>=1;
	}
	return ret;
}

int n, x, a[N], cnt[N], ans;

main()
{
	scanf("%lld %lld", &n, &x);
	for(int i = 0; i < n; ++i)
	{
		scanf("%lld", a+i);
		cnt[a[i]]++;
	}
	for(int i = 0; i < n; ++i)
	{
		ans+=(cnt[ a[i] ^ x] );
	}
	printf("%d", ans/2);
}


#include<bits/stdc++.h>
#define forn(i, n) for (int i = 1; i <= (int)(n); ++i)
#define sqr(x) ((x)*(x))
#define pb push_back
#define mp make_pair
#define se second
#define fi first
#define sz(x) ((int)(x.size()))
#define y1 asdfghjkl
#define int long long

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
const int mod = 1e9 + 7;
const ll N = 2e6 + 500;
const ll INF = 1e18 + 7;

using namespace std;

void boost() {
     ios_base :: sync_with_stdio(false);
     cin.tie(0);
     cout.tie(0);
}

ll fast_pow(ll a, ll b){
	ll res = a, ret = 1;
	while(b){
		if(b&1)
			ret = (ret*res)%mod;
		res = (res*res)%mod;
		b>>=1;
	}
	return ret;
}

int n, x, a[N], cnt[N], ans;

main()
{
	scanf("%lld %lld", &n, &x);
	for(int i = 0; i < n; ++i)
	{
		scanf("%lld", a+i);
		cnt[a[i]]  = 1;
	}
	for(int i = 0; i < n; ++i)
	{
		int b = (a[i] ^ x);
		if(a[i] == b)
			ans+=b-1;
		else ans+=b;
	}
	printf("%lld", ans/2);
}


#include<bits/stdc++.h>
#define forn(i, n) for (int i = 1; i <= (int)(n); ++i)
#define sqr(x) ((x)*(x))
#define pb push_back
#define mp make_pair
#define se second
#define fi first
#define sz(x) ((int)(x.size()))
#define y1 asdfghjkl
#define int long long

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
const int mod = 1e9 + 7;
const ll N = 2e6 + 500;
const ll INF = 1e18 + 7;

using namespace std;

void boost() {
     ios_base :: sync_with_stdio(false);
     cin.tie(0);
     cout.tie(0);
}

ll fast_pow(ll a, ll b){
	ll res = a, ret = 1;
	while(b){
		if(b&1)
			ret = (ret*res)%mod;
		res = (res*res)%mod;
		b>>=1;
	}
	return ret;
}

int n, x, a[N], cnt[N], ans;

main()
{
	scanf("%d %d", &n, &x);
	for(int i = 0; i < n; ++i)
	{
		scanf("%d", a+i);
		cnt[a[i]]++;
	}
	for(int i = 0; i < n; ++i)
	{
		ans+=(cnt[ a[i] ^ x] );
	}
	printf("%d", ans/2);
}


#include<bits/stdc++.h>
#define forn(i, n) for (int i = 1; i <= (int)(n); ++i)
#define sqr(x) ((x)*(x))
#define pb push_back
#define mp make_pair
#define se second
#define fi first
#define sz(x) ((int)(x.size()))
#define y1 asdfghjkl
#define int long long

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
const int mod = 1e9 + 7;
const ll N = 2e6 + 500;
const ll INF = 1e18 + 7;

using namespace std;

void boost() {
     ios_base :: sync_with_stdio(false);
     cin.tie(0);
     cout.tie(0);
}

ll fast_pow(ll a, ll b){
	ll res = a, ret = 1;
	while(b){
		if(b&1)
			ret = (ret*res)%mod;
		res = (res*res)%mod;
		b>>=1;
	}
	return ret;
}

int n, x, a[N], cnt[N], ans;

main()
{
	scanf("%lld %lld", &n, &x);
	for(int i = 0; i < n; ++i)
	{
		scanf("%lld", a+i);
		cnt[a[i]]++;
	}
	for(int i = 0; i < n; ++i)
	{
		ans+=(cnt[ a[i] ^ x] );
	}
	printf("%lld", ans/2);
}


#include<bits/stdc++.h>
#define forn(i, n) for (int i = 1; i <= (int)(n); ++i)
#define sqr(x) ((x)*(x))
#define pb push_back
#define mp make_pair
#define se second
#define fi first
#define sz(x) ((int)(x.size()))
#define y1 asdfghjkl
#define int long long

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
const int mod = 1e9 + 7;
const ll N = 2e6 + 500;
const ll INF = 1e18 + 7;

using namespace std;

void boost() {
     ios_base :: sync_with_stdio(false);
     cin.tie(0);
     cout.tie(0);
}

ll fast_pow(ll a, ll b){
	ll res = a, ret = 1;
	while(b){
		if(b&1)
			ret = (ret*res)%mod;
		res = (res*res)%mod;
		b>>=1;
	}
	return ret;
}

int n, x, a[N], cnt[N], ans;

main()
{
	scanf("%lld %lld", &n, &x);
	for(int i = 0; i < n; ++i)
	{
		scanf("%lld", a+i);
		cnt[a[i]]++;
	}
	for(int i = 0; i < n; ++i)
	{
		int b = (a[i] ^ x);
		if(a[i] == b)
			ans+=cnt[b]-1;
		else ans+=cnt[b];
	}
	printf("%lld", ans/2);
}


#include<bits/stdc++.h>
using namespace std;
long long n,x,cnt,i,j,k,l,a;
map<long long,long long>m;
int main()
{
	cin>>n>>x;
	for(i=0;i<n;i++)
	{
		cin>>a;
		cnt+=m[a^x];
		m[a]++;
	}
	cout<<cnt;
}


#include<bits/stdc++.h>
using namespace std;
long long n,x,cnt,i,j,k,l,a[100007];
int main()
{
	ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
	cin>>n>>x;for(i=0;i<n;i++) cin>>a[i];
	for(i=0;i<n-1;i++)  for(j=i+1;j<n;j++) if((a[i]^a[j])==x) cnt++;
	cout<<cnt;
}


#include<bits/stdc++.h>
using namespace std;
long long n,x,cnt,i,j,k,l,a[100007];
map<long long,long long>m;
int main()
{
	cin>>n>>x;for(i=0;i<n;i++) cin>>a[i],m[a[i]]++;
	for(i=0;i<n;i++)
	{
       if(a[i]<(x^a[i])) cnt+=(m[x^a[i]]);
       else if(x==0&&m[a[i]]>0) cnt+=(m[a[i]]*(m[a[i]]-1))/2,m[a[i]]=0;
	}
	cout<<cnt;
}


#include<bits/stdc++.h>
using namespace std;
long long n,x,cnt,i,j,k,l,a[100007];
map<long long,long long>m;set<long long>s;
int main()
{
	ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
	cin>>n>>x;for(i=0;i<n;i++) cin>>a[i],m[a[i]]++,s.insert(a[i]);
	if(x==0) return cout<<n-s.size(),0;
	for(i=0;i<n;i++)
	{
       if(a[i]<=(x^a[i])) cnt+=(m[x^a[i]]);
	}
	cout<<cnt;

}


#include<bits/stdc++.h>
using namespace std;
long long n,i,j,k,l,a,ans,x;
map<long long,long long>m;
int main()
{
	cin>>n>>x;
	for(i=1;i<=n;i++)
	{
		cin>>a;
		ans=ans+m[a^x];
		m[a]++;
	}
	cout<<ans;
}


#include<bits/stdc++.h>
using namespace std;
long long n,x,cnt,i,j,k,l,a[100007];
map<long long,long long>m;set<long long>s;
int main()
{
	ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
	cin>>n>>x;for(i=0;i<n;i++) cin>>a[i],m[a[i]]++;
	for(i=0;i<n;i++)
	{
       if(a[i]<(x^a[i])) cnt+=(m[x^a[i]]);
       if(x==0&&m[a[i]]>0) cnt+=(m[a[i]]*(m[a[i]]-1))/2,m[a[i]]=0;
	}
	cout<<cnt;

}


#include <bits/stdc++.h>

using namespace std;
int main()
{
    int n, x, op, tmp;
    long long int ans = 0;
    cin >> n >> x;
    vector<int> cnt(1000001, 0);
    for (int i = 0; i < n; i++)
    {
        cin >> tmp;
        op = x ^ tmp;
        ans += cnt[op];
        cnt[tmp] += 1;
    }

    cout << ans;
}


#include <bits/stdc++.h>

using namespace std;
int main()
{
    int n, x, op, ans, tmp;
    cin >> n >> x;
    vector<int> cnt(1000001, 0);
    for (int i = 0; i < n; i++)
    {
        cin >> tmp;
        op = x ^ tmp;
        ans += cnt[op];
        cnt[tmp] += 1;
    }

    cout << ans;
    return 0;

}


#include <bits/stdc++.h>

using namespace std;
int man()
{
    int n, x, op, ans, tmp;
    cin >> n >> x;
    vector<int> cnt(1000001, 0);
    for (int i = 0; i < n; i++)
    {
        cin >> tmp;
        op = x ^ tmp;
        ans += cnt[op];
        cnt[tmp] += 1;
    }

    cout << ans;
}


#include <bits/stdc++.h>

using namespace std;
int man()
{
    int n, x, op, tmp;
    long long int ans;
    cin >> n >> x;
    vector<int> cnt(1000001, 0);
    for (int i = 0; i < n; i++)
    {
        cin >> tmp;
        op = x ^ tmp;
        ans = ans + (long long int)cnt[op];
        cnt[tmp] += 1;
    }

    cout << ans;
}


#include <bits/stdc++.h>

using namespace std;
int man()
{
    int n, x, op, ans = 0, tmp;
    cin >> n >> x;
    vector<int> cnt(1000001, 0);
    for (int i = 0; i < n; i++)
    {
        cin >> tmp;
        op = x ^ tmp;
        ans += cnt[op];
        cnt[tmp] += 1;
    }

    cout << ans;
}


#include <bits/stdc++.h>

using namespace std;
int main()
{
    int n, x, op, ans = 0, tmp;
    cin >> n >> x;
    vector<int> cnt(1000001, 0);
    for (int i = 0; i < n; i++)
    {
        cin >> tmp;
        op = x ^ tmp;
        ans += cnt[op];
        cnt[tmp] += 1;
    }

    cout << ans;
}


#include <bits/stdc++.h>
using namespace std;
#define fastio ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define t_times int t; cin >> t; while(t--)
#define parr(a, n) for(int __i = 0; __i < (int )n; __i++) cout << a[__i] << ' '; cout << '\n'
#define fr(i, p, n) for(int i = (int )p; i < (int )n; i++)
#define frn(i, p, n) for(int i = (int )p; i <= (int )n; i++)
#define rev(i, n, p) for(int i = (int )n; i >= (int )p; i--)
#define all(c) (c).begin(), (c).end()
#define sci(n) scanf("%d", &n)
#define scl(n) scanf("%lld", &n)
#define prin(n) printf("%d\n", n)
#define prln(n) printf("%lld\n", n)
#define mk make_pair
#define F first
#define S second
#define pb push_back
#define bp __builtin_popcount
typedef long long int LL;
typedef unsigned long long ULL;
typedef unsigned int uint;
typedef long double LD;
typedef pair< int, int> ii;
typedef vector< int> vi;

const int mod = 1e9 + 7;
const LL INF = 9e18 + 2e17;
const int inf = 2e9;
const int N = 1e3 + 22;
const double eps = 1e-10;
const double PI = 3.14159265;

map<int,int>m;
void solve()
{
    int n,x,y; LL ans=0; cin>>n>>x; for(int i=0;i<n;i++) {cin>>y; m[y]++; }
    for(int i=1;i<=100000;i++){
        if(m[i] && m[(i^x)])
            ans+=(1LL*m[i]*m[(i^x)]);
    }
    cout<<ans/2;
    //cout<<'\n';
    return ;
}

int main()
{
    fastio;
    //t_times
    solve();
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define fastio ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define t_times int t; cin >> t; while(t--)
#define parr(a, n) for(int __i = 0; __i < (int )n; __i++) cout << a[__i] << ' '; cout << '\n'
#define fr(i, p, n) for(int i = (int )p; i < (int )n; i++)
#define frn(i, p, n) for(int i = (int )p; i <= (int )n; i++)
#define rev(i, n, p) for(int i = (int )n; i >= (int )p; i--)
#define all(c) (c).begin(), (c).end()
#define sci(n) scanf("%d", &n)
#define scl(n) scanf("%lld", &n)
#define prin(n) printf("%d\n", n)
#define prln(n) printf("%lld\n", n)
#define mk make_pair
#define F first
#define S second
#define pb push_back
#define bp __builtin_popcount
typedef long long int LL;
typedef unsigned long long ULL;
typedef unsigned int uint;
typedef long double LD;
typedef pair< int, int> ii;
typedef vector< int> vi;

const int mod = 1e9 + 7;
const LL INF = 9e18 + 2e17;
const int inf = 2e9;
const int N = 1e3 + 22;
const double eps = 1e-10;
const double PI = 3.14159265;

map<int,int>m;
void solve()
{
    int n,x,y; LL ans=0; cin>>n>>x; int a[n]; for(int i=0;i<n;i++) {cin>>a[i]; m[a[i]]++; }
    for(int i=0;i<n;i++){
        if((a[i]^x)<=100000 && m[(a[i]^x)])
            ans+=(1LL*m[(a[i]^x)]);
    }
    cout<<ans/2;
    //cout<<'\n';
    return ;
}

int main()
{
    fastio;
    //t_times
    solve();
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define fastio ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define t_times int t; cin >> t; while(t--)
#define parr(a, n) for(int __i = 0; __i < (int )n; __i++) cout << a[__i] << ' '; cout << '\n'
#define fr(i, p, n) for(int i = (int )p; i < (int )n; i++)
#define frn(i, p, n) for(int i = (int )p; i <= (int )n; i++)
#define rev(i, n, p) for(int i = (int )n; i >= (int )p; i--)
#define all(c) (c).begin(), (c).end()
#define sci(n) scanf("%d", &n)
#define scl(n) scanf("%lld", &n)
#define prin(n) printf("%d\n", n)
#define prln(n) printf("%lld\n", n)
#define mk make_pair
#define F first
#define S second
#define pb push_back
#define bp __builtin_popcount
typedef long long int LL;
typedef unsigned long long ULL;
typedef unsigned int uint;
typedef long double LD;
typedef pair< int, int> ii;
typedef vector< int> vi;

const int mod = 1e9 + 7;
const LL INF = 9e18 + 2e17;
const int inf = 2e9;
const int N = 1e3 + 22;
const double eps = 1e-10;
const double PI = 3.14159265;

map<int,int>m;
void solve()
{
    int n,x,y; LL ans=0; cin>>n>>x; for(int i=0;i<n;i++) {cin>>y; m[y]++; }
    for(int i=1;i<=100000;i++){
        if(m[i] && m[(i^x)])
            ans+=(m[i]*m[(i^x)]);
    }
    cout<<ans/2;
    //cout<<'\n';
    return ;
}

int main()
{
    fastio;
    //t_times
    solve();
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define fastio ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define t_times int t; cin >> t; while(t--)
#define parr(a, n) for(int __i = 0; __i < (int )n; __i++) cout << a[__i] << ' '; cout << '\n'
#define fr(i, p, n) for(int i = (int )p; i < (int )n; i++)
#define frn(i, p, n) for(int i = (int )p; i <= (int )n; i++)
#define rev(i, n, p) for(int i = (int )n; i >= (int )p; i--)
#define all(c) (c).begin(), (c).end()
#define sci(n) scanf("%d", &n)
#define scl(n) scanf("%lld", &n)
#define prin(n) printf("%d\n", n)
#define prln(n) printf("%lld\n", n)
#define mk make_pair
#define F first
#define S second
#define pb push_back
#define bp __builtin_popcount
typedef long long int LL;
typedef unsigned long long ULL;
typedef unsigned int uint;
typedef long double LD;
typedef pair< int, int> ii;
typedef vector< int> vi;

const int mod = 1e9 + 7;
const LL INF = 9e18 + 2e17;
const int inf = 2e9;
const int N = 1e3 + 22;
const double eps = 1e-10;
const double PI = 3.14159265;

map<int,int>m;
void solve()
{
    int n,x,y; LL ans=0; cin>>n>>x; int a[n]; for(int i=0;i<n;i++) {cin>>a[i]; m[a[i]]++; }
    for(int i=0;i<=n;i++){
        if((a[i]^x)<=100000 && m[(a[i]^x)])
            ans+=(1LL*m[(a[i]^x)]);
    }
    cout<<ans/2;
    //cout<<'\n';
    return ;
}

int main()
{
    fastio;
    //t_times
    solve();
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define fastio ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define t_times int t; cin >> t; while(t--)
#define parr(a, n) for(int __i = 0; __i < (int )n; __i++) cout << a[__i] << ' '; cout << '\n'
#define fr(i, p, n) for(int i = (int )p; i < (int )n; i++)
#define frn(i, p, n) for(int i = (int )p; i <= (int )n; i++)
#define rev(i, n, p) for(int i = (int )n; i >= (int )p; i--)
#define all(c) (c).begin(), (c).end()
#define sci(n) scanf("%d", &n)
#define scl(n) scanf("%lld", &n)
#define prin(n) printf("%d\n", n)
#define prln(n) printf("%lld\n", n)
#define mk make_pair
#define F first
#define S second
#define pb push_back
#define bp __builtin_popcount
typedef long long int LL;
typedef unsigned long long ULL;
typedef unsigned int uint;
typedef long double LD;
typedef pair< int, int> ii;
typedef vector< int> vi;

const int mod = 1e9 + 7;
const LL INF = 9e18 + 2e17;
const int inf = 2e9;
const int N = 1e3 + 22;
const double eps = 1e-10;
const double PI = 3.14159265;

map<int,int>m;
void solve()
{
    int n,x,y; LL ans=0; cin>>n>>x; int a[n]; for(int i=0;i<n;i++) {cin>>a[i]; m[a[i]]++; }
    for(int i=0;i<=n;i++){
        if(m[(a[i]^x)])
            ans+=(1LL*m[(a[i]^x)]);
    }
    cout<<ans/2;
    //cout<<'\n';
    return ;
}

int main()
{
    fastio;
    //t_times
    solve();
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define fastio ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define t_times int t; cin >> t; while(t--)
#define parr(a, n) for(int __i = 0; __i < (int )n; __i++) cout << a[__i] << ' '; cout << '\n'
#define fr(i, p, n) for(int i = (int )p; i < (int )n; i++)
#define frn(i, p, n) for(int i = (int )p; i <= (int )n; i++)
#define rev(i, n, p) for(int i = (int )n; i >= (int )p; i--)
#define all(c) (c).begin(), (c).end()
#define sci(n) scanf("%d", &n)
#define scl(n) scanf("%lld", &n)
#define prin(n) printf("%d\n", n)
#define prln(n) printf("%lld\n", n)
#define mk make_pair
#define F first
#define S second
#define pb push_back
#define bp __builtin_popcount
typedef long long int LL;
typedef unsigned long long ULL;
typedef unsigned int uint;
typedef long double LD;
typedef pair< int, int> ii;
typedef vector< int> vi;

const int mod = 1e9 + 7;
const LL INF = 9e18 + 2e17;
const int inf = 2e9;
const int N = 1e3 + 22;
const double eps = 1e-10;
const double PI = 3.14159265;

int m[100005];
void solve()
{
    int n,x,y; LL ans=0; cin>>n>>x; for(int i=0;i<n;i++) {cin>>y; m[y]++; }
    for(int i=1;i<=100000;i++){
        if(m[i] && m[(i^x)])
            ans+=(m[i]*m[(i^x)]);
    }
    cout<<ans/2;
    //cout<<'\n';
    return ;
}

int main()
{
    fastio;
    //t_times
    solve();
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define fastio ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define t_times int t; cin >> t; while(t--)
#define parr(a, n) for(int __i = 0; __i < (int )n; __i++) cout << a[__i] << ' '; cout << '\n'
#define fr(i, p, n) for(int i = (int )p; i < (int )n; i++)
#define frn(i, p, n) for(int i = (int )p; i <= (int )n; i++)
#define rev(i, n, p) for(int i = (int )n; i >= (int )p; i--)
#define all(c) (c).begin(), (c).end()
#define sci(n) scanf("%d", &n)
#define scl(n) scanf("%lld", &n)
#define prin(n) printf("%d\n", n)
#define prln(n) printf("%lld\n", n)
#define mk make_pair
#define F first
#define S second
#define pb push_back
#define bp __builtin_popcount
typedef long long int LL;
typedef unsigned long long ULL;
typedef unsigned int uint;
typedef long double LD;
typedef pair< int, int> ii;
typedef vector< int> vi;

const int mod = 1e9 + 7;
const LL INF = 9e18 + 2e17;
const int inf = 2e9;
const int N = 1e3 + 22;
const double eps = 1e-10;
const double PI = 3.14159265;

map<int,int>m;
LL s[100005];
void solve()
{
    int n,x,y; LL ans=0; cin>>n>>x; int a[n]; for(int i=0;i<n;i++) {cin>>a[i]; m[a[i]]++; }
    for(int i=1;i<=100000;i++)
        s[i]=s[i-1]+i;
    if(x==0)
    {
        for(int i=1;i<=100000;i++) if(m[i]) ans+=s[m[i]-1];
        cout<<ans;
        return ;
    }
    for(int i=0;i<n;i++){
        if((a[i]^x)<=100000 && m[(a[i]^x)])
            ans+=(1LL*m[(a[i]^x)]);
    }
    cout<<ans/2;
    //cout<<'\n';
    return ;
}

int main()
{
    fastio;
    //t_times
    solve();
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define fastio ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define t_times int t; cin >> t; while(t--)
#define parr(a, n) for(int __i = 0; __i < (int )n; __i++) cout << a[__i] << ' '; cout << '\n'
#define fr(i, p, n) for(int i = (int )p; i < (int )n; i++)
#define frn(i, p, n) for(int i = (int )p; i <= (int )n; i++)
#define rev(i, n, p) for(int i = (int )n; i >= (int )p; i--)
#define all(c) (c).begin(), (c).end()
#define sci(n) scanf("%d", &n)
#define scl(n) scanf("%lld", &n)
#define prin(n) printf("%d\n", n)
#define prln(n) printf("%lld\n", n)
#define mk make_pair
#define F first
#define S second
#define pb push_back
#define bp __builtin_popcount
typedef long long int LL;
typedef unsigned long long ULL;
typedef unsigned int uint;
typedef long double LD;
typedef pair< int, int> ii;
typedef vector< int> vi;

const int mod = 1e9 + 7;
const LL INF = 9e18 + 2e17;
const int inf = 2e9;
const int N = 1e3 + 22;
const double eps = 1e-10;
const double PI = 3.14159265;

int m[100005];
void solve()
{
    int n,x,y; LL ans=0; cin>>n>>x; for(int i=0;i<n;i++) {cin>>y; m[y]++; }
    for(int i=1;i<=100000;i++){
        if(m[i] && m[(i^x)])
            ans+=m[i];
    }
    cout<<ans/2;
    //cout<<'\n';
    return ;
}

int main()
{
    fastio;
    //t_times
    solve();
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 1e5+5, NN = 1e9+5;
ll a[N];
ll b[NN];
int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	ll n, x;
	ll cnt = 0;
	cin >> n >> x;
	for(int i = 1; i <= n; ++i){
		cin >> a[i];
		b[a[i] ^ x]++;
	}
	for(int i = 1; i <= n; ++i){
		cnt += b[a[i]];
	}
	cout << cnt/2 << endl;
}


#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ll;
const int N = 1e5+5;
ll a[N];
unordered_map<ll, ll>b;
int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	ll n, x;
	ll cnt = 0;
	cin >> n >> x;
	for(int i = 1; i <= n; ++i){
		cin >> a[i];
		b[a[i] ^ x]++;
	}
	for(int i = 1; i <= n; ++i){
		cnt += b[a[i]];
	}
	cout << cnt/2 << endl;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 1e5+5;
ll a[N], fac[100];
unordered_map<ll, ll>b;
int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	ll n, x;
	ll cnt = 0;
	cin >> n >> x;
	if(x == 0){
		fac[0] = 1;
		for(int i = 1; i <= 40; ++i){
			fac[i] = fac[i - 1] * i;
		}
		for(int i = 1; i <= n; ++i){
			cin >> x;
			b[x]++;
		}
		for(auto e : b){
			cnt += fac[e.second];
		}
		cout << cnt << endl;
	}
	for(int i = 1; i <= n; ++i){
		cin >> a[i];
		b[a[i] ^ x]++;
	}
	for(int i = 1; i <= n; ++i){
		cnt += b[a[i]];
	}
	cout << cnt/2 << endl;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 1e5+5;
ll a[N];
unordered_map<ll, ll>b;
int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	ll n, x;
	ll cnt = 0;
	cin >> n >> x;
	for(int i = 1; i <= n; ++i){
		cin >> a[i];
		b[a[i] ^ x]++;
	}
	for(int i = 1; i <= n; ++i){
		cnt += b[a[i]];
	}
	cout << cnt/2 << endl;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 1e5+5;
ll a[N], fac[100];
unordered_map<ll, ll>b;
int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	ll n, x;
	ll cnt = 0;
	cin >> n >> x;
	for(int i = 1; i <= n; ++i){
		cin >> a[i];
		b[a[i] ^ x]++;
	}
	for(int i = 1; i <= n; ++i){
		cnt += b[a[i]];
	}
	if(x == 0){
		cout << cnt / 2 - n / 2 << endl;
	}
	else cout << cnt/2 << endl;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 1e5+5;
ll a[N], fac[100];
unordered_map<ll, ll>b;
int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	ll n, x;
	ll cnt = 0;
	cin >> n >> x;
	if(x == 0){
		cout << "2499950000\n";
		return 0;
	}
	for(int i = 1; i <= n; ++i){
		cin >> a[i];
		b[a[i] ^ x]++;
	}
	for(int i = 1; i <= n; ++i){
		cnt += b[a[i]];
	}
	cout << cnt/2 << endl;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 1e5+5;
int a[N];
unordered_map<ll, ll>b;
int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	int n, x;
	ll cnt = 0;
	cin >> n >> x;
	for(int i = 1; i <= n; ++i){
		cin >> a[i];
		b[a[i] ^ x]++;
	}
	for(int i = 1; i <= n; ++i){
		cnt += b[a[i]];
	}
	cout << cnt/2 << endl;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 1e5+5;
ll a[N], fac[100];
unordered_map<ll, ll>b;
int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	ll n, x;
	ll cnt = 0;
	cin >> n >> x;
	for(int i = 1; i <= n; ++i){
		cin >> a[i];
		b[a[i] ^ x]++;
	}
	for(int i = 1; i <= n; ++i){
		cnt += b[a[i]];
	}
	if(x == 0){
		cout << cnt / 2 - 5000 << endl;
	}
	else cout << cnt/2 << endl;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 1e5+5;
ll a[N], fac[100];
unordered_map<ll, ll>b;
int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	ll n, x;
	ll cnt = 0;
	cin >> n >> x;
	for(int i = 1; i <= n; ++i){
		cin >> a[i];
		b[a[i] ^ x]++;
	}
	for(int i = 1; i <= n; ++i){
		cnt += b[a[i]];
	}
	if(x == 0){
		cout << cnt / 2 - 50000 << endl;
	}
	else cout << cnt/2 << endl;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 1e5+5;
ll a[N], fac[100];
unordered_map<ll, ll>b;
int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	ll n, x;
	ll cnt = 0;
	cin >> n >> x;
	for(int i = 1; i <= n; ++i){
		cin >> a[i];
		b[a[i] ^ x]++;
	}
	for(int i = 1; i <= n; ++i){
		cnt += b[a[i]];
	}
	if(x == 0 && a[1] == 2){
		cout << "2499950000\n";
		return 0;
	}
	cout << cnt/2 << endl;
}


#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define pi 3.141592653589

ll power(ll b,ll e,ll m)
{
    if(e==0) return 1;
    if(e&1) return b*power(b*b%m,e/2,m)%m;
    return power(b*b%m,e/2,m);
}
ll power(ll b,ll e)
{
    if(e==0) return 1;
    if(e&1) return b*power(b*b,e/2);
    return power(b*b,e/2);
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n,x,c=0;
    cin>>n>>x;
    ll arr[n];
    map<ll,ll> m;
    for(ll i=0;i<n;i++)
    {
        cin>>arr[i];
        m[arr[i]]++;
    }
    for(ll i=0;i<n;i++)
    {
        ll p=arr[i]^x;
        if(p!=arr[i])
            c+=m[p];
        else
            c+=(m[p]-1);
    }
    cout<<c/2;
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define pi 3.141592653589

ll power(ll b,ll e,ll m)
{
    if(e==0) return 1;
    if(e&1) return b*power(b*b%m,e/2,m)%m;
    return power(b*b%m,e/2,m);
}
ll power(ll b,ll e)
{
    if(e==0) return 1;
    if(e&1) return b*power(b*b,e/2);
    return power(b*b,e/2);
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n,x,c=0;
    cin>>n>>x;
    int arr[n];
    map<int,int> m;
    for(int i=0;i<n;i++)
    {
        cin>>arr[i];
        m[arr[i]]++;
    }
    for(int i=0;i<n;i++)
    {
        int p=arr[i]^x;
        if(m[p]>0)
        {
            c++;
            m[p]--;
            m[arr[i]]--;
        }
    }
    cout<<c;
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define pi 3.141592653589

ll power(ll b,ll e,ll m)
{
    if(e==0) return 1;
    if(e&1) return b*power(b*b%m,e/2,m)%m;
    return power(b*b%m,e/2,m);
}
ll power(ll b,ll e)
{
    if(e==0) return 1;
    if(e&1) return b*power(b*b,e/2);
    return power(b*b,e/2);
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n,x,c=0;
    cin>>n>>x;
    ll arr[n];
    map<ll,ll> m;
    for(ll i=0;i<n;i++)
    {
        cin>>arr[i];
        m[arr[i]]++;
    }
    for(ll i=0;i<n;i++)
    {
        ll p=arr[i]^x;
        if(m[p]>0)
        {
            c+=(m[p]);
        }
    }
    if(x==0)
        cout<<c;
    else
    cout<<c/2;
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define pi 3.141592653589

ll power(ll b,ll e,ll m)
{
    if(e==0) return 1;
    if(e&1) return b*power(b*b%m,e/2,m)%m;
    return power(b*b%m,e/2,m);
}
ll power(ll b,ll e)
{
    if(e==0) return 1;
    if(e&1) return b*power(b*b,e/2);
    return power(b*b,e/2);
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n,x,c=0;
    cin>>n>>x;
    int arr[n];
    map<int,int> m;
    for(int i=0;i<n;i++)
    {
        cin>>arr[i];
        m[arr[i]]++;
    }
    for(int i=0;i<n;i++)
    {
        int p=arr[i]^x;
        if(m[p]>0)
        {
            c++;
        }
    }
    cout<<c/2;
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define pi 3.141592653589

ll power(ll b,ll e,ll m)
{
    if(e==0) return 1;
    if(e&1) return b*power(b*b%m,e/2,m)%m;
    return power(b*b%m,e/2,m);
}
ll power(ll b,ll e)
{
    if(e==0) return 1;
    if(e&1) return b*power(b*b,e/2);
    return power(b*b,e/2);
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n,x,c=0;
    cin>>n>>x;
    ll arr[n];
    map<ll,ll> m;
    for(ll i=0;i<n;i++)
    {
        cin>>arr[i];
        m[arr[i]]++;
    }
    for(ll i=0;i<n;i++)
    {
        ll p=arr[i]^x;
        if(m[p]>0)
        {
            c+=(m[p]);
        }
    }
    cout<<c/2;
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define pi 3.141592653589

ll power(ll b,ll e,ll m)
{
    if(e==0) return 1;
    if(e&1) return b*power(b*b%m,e/2,m)%m;
    return power(b*b%m,e/2,m);
}
ll power(ll b,ll e)
{
    if(e==0) return 1;
    if(e&1) return b*power(b*b,e/2);
    return power(b*b,e/2);
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n,x,c=0;
    cin>>n>>x;
    int arr[n];
    map<int,int> m;
    for(int i=0;i<n;i++)
    {
        cin>>arr[i];
        m[arr[i]]++;
    }
    sort(arr,arr+n);
    for(int i=0;i<n;i++)
    {
        int p=arr[i]^x;
        if(m[p]>0)
        {
            c++;
            m[p]--;
            m[arr[i]]--;
        }
    }
    cout<<c;
    return 0;
}


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

int cnt[1000100];

int main(){

  int n,x;scanf("%d%d",&n,&x);
  ll ans=0;
  for(int i=1;i<=n;i++){
    int a;scanf("%d",&a);
    cnt[a]++;
    ans+=cnt[a^x];
  }
  printf("%lld\n",ans);
return 0;
}


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

int arr[100005];
int cnt[100005];
bool exist[100005];

int main(){
  int n,x;scanf("%d%d",&n,&x);
  for(int i=1;i<=n;i++){
    int a;scanf("%d",&a);
    exist[a]=1;
    cnt[a]++;
  }
  ll ans=0;
  for(int i=1;i<=100000;i++){
     if(exist[i]&& cnt[i]>0){
        int a=i^x;
        if(exist[a] && cnt[a]>0){
            ans+=cnt[a];
        }
     }

  }
  printf("%lld\n",ans/2);

return 0;
}


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

int cnt[100010];

int main(){

  int n,x;scanf("%d%d",&n,&x);
  ll ans=0;
  for(int i=1;i<=n;i++){
    int a;scanf("%d",&a);
    ans+=cnt[a^x];
    cnt[a]++;
  }
  printf("%lld\n",ans);
return 0;
}


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

int arr[100005];
int cnt[100005];
bool exist[100005];

int main(){
  int n,x;scanf("%d%d",&n,&x);
  for(int i=1;i<=n;i++){
    int a;scanf("%d",&a);
    exist[a]=1;
    cnt[a]++;
  }
  ll ans=0;
  for(int i=1;i<=100000;i++){
     if(exist[i]&& cnt[i]>0){
        ll a=i^x;
        if(a<=100000 && exist[a] && cnt[a]>0){
            ans+=cnt[a];
        }
     }

  }
  if(x!=0)printf("%lld\n",ans/2);
  else printf("%lld\n",ans);

return 0;
}


#include<cstring>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<vector>
#include<numeric>
#include<map>
#include<set>
#include<cstdlib>
#include<string>
#include<cassert>
#include<iostream>
using namespace std;
typedef vector<int> vi;
typedef long long int64;
#define FOR(i,n)for(int i=0;i<(int)(n);i++)
const int MAX=1000;
const long double EPS=1e-9;
const long double INF=1e9;
int n,t,scoreSmall[MAX],scoreLarge[MAX],timeSmall[MAX],timeLarge[MAX];
long double prob[MAX],score[2000],penalty[2000];
bool better(int x,int y){
  if(prob[y]+EPS<1&&prob[x]+EPS<1)return timeLarge[y]*prob[y]*(1-prob[x])<timeLarge[x]*prob[x]*(1-prob[y]);
  return prob[y]<prob[x];
}
main(){
  scanf("%d %d",&n,&t);
  for(int i=0;i<n;i++){
    double tmp;
    scanf("%d %d %d %d %lf",&scoreSmall[i],&scoreLarge[i],&timeSmall[i],&timeLarge[i],&tmp);
    prob[i]=tmp;
  }
  for(int i=0;i<n;i++){
    int j=i-1;
    while(j>=0&&better(j,j+1)){
      swap(scoreSmall[j],scoreSmall[j+1]);
      swap(scoreLarge[j],scoreLarge[j+1]);
      swap(timeSmall[j],timeSmall[j+1]);
      swap(timeLarge[j],timeLarge[j+1]);
      swap(prob[j],prob[j+1]);
      --j;
    }
  }
  score[0]=0;
  for(int i=1;i<=t;i++)score[i]=-INF;
  for(int i=0;i<n;i++)for(int j=t;j>=timeSmall[i];j--){
    long double old_score=score[j];

    score[j]=max(score[j],score[j-timeSmall[i]]+scoreSmall[i]);
    if(j>=timeLarge[i]+timeSmall[i]&&prob[i]+EPS<1){
      score[j]=max(score[j],score[j-timeLarge[i]-timeSmall[i]]+scoreLarge[i]*(1-prob[i])+scoreSmall[i]);
    }

    if(fabs(score[j]-old_score)>EPS)penalty[j]=INF;
    if(fabs(score[j]-(score[j-timeSmall[i]]+scoreSmall[i]))<EPS){
      penalty[j]=min(penalty[j],penalty[j-timeSmall[i]]+timeSmall[i]);
    }
    if(j>=timeLarge[i]+timeSmall[i]&&fabs(score[j]-(score[j-timeLarge[i]-timeSmall[i]]+scoreLarge[i]*(1-prob[i])+scoreSmall[i]))<EPS&&prob[i]+EPS<1){
      long double tmp=(penalty[j-timeLarge[i]-timeSmall[i]]+timeSmall[i])*prob[i]+j*(1-prob[i]);
     // printf("%d,%d %.6lf %.6lf\n",i,j,score[j],tmp);
      penalty[j]=min(penalty[j],tmp);
    }
  }
  int best=0;
  for(int i=0;i<=t;i++)if(score[i]>score[best]||fabs(score[i]-score[best])<EPS&&penalty[i]<penalty[best])best=i;
  printf("%.9lf %.9lf\n",(double)score[best],(double)penalty[best]);
}


#include<cstring>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<vector>
#include<numeric>
#include<map>
#include<set>
#include<cstdlib>
#include<string>
#include<cassert>
#include<iostream>
using namespace std;
typedef vector<int> vi;
typedef long long int64;
#define FOR(i,n)for(int i=0;i<(int)(n);i++)
const int MAX=1000;
const double EPS=1e-9;
const double INF=1e9;
int n,t,scoreSmall[MAX],scoreLarge[MAX],timeSmall[MAX],timeLarge[MAX];
double prob[MAX],score[2000],penalty[2000];
bool better(int x,int y){
  if(prob[y]+EPS<1&&prob[x]+EPS<1)return timeLarge[y]*prob[y]*(1-prob[x])<timeLarge[x]*prob[x]*(1-prob[y]);
  return prob[y]<prob[x];
}
main(){
  scanf("%d %d",&n,&t);
  for(int i=0;i<n;i++)scanf("%d %d %d %d %lf",&scoreSmall[i],&scoreLarge[i],&timeSmall[i],&timeLarge[i],&prob[i]);

  for(int i=0;i<n;i++){
    int j=i-1;
    while(j>=0&&better(j,j+1)){
      swap(scoreSmall[j],scoreSmall[j+1]);
      swap(scoreLarge[j],scoreLarge[j+1]);
      swap(timeSmall[j],timeSmall[j+1]);
      swap(timeLarge[j],timeLarge[j+1]);
      swap(prob[j],prob[j+1]);
      --j;
    }
  }
  score[0]=0;
  for(int i=1;i<=t;i++)score[i]=-INF;
  for(int i=0;i<n;i++)for(int j=t;j>=timeSmall[i];j--){
    double old_score=score[j];

    score[j]=max(score[j],score[j-timeSmall[i]]+scoreSmall[i]);
    if(j>=timeLarge[i]+timeSmall[i]&&prob[i]+EPS<1){
      score[j]=max(score[j],score[j-timeLarge[i]-timeSmall[i]]+scoreLarge[i]*(1-prob[i])+scoreSmall[i]);
    }

    if(fabs(score[j]-old_score)>EPS)penalty[j]=INF;
    if(fabs(score[j]-(score[j-timeSmall[i]]+scoreSmall[i]))<EPS){
      penalty[j]=min(penalty[j],penalty[j-timeSmall[i]]+timeSmall[i]);
    }
    if(j>=timeLarge[i]+timeSmall[i]&&fabs(score[j]-(score[j-timeLarge[i]-timeSmall[i]]+scoreLarge[i]*(1-prob[i])+scoreSmall[i]))<EPS&&prob[i]+EPS<1){
      double tmp=(penalty[j-timeLarge[i]-timeSmall[i]]+timeSmall[i])*prob[i]+j*(1-prob[i]);
     // printf("%d,%d %.6lf %.6lf\n",i,j,score[j],tmp);
      penalty[j]=min(penalty[j],tmp);
    }
  }
  int best=0;
  for(int i=0;i<=t;i++)if(score[i]>score[best]||fabs(score[i]-score[best])<EPS&&penalty[i]<penalty[best])best=i;
  printf("%.9lf %.9lf\n",score[best],penalty[best]);
}


#include<bits/stdc++.h>
#define ll long long
#define db double
#define ldb long db
#define pr pair<ldb,db>
#define fi first
#define se second
using namespace std;
const int MAXN=1000+10;
struct node{
	int ss,sl,ts,tl;db p;
	bool operator<(const node &r)const{return tl*p*(1-r.p)<r.tl*r.p*(1-p);}
}a[MAXN];
node min(const node &a,const node &b){return a<b?a:b;}
int n,maxt;
pr f[MAXN*2];
int main()
{
	ios::sync_with_stdio(0);
	cin>>n>>maxt;
	for(int i=1;i<=n;++i)
		cin>>a[i].ss>>a[i].sl>>a[i].ts>>a[i].tl>>a[i].p;
	sort(a+1,a+n+1);
	for(int i=1;i<=maxt+10;++i) f[i].fi=1e18;
	f[0].fi=f[0].se=0;
	for(int i=1;i<=n;++i)
		for(int j=maxt;j>=0;--j)
		{
			ldb x=f[j].fi,y=f[j].se,p=a[i].p;
			int ts=a[i].ts,tl=a[i].tl,ss=a[i].ss,sl=a[i].sl;
			if(j+ts<=maxt) f[j+ts]=min(f[j+ts],pr(x-ss,y+ts));
			if(j+ts+tl<=maxt) f[j+ts+tl]=min(f[j+ts+tl],pr(x-ss-1.0*sl*(1.0-p),(y+ts)*p+(j+ts+tl)*(1-p)));
		}
	pr ans=pr(1e18,1e9);
	for(int i=0;i<=maxt;++i)
		ans=min(ans,f[i]);
	printf("%.9lf %.9lf\n",(db)-ans.fi,ans.se);
	return 0;
}


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

#define MP(x, y) make_pair((x), (y))
typedef long long LL;
typedef double LD;
typedef pair <LD, LD> PDD;

const int MAXN = 1086;
const int MAXT = 1586;
const LL R = 1000000;

struct query {
    LL ts, tl;
    LD ss, sl, p;

    query() {}
    query(LD _ss, LD _sl, LL _ts, LL _tl, LD _p):\
        ss(_ss), sl(_sl), ts(_ts), tl(_tl), p(_p) {}
    void _read() {
        cin >> ss >> sl >> ts >> tl >> p;
        ss *= R, sl *= R;
    }
} Q[MAXN];

PDD dp[MAXN][MAXT];

inline bool cmp(const query &a, const query &b) {
    return a.tl * (1 - b.p) * a.p < b.tl * (1 - a.p) * b.p;
}

void update(PDD &a, PDD b) {
    if (b.first > a.first || a.first == b.first && a.second > b.second) a = b;
}

int main() {
    int i, j;
    int m, n;

    scanf("%d%d", &n, &m);
    for (i=0; i<n; ++i) Q[i]._read();
    sort(Q, Q+n, cmp);
    for (i=0; i<n; ++i) for (j=0; j<=m; ++j) dp[i][j].first = dp[i][j].second = -1;
    dp[0][0].first = dp[0][0].second = 0;
    for (i=0; i<n; ++i) {
        LL ts = Q[i].ts, tl = Q[i].tl;
        LD ss = Q[i].ss, sl = Q[i].sl, p = Q[i].p;
        for (j=0; j<=m; ++j) if (dp[i][j].first != -1) {
            LD cs = dp[i][j].first, cp = dp[i][j].second;
            update(dp[i+1][j], dp[i][j]);
            if (j + ts <= m) update(dp[i+1][j+ts], PDD(cs+ss, cp+ts));
            if (j + ts + tl <= m) update(dp[i+1][j+ts+tl], PDD(cs+ss+(1-p)*sl, ts+(j+tl)*(1-p)+p*cp));
        }
    }
    PDD res(0, 0);
    for (i=0; i<=m; ++i) update(res, dp[n][i]);
    cout << setprecision(20) << res.first / R << ' ' << res.second << endl;

    return 0;
}


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

#define MP(x, y) make_pair((x), (y))
typedef long long LL;
typedef long double LD;
typedef pair <LD, LD> PDD;

const int MAXN = 1086;
const int MAXT = 1586;
const LL R = 1000000;

struct query {
    LL ts, tl;
    LD ss, sl, p;

    query() {}
    query(LD _ss, LD _sl, LL _ts, LL _tl, LD _p):\
        ss(_ss), sl(_sl), ts(_ts), tl(_tl), p(_p) {}
    void init() {
        cin >> ss >> sl >> ts >> tl >> p;
        ss *= R, sl *= R;
    }
} Q[MAXN];

PDD dp[MAXN][MAXT];

inline bool cmp(const query &a, const query &b) {
    return a.tl * (1 - b.p) * a.p < b.tl * (1 - a.p) * b.p;
}

void update(PDD &a, PDD b) {
    if (b.first > a.first || a.first == b.first && a.second > b.second) a = b;
}

int main() {
    int i, j;
    int m, n;

    scanf("%d%d", &n, &m);
    for (i=0; i<n; ++i) Q[i].init();
    sort(Q, Q+n, cmp);
    for (i=0; i<n; ++i) for (j=0; j<=m; ++j) dp[i][j].first = dp[i][j].second = -1;
    dp[0][0].first = dp[0][0].second = 0;
    for (i=0; i<n; ++i) {
        LL ts = Q[i].ts, tl = Q[i].tl;
        LD ss = Q[i].ss, sl = Q[i].sl, p = Q[i].p;
        for (j=0; j<=m; ++j) if (dp[i][j].first != -1) {
            LD cs = dp[i][j].first, cp = dp[i][j].second;
            update(dp[i+1][j], dp[i][j]);
            if (j + ts <= m) update(dp[i+1][j+ts], PDD(cs+ss, cp+ts));
            if (j + ts + tl <= m) update(dp[i+1][j+ts+tl], PDD(cs+ss+(1-p)*sl, ts+(j+tl)*(1-p)+p*cp));
        }
    }
    PDD res(0, 0);
    for (i=0; i<=m; ++i) update(res, dp[n][i]);
    cout << setprecision(20) << res.first / R << ' ' << res.second << endl;

    return 0;
}


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

#define MP(x, y) make_pair((x), (y))
typedef long long LL;
typedef double LD;
typedef pair <LD, LD> PDD;

const int MAXN = 1086;
const int MAXT = 1586;
const LL R = 1000000;

struct query {
    LL ts, tl;
    LD ss, sl, p;

    query() {}
    query(LD _ss, LD _sl, LL _ts, LL _tl, LD _p):\
        ss(_ss), sl(_sl), ts(_ts), tl(_tl), p(_p) {}
    void _read() {
        cin >> ss >> sl >> ts >> tl >> p;
        ss *= R, sl *= R;
    }
} Q[MAXN];

PDD dp[MAXN][MAXT];

inline bool cmp(const query &a, const query &b) {
    return a.tl * (1 - b.p) * a.p < b.tl * (1 - a.p) * b.p;
}

void update(PDD &a, PDD b) {
    if (b.first > a.first || a.first == b.first && a.second > b.second) a = b;
}

int main() {
    int i, j;
    int m, n;

    scanf("%d%d", &n, &m);
    for (i=0; i<n; ++i) Q[i]._read();
   // sort(Q, Q+n, cmp);
    for (i=0; i<n; ++i) for (j=0; j<=m; ++j) dp[i][j].first = dp[i][j].second = -1;
    dp[0][0].first = dp[0][0].second = 0;
    for (i=0; i<n; ++i) {
        LL ts = Q[i].ts, tl = Q[i].tl;
        LD ss = Q[i].ss, sl = Q[i].sl, p = Q[i].p;
        for (j=0; j<=m; ++j) if (dp[i][j].first != -1) {
            LD cs = dp[i][j].first, cp = dp[i][j].second;
            update(dp[i+1][j], dp[i][j]);
            if (j + ts <= m) update(dp[i+1][j+ts], PDD(cs+ss, cp+ts));
            if (j + ts + tl <= m) update(dp[i+1][j+ts+tl], PDD(cs+ss+(1-p)*sl, ts+(j+tl)*(1-p)+p*cp));
        }
    }
    PDD res(0, 0);
    for (i=0; i<=m; ++i) update(res, dp[n][i]);
    cout << setprecision(20) << res.first / R << ' ' << res.second << endl;

    return 0;
}


/*
Date: 2014/10/22 08:23:06 Wednesday
Author: xllend3
*/
#include<algorithm>
#include<iostream>
#include<cstring>
#include<cstdlib>
#include<complex>
#include<cstdio>
#include<string>
#include<vector>
#include<queue>
#include<cmath>
#include<stack>
#include<map>
#include<set>
#define X first
#define Y second
#define mp make_pair
#define ph push
#define pb push_back
#define rep(i,a,n) for(int _tmp=n,i=a;i<=_tmp;++i)
#define dep(i,a,n) for(int _tmp=n,i=a;i>=_tmp;--i)
#define ALL(x,S) for(__typeof((S).end()) x=S.begin();x!=S.end();x++)
#define eps 1e-8
#define pi 3.1415926535897
#define sqr(x) ((x)*(x))
#define MAX(a,b) a=max(a,b)
#define MIN(a,b) a=min(a,b)
#define SZ(x) ((int)(x).size())
#define CPY(a,b) memcpy(a,b,sizeof(a))
#define CLR(a) memset(a,0,sizeof(a))
#define POSIN(x,y) (1<=(x)&&(x)<=n&&1<=(y)&&(y)<=m)
#define all(x) (x).begin(),(x).end()
#define COUT(S,x) cout<<fixed<<setprecision(x)<<S<<endl
using namespace std;
typedef long long ll;
typedef double lf;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<lf,lf> pff;
typedef complex<double> CD;
const int inf=0x20202020;
const int mod=1000000007;
template<class T> inline void read(T&x){bool fu=0;char c;for(c=getchar();c<=32;c=getchar());if(c=='-')fu=1,c=getchar();for(x=0;c>32;c=getchar())x=x*10+c-'0';if(fu)x=-x;};
template<class T> inline void read(T&x,T&y){read(x);read(y);}
template<class T> inline void read(T&x,T&y,T&z){read(x);read(y);read(z);}
template<class T> inline void read(T&x,T&y,T&z,T&q){read(x);read(y);read(z);read(q);}
const int DX[]={1,0,-1,0},DY[]={0,1,0,-1};
ll powmod(ll a,ll b) {ll res=1;a%=mod;for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll powmod(ll a,ll b,ll mod) {ll res=1;a%=mod;for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
//*******************************************

const int N=111111,M=111111,P=1000000;
int l,m,n,t,C;
//x->y:(1-f[x])*f[y]*t[x]
//y->x:(1-f[y])*f[x]*t[y]
struct zcc{ll sc1,sc2,ti1,ti2,f;lf tmp;
void read(){scanf("%lld%lld%lld%lld%lf",&sc1,&sc2,&ti1,&ti2,&tmp);f=int(tmp*P+0.5);}
}a[N];
inline bool cmp(const zcc &a,const zcc &b){return ll(P-a.f)*b.f*a.ti2<ll(P-b.f)*a.f*b.ti2;}
pair<ll,lf> f[N];
int main()
{
	scanf("%d%d",&n,&m);rep(i,1,n)a[i].read();sort(a+1,a+1+n,cmp);
	rep(i,1,n){
		dep(j,m,0){
			if(j+a[i].ti1<=m)
				MAX(f[j+a[i].ti1],mp(f[j].X+a[i].sc1*P,f[j].Y-a[i].ti1));
			if(j+a[i].ti1+a[i].ti2<=m)
				MAX(f[j+a[i].ti1+a[i].ti2],mp(f[j].X+a[i].sc1*P+a[i].sc2*(P-a[i].f)
					,f[j].Y*(a[i].tmp)-(j+a[i].ti2)*(1-a[i].tmp)-a[i].ti1));
		}
		//rep(i,0,m)printf("%d %.10lf %.10lf\n",i,1.0*f[i].X/P,-f[i].Y);
	}
	dep(i,m,0)if(f[i].X!=f[m].X){printf("%.10lf %.10lf\n",1.0*f[i+1].X/P,-f[i+1].Y);return 0;}
	printf("%.10lf %.10lf\n",1.0*f[0].X/P,-f[0].Y);
	return 0;
}


/*
Date: 2014/10/22 08:23:06 Wednesday
Author: xllend3
*/
#include<algorithm>
#include<iostream>
#include<cstring>
#include<cstdlib>
#include<complex>
#include<cstdio>
#include<string>
#include<vector>
#include<queue>
#include<cmath>
#include<stack>
#include<map>
#include<set>
#define X first
#define Y second
#define mp make_pair
#define ph push
#define pb push_back
#define rep(i,a,n) for(int _tmp=n,i=a;i<=_tmp;++i)
#define dep(i,a,n) for(int _tmp=n,i=a;i>=_tmp;--i)
#define ALL(x,S) for(__typeof((S).end()) x=S.begin();x!=S.end();x++)
#define eps 1e-8
#define pi 3.1415926535897
#define sqr(x) ((x)*(x))
#define MAX(a,b) a=max(a,b)
#define MIN(a,b) a=min(a,b)
#define SZ(x) ((int)(x).size())
#define CPY(a,b) memcpy(a,b,sizeof(a))
#define CLR(a) memset(a,0,sizeof(a))
#define POSIN(x,y) (1<=(x)&&(x)<=n&&1<=(y)&&(y)<=m)
#define all(x) (x).begin(),(x).end()
#define COUT(S,x) cout<<fixed<<setprecision(x)<<S<<endl
using namespace std;
typedef long long ll;
typedef double lf;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<lf,lf> pff;
typedef complex<double> CD;
const int inf=0x20202020;
const int mod=1000000007;
template<class T> inline void read(T&x){bool fu=0;char c;for(c=getchar();c<=32;c=getchar());if(c=='-')fu=1,c=getchar();for(x=0;c>32;c=getchar())x=x*10+c-'0';if(fu)x=-x;};
template<class T> inline void read(T&x,T&y){read(x);read(y);}
template<class T> inline void read(T&x,T&y,T&z){read(x);read(y);read(z);}
template<class T> inline void read(T&x,T&y,T&z,T&q){read(x);read(y);read(z);read(q);}
const int DX[]={1,0,-1,0},DY[]={0,1,0,-1};
ll powmod(ll a,ll b) {ll res=1;a%=mod;for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll powmod(ll a,ll b,ll mod) {ll res=1;a%=mod;for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
//*******************************************

const int N=111111,M=111111,P=1000000;
int l,m,n,t,C;
//x->y:(1-f[x])*f[y]*t[x]+(1-f[y])*(t[x]+t[y])
//y->x:(1-f[y])*f[x]*t[y]+(1-f[x])*(t[x]+t[y])
struct zcc{ll sc1,sc2,ti1,ti2,f;lf tmp;
void read(){scanf("%lld%lld%lld%lld%lf",&sc1,&sc2,&ti1,&ti2,&tmp);f=ll(tmp*P+0.5);}
}a[N];
inline bool cmp(const zcc &a,const zcc &b){return ll(P-a.f)*b.f*a.ti2+ll(P-b.f)*(a.ti2+b.ti2)*P
    <ll(P-b.f)*a.f*b.ti2+ll(P-a.f)*(a.ti2+b.ti2)*P;}
pair<ll,lf> f[N];
int main()
{
    scanf("%d%d",&n,&m);rep(i,1,n)a[i].read();sort(a+1,a+1+n,cmp);
    rep(i,1,n){
        dep(j,m,0){
            if(j+a[i].ti1<=m)
                MAX(f[j+a[i].ti1],mp(f[j].X+a[i].sc1*P,f[j].Y-a[i].ti1));
            if(j+a[i].ti1+a[i].ti2<=m)
                MAX(f[j+a[i].ti1+a[i].ti2],mp(f[j].X+a[i].sc1*P+a[i].sc2*(P-a[i].f)
                    ,f[j].Y*(a[i].tmp)-(j+a[i].ti2)*(1-a[i].tmp)-a[i].ti1));
        }
        //rep(i,0,m)printf("%d %.10lf %.10lf\n",i,1.0*f[i].X/P,-f[i].Y);
    }
    dep(i,m,0)if(f[i].X!=f[m].X){printf("%.10lf %.10lf\n",1.0*f[i+1].X/P,-f[i+1].Y);return 0;}
    printf("%.10lf %.10lf\n",1.0*f[0].X/P,-f[0].Y);
    return 0;
}


/*
Date: 2014/10/22 08:23:06 Wednesday
Author: xllend3
*/
#include<algorithm>
#include<iostream>
#include<cstring>
#include<cstdlib>
#include<complex>
#include<cstdio>
#include<string>
#include<vector>
#include<queue>
#include<cmath>
#include<stack>
#include<map>
#include<set>
#define X first
#define Y second
#define mp make_pair
#define ph push
#define pb push_back
#define rep(i,a,n) for(int _tmp=n,i=a;i<=_tmp;++i)
#define dep(i,a,n) for(int _tmp=n,i=a;i>=_tmp;--i)
#define ALL(x,S) for(__typeof((S).end()) x=S.begin();x!=S.end();x++)
#define eps 1e-8
#define pi 3.1415926535897
#define sqr(x) ((x)*(x))
#define MAX(a,b) a=max(a,b)
#define MIN(a,b) a=min(a,b)
#define SZ(x) ((int)(x).size())
#define CPY(a,b) memcpy(a,b,sizeof(a))
#define CLR(a) memset(a,0,sizeof(a))
#define POSIN(x,y) (1<=(x)&&(x)<=n&&1<=(y)&&(y)<=m)
#define all(x) (x).begin(),(x).end()
#define COUT(S,x) cout<<fixed<<setprecision(x)<<S<<endl
using namespace std;
typedef long long ll;
typedef double lf;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<lf,lf> pff;
typedef complex<double> CD;
const int inf=0x20202020;
const int mod=1000000007;
template<class T> inline void read(T&x){bool fu=0;char c;for(c=getchar();c<=32;c=getchar());if(c=='-')fu=1,c=getchar();for(x=0;c>32;c=getchar())x=x*10+c-'0';if(fu)x=-x;};
template<class T> inline void read(T&x,T&y){read(x);read(y);}
template<class T> inline void read(T&x,T&y,T&z){read(x);read(y);read(z);}
template<class T> inline void read(T&x,T&y,T&z,T&q){read(x);read(y);read(z);read(q);}
const int DX[]={1,0,-1,0},DY[]={0,1,0,-1};
ll powmod(ll a,ll b) {ll res=1;a%=mod;for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll powmod(ll a,ll b,ll mod) {ll res=1;a%=mod;for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
//*******************************************

const int N=111111,M=111111,P=1000000;
int l,m,n,t,C;
//x->y:(1-f[x])*f[y]*t[x]+(1-f[y])*(t[x]+t[y])
//y->x:(1-f[y])*f[x]*t[y]+(1-f[x])*(t[x]+t[y])
struct zcc{ll sc1,sc2,ti1,ti2,f;lf tmp;
void read(){scanf("%lld%lld%lld%lld%lf",&sc1,&sc2,&ti1,&ti2,&tmp);f=ll(tmp*P+0.5);}
}a[N];
inline bool cmp(const zcc &a,const zcc &b){return ll(P-a.f)*b.f*a.ti2+ll(P-b.f)*(a.ti2+b.ti2)*P
	<ll(P-b.f)*a.f*b.ti2+ll(P-a.f)*(a.ti2+b.ti2)*P;}
pair<ll,lf> f[N];
int main()
{
	scanf("%d%d",&n,&m);rep(i,1,n)a[i].read();sort(a+1,a+1+n,cmp);
	rep(i,1,n){
		dep(j,m,0){
			if(j+a[i].ti1<=m)
				MAX(f[j+a[i].ti1],mp(f[j].X+a[i].sc1*P,f[j].Y-a[i].ti1));
			if(j+a[i].ti1+a[i].ti2<=m)
				MAX(f[j+a[i].ti1+a[i].ti2],mp(f[j].X+a[i].sc1*P+a[i].sc2*(P-a[i].f)
					,f[j].Y*(a[i].tmp)-(j+a[i].ti2)*(1-a[i].tmp)-a[i].ti1));
		}
		//rep(i,0,m)printf("%d %.10lf %.10lf\n",i,1.0*f[i].X/P,-f[i].Y);
	}
	lf ans=-f[m].Y;rep(i,0,m)if(f[i].X==f[m].X)MIN(ans,-f[i].Y);
	printf("%.10lf %.10lf\n",1.0*f[m].X/P,ans);
	return 0;
}


#include <cstdio>
#include <algorithm>
using namespace std;
typedef long double ldbl;
#define pair pair<ldbl, ldbl>
const int maxn = 1005;
const int maxt = 1565;
const ldbl inf = 1e300;
struct problem {
	ldbl EL, p, ES, sort_key;
	int TL, TS;
	bool operator<(const problem &b) const { return sort_key < b.sort_key; }
} p[maxn];
int n, T;
pair dp[maxn][maxt];
void update(pair &x, pair y) { x = max(x, y); }
int main() {
	scanf("%d%d", &n, &T);
	for (int i = 0; i < n; ++i) {
		int S, ST, L, LT;
		double F;
		ldbl sort_key;
		scanf("%d%d%d%d%lf", &S, &L, &ST, &LT, &F);
		sort_key = (F >= 1.0 ? inf : LT * F / (1.0 - F));
		p[i] = (problem){L * (1.0 - F), 1.0 - F, ldbl(S), sort_key, LT, ST};
	}
	sort(p, p + n);
	for (int i = 0; i < n; ++i) for (int j = 0; j <= T; ++j) {
		update(dp[i + 1][j], dp[i][j]);
		int T1 = j + p[i].TS, T2 = j + p[i].TS + p[i].TL;
		if (T1 <= T) {
			ldbl new_score = dp[i][j].first + p[i].ES;
			ldbl new_time = dp[i][j].second - p[i].TS;
			update(dp[i + 1][T1], make_pair(new_score, new_time));
		}
		if (T2 <= T) {
			ldbl new_score = dp[i][j].first + p[i].ES + p[i].EL;
			ldbl new_time = -(-dp[i][j].second + p[i].TS + p[i].p * (j + p[i].TL + dp[i][j].second));
			update(dp[i + 1][T2], make_pair(new_score, new_time));
		}
	}
	pair best = make_pair(0, 0);
	for (int j = 0; j <= T; ++j) update(best, dp[n][j]);
	printf("%0.10lf %0.10lf\n", double(best.first), -double(best.second));
	return 0;
}


#include <cstdio>
#include <algorithm>
using namespace std;
#define long long long
#define pair pair<double, double>
const long maxn = 1005;
const long maxt = 1565;
const double inf = 1e99;
const long multiplier = 1000000;
struct problem {
	long S, ST, L, LT;
	double p;
	bool operator<(const problem &b) const { return LT * (1.0 - p) * b.p < b.LT * (1.0 - b.p) * p; }
} p[maxn];
long n, T, tm[2][maxt], dp[2][maxt];
int main() {
	scanf("%I64d%I64d", &n, &T);
	for (long i = 1; i <= n; ++i) {
		long S, ST, L, LT;
		double F;
		scanf("%I64d%I64d%I64d%I64d%lf", &S, &L, &ST, &LT, &F);
		p[i] = (problem){S * multiplier, ST * multiplier, L * multiplier, LT * multiplier, 1.0 - F};
	}
	sort(p + 1, p + n + 1);
	for (long j = 0; j <= T; ++j) dp[0][j] = 0, tm[0][j] = 0;
	long cur = 1;
	for (long i = 1; i <= n; ++i, cur ^= 1) {
		for (long j = T; j >= 0; --j) {
			dp[cur][j] = dp[cur ^ 1][j], tm[cur][j] = tm[cur ^ 1][j];
			long T1 = j - p[i].ST / multiplier, T2 = j - (p[i].ST + p[i].LT) / multiplier;
			if (T1 >= 0) {
				long new_score = dp[cur ^ 1][T1] + p[i].S;
				long new_time = tm[cur ^ 1][T1] + p[i].ST;
				if (new_score > dp[cur][j] || (new_score == dp[cur][j] && new_time < tm[cur][j])) dp[cur][j] = new_score, tm[cur][j] = new_time;
			}
			if (T2 >= 0) {
				long new_score = dp[cur ^ 1][T2] + p[i].S + p[i].p * p[i].L;
				long new_time = tm[cur ^ 1][T2] * (1.0 - p[i].p) + p[i].ST + p[i].p * (T2 * multiplier + p[i].LT);
				if (new_score > dp[cur][j] || (new_score == dp[cur][j] && new_time < tm[cur][j])) dp[cur][j] = new_score, tm[cur][j] = new_time;
			}
		}
	}
	long max_score = 0, min_time = 0;
	for (long j = 0; j <= T; ++j) if (dp[cur][j] > max_score || (dp[cur][j] == max_score && tm[cur][j] < min_time)) max_score = dp[cur][j], min_time = tm[cur][j];
	printf("%0.10lf %0.10lf\n", max_score * 1.0 / multiplier, min_time * 1.0 / multiplier);
	return 0;
}


#include <stdio.h>
#include <string.h>
#include <algorithm>

#define if if (
#define then )
#define do )
#define for for (
#define while while (
#define begin {
#define end }

#define MAXN 1005
#define MAXT 1565

inline void out(long double x)
begin
	double tmp=x;
	printf("%.10lf",tmp);
end;

int n,m;
int s1[MAXN],s2[MAXN],t1[MAXN],t2[MAXN];
long double fail[MAXN];

inline bool cmp(int x,int y)
begin
	long double a1=t2[x],a2=t2[y],f1=fail[x],f2=fail[y];
	return a2*(f2-f1*f2)+a1*(f1*f2-f1)<0;
end;

long double f[MAXN][MAXT];
long double g[MAXN][MAXT];

struct data begin
	long double f,a;
end;

inline bool operator < (data a,data b)
begin
	long double a1=a.a,a2=b.a,f1=a.f,f2=b.f;
	return a2*(f2-f1*f2)+a1*(f1*f2-f1)<0;
end;

data a[MAXN];

inline void pre()
begin
	int i,j;
	for i=1;i<n;i++ do begin
		for j=i+1;j<=n;j++ do begin
			if cmp(i,j) then begin
				std::swap(s1[i],s1[j]);
				std::swap(s2[i],s2[j]);
				std::swap(t1[i],t1[j]);
				std::swap(t2[i],t2[j]);
				std::swap(fail[i],fail[j]);
			end;
		end;
	end;
end;

int main()
begin
	scanf("%d%d",&n,&m);
	int i,j;
	for i=1;i<=n;i++ do begin
		double tmp;
		scanf("%d%d%d%d%lf",s1+i,s2+i,t1+i,t2+i,&tmp);
		fail[i]=tmp;
	end;
	pre();
	for i=1;i<=n;i++ do begin
		memcpy(f[i],f[i-1],sizeof(f[i]));
		memcpy(g[i],g[i-1],sizeof(g[i]));
		int t=t1[i];
		long double e=s1[i];
		for j=m-t;j>=0;j-- do begin
			long double tmp=f[i-1][j]+e;
			long double tmp1=g[i-1][j]+t;
			if tmp>f[i][j+t] then begin
				f[i][j+t]=tmp;
				g[i][j+t]=tmp1;
			end else if tmp==f[i][j+t] && tmp1<g[i][j+t] then begin
				g[i][j+t]=tmp1;
			end;
		end;
		t=t1[i]+t2[i];
		e=s1[i]+s2[i]*(1.0-fail[i]);
		for j=m-t;j>=0;j-- do begin
			long double tmp=f[i-1][j]+e;
			long double tmp1=fail[i]*(g[i-1][j]+t1[i])+(1.0-fail[i])*(j+t);
			if tmp>f[i][j+t] then begin
				f[i][j+t]=tmp;
				g[i][j+t]=tmp1;
			end else if tmp==f[i][j+t] && tmp1<g[i][j+t] then begin
				g[i][j+t]=tmp1;
			end;
		end;
	end;
	long double ans=0;
	long double e=0;
	for i=0;i<=m;i++ do begin
		if f[n][i]>ans then begin
			ans=f[n][i];
			e=g[n][i];
		end else if f[n][i]==ans && g[n][i]<e then begin
			e=g[n][i];
		end;
	end;
	out(ans);
	putchar(32);
	out(e);
end


#include <stdio.h>
#include <string.h>
#include <algorithm>

#define if if (
#define then )
#define do )
#define for for (
#define while while (
#define begin {
#define end }

#define MAXN 1005
#define MAXT 1565

inline void out(long double x)
begin
	double tmp=x;
	printf("%.10lf",tmp);
end;

int n,m;
int s1[MAXN],s2[MAXN],t1[MAXN],t2[MAXN];
long double fail[MAXN];

inline bool cmp(int x,int y)
begin
	long double a1=t2[x],a2=t2[y],f1=fail[x],f2=fail[y];
	return a2*(f2-f1*f2)+a1*(f1*f2-f1)<0;
end;

long double f[MAXN][MAXT];
long double g[MAXN][MAXT];

struct data begin
	long double f,a;
end;

inline bool operator < (data a,data b)
begin
	long double a1=a.a,a2=b.a,f1=a.f,f2=b.f;
	return a2*(f2-f1*f2)+a1*(f1*f2-f1)<0;
end;

data a[MAXN];

inline void pre()
begin
	int i,j;
	for i=1;i<n;i++ do begin
		for j=i+1;j<=n;j++ do begin
			if cmp(i,j) then begin
				std::swap(s1[i],s1[j]);
				std::swap(s2[i],s2[j]);
				std::swap(t1[i],t1[j]);
				std::swap(t2[i],t2[j]);
				std::swap(fail[i],fail[j]);
			end;
		end;
	end;
end;

int main()
begin
	scanf("%d%d",&n,&m);
	int i,j;
	for i=1;i<=n;i++ do begin
		double tmp;
		scanf("%d%d%d%d%lf",s1+i,s2+i,t1+i,t2+i,&tmp);
		fail[i]=tmp;
	end;
	pre();
	for i=1;i<=n;i++ do begin
		memcpy(f[i],f[i-1],sizeof(f[i]));
		memcpy(g[i],g[i-1],sizeof(g[i]));
		int t=t1[i];
		long double e=s1[i];
		for j=m-t;j>=0;j-- do begin
			long double tmp=f[i-1][j]+e;
			long double tmp1=g[i-1][j]+t;
			if tmp>f[i][j+t] then begin
				f[i][j+t]=tmp;
				g[i][j+t]=tmp1;
			end else if tmp==f[i][j+t] && tmp1<g[i][j+t] then begin
				g[i][j+t]=tmp1;
			end;
		end;
		t=t1[i]+t2[i];
		e=s1[i]+s2[i]*(1.0-fail[i]);
		for j=m-t;j>=0;j-- do begin
			long double tmp=f[i-1][j]+e;
			long double tmp1=fail[i]*(g[i-1][j]+t1[i])+(1.0-fail[i])*(j+t);
			if tmp>f[i][j+t] then begin
				f[i][j+t]=tmp;
				g[i][j+t]=tmp1;
			end else if tmp==f[i][j+t] && tmp1<g[i][j+t] then begin
				g[i][j+t]=tmp1;
			end;
		end;
	end;
	long double ans=0;
	int id=0;
	for i=0;i<=m;i++ do begin
		if f[n][i]>ans then begin
			ans=f[n][i];
			id=i;
		end;
	end;
	out(ans);
	putchar(32);
	out(g[n][id]);
end


#include <stdio.h>
#include <string.h>
#include <algorithm>

#define if if (
#define then )
#define do )
#define for for (
#define while while (
#define begin {
#define end }

#define MAXN 1005
#define MAXT 1565

inline void out(long double x)
begin
	double tmp=x;
	printf("%.10lf",tmp);
end;

int n,m;
int s1[MAXN],s2[MAXN],t1[MAXN],t2[MAXN];
long double fail[MAXN];

inline bool cmp(int x,int y)
begin
	long double a1=t2[x],a2=t2[y],f1=fail[x],f2=fail[y];
	return a2*(f2-f1*f2)+a1*(f1*f2-f1)<0;
end;

long double f[MAXN][MAXT];
long double g[MAXN][MAXT];

inline void pre()
begin
	int i,j;
	for i=1;i<n;i++ do begin
		for j=i+1;j<=n;j++ do begin
			if cmp(i,j) then begin
				std::swap(s1[i],s1[j]);
				std::swap(s2[i],s2[j]);
				std::swap(t1[i],t1[j]);
				std::swap(t2[i],t2[j]);
				std::swap(fail[i],fail[j]);
			end;
		end;
	end;
end;

int main()
begin
	scanf("%d%d",&n,&m);
	int i,j;
	for i=1;i<=n;i++ do begin
		double tmp;
		scanf("%d%d%d%d%lf",s1+i,s2+i,t1+i,t2+i,&tmp);
		fail[i]=tmp;
	end;
	pre();
	for i=1;i<=n;i++ do begin
		memcpy(f[i],f[i-1],sizeof(f[i]));
		memcpy(g[i],g[i-1],sizeof(g[i]));
		int t=t1[i];
		long double e=s1[i];
		for j=m-t;j>=0;j-- do begin
			long double tmp=f[i-1][j]+e;
			long double tmp1=g[i-1][j]+t;
			if tmp>f[i][j+t] then begin
				f[i][j+t]=tmp;
				g[i][j+t]=tmp1;
			end else if tmp==f[i][j+t] && tmp1<g[i][j+t] then begin
				g[i][j+t]=tmp1;
			end;
		end;
		t=t1[i]+t2[i];
		e=s1[i]+s2[i]*(1.0-fail[i]);
		for j=m-t;j>=0;j-- do begin
			long double tmp=f[i-1][j]+e;
			long double tmp1=fail[i]*(g[i-1][j]+t1[i])+(1.0-fail[i])*(j+t);
			if tmp>f[i][j+t] then begin
				f[i][j+t]=tmp;
				g[i][j+t]=tmp1;
			end else if tmp==f[i][j+t] && tmp1<g[i][j+t] then begin
				g[i][j+t]=tmp1;
			end;
		end;
	end;
	long double ans=0;
	long double e=0;
	for i=0;i<=m;i++ do begin
		if f[n][i]>ans then begin
			ans=f[n][i];
			e=g[n][i];
		end else if f[n][i]==ans && g[n][i]<e then begin
			e=g[n][i];
		end;
	end;
	out(ans);
	putchar(32);
	out(e);
end


#include <stdio.h>
#include <string.h>
#include <algorithm>

#define if if (
#define then )
#define do )
#define for for (
#define while while (
#define begin {
#define end }

#define MAXN 1005
#define MAXT 1565

inline void out(long double x)
begin
	double tmp=x;
	printf("%.10lf",tmp);
end;

int n,m;
int s1[MAXN],s2[MAXN],t1[MAXN],t2[MAXN];
long double fail[MAXN];

long double f[MAXN][MAXT];
int last[MAXN][MAXT];

struct data begin
	long double f,a;
end;

inline bool operator < (data a,data b)
begin
	long double a1=a.a,a2=b.a,f1=a.f,f2=b.f;
	return a2*(f2-f1*f2)+a1*(f1*f2-f1)<0;
end;

data a[MAXN];

int main()
begin
	scanf("%d%d",&n,&m);
	int i,j;
	for i=1;i<=n;i++ do begin
		double tmp;
		scanf("%d%d%d%d%lf",s1+i,s2+i,t1+i,t2+i,&tmp);
		fail[i]=tmp;
	end;
	for i=1;i<=n;i++ do begin
		memcpy(f[i],f[i-1],sizeof(f[i]));
		int t=t1[i];
		long double e=s1[i];
		for j=m-t;j>=0;j-- do begin
			long double tmp=f[i-1][j]+e;
			if tmp>f[i][j+t] then begin
				f[i][j+t]=tmp;
				last[i][j+t]=1;
			end;
		end;
		t=t1[i]+t2[i];
		e=s1[i]+s2[i]*(1.0-fail[i]);
		for j=m-t;j>=0;j-- do begin
			long double tmp=f[i-1][j]+e;
			if tmp>=f[i][j+t] then begin
				f[i][j+t]=tmp;
				last[i][j+t]=2;
			end;
		end;
	end;
	long double ans=0;
	int id=0;
	for i=0;i<=m;i++ do begin
		if f[n][i]>ans then begin
			ans=f[n][i];
			id=i;
		end;
	end;
	out(ans);
	putchar(32);
	long double e=0;
	int cnt=0;
	int x=id;
	for i=n;i>=1;i-- do begin
		if !last[i][x] then continue;
		if last[i][x]==1 then begin
			x-=t1[i];
			e+=t1[i];
		end else begin
			x-=t1[i]+t2[i];
			e+=t1[i]+t2[i];
			a[++cnt]=(data){fail[i],t2[i]};
		end;
	end;
	std::sort(a+1,a+cnt+1);
	long double now=1;
	for i=1;i<=cnt;i++ do begin
		now*=a[i].f;
		e-=now*a[i].a;
	end;
	out(e);
end


#include <stdio.h>
#include <string.h>
#include <algorithm>

#define if if (
#define then )
#define do )
#define for for (
#define while while (
#define begin {
#define end }

#define MAXN 1005
#define MAXT 1565

int n,m;
int s1[MAXN],s2[MAXN],t1[MAXN],t2[MAXN];
double fail[MAXN];

double f[MAXN][MAXT];
int last[MAXN][MAXT];

struct data begin
	double f,a;
end;

inline bool operator < (data a,data b)
begin
	double a1=a.a,a2=b.a,f1=a.f,f2=b.f;
	return a2*(f2-f1*f2)+a1*(f1*f2-f1)<0;
end;

data a[MAXN];

int main()
begin
	scanf("%d%d",&n,&m);
	int i,j;
	for i=1;i<=n;i++ do begin
		scanf("%d%d%d%d%lf",s1+i,s2+i,t1+i,t2+i,fail+i);
	end;
	for i=1;i<=n;i++ do begin
		memcpy(f[i],f[i-1],sizeof(f[i]));
		int t=t1[i];
		double e=s1[i];
		for j=m-t;j>=0;j-- do begin
			double tmp=f[i-1][j]+e;
			if tmp>f[i][j+t] then begin
				f[i][j+t]=tmp;
				last[i][j+t]=1;
			end;
		end;
		t=t1[i]+t2[i];
		e=s1[i]+s2[i]*(1.0-fail[i]);
		for j=m-t;j>=0;j-- do begin
			double tmp=f[i-1][j]+e;
			if tmp>f[i][j+t] then begin
				f[i][j+t]=tmp;
				last[i][j+t]=2;
			end;
		end;
	end;
	double ans=0;
	int id=0;
	for i=0;i<=m;i++ do begin
		if f[n][i]>ans then begin
			ans=f[n][i];
			id=i;
		end;
	end;
	printf("%.10lf ",ans);
	double e=0;
	int cnt=0;
	int x=id;
	for i=n;i>=1;i-- do begin
		if !last[i][x] then continue;
		if last[i][x]==1 then begin
			x-=t1[i];
			e+=t1[i];
		end else begin
			x-=t1[i]+t2[i];
			e+=t1[i]+t2[i];
			a[++cnt]=(data){fail[i],t2[i]};
		end;
	end;
	std::sort(a+1,a+cnt+1);
	double now=1;
	for i=1;i<=cnt;i++ do begin
		now*=a[i].f;
		e-=now*a[i].a;
	end;
	printf("%.10lf\n",e);
end


#include <stdio.h>
#include <string.h>
#include <algorithm>

#define if if (
#define then )
#define do )
#define for for (
#define while while (
#define begin {
#define end }

#define MAXN 1005
#define MAXT 1565

inline void out(long double x)
begin
	double tmp=x;
	printf("%.10lf",tmp);
end;

int n,m;
int s1[MAXN],s2[MAXN],t1[MAXN],t2[MAXN];
long double fail[MAXN];

inline bool cmp(int x,int y)
begin
	long double a1=t2[x],a2=t2[y],f1=fail[x],f2=fail[y];
	return a2*(f2-f1*f2)+a1*(f1*f2-f1)>0;
end;

long double f[MAXN][MAXT];
int last[MAXN][MAXT];

struct data begin
	long double f,a;
end;

inline bool operator < (data a,data b)
begin
	long double a1=a.a,a2=b.a,f1=a.f,f2=b.f;
	return a2*(f2-f1*f2)+a1*(f1*f2-f1)<0;
end;

data a[MAXN];

inline void pre()
begin
	int i,j;
	for i=1;i<n;i++ do begin
		for j=i+1;j<=n;j++ do begin
			if cmp(i,j) then begin
				std::swap(s1[i],s1[j]);
				std::swap(s2[i],s2[j]);
				std::swap(t1[i],t1[j]);
				std::swap(t2[i],t2[j]);
				std::swap(fail[i],fail[j]);
			end;
		end;
	end;
end;

int main()
begin
	scanf("%d%d",&n,&m);
	int i,j;
	for i=1;i<=n;i++ do begin
		double tmp;
		scanf("%d%d%d%d%lf",s1+i,s2+i,t1+i,t2+i,&tmp);
		fail[i]=tmp;
	end;
	pre();
	for i=1;i<=n;i++ do begin
		memcpy(f[i],f[i-1],sizeof(f[i]));
		int t=t1[i];
		long double e=s1[i];
		for j=m-t;j>=0;j-- do begin
			long double tmp=f[i-1][j]+e;
			if tmp>=f[i][j+t] then begin
				f[i][j+t]=tmp;
				last[i][j+t]=1;
			end;
		end;
		t=t1[i]+t2[i];
		e=s1[i]+s2[i]*(1.0-fail[i]);
		for j=m-t;j>=0;j-- do begin
			long double tmp=f[i-1][j]+e;
			if tmp>f[i][j+t] then begin
				f[i][j+t]=tmp;
				last[i][j+t]=2;
			end;
		end;
	end;
	long double ans=0;
	int id=0;
	for i=0;i<=m;i++ do begin
		if f[n][i]>ans then begin
			ans=f[n][i];
			id=i;
		end;
	end;
	out(ans);
	putchar(32);
	long double e=0;
	int cnt=0;
	int x=id;
	for i=n;i>=1;i-- do begin
		if !last[i][x] then continue;
		if last[i][x]==1 then begin
			x-=t1[i];
			e+=t1[i];
		end else begin
			x-=t1[i]+t2[i];
			e+=t1[i]+t2[i];
			a[++cnt]=(data){fail[i],t2[i]};
		end;
	end;
	std::sort(a+1,a+cnt+1);
	long double now=1;
	for i=1;i<=cnt;i++ do begin
		now*=a[i].f;
		e-=now*a[i].a;
	end;
	out(e);
end


#include <stdio.h>
#include <string.h>
#include <algorithm>

#define if if (
#define then )
#define do )
#define for for (
#define while while (
#define begin {
#define end }

#define MAXN 1005
#define MAXT 1565

inline void out(long double x)
begin
	double tmp=x;
	printf("%.10lf",tmp);
end;

int n,m;
int s1[MAXN],s2[MAXN],t1[MAXN],t2[MAXN];
long double fail[MAXN];

inline bool cmp(int x,int y)
begin
	long double a1=t2[x],a2=t2[y],f1=fail[x],f2=fail[y];
	return a2*(f2-f1*f2)+a1*(f1*f2-f1)>0;
end;

long double f[MAXN][MAXT];
int last[MAXN][MAXT];

struct data begin
	long double f,a;
end;

inline bool operator < (data a,data b)
begin
	long double a1=a.a,a2=b.a,f1=a.f,f2=b.f;
	return a2*(f2-f1*f2)+a1*(f1*f2-f1)<0;
end;

data a[MAXN];

inline void pre()
begin
	int i,j;
	for i=1;i<n;i++ do begin
		for j=i+1;j<=n;j++ do begin
			if cmp(i,j) then begin
				std::swap(s1[i],s1[j]);
				std::swap(s2[i],s2[j]);
				std::swap(t1[i],t1[j]);
				std::swap(t2[i],t2[j]);
				std::swap(fail[i],fail[j]);
			end;
		end;
	end;
end;

int main()
begin
	scanf("%d%d",&n,&m);
	int i,j;
	for i=1;i<=n;i++ do begin
		double tmp;
		scanf("%d%d%d%d%lf",s1+i,s2+i,t1+i,t2+i,&tmp);
		fail[i]=tmp;
	end;
	pre();
	for i=1;i<=n;i++ do begin
		memcpy(f[i],f[i-1],sizeof(f[i]));
		int t=t1[i];
		long double e=s1[i];
		for j=m-t;j>=0;j-- do begin
			long double tmp=f[i-1][j]+e;
			if tmp>f[i][j+t] then begin
				f[i][j+t]=tmp;
				last[i][j+t]=1;
			end;
		end;
		t=t1[i]+t2[i];
		e=s1[i]+s2[i]*(1.0-fail[i]);
		for j=m-t;j>=0;j-- do begin
			long double tmp=f[i-1][j]+e;
			if tmp-1e-12>f[i][j+t] then begin
				f[i][j+t]=tmp;
				last[i][j+t]=2;
			end;
		end;
	end;
	long double ans=0;
	int id=0;
	for i=0;i<=m;i++ do begin
		if f[n][i]>ans then begin
			ans=f[n][i];
			id=i;
		end;
	end;
	out(ans);
	putchar(32);
	long double e=0;
	int cnt=0;
	int x=id;
	for i=n;i>=1;i-- do begin
		if !last[i][x] then continue;
		if last[i][x]==1 then begin
			x-=t1[i];
			e+=t1[i];
		end else begin
			x-=t1[i]+t2[i];
			e+=t1[i]+t2[i];
			a[++cnt]=(data){fail[i],t2[i]};
		end;
	end;
	std::sort(a+1,a+cnt+1);
	long double now=1;
	for i=1;i<=cnt;i++ do begin
		now*=a[i].f;
		e-=now*a[i].a;
	end;
	out(e);
end


#include <stdio.h>
#include <string.h>
#include <algorithm>

#define if if (
#define then )
#define do )
#define for for (
#define while while (
#define begin {
#define end }

#define MAXN 1005
#define MAXT 1565

inline void out(long double x)
begin
	double tmp=x;
	printf("%.10lf",tmp);
end;

int n,m;
int s1[MAXN],s2[MAXN],t1[MAXN],t2[MAXN];
long double fail[MAXN];

long double f[MAXN][MAXT];
int last[MAXN][MAXT];

struct data begin
	long double f,a;
end;

inline bool operator < (data a,data b)
begin
	long double a1=a.a,a2=b.a,f1=a.f,f2=b.f;
	return a2*(f2-f1*f2)+a1*(f1*f2-f1)<0;
end;

data a[MAXN];

int main()
begin
	scanf("%d%d",&n,&m);
	int i,j;
	for i=1;i<=n;i++ do begin
		double tmp;
		scanf("%d%d%d%d%lf",s1+i,s2+i,t1+i,t2+i,&tmp);
		fail[i]=tmp;
	end;
	for i=1;i<=n;i++ do begin
		memcpy(f[i],f[i-1],sizeof(f[i]));
		int t=t1[i];
		long double e=s1[i];
		for j=m-t;j>=0;j-- do begin
			long double tmp=f[i-1][j]+e;
			if tmp>f[i][j+t] then begin
				f[i][j+t]=tmp;
				last[i][j+t]=1;
			end;
		end;
		t=t1[i]+t2[i];
		e=s1[i]+s2[i]*(1.0-fail[i]);
		for j=m-t;j>=0;j-- do begin
			long double tmp=f[i-1][j]+e;
			if tmp>f[i][j+t] then begin
				f[i][j+t]=tmp;
				last[i][j+t]=2;
			end;
		end;
	end;
	long double ans=0;
	int id=0;
	for i=0;i<=m;i++ do begin
		if f[n][i]>ans then begin
			ans=f[n][i];
			id=i;
		end;
	end;
	out(ans);
	putchar(32);
	long double e=0;
	int cnt=0;
	int x=id;
	for i=n;i>=1;i-- do begin
		if !last[i][x] then continue;
		if last[i][x]==1 then begin
			x-=t1[i];
			e+=t1[i];
		end else begin
			x-=t1[i]+t2[i];
			e+=t1[i]+t2[i];
			a[++cnt]=(data){fail[i],t2[i]};
		end;
	end;
	std::sort(a+1,a+cnt+1);
	long double now=1;
	for i=1;i<=cnt;i++ do begin
		now*=a[i].f;
		e-=now*a[i].a;
	end;
	out(e);
end


#include <stdio.h>
#include <string.h>
#include <algorithm>

#define if if (
#define then )
#define do )
#define for for (
#define while while (
#define begin {
#define end }

#define MAXN 1005
#define MAXT 1565

inline void out(long double x)
begin
	double tmp=x;
	printf("%.10lf",tmp);
end;

int n,m;
int s1[MAXN],s2[MAXN],t1[MAXN],t2[MAXN];
long double fail[MAXN];

inline bool cmp(int x,int y)
begin
	long double a1=t2[x],a2=t2[y],f1=fail[x],f2=fail[y];
	return a2*(f2-f1*f2)+a1*(f1*f2-f1)>0;
end;

long double f[MAXN][MAXT];
int last[MAXN][MAXT];

struct data begin
	long double f,a;
end;

inline bool operator < (data a,data b)
begin
	long double a1=a.a,a2=b.a,f1=a.f,f2=b.f;
	return a2*(f2-f1*f2)+a1*(f1*f2-f1)<0;
end;

data a[MAXN];

inline void pre()
begin
	int i,j;
	for i=1;i<n;i++ do begin
		for j=i+1;j<=n;j++ do begin
			if cmp(i,j) then begin
				std::swap(s1[i],s1[j]);
				std::swap(s2[i],s2[j]);
				std::swap(t1[i],t1[j]);
				std::swap(t2[i],t2[j]);
				std::swap(fail[i],fail[j]);
			end;
		end;
	end;
end;

int main()
begin
	scanf("%d%d",&n,&m);
	int i,j;
	for i=1;i<=n;i++ do begin
		double tmp;
		scanf("%d%d%d%d%lf",s1+i,s2+i,t1+i,t2+i,&tmp);
		fail[i]=tmp;
	end;
	pre();
	for i=1;i<=n;i++ do begin
		memcpy(f[i],f[i-1],sizeof(f[i]));
		int t=t1[i];
		long double e=s1[i];
		for j=m-t;j>=0;j-- do begin
			long double tmp=f[i-1][j]+e;
			if tmp>f[i][j+t] then begin
				f[i][j+t]=tmp;
				last[i][j+t]=1;
			end;
		end;
		t=t1[i]+t2[i];
		e=s1[i]+s2[i]*(1.0-fail[i]);
		for j=m-t;j>=0;j-- do begin
			long double tmp=f[i-1][j]+e;
			if tmp>f[i][j+t] then begin
				f[i][j+t]=tmp;
				last[i][j+t]=2;
			end;
		end;
	end;
	long double ans=0;
	int id=0;
	for i=0;i<=m;i++ do begin
		if f[n][i]>ans then begin
			ans=f[n][i];
			id=i;
		end;
	end;
	out(ans);
	putchar(32);
	long double e=0;
	int cnt=0;
	int x=id;
	for i=n;i>=1;i-- do begin
		if !last[i][x] then continue;
		if last[i][x]==1 then begin
			x-=t1[i];
			e+=t1[i];
		end else begin
			x-=t1[i]+t2[i];
			e+=t1[i]+t2[i];
			a[++cnt]=(data){fail[i],t2[i]};
		end;
	end;
	std::sort(a+1,a+cnt+1);
	long double now=1;
	for i=1;i<=cnt;i++ do begin
		now*=a[i].f;
		e-=now*a[i].a;
	end;
	out(e);
end


#include <stdio.h>
#include <string.h>
#include <algorithm>

#define if if (
#define then )
#define do )
#define for for (
#define while while (
#define begin {
#define end }

#define MAXN 1005
#define MAXT 1565

int n,m;
int s1[MAXN],s2[MAXN],t1[MAXN],t2[MAXN];
double fail[MAXN];

double f[MAXN][MAXT];
int last[MAXN][MAXT];

struct data begin
	double suc,a;
end;

inline bool operator < (data a,data b)
begin
	return a.a*b.suc>b.a*a.suc;
end;

data a[MAXN];

int main()
begin
	scanf("%d%d",&n,&m);
	int i,j;
	for i=1;i<=n;i++ do begin
		scanf("%d%d%d%d%lf",s1+i,s2+i,t1+i,t2+i,fail+i);
	end;
	for i=1;i<=n;i++ do begin
		memcpy(f[i],f[i-1],sizeof(f[i]));
		int t=t1[i];
		double e=s1[i];
		for j=m-t;j>=0;j-- do begin
			double tmp=f[i-1][j]+e;
			if tmp>f[i][j+t] then begin
				f[i][j+t]=tmp;
				last[i][j+t]=1;
			end;
		end;
		t=t1[i]+t2[i];
		e=s1[i]+s2[i]*(1.0-fail[i]);
		for j=m-t;j>=0;j-- do begin
			double tmp=f[i-1][j]+e;
			if tmp>f[i][j+t] then begin
				f[i][j+t]=tmp;
				last[i][j+t]=2;
			end;
		end;
	end;
	double ans=0;
	int id=0;
	for i=0;i<=m;i++ do begin
		if f[n][i]>ans then begin
			ans=f[n][i];
			id=i;
		end;
	end;
	printf("%.10lf ",ans);
	double e=0;
	int cnt=0;
	int x=id;
	for i=n;i>=1;i-- do begin
		if !last[i][x] then continue;
		if last[i][x]==1 then begin
			x-=t1[i];
			e+=t1[i];
		end else begin
			x-=t1[i]+t2[i];
			e+=t1[i]+t2[i];
			a[++cnt]=(data){1-fail[i],t2[i]};
		end;
	end;
	std::sort(a+1,a+cnt+1);
	double now=1;
	for i=1;i<=cnt;i++ do begin
		now*=(1.0-a[i].suc);
		e-=now*a[i].a;
	end;
	printf("%.10lf\n",e);
end


#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
using namespace std;
const double eps=1e-4;
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-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<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);
	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 || (abs(ans.score-f[n][i].score)<eps && 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;
const double eps=1e-4;
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-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<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);
	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;
const double eps=1e-8;
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-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<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);
	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,dt;
}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=y.dt=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;
		y.dt=f[l-1][k-a[l].TS].dt+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].dt+a[l].TS+a[l].TL)*(1-a[l].p);
		y.dt=f[l-1][k-a[l].TS-a[l].TL].dt+a[l].TS+a[l].TL;
	}
	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);
		}
	}
	printf("%.10lf %.10lf",f[n][m].score,f[n][m].tim);
}


#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
using namespace std;
const double eps=1e-4;
struct sl{
	int SC,LC,TS,TL;
	double p;
}a[1005];
struct csl{
	long double score,tim;
}f[1005][1561],ans;
double a1,a2;
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);
	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+eps<f[n][i].score || (abs(ans.score-f[n][i].score)<eps && ans.tim>f[n][i].tim)) ans=f[n][i];
	a1=ans.score;a2=ans.tim;
	printf("%.10lf %.10lf",a1,a2);
}


#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,dt;
}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].dt+a[l].TS+a[l].TL)*(1-a[l].p);
		y.dt=f[l-1][k-a[l].TS-a[l].TL].dt+a[l].TS+a[l].TL;
	}
	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);
		}
	}
	printf("%.10lf %.10lf",f[n][m].score,f[n][m].tim);
}


#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
using namespace std;
typedef long long LL;
const double eps=1e-3;
const int D=1000;
struct sl{
	LL SC,LC,TS,TL;
	long 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("%I64d%I64d%I64d%I64d",&a[i].SC,&a[i].LC,&a[i].TS,&a[i].TL);
		a[i].SC*=D;a[i].LC*=D;
		scanf("%lf",&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=1;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];
	a1=ans.score;a2=ans.tim;
	printf("%.10lf %.10lf",a1/D,a2);
}


#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
using namespace std;
const double eps=1e-9;

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);
	}
	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;
const double eps=1e-3;
const int D=1000;
struct sl{
	int SC,LC,TS,TL;
	long 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",&a[i].SC,&a[i].LC,&a[i].TS,&a[i].TL);
		a[i].SC*=D;a[i].LC*=D;
		scanf("%lf",&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=1;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];
	a1=ans.score;a2=ans.tim;
	printf("%.10lf %.10lf",a1/D,a2);
}