#K42197. Separate Linked List Values

    ID: 27034 Type: Default 1000ms 256MiB

Separate Linked List Values

Separate Linked List Values

You are given a singly linked list containing nodes with values that can be either integers or strings. Your task is to traverse the linked list and separate the values into two groups: one group for all integer values and the other group for all string values.

The input will start with an integer n indicating the number of nodes in the list, followed by n lines each containing a single value. If a value can be parsed as an integer, it should be treated as an integer; otherwise, it is a string.

Your program should output two lines: the first line contains all integer values in the order of appearance (separated by a space), and the second line contains all string values (separated by a space). If a group is empty, output an empty line.

For example, given the list: 1, apple, 2, banana, the program should output:

1 2
apple banana

inputFormat

The first line of input contains a single integer n (n ≥ 0) representing the number of nodes in the linked list. The following n lines each contain one value. A value is considered an integer if it can be entirely parsed as an integer, otherwise it is a string.

outputFormat

Output two lines. The first line should list all the integer values found in the linked list separated by a space. The second line should list all the string values separated by a space. If no integers or strings are found, output an empty line for that group.

## sample
4
1
apple
2
banana
1 2

apple banana

</p>