CSES - Coin Piles

Xem dạng PDF

Gửi bài giải

Điểm: 1,00 (OI)
Giới hạn thời gian: 1.0s
Giới hạn bộ nhớ: 512M
Input: stdin
Output: stdout

Nguồn bài:
https://cses.fi/problemset/task/1754
Dạng bài
Ngôn ngữ cho phép
C, C++, Java, Kotlin, Pascal, PyPy, Python, Scratch

You have two coin piles containing ~a~ and ~b~ coins. On each move, you can either remove one coin from the left pile and two coins from the right pile, or two coins from the left pile and one coin from the right pile.

Your task is to efficiently find out if you can empty both the piles.

Input

  • The first input line has an integer ~t~: the number of tests.

After this, there are ~t~ lines, each of which has two integers ~a~ and ~b~: the numbers of coins in the piles.

Output

  • For each test, print "YES" if you can empty the piles and "NO" otherwise.

Constraints

  • ~1 \le t \le 10^5~
  • ~0 \le a, b \le 10^9~

Example Input

3
2 1
2 2
3 3

Example Output

YES
NO
YES

Bình luận

Hãy đọc nội quy trước khi bình luận.


Không có bình luận tại thời điểm này.