#include <stdio.h>

#include <string.h>

int main()

{

int n,data[100000],best[100000],a,b,now,max,pre[100000],last,show[100000],count;

scanf("%d",&n);

while (n > 0)

{

for (a = 0; a < 100000; a++)

{

best[a] = 1;

pre[a] = 0;

}

now = 0;

while(scanf("%d",&data[now])==1)

now++;

max = 1;

for (a = 0; a < now-1; a++)

{

for (b = a+1; b < now; b++)

if (data

**> data[a])**

if (best[a]+1>best

if (best[a]+1>best

**)**

{

best{

best

**=best[a]+1;**

if (bestif (best

**> max)**

{

last = b;

max = best{

last = b;

max = best

**;**

}

pre}

pre

**= a;**

}

}

printf("Max hits: %d",max);

count = 0;

show[count] = last;

count++;

now = last;

max--;

while(max)

{

show[count] = pre[now];

now = pre[now];

count++;

max--;

}

for (a = count -1; a >= 0;a--)

printf("\n%d",data[show[a]]);

printf("\n");

n--;

if (n > 0)

printf("\n");

}

return 0;

}}

}

printf("Max hits: %d",max);

count = 0;

show[count] = last;

count++;

now = last;

max--;

while(max)

{

show[count] = pre[now];

now = pre[now];

count++;

max--;

}

for (a = count -1; a >= 0;a--)

printf("\n%d",data[show[a]]);

printf("\n");

n--;

if (n > 0)

printf("\n");

}

return 0;

}