#include #include #include #include #include #include #include #include #include using namespace std; using ll = long long; void makeCount(char* str, int* counts) { while (*str != '\0') { counts[*(str++) - '0'] += 1; } } int main() { cin.tie(nullptr); ios::sync_with_stdio(false); int n; cin >> n; char aStr[100] {}; char bStr[100] {}; char bigStr[100] {}; for (int i = 0; i < n; i++) { ll big, a, b; cin >> big >> a >> b; int smallCounts[10] {}; int bigCounts[10] {}; if (a * b != big) { cout << "NO\n"; continue; } lltoa(big, bigStr, 10); int bigLen = strlen(bigStr); if (bigLen % 2 != 0) { cout << "NO\n"; continue; } int k = bigLen / 2; lltoa(a, aStr, 10); lltoa(b, bStr, 10); if (strlen(aStr) != k || strlen(bStr) != k) { cout << "NO\n"; continue; } if (a % 10 != 0 && b % 10 != 0) { cout << "NO\n"; continue; } makeCount(aStr, smallCounts); makeCount(bStr, smallCounts); makeCount(bigStr, bigCounts); bool bad = false; for (int j = 0; j < n; j++) { if (smallCounts[j] != bigCounts[j]) { cout << "NO\n"; bad = true; break; } } if (!bad) { cout << "YES\n"; } } return 0; }