#C9566. Target in a Fibonacci-like Sequence

    ID: 53673 Type: Default 1000ms 256MiB

Target in a Fibonacci-like Sequence

Target in a Fibonacci-like Sequence

You are given three integers A, B, and T. Using A and B as the first two terms of a sequence, the remainder of the sequence is generated by the recurrence:

\(S_0 = A,\ S_1 = B,\ S_n = S_{n-2} + S_{n-1}\) for \(n \ge 2\).

Your task is to determine whether the target value T appears in the sequence. If it does, output "YES"; otherwise, output "NO".

Note: The sequence is generated until the current term exceeds T. It is possible that T is equal to either of the first two terms.

inputFormat

The input begins with an integer \(Q\) on the first line, representing the number of queries. Each of the following \(Q\) lines contains three integers \(A\), \(B\), and \(T\) separated by spaces.

\(1 \le Q \le 10^5\); the values of \(A\), \(B\), and \(T\) can be assumed to fit in a standard 32-bit integer.

outputFormat

For each query, output a single line with the answer: "YES" if the target value \(T\) is present in the sequence, or "NO" otherwise.

## sample
5
1 1 5
0 1 8
3 5 14
2 2 12
5 8 21
YES

YES NO NO YES

</p>