////=====Bismillahir Rahmanir Rahim=====////

/*                        ______
 _______   /\     |``\   |        |  /
    |     /  \    |__/   |____    |/
    |    / _ _\   |  \   |        |\
    |   /      \  |   \  |______  |  \

            Dept. of CSE
        Comilla  University

*/
#include<bits/stdc++.h>
#define fi 2*acos(0.0)
#define ll long long
#define FIO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define Node struct node
#define spc " "
#define  E  2.71828182845904523536
#define pb push_back
#define pp pop_back
#define ff first
#define ss second
#define valid(nx,ny) nx>=0 && nx<n && ny>=0 && ny<m
#define edl "\n"
#define infinity 10000000000000000
#define mod 1000000007
#define cn continue
using namespace std;
typedef pair<int, int> pi;
typedef pair<ll, ll> pll;
typedef vector<ll> vi;
typedef vector<pi> vpi;
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args)
{
    cerr << *it << " = " << a <<","<< spc;
    err(++it, args...);
    cout<<edl;
}
///Bit manipulation

bool checkbit(ll mask,ll bit){return mask & (1LL<<bit);}
int setbit(int mask,int bit){ return mask | (1<<bit) ; }
int clearbit(int mask,int bit){return mask & ~(1<<bit);}
int togglebit(int mask,int bit){return mask ^ (1<<bit);}
int bitno(int mask) {return (int)__builtin_popcount(mask);}

int fx[]={0,0,+1,-1};
int fy[]={+1,-1,0,0};

/// KNIGHT MOVE

int x_move[] = {2, 1, -1, -2, -2, -1, 1, 2};
int y_move[] = {1, 2, 2, 1, -1, -2, -2, -1};

///=====================================///

const long long maX=1e6+5;
//vector<ll>Graph[maX],cost[maX];
map<string,ll>check;
///check n=1;
///check corner case;

int main()
{
    ll test;
    cin>>test;
    while(test--){
        ll n;cin>>n;
        ll ara[n];
        ll Xor=0;
        ll sum=0;
        for(ll i=0;i<n;i++){
        cin>>ara[i];
        sum+=ara[i];
        Xor^=ara[i];
        }
        if(sum==2*Xor){
            cout<<0<<endl;
            cn;
        }
        cout<<2<<endl;
        cout<<Xor <<spc<<Xor+sum<<endl;
    }
return 0;
}


////=====Bismillahir Rahmanir Rahim=====////

/*                        ______
 _______   /\     |``\   |        |  /
    |     /  \    |__/   |____    |/
    |    / _ _\   |  \   |        |\
    |   /      \  |   \  |______  |  \

            Dept. of CSE
        Comilla  University

*/
#include<bits/stdc++.h>
#define fi 2*acos(0.0)
#define ll long long
#define FIO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define Node struct node
#define spc " "
#define  E  2.71828182845904523536
#define pb push_back
#define pp pop_back
#define ff first
#define ss second
#define valid(nx,ny) nx>=0 && nx<n && ny>=0 && ny<m
#define edl "\n"
#define infinity 10000000000000000
#define mod 1000000007
#define cn continue
using namespace std;
typedef pair<int, int> pi;
typedef pair<ll, ll> pll;
typedef vector<ll> vi;
typedef vector<pi> vpi;
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args)
{
    cerr << *it << " = " << a <<","<< spc;
    err(++it, args...);
    cout<<edl;
}
///Bit manipulation

bool checkbit(ll mask,ll bit){return mask & (1LL<<bit);}
int setbit(int mask,int bit){ return mask | (1<<bit) ; }
int clearbit(int mask,int bit){return mask & ~(1<<bit);}
int togglebit(int mask,int bit){return mask ^ (1<<bit);}
int bitno(int mask) {return (int)__builtin_popcount(mask);}

int fx[]={0,0,+1,-1};
int fy[]={+1,-1,0,0};

/// KNIGHT MOVE

int x_move[] = {2, 1, -1, -2, -2, -1, 1, 2};
int y_move[] = {1, 2, 2, 1, -1, -2, -2, -1};

///=====================================///

const long long maX=1e6+5;
//vector<ll>Graph[maX],cost[maX];
map<string,ll>check;
///check n=1;
///check corner case;

int main()
{
    ll test;
    cin>>test;
    while(test--){
        ll n;cin>>n;
        ll ara[n];
        ll Xor=0;
        ll sum=0;
        for(ll i=0;i<n;i++){
        cin>>ara[i];
        sum+=ara[i];
        Xor^=ara[i];
        }
        if(sum==Xor){
            cout<<2<<endl;
            cout<<Xor/2 <<spc<<Xor/2<<endl;
            cn;
        }
        if(sum==2*Xor){
            cout<<0<<endl;
            cn;
        }
        cout<<2<<endl;
        cout<<Xor <<spc<<Xor+sum<<endl;
    }
return 0;
}


////=====Bismillahir Rahmanir Rahim=====////

/*                        ______
 _______   /\     |``\   |        |  /
    |     /  \    |__/   |____    |/
    |    / _ _\   |  \   |        |\
    |   /      \  |   \  |______  |  \

            Dept. of CSE
        Comilla  University

*/
#include<bits/stdc++.h>
#define fi 2*acos(0.0)
#define ll long long
#define FIO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define Node struct node
#define spc " "
#define  E  2.71828182845904523536
#define pb push_back
#define pp pop_back
#define ff first
#define ss second
#define valid(nx,ny) nx>=0 && nx<n && ny>=0 && ny<m
#define edl "\n"
#define infinity 10000000000000000
#define mod 1000000007
#define cn continue
using namespace std;
typedef pair<int, int> pi;
typedef pair<ll, ll> pll;
typedef vector<ll> vi;
typedef vector<pi> vpi;
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args)
{
    cerr << *it << " = " << a <<","<< spc;
    err(++it, args...);
    cout<<edl;
}
///Bit manipulation

bool checkbit(ll mask,ll bit){return mask & (1LL<<bit);}
int setbit(int mask,int bit){ return mask | (1<<bit) ; }
int clearbit(int mask,int bit){return mask & ~(1<<bit);}
int togglebit(int mask,int bit){return mask ^ (1<<bit);}
int bitno(int mask) {return (int)__builtin_popcount(mask);}

int fx[]={0,0,+1,-1};
int fy[]={+1,-1,0,0};

/// KNIGHT MOVE

int x_move[] = {2, 1, -1, -2, -2, -1, 1, 2};
int y_move[] = {1, 2, 2, 1, -1, -2, -2, -1};

///=====================================///

const long long maX=1e6+5;
//vector<ll>Graph[maX],cost[maX];
map<string,ll>check;
///check n=1;
///check corner case;

int main()
{
    ll test;
    cin>>test;
    while(test--){
        ll n;cin>>n;
        ll ara[n];
        ll Xor=0;
        ll sum=0;
        for(ll i=0;i<n;i++){
        cin>>ara[i],sum+=ara[i];
        Xor^=ara[i];
        }
        if(sum==2*Xor){
            cout<<0<<endl;
            cn;
        }
        cout<<1<<endl;
        cout<<sum<<endl;
    }
return 0;
}


////=====Bismillahir Rahmanir Rahim=====////

/*                        ______
 _______   /\     |``\   |        |  /
    |     /  \    |__/   |____    |/
    |    / _ _\   |  \   |        |\
    |   /      \  |   \  |______  |  \

            Dept. of CSE
        Comilla  University

*/
#include<bits/stdc++.h>
#define fi 2*acos(0.0)
#define ll long long
#define FIO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define Node struct node
#define spc " "
#define  E  2.71828182845904523536
#define pb push_back
#define pp pop_back
#define ff first
#define ss second
#define valid(nx,ny) nx>=0 && nx<n && ny>=0 && ny<m
#define edl "\n"
#define infinity 10000000000000000
#define mod 1000000007
#define cn continue
using namespace std;
typedef pair<int, int> pi;
typedef pair<ll, ll> pll;
typedef vector<ll> vi;
typedef vector<pi> vpi;
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args)
{
    cerr << *it << " = " << a <<","<< spc;
    err(++it, args...);
    cout<<edl;
}
///Bit manipulation

bool checkbit(ll mask,ll bit){return mask & (1LL<<bit);}
int setbit(int mask,int bit){ return mask | (1<<bit) ; }
int clearbit(int mask,int bit){return mask & ~(1<<bit);}
int togglebit(int mask,int bit){return mask ^ (1<<bit);}
int bitno(int mask) {return (int)__builtin_popcount(mask);}

int fx[]={0,0,+1,-1};
int fy[]={+1,-1,0,0};

/// KNIGHT MOVE

int x_move[] = {2, 1, -1, -2, -2, -1, 1, 2};
int y_move[] = {1, 2, 2, 1, -1, -2, -2, -1};

///=====================================///

const long long maX=1e6+5;
//vector<ll>Graph[maX],cost[maX];
map<string,ll>check;
///check n=1;
///check corner case;

int main()
{
    ll test;
    cin>>test;
    while(test--){
        ll n;cin>>n;
        ll ara[n];
        ll Xor=0;
        ll sum=0;
        for(ll i=0;i<n;i++){
        cin>>ara[i],sum+=ara[i];
        Xor^=ara[i];
        }
        if(sum==Xor){
            cout<<2<<endl;
            cout<<Xor/2 <<spc<<Xor/2<<endl;
        }
        if(sum==2*Xor){
            cout<<0<<endl;
            cn;
        }
        cout<<1<<endl;
        cout<<sum<<endl;
    }
return 0;
}


////=====Bismillahir Rahmanir Rahim=====////

/*                        ______
 _______   /\     |``\   |        |  /
    |     /  \    |__/   |____    |/
    |    / _ _\   |  \   |        |\
    |   /      \  |   \  |______  |  \

            Dept. of CSE
        Comilla  University

*/
#include<bits/stdc++.h>
#define fi 2*acos(0.0)
#define ll long long
#define FIO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define Node struct node
#define spc " "
#define  E  2.71828182845904523536
#define pb push_back
#define pp pop_back
#define ff first
#define ss second
#define valid(nx,ny) nx>=0 && nx<n && ny>=0 && ny<m
#define edl "\n"
#define infinity 10000000000000000
#define mod 1000000007
#define cn continue
using namespace std;
typedef pair<int, int> pi;
typedef pair<ll, ll> pll;
typedef vector<ll> vi;
typedef vector<pi> vpi;
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args)
{
    cerr << *it << " = " << a <<","<< spc;
    err(++it, args...);
    cout<<edl;
}
///Bit manipulation

bool checkbit(ll mask,ll bit){return mask & (1LL<<bit);}
int setbit(int mask,int bit){ return mask | (1<<bit) ; }
int clearbit(int mask,int bit){return mask & ~(1<<bit);}
int togglebit(int mask,int bit){return mask ^ (1<<bit);}
int bitno(int mask) {return (int)__builtin_popcount(mask);}

int fx[]={0,0,+1,-1};
int fy[]={+1,-1,0,0};

/// KNIGHT MOVE

int x_move[] = {2, 1, -1, -2, -2, -1, 1, 2};
int y_move[] = {1, 2, 2, 1, -1, -2, -2, -1};

///=====================================///

const long long maX=1e6+5;
//vector<ll>Graph[maX],cost[maX];
map<string,ll>check;
///check n=1;
///check corner case;

int main()
{
    ll test;
    cin>>test;
    while(test--){
        ll n;cin>>n;
        ll ara[n];
        ll Xor=0;
        ll sum=0;
        for(ll i=0;i<n;i++){
        cin>>ara[i],sum+=ara[i];
        Xor^=ara[i];
        }
        if(sum==Xor){
            cout<<2<<endl;
            cout<<Xor/2 <<spc<<Xor/2<<endl;
        }
        if(sum==2*Xor){
            cout<<0<<endl;
            cn;
        }
        cout<<2<<endl;
        cout<<Xor <<spc<<Xor+sum<<endl;
    }
return 0;
}


#include<bits/stdc++.h>
using namespace std;
int cmp(int a,int b) {
	return a>b;
}
int main() {
		int t;
		cin>>t;
		while(t--)
		{
			int n;
			int a[100005];
			cin>>n;
			int sum=0;

			for(int i=0;i<n;i++)
			{
				cin>>a[i];
				sum+=a[i];
			}
			int sum2=a[0];
			for(int i=1;i<n;i++)
			{

				sum2^=a[i];
			}
			if(sum==2*sum2)cout<<0<<endl<<endl;
			else
			{
				if(sum==sum2)
				{
					cout<<2<<endl;
					cout<<sum/2<<" "<<sum/2<<endl;
				}
				if(sum2==0)
				{
					cout<<1<<endl;
					cout<<sum<<endl;
				}

			}

		}

}


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

int main() {
	long long t;
	cin>>t;
	while(t--) {
		long long n;
		long long a[100005];
		cin>>n;
		long long sum=0;

		for(long long i=0; i<n; i++) {
			cin>>a[i];
			sum+=a[i];
		}
		long long sum2=a[0];
		for(long long i=1; i<n; i++) {

			sum2^=a[i];
		}
		if(sum==2*sum2)cout<<0<<endl<<endl;
		else {
			if(sum==sum2) {

				if(sum%2) {
					sum++;
					sum2^=1;
					cout<<3<<endl;
					cout<<1<<" "<<abs(sum2*2-sum)/2<<" "<<abs(sum2*2-sum)/2<<endl;
				} else {
					cout<<2<<endl;
					cout<<sum/2<<" "<<sum/2<<endl;
				}

			} else if(sum2==0) {
				cout<<1<<endl;
				cout<<sum<<endl;
			} else {
				if(sum%2) {
					sum++;
					sum2^=1;
					cout<<3<<endl;
					cout<<1<<" "<<abs(sum2*2-sum)/2<<" "<<abs(sum2*2-sum)/2<<endl;
				} else {
					cout<<2<<endl;
					cout<<sum/2<<" "<<sum/2<<endl;
				}
			}

		}

	}

}


