I add new line after every TC but now im getting TLE pls help

import java.util.Scanner;

public class Main {
private Node head;
private Node tail;
private int size;

private class Node {
	int data;
	Node next;

	Node(int data, Node next) {
		this.data = data;
		this.next = next;
	}
}

public Main() {
	this.head = null;
	this.tail = null;
	this.size = 0;
}

public int size() {
	return this.size;
}

public void addLast(int data) {
	Node node = new Node(data, null);

	if (this.size() == 0) {
		this.head = node;
		this.tail = node;
	} else {
		this.tail.next = node;
		this.tail = node;
	}
	this.size++;
}

public static void display(Node temp) {

	while (temp != null) {
		System.out.print(temp.data + " ");
		temp = temp.next;
	}
	

}

static Node merge(Node h1, Node h2) {
	if (h1 == null) {
		return h2;
	}
	if (h2 == null) {
		return h1;
	}

	if (h1.data < h2.data) {
		h1.next = merge(h1.next, h2);
		return h1;
	} else {
		h2.next = merge(h1, h2.next);
		return h2;
	}
}

public static void main(String[] args) {
	Scanner scanner = new Scanner(System.in);
	int T = scanner.nextInt();
	Main list1 = new Main();
	Main list2 = new Main();
	while (T-- > 0) {

		int S1 = scanner.nextInt();
		for (int i = 0; i < S1; i++) {
			list1.addLast(scanner.nextInt());
		}

		int S2 = scanner.nextInt();
		for (int i = 0; i < S2; i++) {
			list2.addLast(scanner.nextInt());
		}
		Node head = merge(list1.head, list2.head);
		display(head);
		System.out.println();
	}

}

}

hey
Try to Start from the head of the two lists and consume that element from the two of the Lists first which is smaller and add that element into the ans list. After consuming, Advance the iterator to point to the next node in the list. The size of the Lists can be different so after consuming elements simultaneously from the two list, We need to check if any of the two list is empty, and add the elements of that list as it is in the answer List.

refer to this approach to tackle the tle