First and Last Occurrence

EASY · C · 2000ms

Since some book IDs are duplicated across branch copies, Arif now needs both the FIRST and LAST shelf positions of a requested ID. Read a sorted array (may contain duplicates) of N integers and a query X. Print the first and last 1-indexed positions of X, or "-1 -1" if not present.

Input

Line1: N. Line2: N sorted integers. Line3: X.

Output

Two integers: first and last positions.

Constraints

1 ≤ N ≤ 10^5

Sample Input

6
1 2 2 2 3 5
2

Sample Output

2 4
main.c
Loading editor…

Write C, then Run (custom I/O) or Submit (sample tests). ⌘/Ctrl+Enter submits.

First and Last Occurrence · DIU ContestHub