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)
_ = int(eval(input()))

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

selector = 0

count = 1

pre_a = A[0]

for a in A[1:]:

    if selector == 0:

        selector = a - pre_a

    elif selector * (a - pre_a) < 0:

        count += 1

        selector = 0

    pre_a = a

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)

_ = int(eval(input()))
A = [int(a) for a in input().split()]
selector = 0
count = 1
pre_a = A[0]
for a in A[1:]:
    if selector == 0:
        selector = a - pre_a
    elif selector * (a - pre_a) < 0:
        count += 1
        selector = 0
    pre_a = a
print(count)

-N = int(eval(input())) -sub = 0 +_ = int(eval(input())) +A = [int(a) for a in input().split()] +selector = 0 -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 +pre_a = A[0] +for a in A[1:]: +    if selector == 0: +        selector = a - pre_a +    elif selector * (a - pre_a) < 0: +        count += 1 +        selector = 0 +    pre_a = a