Islands in the Data Stream
Given a sequence of integers , an island in the sequence is a contiguous subsequence for which each element is greater than the elements immediately before and after the subsequence. In the examples below, each island in the sequence has a bracket below it. The bracket for an island contained within another island is below the bracket of the containing island.
Write a program that takes as input a sequence of non-negative integers, in which each integer differs from the previous integer by at most , and outputs the number of islands in the sequence.
Input
The first line contains the number of data sets that follow. Each data set should be processed identically and independently.
Each data set consists of a single line. It contains the data set number , followed by non-negative integers separated by a single space. The first and last integers in the sequence will be . Each integer will differ from the previous integer by at most .
Output
For each data set print a line that consists of the data set number , followed by a single space followed by the number of islands in the sequence.