The sequence $\{a_n\}_{n\geq 1}$ is defined by the recurrence relation $a_{n+2} = 7a_{n+1} - a_n$ for positive integers $n$, with initial values $a_1 = 1$ and $a_2 = 8$. Another sequence, $\{b_n\}$, is defined by the recurrence relation $b_{n+2} = 3b_{n+1} - b_n$ for positive integers $n$, with initial values $b_1 = 1$ and $b_2 = 2$. Find $\gcd(a_{5000}, b_{501})$.

Let's think step by step and output the final answer within \boxed{}.
user