AMC 10A 2021 Spring Problem 20

In how many ways can the sequence 1,2,3,4,5 be rearranged so that no three consecutive terms are increasing and no three consecutive terms are decreasing?

Answer Choices
A. 10
B. 18
C. 24
D. 32
E. 44