Consider a sequence defined recursively by \( a_1 = 2 \) and \( a_{n+1} = 3a_n + 1 \) for \( n \geq 1 \). Determine the value of \( a_{10} \mod 7 \). Let's think step by step and output the final answer within \boxed{}.
user