#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  while (t--) {
    int n;
    cin >> n;
    vector<long long> a(n), ans;
    for (int i = 0; i < n; i++) cin >> a[i];
    auto sum = accumulate(a.begin(), a.end(), 0LL);
    long long xsum = 0;
    for (int i = 0; i < n; i++) xsum = (xsum ^ a[i]);
    if (sum == xsum * 2) {
      cout << 0 << endl;
      cout << endl;
    } else {
      if (xsum != 0) {
        ans.push_back(xsum);
        sum += xsum;
      }
      ans.push_back(sum);
      cout << ans.size() << endl;
      for (int i = 0; i < ans.size(); i++) {
        if (i != 0) cout << " ";
        cout << ans[i];
      }
      cout << endl;
    }
  }
}