#include<bits/stdc++.h>
using namespace std;
int cmp(int a,int b) {
	return a>b;
}
int main() {
	int t;
	cin>>t;
	while(t--) {
		int n;
		int a[100005];
		cin>>n;
		int sum=0;

		for(int i=0; i<n; i++) {
			cin>>a[i];
			sum+=a[i];
		}
		int sum2=a[0];
		for(int i=1; i<n; i++) {

			sum2^=a[i];
		}
		if(sum==2*sum2)cout<<0<<endl<<endl;
		else {
			if(sum==sum2) {

				if(sum%2) {
					sum++;
					sum2^=1;
					cout<<3<<endl;
					cout<<1<<" "<<abs(sum2*2-sum)/2<<" "<<abs(sum2*2-sum)/2<<endl;
				} else {
					cout<<2<<endl;
					cout<<sum/2<<" "<<sum/2<<endl;
				}

			} else if(sum2==0) {
				cout<<1<<endl;
				cout<<sum<<endl;
			} else {
				cout<<2<<endl;
				cout<<(sum2*2-sum)/2<<" "<<(sum2*2-sum)/2<<endl;
			}

		}

	}

}


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

int main() {
	long long t;
	cin>>t;
	while(t--) {
		long long n;
		long long a[100005];
		cin>>n;
		long long sum=0;

		for(long long i=0; i<n; i++) {
			cin>>a[i];
			sum+=a[i];
		}
		long long sum2=a[0];
		for(long long i=1; i<n; i++) {

			sum2^=a[i];
		}
		if(sum==2*sum2)cout<<0<<endl<<endl;
		else {
			long long add=(1ll<<50)+sum%2;
			if(sum2==0) {
				cout<<1<<endl;
				cout<<sum<<endl;
			} else {

					sum+=add;
					sum2^=add;
					cout<<3<<endl;
					cout<<add<<" "<<abs(sum2*2-sum)/2<<" "<<abs(sum2*2-sum)/2<<endl;

			}

		}

	}

}


#include<bits/stdc++.h>
using namespace std;
int cmp(int a,int b) {
	return a>b;
}
int main() {
	int t;
	cin>>t;
	while(t--) {
		int n;
		int a[100005];
		cin>>n;
		int sum=0;

		for(int i=0; i<n; i++) {
			cin>>a[i];
			sum+=a[i];
		}
		int sum2=a[0];
		for(int i=1; i<n; i++) {

			sum2^=a[i];
		}
		if(sum==2*sum2)cout<<0<<endl<<endl;
		else {
			if(sum==sum2) {

				if(sum%2) {
					sum++;
					sum2^=1;
					cout<<3<<endl;
					cout<<1<<" "<<abs(sum2*2-sum)/2<<" "<<abs(sum2*2-sum)/2<<endl;
				} else {
					cout<<2<<endl;
					cout<<sum/2<<" "<<sum/2<<endl;
				}

			} else if(sum2==0) {
				cout<<1<<endl;
				cout<<sum<<endl;
			} else {
				if(sum%2) {
					sum++;
					sum2^=1;
					cout<<3<<endl;
					cout<<1<<" "<<abs(sum2*2-sum)/2<<" "<<abs(sum2*2-sum)/2<<endl;
				} else {
					cout<<2<<endl;
					cout<<sum/2<<" "<<sum/2<<endl;
				}
			}

		}

	}

}


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

int main() {
	long long t;
	cin>>t;
	while(t--) {
		long long n;
		long long a[100005];
		cin>>n;
		long long sum=0;

		for(long long i=0; i<n; i++) {
			cin>>a[i];
			sum+=a[i];
		}
		long long sum2=a[0];
		for(long long i=1; i<n; i++) {

			sum2^=a[i];
		}
		if(sum==2*sum2)cout<<0<<endl<<endl;
		else {/*
			long long add=(1ll<<50)+sum%2;
			if(sum2==0) {
				cout<<1<<endl;
				cout<<sum<<endl;
			} else {

					sum+=add;
					sum2^=add;
					cout<<3<<endl;
					cout<<add<<" "<<abs(sum2*2-sum)/2<<" "<<abs(sum2*2-sum)/2<<endl;

			}*/
			cout<<2<<endl<<sum2<<" "<<sum+sum2<<endl;

		}

	}

}


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

int main() {
	long long t;
	cin>>t;
	while(t--) {
		long long n;
		long long a[100005];
		cin>>n;
		long long sum=0;

		for(long long i=0; i<n; i++) {
			cin>>a[i];
			sum+=a[i];
		}
		long long sum2=a[0];
		for(long long i=1; i<n; i++) {

			sum2^=a[i];
		}
		if(sum==2*sum2)cout<<0<<endl<<endl;
		else {
			long long add=(100000)+sum%2;
			if(sum2==0) {
				cout<<1<<endl;
				cout<<sum<<endl;
			} else {

					sum+=add;
					sum2^=add;
					cout<<3<<endl;
					cout<<add<<" "<<abs(sum2*2-sum)/2<<" "<<abs(sum2*2-sum)/2<<endl;

			}

		}

	}

}


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

int main() {
	long long t;
	cin>>t;
	while(t--) {
		long long n;
		long long a[100005];
		cin>>n;
		long long sum=0;

		for(long long i=0; i<n; i++) {
			cin>>a[i];
			sum+=a[i];
		}
		long long sum2=a[0];
		for(long long i=1; i<n; i++) {

			sum2^=a[i];
		}
		if(sum==2*sum2)cout<<0<<endl<<endl;
		else {
			long long add=(1ll<<30)+sum%2;
			if(sum2==0) {
				cout<<1<<endl;
				cout<<sum<<endl;
			} else {

					sum+=add;
					sum2^=add;
					cout<<3<<endl;
					cout<<add<<" "<<abs(sum2*2-sum)/2<<" "<<abs(sum2*2-sum)/2<<endl;

			}

		}

	}

}


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

int main() {
	long long t;
	cin>>t;
	while(t--) {
		long long n;
		long long a[100005];
		cin>>n;
		long long sum=0;

		for(long long i=0; i<n; i++) {
			cin>>a[i];
			sum+=a[i];
		}
		long long sum2=a[0];
		for(long long i=1; i<n; i++) {

			sum2^=a[i];
		}
		if(sum==2*sum2)cout<<0<<endl<<endl;
		else {
			long long add=(1ll<<40)+sum%2;
			if(sum2==0) {
				cout<<1<<endl;
				cout<<sum<<endl;
			} else {

					sum+=add;
					sum2^=add;
					cout<<3<<endl;
					cout<<add<<" "<<abs(sum2*2-sum)/2<<" "<<abs(sum2*2-sum)/2<<endl;

			}

		}

	}

}


#include<bits/stdc++.h>
using namespace std;
int cmp(int a,int b) {
	return a>b;
}
int main() {
		int t;
		cin>>t;
		while(t--)
		{
			int n;
			int a[100005];
			cin>>n;
			int sum=0;

			for(int i=0;i<n;i++)
			{
				cin>>a[i];
				sum+=a[i];
			}
			int sum2=a[0];
			for(int i=1;i<n;i++)
			{

				sum2^=a[i];
			}
			if(sum==2*sum2)cout<<0<<endl<<endl;
			else
			{
				if(sum==sum2)
				{
					cout<<2<<endl;
					cout<<sum/2<<" "<<sum/2<<endl;
				}
				else if(sum2==0)
				{
					cout<<1<<endl;
					cout<<sum<<endl;
				}
				else
				{
					cout<<2<<endl;
					cout<<(sum-sum2)/2<<" "<<(sum-sum2)/2<<endl;
				}

			}

		}

}


#include<bits/stdc++.h>
using namespace std;
int cmp(int a,int b) {
	return a>b;
}
int main() {
	int t;
	cin>>t;
	while(t--) {
		int n;
		int a[100005];
		cin>>n;
		int sum=0;

		for(int i=0; i<n; i++) {
			cin>>a[i];
			sum+=a[i];
		}
		int sum2=a[0];
		for(int i=1; i<n; i++) {

			sum2^=a[i];
		}
		if(sum==2*sum2)cout<<0<<endl<<endl;
		else {
			if(sum==sum2) {

				if(sum%2) {
					sum++;
					sum2^=1;
					cout<<3<<endl;
					cout<<1<<" "<<abs(sum2*2-sum)/2<<" "<<abs(sum2*2-sum)/2<<endl;
				} else {
					cout<<2<<endl;
					cout<<sum/2<<" "<<sum/2<<endl;
				}

			} else if(sum2==0) {
				cout<<1<<endl;
				cout<<sum<<endl;
			} else {
				if(sum2%2) {
					sum++;
					sum2^=1;
					cout<<3<<endl;
					cout<<1<<" "<<abs(sum2*2-sum)/2<<" "<<abs(sum2*2-sum)/2<<endl;
				} else {
					cout<<2<<endl;
					cout<<sum/2<<" "<<sum/2<<endl;
				}
			}

		}

	}

}


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

int main() {
	long long t;
	cin>>t;
	while(t--) {
		long long n;
		long long a[100005];
		cin>>n;
		long long sum=0;

		for(long long i=0; i<n; i++) {
			cin>>a[i];
			sum+=a[i];
		}
		long long sum2=a[0];
		for(long long i=1; i<n; i++) {

			sum2^=a[i];
		}
		if(sum==2*sum2)cout<<0<<endl<<endl;
		else {
			long long add=(1ll<<14)+sum%2;
			if(sum2==0) {
				cout<<1<<endl;
				cout<<sum<<endl;
			} else {

					sum+=add;
					sum2^=add;
					cout<<3<<endl;
					cout<<add<<" "<<abs(sum2*2-sum)/2<<" "<<abs(sum2*2-sum)/2<<endl;

			}

		}

	}

}


#include "bits/stdc++.h"
#define ll long long
#define endl "\n"
using namespace std;
int main(){
    ll t;
    cin>>t;
    while(t--){
        ll n;
        cin>>n;
        ll a[n];
        ll s = 0,x = 0;
        for(ll i = 0;i < n; i++){
            cin>>a[i];
            s+=a[i];
            x^=a[i];
        }
        cout<<2<<endl;
        cout<<x<<' '<<s+x<<endl;

    }
}


#include "bits/stdc++.h"
#define ll long long
#define endl "\n"
using namepsace std'
int main(){
    ll t;
    cin>>t;
    while(t--){
        ll n;
        cin>>n;
        ll a[n];
        ll s = 0,x = 0;
        for(ll i = 0;i < n; i++){
            cin>>a[i];
            s+=a[i];
            x^=a[i];
        }
        cout<<2<<endl;
        cout<<x<<' '<<s+x<<endl;

    }
}


#include "bits/stdc++.h"
#define ll long long
#define endl "\n"

int main(){
    ll t;
    cin>>t;
    while(t--){
        ll n;
        cin>>n;
        ll a[n];
        ll s = 0,x = 0;
        for(ll i = 0;i < n; i++){
            cin>>a[i];
            s+=a[i];
            x^=a[i];
        }
        cout<<2<<endl;
        cout<<x<<' '<<s+x<<endl;

    }
}


#include " bits/stdc++.h"
#define ll long long
#define endl "\n"
using namespace std;

int main(){
    ll t;
    cin>>t;
    while(t--){
        ll n;
        cin>>n;
        ll a[n];
        ll s = 0,x = 0;
        for(ll i = 0;i < n; i++){
            cin>>a[i];
            s+=a[i];
            x^=a[i];
        }
        cout<<2<<endl;
        cout<<x<<' '<<s+x<<endl;

    }
}


#include " bits/stdc++.h"
#define ll long long
#define endl "\n"

int main(){
    ll t;
    cin>>t;
    while(t--){
        ll n;
        cin>>n;
        ll a[n];
        ll s = 0,x = 0;
        for(ll i = 0;i < n; i++){
            cin>>a[i];
            s+=a[i];
            x^=a[i];
        }
        cout<<2<<endl;
        cout<<x<<' '<<s+x<<endl;

    }
}


#include "bits/stdc++.h"
#define ll long long
#define endl "\n"
using namepsace std;
int main(){
    ll t;
    cin>>t;
    while(t--){
        ll n;
        cin>>n;
        ll a[n];
        ll s = 0,x = 0;
        for(ll i = 0;i < n; i++){
            cin>>a[i];
            s+=a[i];
            x^=a[i];
        }
        cout<<2<<endl;
        cout<<x<<' '<<s+x<<endl;

    }
}


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

using ll=long long;

int main(){

	ll tt;
	cin>>tt;
	while(tt--){
		ll n;
		cin>>n;
		ll sum=0;
		ll x,xr=0;
		ll i;
		for(i=0;i<n;i++){
			cin>>x;
			sum+=x;
			xr^=x;
		}
		cout<<2<<"\n";
		cout<< xr <<" "<<sum+xr<<"\n";
	}

}


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

using ll=long long;

int main(){

	ll tt;
	cin>>tt;
	while(tt--){
		ll n;
		cin>>n;
		ll sum=0;
		ll x,xr=0;
		ll i;
		for(i=0;i<n;i++){
			cin>>x;
			sum+=x;
			xr^=x;
		}
		cout<<2<<"\n";
		cout<< sum+xr+sum+xr <<" "<<(sum^xr)<<"\n";
	}

}


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

ll turnOffK(ll n, ll k)
{
    // k must be greater than 0
    if (k <= 0) return n;

    // Do & of n with a number with all set bits except
    // the k'th bit
    return (n & ~(1 << (k - 1)));
}

ll setb(ll n,ll pos,ll flag){
	if(flag){
//		cout<<"flag is 1\nbefore bit set "<<n<<"\n";
		n=(n|(1<<pos));
//		cout<<"after bit set "<<n<<"\n";
		return n;
	}
}

