In this question, we can dispart the sequence, then you will obtain $$$n$$$ pairs of $$$a_i$$$ and $$$b_i$$$. To judge whether the answer is YES or NO, we can compare the steps of making $$$a_i$$$ equals to $$$0$$$. Let the steps to be $$$k_1, k_2, \dots, k_{n-1}, k_n$$$, if $$$k_1\equiv k_2\equiv \dots \equiv k_{n - 1}\equiv k_n\pmod{3}$$$, then the answer is YES, otherwise it's NO. The reason is when $$$a_i = 0, b_i = y$$$, then after two more operations, it will be $$$a_i = 0, b_i = y$$$ again and the state of these two operations are $$$a_i = y, b_i = y$$$ and $$$a_i = y, b_i = 0$$$, so it's a cycle with a period of three.
Then, the main problem is how to calculate the value of $$$k_i\bmod 3$$$. The most violent way is to do it step by step, however it will be $$$\color{red}{Time\enspace limit\enspace exceed}$$$. Accordingly, this way is not desirable. Now, let $$$x = a_i$$$ and $$$y = b_i$$$, if $$$y \gt x$$$, then after $$$3$$$ operations, $$$b_i$$$ will equals to $$$y - 2x$$$, and after $$$6$$$ operations, $$$b_i$$$ will equals to $$$y - 4x$$$, and so on. Accordingly, we can let $$$y = y \bmod 2x$$$ and because of the period is $$$3$$$, then it won't change the value of $$$k_i \bmod 3$$$. Otherwise, we just do the violent operation. The time complexity will be about $$$O(n\log n)$$$ on account of the modulo operation. It will be much faster than before!