#include <bits/stdc++.h>
using namespace std;

void solve() {
	int x, y;
	cin >> x >> y;
	if (x + 1 == y) {
		cout << "YES" << endl;
	} else if (x <= y) {
		cout << "NO" << endl;
	} else {
		int diff = x - y + 1;
		if (diff % 9 == 0) cout << "YES" << endl;
		else cout << "NO" << endl;
	}
}

int main() {
	int t;
	cin >> t;
	while (t--) solve();
}