int main(){
	#ifndef ONLINE_JUDGE
		freopen("input.txt","r",stdin);
	#endif
	ll tt;
	cin>>tt;
	while(tt--){
		ll n,i,ok=0,sum=0,xxor=0;
		cin>>n;
		ll arr[n];
		for(i=0;i<n;i++){
			cin>>arr[i];
			sum+=arr[i];
			xxor^=arr[i];
		}
		ll ans=0,carry=0,t1=0,t2=0,t3=0;

//		cout<<"sum "<<sum<<" xor "<<xxor<<"\n";

		i=0;
		t1=sum&(1<<i);

//		cout<<"t1 "<<t1<<"\n";

		if(t1){
			ans=setb(ans,i,1);
			carry=1;
			t2=1;
		}
		else{

			t2=0;
		}

//		cout<<"t2 "<<t2<<"\n";

		t3=(xxor&(1<<i))^t2;

//		cout<<"t3 "<<t3<<"\n";
//		cout<<"carry "<<carry<<"\n\n";

		ll x;

		for(i=1;i<=63;i++){
			t1=((sum&(1<<i))>>i);
//			cout<<"t1 "<<t1<<"\n";
			if(t1+carry == t3){
				t2=0;
				if(t1+carry+t2 >= 2)carry=1;
				else carry=0;
			}
			else{
				t2=1;
				ans=setb(ans,i,t2);
				if(t1+carry+t2 >= 2)carry=1;
				else carry=0;
			}

//			cout<<"t2 "<<t2<<"\n";

			t3=((xxor&(1<<i))>>i)^t2;

//			cout<<"t3 "<<t3<<"\n";
//			cout<<"carry "<<carry<<"\n\n";

			//cin>>x;
//			cout<<ans<<"\n\n";
		}
		if(ans==0)cout<<0<<"\n\n";
		else{
			cout<<1<<"\n";
			cout<<ans<<"\n";
		}
	}

}


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

ll turnOffK(ll n, ll k)
{
    // k must be greater than 0
    if (k <= 0) return n;

    // Do & of n with a number with all set bits except
    // the k'th bit
    return (n & ~(1 << (k - 1)));
}

ll setb(ll n,ll pos,ll flag){
	if(flag){
//		cout<<"flag is 1\nbefore bit set "<<n<<"\n";
		n=(n|(1<<pos));
//		cout<<"after bit set "<<n<<"\n";
		return n;
	}
}

int main(){
	#ifndef ONLINE_JUDGE
		freopen("input.txt","r",stdin);
	#endif
	ll tt;
	cin>>tt;
	while(tt--){
		ll n,i,ok=0,sum=0,xxor=0;
		cin>>n;
		ll arr[n];
		for(i=0;i<n;i++){
			cin>>arr[i];
			sum+=arr[i];
			xxor^=arr[i];
		}
		ll ans=0,carry=0,t1=0,t2=0,t3=0;

//		cout<<"sum "<<sum<<" xor "<<xxor<<"\n";

		i=0;
		t1=sum&(1<<i);

//		cout<<"t1 "<<t1<<"\n";

		if(t1){
			ans=setb(ans,i,1);
			carry=1;
			t2=1;
		}
		else{

			t2=0;
		}

//		cout<<"t2 "<<t2<<"\n";

		t3=(xxor&(1<<i))^t2;

//		cout<<"t3 "<<t3<<"\n";

		ll x;

		for(i=1;i<=63;i++){
			t1=((sum&(1<<i))>>i);
//			cout<<"t1 "<<t1<<"\n";
			if(t1+carry == t3){
				t2=0;
				if(t1+carry+t2 == 2)carry=1;
				else carry=0;
			}
			else{
				t2=1;
				ans=setb(ans,i,t2);
				if(t1+carry+t2 == 2)carry=1;
				else carry=0;
			}

//			cout<<"t2 "<<t2<<"\n";

			t3=((xxor&(1<<i))>>i)^t2;

//			cout<<"t3 "<<t3<<"\n";

			//cin>>x;
//			cout<<ans<<"\n\n";
		}
		if(ans==0)cout<<0<<"\n\n";
		else{
			cout<<1<<"\n";
			cout<<ans<<"\n";
		}
	}

}


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

using ll=long long;

int main(){

	ll tt;
	cin>>tt;
	while(tt--){
		ll n;
		cin>>n;
		ll sum=0;
		ll x,xr=0;
		ll i;
		for(i=0;i<n;i++){
			cin>>x;
			sum+=x;
			xr^=x;
		}
		cout<<2<<"\n";
		cout<< sum+xr+sum+xr <<" "<<((sum+xr)^xr)<<"\n";
	}

}


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

ll turnOffK(ll n, ll k)
{
    // k must be greater than 0
    if (k <= 0) return n;

    // Do & of n with a number with all set bits except
    // the k'th bit
    return (n & ~(1 << (k - 1)));
}

ll setb(ll n,ll pos,ll flag){
	if(flag){
//		cout<<"flag is 1\nbefore bit set "<<n<<"\n";
		n=(n|(1<<pos));
//		cout<<"after bit set "<<n<<"\n";
		return n;
	}
}

int main(){
	#ifndef ONLINE_JUDGE
		freopen("input.txt","r",stdin);
	#endif
	ll tt;
	cin>>tt;
	while(tt--){
		ll n,i,ok=0,sum=0,xxor=0;
		cin>>n;
		ll arr[n];
		for(i=0;i<n;i++){
			cin>>arr[i];
			sum+=arr[i];
			xxor^=arr[i];
		}
		ll ans=0,carry=0,t1=0,t2=0,t3=0;

//		cout<<"sum "<<sum<<" xor "<<xxor<<"\n";

		i=0;
		t1=((sum&(1<<i))>>i);

//		cout<<"t1 "<<t1<<"\n";

		if(t1){
			ans=setb(ans,i,1);
			carry=1;
			t2=1;
		}
		else{

			t2=0;
		}

//		cout<<"t2 "<<t2<<"\n";

		t3=((xxor&(1<<i))>>i)^t2;

//		cout<<"t3 "<<t3<<"\n";

		if(t2)ans=setb(ans,0,1);

//		cout<<"carry "<<carry<<"\n\n";

		ll x;

		for(i=1;i<=63;i++){
			t1=((sum&(1<<i))>>i);
//			cout<<"t1 "<<t1<<"\n";
			if(((t1+carry)&1) == t3){
				t2=0;
				if(t1+carry+t2 >= 2)carry=1;
				else carry=0;
			}
			else{
				t2=1;
				ans=setb(ans,i,t2);
				if(t1+carry+t2 >= 2)carry=1;
				else carry=0;
			}

//			cout<<"t2 "<<t2<<"\n";

			t3=((xxor&(1<<i))>>i)^t2;

//			cout<<"t3 "<<t3<<"\n";
//			cout<<"carry "<<carry<<"\n\n";

//			cin>>x;
//			cout<<ans<<"\n\n";
		}
		if(ans==0)cout<<0<<"\n\n";
		else{
			cout<<1<<"\n";
			cout<<ans<<"\n";
		}
	}

}


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

ll turnOffK(ll n, ll k)
{
    // k must be greater than 0
    if (k <= 0) return n;

    // Do & of n with a number with all set bits except
    // the k'th bit
    return (n & ~(1 << (k - 1)));
}

ll setb(ll n,ll pos,ll flag){
	if(flag){
//		cout<<"flag is 1\nbefore bit set "<<n<<"\n";
		n=(n|(1<<pos));
//		cout<<"after bit set "<<n<<"\n";
		return n;
	}
}

int main(){
	#ifndef ONLINE_JUDGE
		freopen("input.txt","r",stdin);
	#endif
	ll tt;
	cin>>tt;
	while(tt--){
		ll n,i,ok=0,sum=0,xxor=0;
		cin>>n;
		ll arr[n];
		for(i=0;i<n;i++){
			cin>>arr[i];
			sum+=arr[i];
			xxor^=arr[i];
		}
		ll ans=0,carry=0,t1=0,t2=0,t3=0;

//		cout<<"sum "<<sum<<" xor "<<xxor<<"\n";

		i=0;
		t1=sum&(1<<i);

//		cout<<"t1 "<<t1<<"\n";

		if(t1){
			ans=setb(ans,i,1);
			carry=1;
			t2=1;
		}
		else{
			ans=setb(ans,i,0);
			t2=0;
		}

//		cout<<"t2 "<<t2<<"\n";

		t3=(xxor&(1<<i))^t2;

//		cout<<"t3 "<<t3<<"\n";

		ll x;

		for(i=1;i<=63;i++){
			t1=((sum&(1<<i))>>i);
//			cout<<"t1 "<<t1<<"\n";
			if(t1+carry == t3){
				t2=0;
				if(t1+carry+t2 == 2)carry=1;
				else carry=0;
			}
			else{
				t2=1;
				ans=setb(ans,i,t2);
				if(t1+carry+t2 == 2)carry=1;
				else carry=0;
			}

//			cout<<"t2 "<<t2<<"\n";

			t3=((xxor&(1<<i))>>i)^t2;

//			cout<<"t3 "<<t3<<"\n";

			//cin>>x;
//			cout<<ans<<"\n\n";
		}
		if(ans==0)cout<<0<<"\n\n";
		else{
			cout<<1<<"\n";
			cout<<ans<<"\n";
		}
	}

}


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

ll turnOffK(ll n, ll k)
{
    // k must be greater than 0
    if (k <= 0) return n;

    // Do & of n with a number with all set bits except
    // the k'th bit
    return (n & ~(1 << (k - 1)));
}

ll setb(ll n,ll pos,ll flag){
	if(flag){
//		cout<<"flag is 1\nbefore bit set "<<n<<"\n";
		n=(n|(1<<pos));
//		cout<<"after bit set "<<n<<"\n";
		return n;
	}
}

int main(){
	#ifndef ONLINE_JUDGE
		freopen("input.txt","r",stdin);
	#endif
	ll tt;
	cin>>tt;
	while(tt--){
		ll n,i,ok=0,sum=0,xxor=0;
		cin>>n;
		ll arr[n];
		for(i=0;i<n;i++){
			cin>>arr[i];
			sum+=arr[i];
			xxor^=arr[i];
		}
		ll ans=0,carry=0,t1=0,t2=0,t3=0;

//		cout<<"sum "<<sum<<" xor "<<xxor<<"\n";

		i=0;
		t1=sum&(1<<i);

//		cout<<"t1 "<<t1<<"\n";

		if(t1){
			ans=setb(ans,i,1);
			carry=1;
			t2=1;
		}
		else{
			ans=setb(ans,i,0);
			t2=0;
		}

//		cout<<"t2 "<<t2<<"\n";

		t3=(xxor&(1<<i))^t2;

//		cout<<"t3 "<<t3<<"\n";

		ll x;

		for(i=1;i<=63;i++){
			t1=((sum&(1<<i))>>i);
//			cout<<"t1 "<<t1<<"\n";
			if(t1+carry == t3){
				t2=0;
				if(t1+carry+t2 == 2)carry=1;
				else carry=0;
			}
			else{
				t2=1;
				ans=setb(ans,i,t2);
				if(t1+carry+t2 == 2)carry=1;
				else carry=0;
			}

//			cout<<"t2 "<<t2<<"\n";

			t3=((xxor&(1<<i))>>i)^t2;

//			cout<<"t3 "<<t3<<"\n";

			//cin>>x;
//			cout<<ans<<"\n\n";
		}
		ans--;
		if(ans==0)cout<<0<<"\n\n";
		else{
			cout<<1<<"\n";
			cout<<ans<<"\n";
		}
	}

}


///////////////////// author : TrEbLeCleF /////////////////////
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;
typedef vector<pii> vpii;

#define pb(x) push_back(x)
#define deb(x) cerr <<#x<<" = "<<x<<"\n"
#define print(v,s,e) for(int i = s; i < e; i++)cout << v[i]<<" ";cout<<"\n";
#define INF 1e17
#define PI 3.14159265358979323846
int del_x[4] = {-1, 1, 0, 0};
int del_y[4] = {0, 0, 1, -1};
int XX[8] = {-1, -1, -1, 0, 1, 1, 1, 0};
int YY[8] = {-1, 0, 1, 1, 1, 0, -1, -1};
/////////////////////////// GLOBAL ///////////////////////////

/////////////////////////// GLOBAL ///////////////////////////
void solve(){
	int n;cin >> n;
	int a[n];
	ll S = 0, X = 0;
	for(int i=0;i<n;i++){
		cin >> a[i];
		S+=a[i];
		X^=a[i];
	}
	if(S==2*X){
		cout << 0 <<"\n";
		cout <<"\n";
	}
	else{

		ll low = 1, high = 1e18;
		ll ans;
		while(low<=high){
			ll mid = low+(high-low)/2;
			if((mid%2==0 && S%2!=0) || (mid%2!=0&&S%2==0)){
				mid++;
			}
			if(2*(X^mid)-mid-S > 0){
				ans = mid;
				break;
			}
			else{
				low = mid+1;
			}
		}
		cout << 3 <<"\n";
		ll other = (2*(X^ans)-ans-S)/2;
		cout << ans <<" "<<other <<" "<<other<<"\n";
		//cout << "sum = "<<S+2*other+ans<<"\n";
		//cout <<"xor - "<<(ans^X) <<"\n";

	}

}

int main(){
	#ifndef ONLINE_JUDGE
	clock_t tStart = clock();
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	freopen("error.txt", "w", stderr);
	#endif
    ios_base:: sync_with_stdio(false);
   	cin.tie(0);
	int t=1;
	cin >> t;
	while(t--){
		solve();
	}
	/* #ifndef ONLINE_JUDGE
    printf("\nRun Time -> %.10fs\n", (double)(clock()-tStart) / CLOCKS_PER_SEC);
    #endif  */
}


///////////////////// author : TrEbLeCleF /////////////////////
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;
typedef vector<pii> vpii;

