N = int(eval(input()))

selector = 0

count = 1

A = [int(i) for i in input().split()]

pre_num = A[0]

for num in A[1:]:

    if selector == 0:

        selector = num - pre_num

    if selector > 0:

        if num < pre_num:

            selector = 0

            count += 1

    if selector < 0:

        if num > pre_num:

            selector = 0

            count += 1

    pre_num = num

print(count)
N = int(eval(input()))

sub = 0

count = 1

A = [int(i) for i in input().split()]

if N > 1:

	pre_num = A[1]

	pre_sub = A[1] - A[0]

for num in A[2:]:

    if not pre_num == num:

        if pre_sub * (num - pre_num) < 0:

            count += 1

            pre_sub = 0

        else:

          	pre_sub = num - pre_num

        pre_num = num

print(count)
N = int(eval(input()))
selector = 0
count = 1
A = [int(i) for i in input().split()]
pre_num = A[0]
for num in A[1:]:
    if selector == 0:
        selector = num - pre_num
    if selector > 0:
        if num < pre_num:
            selector = 0
            count += 1
    if selector < 0:
        if num > pre_num:
            selector = 0
            count += 1
    pre_num = num
print(count)

N = int(eval(input()))
sub = 0
count = 1
A = [int(i) for i in input().split()]
if N > 1:
    pre_num = A[1]
    pre_sub = A[1] - A[0]
for num in A[2:]:
    if not pre_num == num:
        if pre_sub * (num - pre_num) < 0:
            count += 1
            pre_sub = 0
        else:
            pre_sub = num - pre_num
        pre_num = num
print(count)

-selector = 0 +sub = 0 -pre_num = A[0] -for num in A[1:]: -    if selector == 0: -        selector = num - pre_num -    if selector > 0: -        if num < pre_num: -            selector = 0 +if N > 1: +    pre_num = A[1] +    pre_sub = A[1] - A[0] +for num in A[2:]: +    if not pre_num == num: +        if pre_sub * (num - pre_num) < 0: -    if selector < 0: -        if num > pre_num: -            selector = 0 -            count += 1 -    pre_num = num +            pre_sub = 0 +        else: +            pre_sub = num - pre_num +        pre_num = num