You are required to do sorting after inserting an element.
The first line contains a non-negative integer N that specifies the number of testcases. The first line of testcases contains a non-negative integer P (0<=op count<65536) that specifies the number of operations. The second line for testcases contains operations. Each operations (C, I or S) are separated by a space. Each testcases are separated by a newline character (\n).
C stands for “clear”. Free all nodes in the list.
I stands for “insert and sort”, following by a non-negative integer (insert value, 0<=insert value<65536). Insert a node and sort the list. Sort the list in ascending order. (Hint: You can insert a node on the appropriate position.)
S stands for “show”. Print the value of all nodes in the list. Separate every prints by a whitespace character. If the list is empty, do not print anything.
Print a space after doing S operations (if S has printed something).
e.g. If linked list has 2 elements (1, 2), print "1 2 ".