#define pb(x) push_back(x)
#define deb(x) cerr <<#x<<" = "<<x<<"\n"
#define print(v,s,e) for(int i = s; i < e; i++)cout << v[i]<<" ";cout<<"\n";
#define INF 1e17
#define PI 3.14159265358979323846
int del_x[4] = {-1, 1, 0, 0};
int del_y[4] = {0, 0, 1, -1};
int XX[8] = {-1, -1, -1, 0, 1, 1, 1, 0};
int YY[8] = {-1, 0, 1, 1, 1, 0, -1, -1};
/////////////////////////// GLOBAL ///////////////////////////

/////////////////////////// GLOBAL ///////////////////////////
void solve(){
	int n;cin >> n;
	int a[n];
	int S = 0, X = 0;
	for(int i=0;i<n;i++){
		cin >> a[i];
		S+=a[i];
		X^=a[i];
	}
	if(S==2*X){
		cout << 0 <<"\n";
		cout <<"\n";
	}
	else{

		ll low = 1, high = 1e18;
		ll ans;
		while(low<=high){
			ll mid = low+(high-low)/2;
			if((mid%2==0 && S%2!=0) || (mid%2!=0&&S%2==0)){
				mid++;
			}
			if(2*(X^mid)-mid-S > 0){
				ans = mid;
				break;
			}
			else{
				low = mid+1;
			}
		}
		cout << 3 <<"\n";
		ll other = (2*(X^ans)-ans-S)/2;
		cout << ans <<" "<<other <<" "<<other<<"\n";
		//cout << "sum = "<<S+2*other+ans<<"\n";
		//cout <<"xor - "<<(ans^X) <<"\n";

	}

}

int main(){
	#ifndef ONLINE_JUDGE
	clock_t tStart = clock();
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	freopen("error.txt", "w", stderr);
	#endif
    ios_base:: sync_with_stdio(false);
   	cin.tie(0);
	int t=1;
	cin >> t;
	while(t--){
		solve();
	}
	/* #ifndef ONLINE_JUDGE
    printf("\nRun Time -> %.10fs\n", (double)(clock()-tStart) / CLOCKS_PER_SEC);
    #endif  */
}


///////////////////// author : TrEbLeCleF /////////////////////
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;
typedef vector<pii> vpii;

#define pb(x) push_back(x)
#define deb(x) cerr <<#x<<" = "<<x<<"\n"
#define print(v,s,e) for(int i = s; i < e; i++)cout << v[i]<<" ";cout<<"\n";
#define INF 1e17
#define PI 3.14159265358979323846
int del_x[4] = {-1, 1, 0, 0};
int del_y[4] = {0, 0, 1, -1};
int XX[8] = {-1, -1, -1, 0, 1, 1, 1, 0};
int YY[8] = {-1, 0, 1, 1, 1, 0, -1, -1};
/////////////////////////// GLOBAL ///////////////////////////

/////////////////////////// GLOBAL ///////////////////////////
void solve(){
	int n;cin >> n;
	int a[n];
	int S = 0, X = 0;
	for(int i=0;i<n;i++){
		cin >> a[i];
		S+=a[i];
		X^=a[i];
	}
	if(S==2*X){
		cout << 0 <<"\n";
		cout <<"\n";
	}
	else{
		if(S==X){
			cout << 2 <<"\n";
			cout << S/2 <<" "<<S/2 <<"\n";
		}
		else{
			ll low = 1, high = 100;
			ll ans;
			while(low<=high){
				ll mid = low+(high-low)/2;
				if((X^mid) > int((S+mid)/2)){
					ans = mid;

					break;
				}
				else{
					high = mid-1;
				}
			}
			cout << 3 <<"\n";
			int other = 2*(X^ans)-ans-S;
			cout << ans <<" "<<other <<" "<<other<<"\n";
		}
	}

}

int main(){
	#ifndef ONLINE_JUDGE
	clock_t tStart = clock();
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	freopen("error.txt", "w", stderr);
	#endif
    ios_base:: sync_with_stdio(false);
   	cin.tie(0);
	int t=1;
	cin >> t;
	while(t--){
		solve();
	}
	/* #ifndef ONLINE_JUDGE
    printf("\nRun Time -> %.10fs\n", (double)(clock()-tStart) / CLOCKS_PER_SEC);
    #endif  */
}


///////////////////// author : TrEbLeCleF /////////////////////
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;
typedef vector<pii> vpii;

#define pb(x) push_back(x)
#define deb(x) cerr <<#x<<" = "<<x<<"\n"
#define print(v,s,e) for(int i = s; i < e; i++)cout << v[i]<<" ";cout<<"\n";
#define INF 1e17
#define PI 3.14159265358979323846
int del_x[4] = {-1, 1, 0, 0};
int del_y[4] = {0, 0, 1, -1};
int XX[8] = {-1, -1, -1, 0, 1, 1, 1, 0};
int YY[8] = {-1, 0, 1, 1, 1, 0, -1, -1};
/////////////////////////// GLOBAL ///////////////////////////

/////////////////////////// GLOBAL ///////////////////////////
void solve(){
	int n;cin >> n;
	int a[n];
	ll S = 0, X = 0;
	for(int i=0;i<n;i++){
		cin >> a[i];
		S+=a[i];
		X^=a[i];
	}
	if(S==2*X){
		cout << 0 <<"\n";
		cout <<"\n";
	}
	else{
		cout << 2 <<"\n";
		cout << X <<" " << X+S <<"\n";
	}

}

int main(){
	#ifndef ONLINE_JUDGE
	clock_t tStart = clock();
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	freopen("error.txt", "w", stderr);
	#endif
    ios_base:: sync_with_stdio(false);
   	cin.tie(0);
	int t=1;
	cin >> t;
	while(t--){
		solve();
	}
	/* #ifndef ONLINE_JUDGE
    printf("\nRun Time -> %.10fs\n", (double)(clock()-tStart) / CLOCKS_PER_SEC);
    #endif  */
}


import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Scanner;

public class countTheRectangles {
	public static void main(String[] args) {
		Scanner scan=new Scanner(System.in);
		int n=scan.nextInt();
		int[][] data=new int[n][4];
		int hct=0;
		for(int i=0;i<n;i++) {
			for(int j=0;j<4;j++) {
				data[i][j]=scan.nextInt();
			}
			if(data[i][0]>data[i][2]) {
				int temp=data[i][0];
				data[i][0]=data[i][2];
				data[i][2]=temp;
			}
			if(data[i][1]>data[i][3]) {
				int temp=data[i][1];
				data[i][1]=data[i][3];
				data[i][3]=temp;
			}
			if(data[i][1]==data[i][3]) hct++;
		}
		horiz[] h=new horiz[hct];
		for(int i=0;i<n;i++) {
			if(data[i][1]==data[i][3]) h[--hct]=new horiz(data[i][0],data[i][2],data[i][1]);
		}
		Arrays.sort(h);

		final int OFFSET=5001;

		ArrayList<event> a=new ArrayList<>();
		for(int i=0;i<n;i++) {
			if(data[i][0]==data[i][2]) {
				event e1=new event(data[i][0],data[i][0],data[i][1],1);
				event e2=new event(data[i][0],data[i][0],data[i][3],2);
				a.add(e1);
				a.add(e2);
				e2.below=e1;
			}
			else {
				a.add(new event(data[i][0],data[i][2],data[i][1],3));
			}
		}
		Collections.sort(a);
		long res=0L;
		for(int i=0;i<h.length;i++) {
			bit b=new bit(10000);

			for(int j=0;j<a.size();j++) {
				event e=a.get(j);
				if(e.type==1) {
					if(e.x1>=h[i].x1&&e.x1<=h[i].x2&&e.y<=h[i].y) {
						b.update(e.x1+OFFSET,1);
					}
				}
				else if(e.type==2) {
					if(e.x1>=h[i].x1&&e.x1<=h[i].x2&&e.below.y<=h[i].y) {
						b.update(e.x1+OFFSET,-1);
					}
				}
				else {
					if(e.y>h[i].y) {
						long x=b.sum(e.x1+OFFSET,e.x2+OFFSET);
						res+=x*(x-1)/2;
					}
				}
			}
		}
		System.out.println(res);
	}
	/*
7
-1 4 -1 -2
6 -1 -2 -1
-1 3 6 3
2 -2 2 4
4 -1 4 3
5 3 5 1
5 2 1 2
	 */
	static class bit {
		int n;
		int[] a;

		public bit(int size) {
			this.n=size+1;
			a = new int[n];
		}
		void update(int i,int delta) {
			while(i<n) {
				a[i]+=delta;
				i+=Integer.lowestOneBit(i);
			}
		}
		long sum(int i) {
			long res=0L;
			while(i>0) {
				res+=a[i];
				i-=Integer.lowestOneBit(i);
			}
			return res;
		}
		long sum(int i,int j) {
			return sum(j)-sum(i-1);
		}
	}
	static class event implements Comparable<event> {
		int x1,x2,y;
		int type;//1=open, 2=close, 3=horizontal
		event below;//only applicable for type=2
		event(int x1, int x2, int y, int type) {
			this.x1=x1;
			this.x2=x2;
			this.y=y;
			this.type=type;
		}
		@Override
		public int compareTo(event o) {
			if(y==o.y) {
				if(type==3) return -1;
				if(o.type==3) return 1;
				return 0;
			}
			return y-o.y;
		}
		public String toString() {
			return x1+" "+x2+" "+y+" "+type;
		}
	}
	static class horiz implements Comparable<horiz> {
		int x1,x2,y;
		horiz(int x1, int x2, int y) {
			this.x1=x1;
			this.x2=x2;
			this.y=y;
		}
		@Override
		public int compareTo(horiz o) {
			return y-o.y;
		}
	}
}


import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Scanner;

public class countTheRectangles {
	public static void main(String[] args) {
		Scanner scan=new Scanner(System.in);
		int n=scan.nextInt();
		int[][] data=new int[n][4];
		int hct=0;
		for(int i=0;i<n;i++) {
			for(int j=0;j<4;j++) {
				data[i][j]=scan.nextInt();
			}
			if(data[i][0]>data[i][2]) {
				int temp=data[i][0];
				data[i][0]=data[i][2];
				data[i][2]=temp;
			}
			if(data[i][1]>data[i][3]) {
				int temp=data[i][1];
				data[i][1]=data[i][3];
				data[i][3]=temp;
			}
			if(data[i][1]==data[i][3]) hct++;
		}
		horiz[] h=new horiz[hct];
		for(int i=0;i<n;i++) {
			if(data[i][1]==data[i][3]) h[--hct]=new horiz(data[i][0],data[i][2],data[i][1]);
		}
		Arrays.sort(h);

		final int OFFSET=5001;

		ArrayList<event> a=new ArrayList<>();
		for(int i=0;i<n;i++) {
			if(data[i][0]==data[i][2]) {
				event e1=new event(data[i][0],data[i][0],data[i][1],1);
				event e2=new event(data[i][0],data[i][0],data[i][3],2);
				a.add(e1);
				a.add(e2);
				e2.below=e1;
			}
			else {
				a.add(new event(data[i][0],data[i][2],data[i][1],3));
			}
		}
		Collections.sort(a);
		long res=0L;
		for(int i=0;i<h.length;i++) {
			bit b=new bit(10000);

			for(int j=0;j<a.size();j++) {
				event e=a.get(j);
				if(e.type==1) {
					if(e.x1>=h[i].x1&&e.x1<=h[i].x2&&e.y<=h[i].y) {
						b.update(e.x1+OFFSET,1);
					}
				}
				else if(e.type==2) {
					if(e.x1>=h[i].x1&&e.x1<=h[i].x2&&e.below.y<=h[i].y) {
						b.update(e.x1+OFFSET,-1);
					}
				}
				else {
					if(e.y>h[i].y) {
						long x=b.sum(e.x1+OFFSET,e.x2+OFFSET);
						res+=x*(x-1)/2;
					}
				}
			}
		}
		System.out.println(res);
	}
	/*
7
-1 4 -1 -2
6 -1 -2 -1
-1 3 6 3
2 -2 2 4
4 -1 4 3
5 3 5 1
5 2 1 2
	 */
	static class bit {
		int n;
		int[] a;

		public bit(int size) {
			this.n=size+1;
			a = new int[n];
		}
		void update(int i,int delta) {
			while(i<n) {
				a[i]+=delta;
				i+=Integer.lowestOneBit(i);
			}
		}
		long sum(int i) {
			long res=0L;
			while(i>0) {
				res+=a[i];
				i-=Integer.lowestOneBit(i);
			}
			return res;
		}
		long sum(int i,int j) {
			return sum(j)-sum(i-1);
		}
	}
	static class event implements Comparable<event> {
		int x1,x2,y;
		int type;//1=open, 2=close, 3=horizontal
		event below;//only applicable for type=2
		event(int x1, int x2, int y, int type) {
			this.x1=x1;
			this.x2=x2;
			this.y=y;
			this.type=type;
		}
		@Override
		public int compareTo(event o) {
			if(y==o.y) {
				if(type==3) return -1;
				return 1;
			}
			return y-o.y;
		}
		public String toString() {
			return x1+" "+x2+" "+y+" "+type;
		}
	}
	static class horiz implements Comparable<horiz> {
		int x1,x2,y;
		horiz(int x1, int x2, int y) {
			this.x1=x1;
			this.x2=x2;
			this.y=y;
		}
		@Override
		public int compareTo(horiz o) {
			return y-o.y;
		}
	}
}


import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Scanner;

