Have you ever seen the wave? It's a wonderful view of nature. Little Q is attracted to such wonderful thing, he even likes everything that looks like wave. Formally, he defines a sequence $a_1,a_2,...,a_n$ as ''wavel'' if and only if $a_1<a_2>a_3<a_4>a_5<a_6...$
Picture from Wikimedia Commons
Now given two sequences $a_1,a_2,...,a_n$ and $b_1,b_2,...,b_m$, Little Q wants to find two sequences $f_1,f_2,...,f_k(1\leq f_i\leq n,f_i<f_{i+1})$ and $g_1,g_2,...,g_k(1\leq g_i\leq m,g_i<g_{i+1})$, where $a_{f_i}=b_{g_i}$ always holds and sequence $a_{f_1},a_{f_2},...,a_{f_k}$ is ''wavel''.
Moreover, Little Q is wondering how many such two sequences $f$ and $g$ he can find. Please write a program to help him figure out the answer.