#include<stdio.h>#include<stdlib.h>//单链表逆置typedefstructNode*node;structNode{int data;
node next;};
node createList(){
node head, a, b;
head =NULL;int n, num;scanf("%d",&n);for(int i =0; i < n; i++){scanf("%d",&num);
b =(node)malloc(sizeof(node));
b->data = num;
b->next =NULL;if(head==NULL){
a = head = b;}else{
a->next = b;
a = b;}}return head;}
node reverseList(node head){
node a, b, c;
a = c =NULL;
b = head;while(b){
c = b->next;
b->next = a;
a = b;
b = c;}return a;}voidprintList(node head){
node p = head;while(p->next){printf("%d ", p->data);
p = p->next;}printf("%d\n", p->data);}intmain(){
node head;int m;scanf("%d",&m);for(int i =0; i < m; i++){
head =createList();
head =reverseList(head);printList(head);}return0;}