public class countTheRectangles {
	public static void main(String[] args) {
		Scanner scan=new Scanner(System.in);
		int n=scan.nextInt();
		int[][] data=new int[n][4];
		int hct=0;
		for(int i=0;i<n;i++) {
			for(int j=0;j<4;j++) {
				data[i][j]=scan.nextInt();
			}
			if(data[i][0]>data[i][2]) {
				int temp=data[i][0];
				data[i][0]=data[i][2];
				data[i][2]=temp;
			}
			if(data[i][1]>data[i][3]) {
				int temp=data[i][1];
				data[i][1]=data[i][3];
				data[i][3]=temp;
			}
			if(data[i][1]==data[i][3]) hct++;
		}
		horiz[] h=new horiz[hct];
		for(int i=0;i<n;i++) {
			if(data[i][1]==data[i][3]) h[--hct]=new horiz(data[i][0],data[i][2],data[i][1]);
		}
		Arrays.sort(h);

		final int OFFSET=5001;

		ArrayList<event> a=new ArrayList<>();
		for(int i=0;i<n;i++) {
			if(data[i][0]==data[i][2]) {
				event e1=new event(data[i][0],data[i][0],data[i][1],1);
				event e2=new event(data[i][0],data[i][0],data[i][3],2);
				a.add(e1);
				a.add(e2);
				e2.below=e1;
			}
			else {
				a.add(new event(data[i][0],data[i][2],data[i][1],3));
			}
		}
		Collections.sort(a);
		long res=0L;
		for(int i=0;i<h.length;i++) {
			bit b=new bit(10000);

			for(int j=0;j<a.size();j++) {
				event e=a.get(j);
				if(e.type==1) {
					if(e.x1>=h[i].x1&&e.x1<=h[i].x2&&e.y<=h[i].y) {
						b.update(e.x1+OFFSET,1);
					}
				}
				else if(e.type==2) {
					if(e.x1>=h[i].x1&&e.x1<=h[i].x2&&e.below.y<=h[i].y) {
						b.update(e.x1+OFFSET,-1);
					}
				}
				else {
					if(e.y>h[i].y) {
						long x=b.sum(e.x1+OFFSET,e.x2+OFFSET);
						res+=x*(x-1)/2;
					}
				}
			}
		}
		System.out.println(res);
	}
	/*
7
-1 4 -1 -2
6 -1 -2 -1
-1 3 6 3
2 -2 2 4
4 -1 4 3
5 3 5 1
5 2 1 2
	 */
	static class bit {
		int n;
		int[] a;

		public bit(int size) {
			this.n=size+1;
			a = new int[n];
		}
		void update(int i,int delta) {
			while(i<n) {
				a[i]+=delta;
				i+=Integer.lowestOneBit(i);
			}
		}
		long sum(int i) {
			long res=0L;
			while(i>0) {
				res+=a[i];
				i-=Integer.lowestOneBit(i);
			}
			return res;
		}
		long sum(int i,int j) {
			return sum(j)-sum(i-1);
		}
	}
	static class event implements Comparable<event> {
		int x1,x2,y;
		int type;//1=open, 2=close, 3=horizontal
		event below;//only applicable for type=2
		event(int x1, int x2, int y, int type) {
			this.x1=x1;
			this.x2=x2;
			this.y=y;
			this.type=type;
		}
		@Override
		public int compareTo(event o) {
			if(y==o.y) {
				if(type==3) return -1;
			}
			return y-o.y;
		}
		public String toString() {
			return x1+" "+x2+" "+y+" "+type;
		}
	}
	static class horiz implements Comparable<horiz> {
		int x1,x2,y;
		horiz(int x1, int x2, int y) {
			this.x1=x1;
			this.x2=x2;
			this.y=y;
		}
		@Override
		public int compareTo(horiz o) {
			return y-o.y;
		}
	}
}


import java.util.*;

public class CountTheRectangles {

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        List<Segment> horizontal = new ArrayList<>();
        List<Segment> vertical = new ArrayList<>();
        for (int i = 0; i < n; i++) {
            int x1 = in.nextInt();
            int y1 = in.nextInt();
            int x2 = in.nextInt();
            int y2 = in.nextInt();
            if (x1 == x2) {
                vertical.add(new Segment(x1, y1, y2));
            } else {
                horizontal.add(new Segment(y1, x1, x2));
            }
        }
        if (horizontal.size() > vertical.size()) {
            List<Segment> temp = horizontal;
            horizontal = vertical;
            vertical = temp;
        }
        vertical.sort((s1, s2) -> {
            if (s1.v2 != s2.v2) {
                return s1.v2 - s2.v2;
            } else if (s1.v1 != s2.v1) {
                return s1.v1 - s2.v1;
            } else {
                return s1.u - s2.u;
            }
        });
        horizontal.sort((s1, s2) -> {
            if (s1.u != s2.u) {
                return s1.u - s2.u;
            } else if (s1.v2 != s2.v2) {
                return s1.v2 - s2.v2;
            } else {
                return s1.v1 - s2.v1;
            }
        });
        long answer = 0;
        Queue<Segment> queue = new LinkedList<>();
        SegmentTree segmentTree = new SegmentTree(-5000, 5000);
        for (int i = 0; i < horizontal.size(); i++) {
            Segment h = horizontal.get(i);
            //System.out.println("*****h = " + h + "*****");
            for (Segment v : vertical) {
                if (v.v1 <= h.u && h.u <= v.v2 && h.v1 <= v.u && v.u <= h.v2) {
                    queue.add(v);
                    segmentTree.update(v.u, 1);
                    //System.out.println("adding " + v);
                }
            }
            for (int j = i + 1; j < horizontal.size(); j++) {
                Segment ho = horizontal.get(j);
                while (!queue.isEmpty() && queue.peek().v2 < ho.u) {
                    //System.out.println("removing " + queue.peek());
                    segmentTree.update(queue.remove().u, -1);
                }
                long amt = segmentTree.query(ho.v1, ho.v2);
                //System.out.println("h = " + h + ", ho = " + ho + ", amt = " + amt);
                answer += (amt * (amt - 1)) >> 1L;
            }
            while (!queue.isEmpty()) {
                //System.out.println("removing " + queue.peek());
                segmentTree.update(queue.remove().u, -1);
            }
        }
        System.out.println(answer);
    }

    static class Segment {
        final int u;
        final int v1;
        final int v2;

        Segment(int u, int v1, int v2) {
            this.u = u;
            this.v1 = Math.min(v1, v2);
            this.v2 = Math.max(v1, v2);
        }

        @Override
        public String toString() {
            return "Segment{" +
                    "u=" + u +
                    ", v1=" + v1 +
                    ", v2=" + v2 +
                    '}';
        }
    }

    static class SegmentTree {
        final long[] val;
        final int treeFrom;
        final int length;

        public static final long IDENTITY = 0;

        long combine(long a, long b) {
            return a + b;
        }

        SegmentTree(int treeFrom, int treeTo) {
            this.treeFrom = treeFrom;
            int length = treeTo - treeFrom + 1;
            int l;
            for (l = 0; (1 << l) < length; l++);
            val = new long[1 << (l + 1)];
            this.length = 1 << l;
        }

        void update(int index, long delta) {
            int node = index - treeFrom + length;
            val[node] += delta;
            for (node >>= 1; node > 0; node >>= 1) {
                val[node] = val[node << 1] + val[(node << 1) + 1];
            }
        }

        long query(int from, int to) {
            if (to < from) {
                return 0;
            }
            return query(1, 0, length - 1, from - treeFrom, to - treeFrom);
        }

        long query(int node, int segFrom, int segTo, int from, int to) {
            if(segTo < from || segFrom > to) return IDENTITY;
            if(segFrom >= from && segTo <= to) {
                return val[node];
            }
            int mid = (segFrom + segTo) >> 1;
            return combine(
                    query(node << 1, segFrom, mid, from, to),
                    query((node << 1) + 1, mid + 1, segTo, from, to)
            );
        }
    }
}


import java.util.*;

public class CountTheRectangles2 {

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        List<Segment> horizontal = new ArrayList<>();
        List<Segment> vertical = new ArrayList<>();
        for (int i = 0; i < n; i++) {
            int x1 = in.nextInt();
            int y1 = in.nextInt();
            int x2 = in.nextInt();
            int y2 = in.nextInt();
            if (x1 == x2) {
                vertical.add(new Segment(x1, y1, y2));
            } else {
                horizontal.add(new Segment(y1, x1, x2));
            }
        }
        if (horizontal.size() > vertical.size()) {
            List<Segment> temp = horizontal;
            horizontal = vertical;
            vertical = temp;
        }
        vertical.sort((s1, s2) -> {
            if (s1.v2 != s2.v2) {
                return s1.v2 - s2.v2;
            } else if (s1.v1 != s2.v1) {
                return s1.v1 - s2.v1;
            } else {
                return s1.u - s2.u;
            }
        });
        horizontal.sort((s1, s2) -> {
            if (s1.u != s2.u) {
                return s1.u - s2.u;
            } else if (s1.v2 != s2.v2) {
                return s1.v2 - s2.v2;
            } else {
                return s1.v1 - s2.v1;
            }
        });
        long answer = 0;
        Queue<Segment> queue = new LinkedList<>();
        SegmentTree segmentTree = new SegmentTree(-5000, 5000);
        for (int i = 0; i < horizontal.size(); i++) {
            Segment h = horizontal.get(i);
            //System.out.println("*****h = " + h + "*****");
            for (Segment v : vertical) {
                if (v.v1 <= h.u && h.u <= v.v2 && h.v1 <= v.u && v.u <= h.v2) {
                    queue.add(v);
                    segmentTree.update(v.u, 1);
                    //System.out.println("adding " + v);
                }
            }
            for (int j = i + 1; j < horizontal.size(); j++) {
                Segment ho = horizontal.get(j);
                while (!queue.isEmpty() && queue.peek().v2 < ho.u) {
                    //System.out.println("removing " + queue.peek());
                    segmentTree.update(queue.remove().u, -1);
                }
                long amt = segmentTree.query(ho.v1, ho.v2);
                //System.out.println("h = " + h + ", ho = " + ho + ", amt = " + amt);
                answer += (amt * (amt - 1)) >> 1L;
            }
            while (!queue.isEmpty()) {
                //System.out.println("removing " + queue.peek());
                segmentTree.update(queue.remove().u, -1);
            }
        }
        System.out.println(answer);
    }

    static class Segment {
        final int u;
        final int v1;
        final int v2;

        Segment(int u, int v1, int v2) {
            this.u = u;
            this.v1 = Math.min(v1, v2);
            this.v2 = Math.max(v1, v2);
        }

        @Override
        public String toString() {
            return "Segment{" +
                    "u=" + u +
                    ", v1=" + v1 +
                    ", v2=" + v2 +
                    '}';
        }
    }

    static class SegmentTree {
        final long[] val;
        final int treeFrom;
        final int length;

        SegmentTree(int treeFrom, int treeTo) {
            this.treeFrom = treeFrom;
            int length = treeTo - treeFrom + 1;
            int l;
            for (l = 0; (1 << l) < length; l++);
            val = new long[1 << (l + 1)];
            this.length = 1 << l;
        }

        void update(int index, long delta) {
            int node = index - treeFrom + length;
            val[node] += delta;
            for (node >>= 1; node > 0; node >>= 1) {
                val[node] = val[node << 1] + val[(node << 1) + 1];
            }
        }

        long query(int from, int to) {
            if (to < from) {
                return 0;
            }
            from += length - treeFrom;
            to += length - treeFrom + 1;
            long res = 0;
            for (; from + (from & -from) <= to; from += from & -from) {
                res += val[from / (from & -from)];
            }
            for (; to - (to & -to) >= from; to -= to & -to) {
                res += val[(to - (to & -to)) / (to & -to)];
            }
            return res;
        }
    }
}


import java.util.*;

public class CountTheRectangles {

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        List<Segment> horizontal = new ArrayList<>();
        List<Segment> vertical = new ArrayList<>();
        for (int i = 0; i < n; i++) {
            int x1 = in.nextInt();
            int y1 = in.nextInt();
            int x2 = in.nextInt();
            int y2 = in.nextInt();
            if (x1 == x2) {
                vertical.add(new Segment(x1, y1, y2));
            } else {
                horizontal.add(new Segment(y1, x1, x2));
            }
        }
        vertical.sort((s1, s2) -> {
            if (s1.v2 != s2.v2) {
                return s1.v2 - s2.v2;
            } else if (s1.v1 != s2.v1) {
                return s1.v1 - s2.v1;
            } else {
                return s1.u - s2.u;
            }
        });
        horizontal.sort((s1, s2) -> {
            if (s1.u != s2.u) {
                return s1.u - s2.u;
            } else if (s1.v2 != s2.v2) {
                return s1.v2 - s2.v2;
            } else {
                return s1.v1 - s2.v1;
            }
        });
        long answer = 0;
        Queue<Segment> queue = new LinkedList<>();
        SegmentTree segmentTree = new SegmentTree(-5000, 5000);
        for (int i = 0; i < horizontal.size(); i++) {
            Segment h = horizontal.get(i);
            //System.out.println("*****h = " + h + "*****");
            for (Segment v : vertical) {
                if (v.v1 <= h.u && h.u <= v.v2 && h.v1 <= v.u && v.u <= h.v2) {
                    queue.add(v);
                    segmentTree.update(v.u, 1);
                    //System.out.println("adding " + v);
                }
            }
            for (int j = i + 1; j < horizontal.size(); j++) {
                Segment ho = horizontal.get(j);
                while (!queue.isEmpty() && queue.peek().v2 < ho.u) {
                    //System.out.println("removing " + queue.peek());
                    segmentTree.update(queue.remove().u, -1);
                }
                long amt = segmentTree.query(ho.v1, ho.v2);
                //System.out.println("h = " + h + ", ho = " + ho + ", amt = " + amt);
                answer += (amt * (amt - 1)) >> 1L;
            }
            while (!queue.isEmpty()) {
                //System.out.println("removing " + queue.peek());
                segmentTree.update(queue.remove().u, -1);
            }
        }
        System.out.println(answer);
    }

    static class Segment {
        final int u;
        final int v1;
        final int v2;

        Segment(int u, int v1, int v2) {
            this.u = u;
            this.v1 = Math.min(v1, v2);
            this.v2 = Math.max(v1, v2);
        }

        @Override
        public String toString() {
            return "Segment{" +
                    "u=" + u +
                    ", v1=" + v1 +
                    ", v2=" + v2 +
                    '}';
        }
    }

    static class SegmentTree {
        final long[] val;
        final int treeFrom;
        final int treeTo;

        public static final long IDENTITY = 0;

        long combine(long a, long b) {
            return a + b;
        }

        SegmentTree(int treeFrom, int treeTo) {
            this.treeFrom = treeFrom;
            this.treeTo = treeTo;
            int length = treeTo - treeFrom + 1;
            int l;
            for (l = 0; (1 << l) < length; l++);
            val = new long[1 << (l + 1)];
        }

        void update(int index, long delta) {
            update(1, treeFrom, treeTo, index, delta);
        }

        void update(int node, int segFrom, int segTo, int index, long delta) {
            if (segFrom == segTo) {
                val[node] += delta;
            } else {
                int mid = (segFrom + segTo) >> 1;
                if (index <= mid) {
                    update(node << 1, segFrom, mid, index, delta);
                } else {
                    update((node << 1) + 1, mid + 1, segTo, index, delta);
                }
                val[node] = combine(val[node << 1], val[(node << 1) + 1]);
            }
        }

        long query(int from, int to) {
            if (to < from) {
                return 0;
            }
            return query(1, treeFrom, treeTo, from, to);
        }

        long query(int node, int segFrom, int segTo, int from, int to) {
            if(segTo < from || segFrom > to) return IDENTITY;
            if(segFrom >= from && segTo <= to) {
                return val[node];
            }
            int mid = (segFrom + segTo) >> 1;
            return combine(
                    query(node << 1, segFrom, mid, from, to),
                    query((node << 1) + 1, mid + 1, segTo, from, to)
            );
        }
    }
}


