#include #include #include #include #include #include #include #include #include int main() { std::ios::sync_with_stdio(false); std::cin.tie(nullptr); std::string line; std::istringstream iss; int t = 0; std::cin >> t; std::cin.get(); for (int i = 0; i < t; i++) { std::getline(std::cin, line); iss.clear(); iss.str(line); int64_t n, a, b; iss >> n >> a >> b; std::string n_ = std::to_string(n); //std::cout << "n_: " << n_ << "\n"; std::string a_ = std::to_string(a); //std::cout << "a_: " << a_ << "\n"; std::string b_ = std::to_string(b); //std::cout << "b_: " << b_ << "\n\n-----\n"; // std::cerr << "\n=== " << line << " ===\n\n"; if (a * b != n) { std::cout << "NO\n"; // std::cout << "soucin: " << a_.length() << ", " << b_.length() << "\n"; continue; } if (a_.length() != b_.length() || n_.length() != 2 * a_.length()) { std::cout << "NO\n"; // std::cout << "delka: " << a_ << " " << a_.length() << ", " << b_ << " " << b_.length() << "\n"; continue; } if (a % 10 == 0 && b % 10 == 0) { std::cout << "NO\n"; // std::cout << "modulo: " << a_.length() << ", " << b_.length() << "\n"; continue; } std::set setN; std::set setC; for (size_t j = 0; j < n_.length(); ++j) { setN.insert(n_[j]); } std::string cat = a_ + b_; // std::cout << "cat: " << cat << ", " << cat.length() << '\n'; for (size_t j = 0; j < cat.length(); ++j) { setC.insert(cat[j]); } // std::cout << "setN: "; // for (auto s : setN) { // std::cout << s << ", "; // } // std::cout << "\nSetC: "; // for (auto s : setC) { // std::cout << s << ", "; // } // std::cout << "\n"; if (setC.size() != setN.size()) { goto umri; } if (setC != setN) goto umri; std::cout << "YES\n"; continue; umri: std::cout << "NO\n"; } return 0; }