687. Partition List

0

Easy

Given the *head* of a linked list and a value *x*, partition the linked list such that all nodes with values less than *x* come before nodes with values greater than or equal to *x*. The original relative order of the nodes in each partition should be preserved.

Input Format

The first line contains two space-separated integers, N and X, representing the number of nodes in the linked list and the value of x, respectively.
The second line contains N space-separated integers, representing the values of the nodes in the linked list.

Output Format

Print the updated linked list.

Example

Input

6 3 1 4 3 2 5 2

Output

1 2 2 4 3 5

Constraints

The number of nodes in the list is between 0 and 200, inclusive.
Each node's value is between -100 and 100, inclusive.
The value of x is between -200 and 200, inclusive.
Loading...

View Submissions

Console