import java.util.*;

public class CountTheRectangles3 {

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        List<Segment> horizontal = new ArrayList<>();
        List<Segment> vertical = new ArrayList<>();
        for (int i = 0; i < n; i++) {
            int x1 = in.nextInt();
            int y1 = in.nextInt();
            int x2 = in.nextInt();
            int y2 = in.nextInt();
            if (x1 == x2) {
                vertical.add(new Segment(x1, y1, y2));
            } else {
                horizontal.add(new Segment(y1, x1, x2));
            }
        }
        if (horizontal.size() > vertical.size()) {
            List<Segment> temp = horizontal;
            horizontal = vertical;
            vertical = temp;
        }
        vertical.sort((s1, s2) -> {
            if (s1.v2 != s2.v2) {
                return s1.v2 - s2.v2;
            } else if (s1.v1 != s2.v1) {
                return s1.v1 - s2.v1;
            } else {
                return s1.u - s2.u;
            }
        });
        horizontal.sort((s1, s2) -> {
            if (s1.u != s2.u) {
                return s1.u - s2.u;
            } else if (s1.v2 != s2.v2) {
                return s1.v2 - s2.v2;
            } else {
                return s1.v1 - s2.v1;
            }
        });
        long answer = 0;
        Queue<Segment> queue = new LinkedList<>();
        BinaryIndexTree bixTree = new BinaryIndexTree(-5000, 5000);
        for (int i = 0; i < horizontal.size(); i++) {
            Segment h = horizontal.get(i);
            //System.out.println("*****h = " + h + "*****");
            for (Segment v : vertical) {
                if (v.v1 <= h.u && h.u <= v.v2 && h.v1 <= v.u && v.u <= h.v2) {
                    queue.add(v);
                    bixTree.update(v.u, 1);
                    //System.out.println("adding " + v);
                }
            }
            for (int j = i + 1; j < horizontal.size(); j++) {
                Segment ho = horizontal.get(j);
                while (!queue.isEmpty() && queue.peek().v2 < ho.u) {
                    //System.out.println("removing " + queue.peek());
                    bixTree.update(queue.remove().u, -1);
                }
                long amt = bixTree.query(ho.v1, ho.v2);
                //System.out.println("h = " + h + ", ho = " + ho + ", amt = " + amt);
                answer += (amt * (amt - 1)) >> 1L;
            }
            while (!queue.isEmpty()) {
                //System.out.println("removing " + queue.peek());
                bixTree.update(queue.remove().u, -1);
            }
        }
        System.out.println(answer);
    }

    static class Segment {
        final int u;
        final int v1;
        final int v2;

        Segment(int u, int v1, int v2) {
            this.u = u;
            this.v1 = Math.min(v1, v2);
            this.v2 = Math.max(v1, v2);
        }

        @Override
        public String toString() {
            return "Segment{" +
                    "u=" + u +
                    ", v1=" + v1 +
                    ", v2=" + v2 +
                    '}';
        }
    }

    static class BinaryIndexTree {
        final long[] val;
        final int treeFrom;

        BinaryIndexTree(int treeFrom, int treeTo) {
            val = new long[treeTo - treeFrom + 2];
            this.treeFrom = treeFrom;
        }

        void update(int index, long delta) {
            for (int i = index + 1 - treeFrom; i < val.length; i += i & -i) {
                val[i] += delta;
            }
        }

        long query(int to) {
            long res = 0;
            for (int i = to + 1 - treeFrom; i > 0; i -= i & -i) {
                res += val[i];
            }
            return res;
        }

        long query(int from, int to) {
            if (to < from) {
                return 0;
            }
            return query(to) - query(from - 1);
        }
    }
}


import java.util.*;

public class CountTheRectangles {

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        List<Segment> horizontal = new ArrayList<>();
        List<Segment> vertical = new ArrayList<>();
        for (int i = 0; i < n; i++) {
            int x1 = in.nextInt();
            int y1 = in.nextInt();
            int x2 = in.nextInt();
            int y2 = in.nextInt();
            if (x1 == x2) {
                vertical.add(new Segment(x1, y1, y2));
            } else {
                horizontal.add(new Segment(y1, x1, x2));
            }
        }
        if (horizontal.size() > vertical.size()) {
            List<Segment> temp = horizontal;
            horizontal = vertical;
            vertical = temp;
        }
        vertical.sort((s1, s2) -> {
            if (s1.v2 != s2.v2) {
                return s1.v2 - s2.v2;
            } else if (s1.v1 != s2.v1) {
                return s1.v1 - s2.v1;
            } else {
                return s1.u - s2.u;
            }
        });
        horizontal.sort((s1, s2) -> {
            if (s1.u != s2.u) {
                return s1.u - s2.u;
            } else if (s1.v2 != s2.v2) {
                return s1.v2 - s2.v2;
            } else {
                return s1.v1 - s2.v1;
            }
        });
        long answer = 0;
        Queue<Segment> queue = new LinkedList<>();
        SegmentTree segmentTree = new SegmentTree(-5000, 5000);
        for (int i = 0; i < horizontal.size(); i++) {
            Segment h = horizontal.get(i);
            //System.out.println("*****h = " + h + "*****");
            for (Segment v : vertical) {
                if (v.v1 <= h.u && h.u <= v.v2 && h.v1 <= v.u && v.u <= h.v2) {
                    queue.add(v);
                    segmentTree.update(v.u, 1);
                    //System.out.println("adding " + v);
                }
            }
            for (int j = i + 1; j < horizontal.size(); j++) {
                Segment ho = horizontal.get(j);
                while (!queue.isEmpty() && queue.peek().v2 < ho.u) {
                    //System.out.println("removing " + queue.peek());
                    segmentTree.update(queue.remove().u, -1);
                }
                long amt = segmentTree.query(ho.v1, ho.v2);
                //System.out.println("h = " + h + ", ho = " + ho + ", amt = " + amt);
                answer += (amt * (amt - 1)) >> 1L;
            }
            while (!queue.isEmpty()) {
                //System.out.println("removing " + queue.peek());
                segmentTree.update(queue.remove().u, -1);
            }
        }
        System.out.println(answer);
    }

    static class Segment {
        final int u;
        final int v1;
        final int v2;

        Segment(int u, int v1, int v2) {
            this.u = u;
            this.v1 = Math.min(v1, v2);
            this.v2 = Math.max(v1, v2);
        }

        @Override
        public String toString() {
            return "Segment{" +
                    "u=" + u +
                    ", v1=" + v1 +
                    ", v2=" + v2 +
                    '}';
        }
    }

    static class SegmentTree {
        final long[] val;
        final int treeFrom;
        final int treeTo;

        public static final long IDENTITY = 0;

        long combine(long a, long b) {
            return a + b;
        }

        SegmentTree(int treeFrom, int treeTo) {
            this.treeFrom = treeFrom;
            this.treeTo = treeTo;
            int length = treeTo - treeFrom + 1;
            int l;
            for (l = 0; (1 << l) < length; l++);
            val = new long[1 << (l + 1)];
        }

        void update(int index, long delta) {
            update(1, treeFrom, treeTo, index, delta);
        }

        void update(int node, int segFrom, int segTo, int index, long delta) {
            if (segFrom == segTo) {
                val[node] += delta;
            } else {
                int mid = (segFrom + segTo) >> 1;
                if (index <= mid) {
                    update(node << 1, segFrom, mid, index, delta);
                } else {
                    update((node << 1) + 1, mid + 1, segTo, index, delta);
                }
                val[node] = combine(val[node << 1], val[(node << 1) + 1]);
            }
        }

        long query(int from, int to) {
            if (to < from) {
                return 0;
            }
            return query(1, treeFrom, treeTo, from, to);
        }

        long query(int node, int segFrom, int segTo, int from, int to) {
            if(segTo < from || segFrom > to) return IDENTITY;
            if(segFrom >= from && segTo <= to) {
                return val[node];
            }
            int mid = (segFrom + segTo) >> 1;
            return combine(
                    query(node << 1, segFrom, mid, from, to),
                    query((node << 1) + 1, mid + 1, segTo, from, to)
            );
        }
    }
}


//Created by Aminul on 7/15/2019.

import java.io.*;
import java.util.*;

import static java.lang.Math.*;

public class E {
    public static void main(String[] args) throws Exception {
        Scanner in = new Scanner(System.in);
        PrintWriter pw = new PrintWriter(System.out);

        int n = in.nextInt();
        BitSet bitSet[] = new BitSet[n];
        List<Integer> h = new ArrayList<>(), v = new ArrayList<>();
        int lines[][] = new int[n][];
        for (int i = 0; i < n; i++) {
            int x1 = in.nextInt(), y1 = in.nextInt();
            int x2 = in.nextInt(), y2 = in.nextInt();
            if (x1 > x2 || y1 > y2) {
                int tmpx = x1, tmpy = y1;
                x1 = x2;
                y1 = y2;
                x2 = tmpx;
                y2 = tmpy;
            }

            if(y1 == y2) h.add(i);
            if(x1 == x2) v.add(i);

            lines[i] = new int[]{x1, y1, x2, y2};
            bitSet[i] = new BitSet(n);
        }

        for (int hz : h) {
            for (int vr : v) {
                if (intersection(lines[hz], lines[vr])) {
                    bitSet[hz].set(vr);
                }
            }
        }

        long ans = 0;
        BitSet tmp = new BitSet();
        int HL[] = listToArr(h);
        int szH = HL.length;
        for (int i = 0; i < szH; i++) {
            for (int j = i + 1; j < szH; j++) {
                int h1 = HL[i], h2 = HL[j];
                tmp.or(bitSet[h1]);
                tmp.and(bitSet[h2]);
                long cnt = tmp.cardinality();
                ans += (cnt * (cnt - 1)) / 2;
                //tmp.xor(tmp);
            }
            tmp = new BitSet();
        }

        pw.println(ans);

        pw.close();
    }

    static int[] listToArr(List<Integer> list){
        return list.stream().filter(Objects::nonNull).mapToInt(Integer::intValue).toArray();
    }

    //a[0] = x1, a[1] = y[1], a[2] = x2, a[3] = y2
    static boolean intersection(int h[], int v[]) {
        return h[0] <= v[0] && h[2] >= v[0] && v[1] <= h[1] && v[3] >= h[3];
    }

    static void debug(Object... obj) {
        System.err.println(Arrays.deepToString(obj));
    }
}


//Created by Aminul on 7/15/2019.

import java.io.*;
import java.util.*;

import static java.lang.Math.*;

public class E {
    public static void main(String[] args) throws Exception {
        Scanner in = new Scanner(System.in);
        PrintWriter pw = new PrintWriter(System.out);
        int n = in.nextInt();
        BitSet bitSet[] = new BitSet[n];
        List<Integer> h = new ArrayList<>(), v = new ArrayList<>();
        int lines[][] = new int[n][];
        for (int i = 0; i < n; i++) {
            int x1 = in.nextInt(), y1 = in.nextInt();
            int x2 = in.nextInt(), y2 = in.nextInt();
            if (x1 > x2 || y1 > y2) {
                int tmpx = x1, tmpy = y1;
                x1 = x2;
                y1 = y2;
                x2 = tmpx;
                y2 = tmpy;
            }
            if (x1 == x2) v.add(i);
            else h.add(i);
            lines[i] = new int[]{x1, y1, x2, y2};
            bitSet[i] = new BitSet(n);
        }

        for (int hz : h) {
            for (int vr : v) {
                if (intersection(lines[hz], lines[vr])) {
                    bitSet[hz].set(vr);
                }
            }
        }

        long ans = 0;
        BitSet tmp = new BitSet(n);
        int HL[] = listToArr(h);
        int szH = HL.length;
        for (int i = 0; i < szH; i++) {
            for (int j = i + 1; j < szH; j++) {
                int h1 = HL[i], h2 = HL[j];
                tmp.or(bitSet[h1]);
                tmp.and(bitSet[h2]);
                long cnt = tmp.cardinality();
                ans += (cnt * (cnt - 1)) / 2;
                tmp.xor(tmp);
            }
        }

        pw.println(ans);

        pw.close();
    }

