2015 AIME I Problem 9

Let S be the set of all ordered triples of integers \left(a_{1}, a_{2}, a_{3}\right) with 1 \leq a_{1}, a_{2}, a_{3} \leq 10. Each ordered triple in S generates a sequence according to the rule a_{n}= a_{n-1} \cdot\left|a_{n-2}-a_{n-3}\right| for n \geq 4. Find the number of such sequences for which a_{n}=0 for some n.