#include <bits/stdc++.h>
using namespace std;
long long n, a[100005], pre[100005], t[100005];
long long sta[100005], top;
long long f[100005];
void work() {
  scanf("%lld", &n);
  for (long long i = 1; i <= n; i++)
    scanf("%lld", &a[i]), f[i] = t[i] = pre[i] = 0;
  long long xx, yy, tx, ty;
  xx = -a[1];
  yy = a[1];
  tx = ty = 1;
  for (long long i = 2; i <= n; i++) {
    if (a[i] + xx > yy - a[i])
      f[i] = a[i] + xx, pre[i] = tx, t[i] = t[tx] + 1;
    else if (a[i] + xx == yy - a[i]) {
      if (t[tx] < t[ty])
        f[i] = a[i] + xx, pre[i] = tx, t[i] = t[tx] + 1;
      else
        f[i] = yy - a[i], pre[i] = ty, t[i] = t[ty] + 1;
    } else
      f[i] = yy - a[i], pre[i] = ty, t[i] = t[ty] + 1;
    if (f[i] - a[i] > xx)
      xx = f[i] - a[i], tx = i;
    else if (f[i] - a[i] == xx && t[i] < t[tx])
      tx = i;
    if (f[i] + a[i] > yy)
      yy = f[i] + a[i], ty = i;
    else if (f[i] + a[i] == yy && t[i] < t[ty])
      ty = i;
  }
  long long ans = 0;
  for (long long i = 1; i <= n; i++)
    if (f[i] > f[ans]) ans = i;
  printf("%lld\n", t[ans] + 1);
  while (ans) sta[++top] = ans, ans = pre[ans];
  while (top) printf("%lld ", a[sta[top--]]);
  putchar('\n');
}
signed main() {
  long long T;
  scanf("%lld", &T);
  while (T--) work();
  return 0;
}