    static int[] listToArr(List<Integer> list){
        return list.stream().filter(Objects::nonNull).mapToInt(Integer::intValue).toArray();
    }

    //a[0] = x1, a[1] = y[1], a[2] = x2, a[3] = y2
    static boolean intersection(int h[], int v[]) {
        return h[0] <= v[0] && h[2] >= v[0] && v[1] <= h[1] && v[3] >= h[3];
    }

    static void debug(Object... obj) {
        System.err.println(Arrays.deepToString(obj));
    }
}


//Created by Aminul on 7/15/2019.

import java.io.*;
import java.util.*;

import static java.lang.Math.*;

public class E {
    public static void main(String[] args) throws Exception {
        Scanner in = new Scanner(System.in);
        PrintWriter pw = new PrintWriter(System.out);
        int n = in.nextInt();
        BitSet bitSet[] = new BitSet[n];
        List<Integer> h = new ArrayList<>(), v = new ArrayList<>();
        int lines[][] = new int[n][];
        for (int i = 0; i < n; i++) {
            int x1 = in.nextInt(), y1 = in.nextInt();
            int x2 = in.nextInt(), y2 = in.nextInt();
            if (x1 > x2 || y1 > y2) {
                int tmpx = x1, tmpy = y1;
                x1 = x2;
                y1 = y2;
                x2 = tmpx;
                y2 = tmpy;
            }
            if (x1 == x2) v.add(i);
            else h.add(i);
            lines[i] = new int[]{x1, y1, x2, y2};
            bitSet[i] = new BitSet(n);
        }

        for (int hz : h) {
            for (int vr : v) {
                if (intersection(lines[hz], lines[vr])) {
                    bitSet[hz].set(vr);
                }
            }
        }

        long ans = 0;
        BitSet tmp = new BitSet(n);
        for (int i = 0; i < h.size(); i++) {
            for (int j = i + 1; j < h.size(); j++) {
                int h1 = h.get(i), h2 = h.get(j);
                tmp.or(bitSet[h1]);
                tmp.and(bitSet[h2]);
                long cnt = tmp.cardinality();
                ans += (cnt * (cnt - 1)) / 2;
                tmp.clear();
            }
        }

        pw.println(ans);

        pw.close();
    }

    //a[0] = x1, a[1] = y[1], a[2] = x2, a[3] = y2
    static boolean intersection(int h[], int v[]) {
        return h[0] <= v[0] && h[2] >= v[0] && v[1] <= h[1] && v[3] >= h[3];
    }

    static void debug(Object... obj) {
        System.err.println(Arrays.deepToString(obj));
    }
}


//Created by Aminul on 7/15/2019.

import java.io.*;
import java.util.*;

import static java.lang.Math.*;

public class E {
    public static void main(String[] args) throws Exception {
        Scanner in = new Scanner(System.in);
        PrintWriter pw = new PrintWriter(System.out);
        int n = in.nextInt();
        BitSet bitSet[] = new BitSet[n];
        List<Integer> h = new ArrayList<>(), v = new ArrayList<>();
        int lines[][] = new int[n][];
        for (int i = 0; i < n; i++) {
            int x1 = in.nextInt(), y1 = in.nextInt();
            int x2 = in.nextInt(), y2 = in.nextInt();
            if (x1 > x2 || y1 > y2) {
                int tmpx = x1, tmpy = y1;
                x1 = x2;
                y1 = y2;
                x2 = tmpx;
                y2 = tmpy;
            }
            if (x1 == x2) v.add(i);
            else h.add(i);
            lines[i] = new int[]{x1, y1, x2, y2};
            bitSet[i] = new BitSet(n);
        }

        for (int hz : h) {
            for (int vr : v) {
                if (intersection(lines[hz], lines[vr])) {
                    bitSet[hz].set(vr);
                }
            }
        }

        long ans = 0;
        BitSet tmp = new BitSet(n);
        for (int i = 0; i < h.size(); i++) {
            for (int j = i + 1; j < h.size(); j++) {
                int h1 = h.get(i), h2 = h.get(j);
                tmp.or(bitSet[h1]);
                tmp.and(bitSet[h2]);
                long cnt = tmp.cardinality();
                ans += (cnt * (cnt - 1)) / 2;
                tmp.xor(tmp);
            }
        }

        pw.println(ans);

        pw.close();
    }

    //a[0] = x1, a[1] = y[1], a[2] = x2, a[3] = y2
    static boolean intersection(int h[], int v[]) {
        return h[0] <= v[0] && h[2] >= v[0] && v[1] <= h[1] && v[3] >= h[3];
    }

    static void debug(Object... obj) {
        System.err.println(Arrays.deepToString(obj));
    }
}


//Created by Aminul on 7/15/2019.

import java.io.*;
import java.util.*;

import static java.lang.Math.*;

public class E {
    public static void main(String[] args) throws Exception {
        Scanner in = new Scanner(System.in);
        PrintWriter pw = new PrintWriter(System.out);
        int n = in.nextInt();
        BitSet bitSet[] = new BitSet[n];
        ArrayDeque<Integer> h = new ArrayDeque<>(), v = new ArrayDeque<>();
        int lines[][] = new int[n][];
        for (int i = 0; i < n; i++) {
            int x1 = in.nextInt(), y1 = in.nextInt();
            int x2 = in.nextInt(), y2 = in.nextInt();
            if (x1 > x2 || y1 > y2) {
                int tmpx = x1, tmpy = y1;
                x1 = x2;
                y1 = y2;
                x2 = tmpx;
                y2 = tmpy;
            }

            if(y1 == y2) h.addLast(i);
            if(x1 == x2) v.addLast(i);

            lines[i] = new int[]{x1, y1, x2, y2};
            bitSet[i] = new BitSet(n);
        }

        if(h.size() > v.size()) {
            ArrayDeque<Integer> tmp = h;
            h = v;
            v = tmp;
        }

        for (int hz : h) {
            for (int vr : v) {
                if (checkIntersection(lines[hz], lines[vr])) {
                    bitSet[hz].set(vr);
                }
            }
        }

        long ans = 0;
        BitSet tmp = new BitSet();
        int HL[] = listToArr(h);
        int szH = HL.length;
        for (int i = 0; i < szH; i++) {
            for (int j = i + 1; j < szH; j++) {
                int h1 = HL[i], h2 = HL[j];
                tmp.or(bitSet[h1]);
                tmp.and(bitSet[h2]);
                long cnt = tmp.cardinality();
                ans += (cnt * (cnt - 1)) / 2;
            }
            tmp = new BitSet();
        }

        pw.println(ans);

        pw.close();
    }

    static int[] listToArr(ArrayDeque<Integer> list){
        return list.stream().filter(Objects::nonNull).mapToInt(Integer::intValue).toArray();
    }

    static boolean checkIntersection(int a[], int b[]) {
        return intersection(a, b) | intersection(b, a);
    }

    //a[0] = x1, a[1] = y[1], a[2] = x2, a[3] = y2
    static boolean intersection(int h[], int v[]) {
        return h[0] <= v[0] && h[2] >= v[0] && v[1] <= h[1] && v[3] >= h[3];
    }

    static void debug(Object... obj) {
        System.err.println(Arrays.deepToString(obj));
    }
}


//Created by Aminul on 7/15/2019.

import java.io.*;
import java.util.*;

import static java.lang.Math.*;

public class E {
    public static void main(String[] args) throws Exception {
        Scanner in = new Scanner(System.in);
        PrintWriter pw = new PrintWriter(System.out);
        Long start = System.currentTimeMillis();
        try {
            in = new Scanner(new FileInputStream("e_in.txt"));
            //pw = new PrintWriter("a.txt");
        } catch (Exception e) {}

        int n = in.nextInt();
        BitSet bitSet[] = new BitSet[n];
        ArrayDeque<Integer> h = new ArrayDeque<>(), v = new ArrayDeque<>();
        int lines[][] = new int[n][];
        for (int i = 0; i < n; i++) {
            int x1 = in.nextInt(), y1 = in.nextInt();
            int x2 = in.nextInt(), y2 = in.nextInt();
            if (x1 > x2 || y1 > y2) {
                int tmpx = x1, tmpy = y1;
                x1 = x2;
                y1 = y2;
                x2 = tmpx;
                y2 = tmpy;
            }

            if(y1 == y2) h.addLast(i);
            if(x1 == x2) v.addLast(i);

            lines[i] = new int[]{x1, y1, x2, y2};
            bitSet[i] = new BitSet(n);
        }

        if(h.size() > v.size()) {
            ArrayDeque<Integer> tmp = h;
            h = v;
            v = tmp;
        }

        if(n > 100) System.out.println(h.size() + " " + v.size() + " " +(System.currentTimeMillis() - start));

        for (int hz : h) {
            for (int vr : v) {
                if (checkIntersection(lines[hz], lines[vr])) {
                    bitSet[hz].set(vr);
                }
            }
        }

        if(n > 100) System.out.println(h.size() + " " + v.size() + " " +(System.currentTimeMillis() - start));

        long ans = 0;
        BitSet tmp = new BitSet();
        int HL[] = listToArr(h);
        int szH = HL.length;
        for (int i = 0; i < szH; i++) {
            for (int j = i + 1; j < szH; j++) {
                int h1 = HL[i], h2 = HL[j];
                tmp.or(bitSet[h1]);
                tmp.and(bitSet[h2]);
                long cnt = tmp.cardinality();
                ans += (cnt * (cnt - 1)) / 2;
            }
            tmp = new BitSet();
        }

        pw.println(ans);

        debug(System.currentTimeMillis() - start);
        pw.close();
    }

    static int[] listToArr(ArrayDeque<Integer> list){
        return list.stream().filter(Objects::nonNull).mapToInt(Integer::intValue).toArray();
    }

    static boolean checkIntersection(int a[], int b[]) {
        return intersection(a, b) | intersection(b, a);
    }

    //a[0] = x1, a[1] = y[1], a[2] = x2, a[3] = y2
    static boolean intersection(int h[], int v[]) {
        return h[0] <= v[0] && h[2] >= v[0] && v[1] <= h[1] && v[3] >= h[3];
    }

    static void debug(Object... obj) {
        System.err.println(Arrays.deepToString(obj));
    }
}


import java.io.*;
import java.util.*;

public class Main {

    static int maxn = 5001;

    static class Node {
        int x1, x2, y1, y2;
        public Node(int x1, int x2, int y1, int y2){
            this.x1 = x1;
            this.x2 = x2;
            this.y1 = y1;
            this.y2 = y2;
        }
    }

    static class BIT {
        int[] c;
        int size;

        public BIT(int size) {
            c = new int[size + 1];
            this.size = size + 1;
        }

        public int get(int x) {
            int sum = 0;
            for (; x > 0; x -= x & (-x)) {
                sum += c[x];
            }
            return sum;
        }

        public void update(int x, int val) {
            for (; x < size; x += x & (-x)) {
                c[x] += val;
            }
        }
    }

    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        int n = input.nextInt();
        ArrayList<Node> hlist = new ArrayList<>();
        ArrayList<Node> vlist = new ArrayList<>();

        int x1, x2, y1, y2;
        for (int i = 0; i < n; i++) {
            x1 = input.nextInt() + maxn;
            y1 = input.nextInt() + maxn;
            x2 = input.nextInt() + maxn;
            y2 = input.nextInt() + maxn;
            if (x1 > x2) { int tmp = x1; x1 = x2; x2 = tmp; }
            if (y1 > y2) { int tmp = y1; y1 = y2; y2 = tmp; }
            if (x1 == x2) vlist.add(new Node(x1, x2, y1, y2));
            else hlist.add(new Node(x1, x2, y1, y2));
        }
        Collections.sort(hlist, (a, b) -> a.y1 - b.y1);
        Collections.sort(vlist, (a, b) -> b.y2 - a.y2);

        long ans = 0;
        for (int i = 0; i < hlist.size(); i++) {
            Node x = hlist.get(i);
            BIT bit = new BIT(2 * maxn);
            Stack<Node> stk = new Stack<>();
            for (int j = 0; j < vlist.size(); j++) {
                Node y = vlist.get(j);
                if (y.y1 <= x.y1 && x.x1 <= y.x1 && y.x1 <= x.x2) {
                    bit.update(y.x1, 1);
                    stk.push(y);
                }
            }
            for (int j = i + 1; j < hlist.size(); j++) {
                Node y = hlist.get(j);
                while (!stk.empty()) {
                    Node cur = stk.peek();
                    if (cur.y2 < y.y2) {
                        bit.update(cur.x1, -1);
                        stk.pop();
                    }
                    else break;
                }
                int l = Math.max(x.x1, y.x1);
                int r = Math.min(x.x2, y.x2);
                if (l > r) continue;
                long cnt = bit.get(r) - bit.get(l - 1);
                ans += cnt * (cnt - 1) / 2;
            }
        }
        System.out.println(ans);
    }
}


//Created by Aminul on 7/15/2019.

import java.io.*;
import java.util.*;

import static java.lang.Math.*;

public class E {
    public static void main(String[] args) throws Exception {
        Scanner in = new Scanner(System.in);
        PrintWriter pw = new PrintWriter(System.out);
        Long start = System.currentTimeMillis();
        try {
            in = new Scanner(new FileInputStream("e_in.txt"));
            //pw = new PrintWriter("a.txt");
        } catch (Exception e) {}

        int n = in.nextInt();
        BitSet bitSet[] = new BitSet[n];
        ArrayDeque<Integer> h = new ArrayDeque<>(), v = new ArrayDeque<>();
        int lines[][] = new int[n][];
        for (int i = 0; i < n; i++) {
            int x1 = in.nextInt(), y1 = in.nextInt();
            int x2 = in.nextInt(), y2 = in.nextInt();
            if (x1 > x2 || y1 > y2) {
                int tmpx = x1, tmpy = y1;
                x1 = x2;
                y1 = y2;
                x2 = tmpx;
                y2 = tmpy;
            }

            if(y1 == y2) h.addLast(i);
            if(x1 == x2) v.addLast(i);

            lines[i] = new int[]{x1, y1, x2, y2};
            bitSet[i] = new BitSet(n);
        }

        if(h.size() > v.size()) {
            ArrayDeque<Integer> tmp = h;
            h = v;
            v = tmp;
        }

        //if(n > 100) System.out.println(h.size() + " " + v.size() + " " +(System.currentTimeMillis() - start));

        for (int hz : h) {
            for (int vr : v) {
                if (checkIntersection(lines[hz], lines[vr])) {
                    bitSet[hz].set(vr);
                }
            }
        }

        long ans = 0;
        BitSet tmp = new BitSet();
        int HL[] = listToArr(h);
        int szH = HL.length;
        for (int i = 0; i < szH; i++) {
            for (int j = i + 1; j < szH; j++) {
                int h1 = HL[i], h2 = HL[j];
                tmp.or(bitSet[h1]);
                tmp.and(bitSet[h2]);
                long cnt = tmp.cardinality();
                ans += (cnt * (cnt - 1)) / 2;
            }
            tmp = new BitSet();
            if(i > 100) System.out.println(i + " " + (System.currentTimeMillis() - start));
        }

        pw.println(ans);

        debug(System.currentTimeMillis() - start);
        pw.close();
    }

    static int[] listToArr(ArrayDeque<Integer> list){
        return list.stream().filter(Objects::nonNull).mapToInt(Integer::intValue).toArray();
    }

    static boolean checkIntersection(int a[], int b[]) {
        return intersection(a, b) | intersection(b, a);
    }

    //a[0] = x1, a[1] = y[1], a[2] = x2, a[3] = y2
    static boolean intersection(int h[], int v[]) {
        return h[0] <= v[0] && h[2] >= v[0] && v[1] <= h[1] && v[3] >= h[3];
    }

    static void debug(Object... obj) {
        System.err.println(Arrays.deepToString(obj));
    }
}


//Created by Aminul on 7/15/2019.

import java.io.*;
import java.util.*;

import static java.lang.Math.*;

public class E {
    public static void main(String[] args) throws Exception {
        Scanner in = new Scanner(System.in);
        PrintWriter pw = new PrintWriter(System.out);
        Long start = System.currentTimeMillis();
        try {
            in = new Scanner(new FileInputStream("e_in.txt"));
            //pw = new PrintWriter("a.txt");
        } catch (Exception e) {}

        int n = in.nextInt();
        BitSet bitSet[] = new BitSet[n];
        ArrayDeque<Integer> h = new ArrayDeque<>(), v = new ArrayDeque<>();
        int lines[][] = new int[n][];
        for (int i = 0; i < n; i++) {
            int x1 = in.nextInt(), y1 = in.nextInt();
            int x2 = in.nextInt(), y2 = in.nextInt();
            if (x1 > x2 || y1 > y2) {
                int tmpx = x1, tmpy = y1;
                x1 = x2;
                y1 = y2;
                x2 = tmpx;
                y2 = tmpy;
            }

            if(y1 == y2) h.addLast(i);
            if(x1 == x2) v.addLast(i);

            lines[i] = new int[]{x1, y1, x2, y2};
            bitSet[i] = new BitSet(n);
        }

        if(h.size() > v.size()) {
            ArrayDeque<Integer> tmp = h;
            h = v;
            v = tmp;
        }

        //if(n > 100) System.out.println(h.size() + " " + v.size() + " " +(System.currentTimeMillis() - start));

        for (int hz : h) {
            for (int vr : v) {
                if (checkIntersection(lines[hz], lines[vr])) {
                    bitSet[hz].set(vr);
                }
            }
        }

        long ans = 0;
        BitSet tmp = new BitSet();
        int HL[] = listToArr(h);
        int szH = HL.length;
        for (int i = 0; i < szH; i++) {
            for (int j = i + 1; j < szH; j++) {
                int h1 = HL[i], h2 = HL[j];
                tmp.or(bitSet[h1]);
                tmp.and(bitSet[h2]);
                long cnt = tmp.cardinality();
                ans += (cnt * (cnt - 1)) / 2;
            }
            tmp = new BitSet();
            if(n > 100 && i % 100 == 0) System.out.println(i + " " + (System.currentTimeMillis() - start));
        }

        pw.println(ans);

        debug(System.currentTimeMillis() - start);
        pw.close();
    }

    static int[] listToArr(ArrayDeque<Integer> list){
        return list.stream().filter(Objects::nonNull).mapToInt(Integer::intValue).toArray();
    }

    static boolean checkIntersection(int a[], int b[]) {
        return intersection(a, b) | intersection(b, a);
    }

    //a[0] = x1, a[1] = y[1], a[2] = x2, a[3] = y2
    static boolean intersection(int h[], int v[]) {
        return h[0] <= v[0] && h[2] >= v[0] && v[1] <= h[1] && v[3] >= h[3];
    }

    static void debug(Object... obj) {
        System.err.println(Arrays.deepToString(obj));
    }
}


//Created by Aminul on 7/15/2019.

import java.io.*;
import java.util.*;

import static java.lang.Math.*;

public class E {
    public static void main(String[] args) throws Exception {
        Scanner in = new Scanner(System.in);
        PrintWriter pw = new PrintWriter(System.out);
        Long start = System.currentTimeMillis();
        try {
            in = new Scanner(new FileInputStream("e_in.txt"));
            //pw = new PrintWriter("a.txt");
        } catch (Exception e) {}

        int n = in.nextInt();
        BitSet bitSet[] = new BitSet[n];
        ArrayDeque<Integer> h = new ArrayDeque<>(), v = new ArrayDeque<>();
        int lines[][] = new int[n][];
        for (int i = 0; i < n; i++) {
            int x1 = in.nextInt(), y1 = in.nextInt();
            int x2 = in.nextInt(), y2 = in.nextInt();
            if (x1 > x2 || y1 > y2) {
                int tmpx = x1, tmpy = y1;
                x1 = x2;
                y1 = y2;
                x2 = tmpx;
                y2 = tmpy;
            }

            if(y1 == y2) h.addLast(i);
            if(x1 == x2) v.addLast(i);

            lines[i] = new int[]{x1, y1, x2, y2};
            bitSet[i] = new BitSet(n);
        }

        if(h.size() > v.size()) {
            ArrayDeque<Integer> tmp = h;
            h = v;
            v = tmp;
        }

        System.out.println(h.size() + " " + v.size());

        for (int hz : h) {
            for (int vr : v) {
                if (checkIntersection(lines[hz], lines[vr])) {
                    bitSet[hz].set(vr);
                }
            }
        }

        long ans = 0;
        BitSet tmp = new BitSet();
        int HL[] = listToArr(h);
        int szH = HL.length;
        for (int i = 0; i < szH; i++) {
            for (int j = i + 1; j < szH; j++) {
                int h1 = HL[i], h2 = HL[j];
                tmp.or(bitSet[h1]);
                tmp.and(bitSet[h2]);
                long cnt = tmp.cardinality();
                ans += (cnt * (cnt - 1)) / 2;
            }
            tmp = new BitSet();
        }

        pw.println(ans);

        debug(System.currentTimeMillis() - start);
        pw.close();
    }

    static int[] listToArr(ArrayDeque<Integer> list){
        return list.stream().filter(Objects::nonNull).mapToInt(Integer::intValue).toArray();
    }

    static boolean checkIntersection(int a[], int b[]) {
        return intersection(a, b) | intersection(b, a);
    }

    //a[0] = x1, a[1] = y[1], a[2] = x2, a[3] = y2
    static boolean intersection(int h[], int v[]) {
        return h[0] <= v[0] && h[2] >= v[0] && v[1] <= h[1] && v[3] >= h[3];
    }

    static void debug(Object... obj) {
        System.err.println(Arrays.deepToString(obj));
    }
}


import java.util.*;
import java.io.*;

public class tr0 {
	static PrintWriter out;
	static StringBuilder sb;
	static int mod = 998244353;
	static long inf = (long) 1e16;
	static int[] l, r;
	static int n, m, id;
	static long all, ans;
	static ArrayList<Integer>[] ad;
	static long[][][] memo;
	static long[] a;
	static ArrayList<Integer> h;
	static boolean vis[];

	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		out = new PrintWriter(System.out);
		int offset = 5001;
		n = sc.nextInt();
		int v = 0;
		int h = 0;
		int[] xs = new int[n];
		int[] ys = new int[n];
		int[] xe = new int[n];
		int[] ye = new int[n];
		for (int i = 0; i < n; i++) {
			xs[i] = sc.nextInt() + offset;
			ys[i] = sc.nextInt() + offset;
			xe[i] = sc.nextInt() + offset;
			ye[i] = sc.nextInt() + offset;
			if (xs[i] == xe[i]) {
				int min = Math.min(ys[i], ye[i]);
				int max = Math.max(ys[i], ye[i]);
				ys[i] = min;
				ye[i] = max;
				v++;
			} else {
				int min = Math.min(xs[i], xe[i]);
				int max = Math.max(xs[i], xe[i]);
				xs[i] = min;
				xe[i] = max;
				h++;
			}
		}
		long ans = 0;
		tri[] V = new tri[v];
		tri[] H = new tri[h];
		int iv = 0;
		int ih = 0;
		for (int i = 0; i < n; i++) {
			if (xs[i] == xe[i]) {
				V[iv++] = new tri(xs[i], ys[i], ye[i]);
			} else {
				H[ih++] = new tri(ys[i], xs[i], xe[i]);
			}
		}
		Arrays.sort(V);
		// System.out.println(Arrays.toString(V));
		// System.out.println(Arrays.toString(H));
		for (int i = 0; i < v; i++) {
			SegmentTree st = new SegmentTree(new int[16385]);
			int interlinked = 0;
			for (int inter = 0; inter < h; inter++) {
				if (H[inter].d >= V[i].st && H[inter].d <= V[i].ed && V[i].d >= H[inter].st && V[i].d <= H[inter].ed) {
					interlinked++;
				}
			}
			tri[] ar = new tri[interlinked];
			int id = 0;
			for (int inter = 0; inter < h; inter++) {
				if (H[inter].d >= V[i].st && H[inter].d <= V[i].ed && V[i].d >= H[inter].st && V[i].d <= H[inter].ed) {
					ar[id++] = new tri(H[inter].ed - V[i].d, H[inter].d, 0);
					// st.update_point(H[inter].d, 1);
				}
			}
			Arrays.sort(ar);
			for (int j = 0; j < interlinked; j++)
				st.update_point(H[j].d, 1);
			id = 0;
			for (int j = i + 1; j < v; j++) {
				while (id < interlinked && ar[id].d < V[j].d - V[i].d) {
					st.update_point(ar[id].st, -1);
					id++;
				}
				long x = st.query(V[j].st, V[j].ed);
				ans += x * (x - 1) / 2;
			}
		}
		System.out.println(ans);
		out.flush();
	}

	public static class SegmentTree { // 1-based DS, OOP

		int N; // the number of elements in the array as a power of 2 (i.e. after padding)
		int[] array, sTree, lazy;

		SegmentTree(int[] in) {
			array = in;
			N = in.length - 1;
			sTree = new int[N << 1]; // no. of nodes = 2*N - 1, we add one to cross out index zero
			lazy = new int[N << 1];
			build(1, 1, N);
		}

		void build(int node, int b, int e) // O(n)
		{
			if (b == e)
				sTree[node] = array[b];
			else {
				int mid = b + e >> 1;
				build(node << 1, b, mid);
				build(node << 1 | 1, mid + 1, e);
				sTree[node] = sTree[node << 1] + sTree[node << 1 | 1];
			}
		}

		void update_point(int index, int val) // O(log n)
		{
			index += N - 1;
			sTree[index] += val;
			while (index > 1) {
				index >>= 1;
				sTree[index] = sTree[index << 1] + sTree[index << 1 | 1];
			}
		}

		int query(int i, int j) {
			return query(1, 1, N, i, j);
		}

		int query(int node, int b, int e, int i, int j) // O(log n)
		{
			if (i > e || j < b)
				return 0;
			if (b >= i && e <= j)
				return sTree[node];
			int mid = b + e >> 1;
			int q1 = query(node << 1, b, mid, i, j);
			int q2 = query(node << 1 | 1, mid + 1, e, i, j);
			return q1 + q2;

		}

	}

	static class tri implements Comparable<tri> {
		int d, st, ed;

		tri(int d, int s, int e) {
			this.d = d;
			st = s;
			ed = e;
		}

		public String toString() {
			return d + " " + st + " " + ed;
		}

		@Override
		public int compareTo(tri o) {
			return d - o.d;
		}

	}

	static class Scanner {
		StringTokenizer st;
		BufferedReader br;

		public Scanner(InputStream system) {
			br = new BufferedReader(new InputStreamReader(system));
		}

		public Scanner(String file) throws Exception {
			br = new BufferedReader(new FileReader(file));
		}

		public String next() throws IOException {
			while (st == null || !st.hasMoreTokens())
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}

		public String nextLine() throws IOException {
			return br.readLine();
		}

		public int nextInt() throws IOException {
			return Integer.parseInt(next());
		}

		public double nextDouble() throws IOException {
			return Double.parseDouble(next());
		}

		public char nextChar() throws IOException {
			return next().charAt(0);
		}

		public Long nextLong() throws IOException {
			return Long.parseLong(next());
		}

		public int[] nextArrInt(int n) throws IOException {
			int[] a = new int[n];
			for (int i = 0; i < n; i++)
				a[i] = nextInt();
			return a;
		}

		public long[] nextArrLong(int n) throws IOException {
			long[] a = new long[n];
			for (int i = 0; i < n; i++)
				a[i] = nextLong();
			return a;
		}

		public boolean ready() throws IOException {
			return br.ready();
		}

		public void waitForInput() throws InterruptedException {
			Thread.sleep(3000);
		}
	}
}