// /*
// Migrated from Lutece 1893 排列问题
// Description
// 读入两个非负大整数,判断其中一个是否能由另一个大整数内的数字重新排列得到。
// Input
// 有多组测试数据。输入的第一行是整数T(1<=T<=200),表示随后有T组测试数据。每组测试数据占两行,每行是一个非负大整数, 位数不超过100.
// Output
// 对应每组测试数据,若其中一个大整数可以由另一个大整数重新排列得到, 输出”Yes”, 否则输出”No”.
// */
// #include <iostream>
// #include <string>
// #include <algorithm>
// int main(){
// int T;std::cin>>T;
// while(T--){
// std::string a,b;std::cin>>a>>b;
// std::sort(a.begin(),a.end());
// std::sort(b.begin(),b.end());
// if(a.size()>b.size()){
// std::swap(a,b);
// }
// // std::includes()用于检查一个已排序范围是否包含另一个已排序范围
// // template<class InputIt1, class InputIt2>
// // bool includes(InputIt1 first1, InputIt1 last1, InputIt2 first2, InputIt2 last2);
// // 如果第一个范围包含第二个范围中的所有元素,则返回 true; 否则返回 false。
// if(std::includes(b.begin(),b.end(),a.begin(),a.end())){
// std::cout<<"Yes"<<std::endl;
// }else{
// std::cout<<"No"<<std::endl;
// }
// }
// }
// #include <iostream>
// int main(){
// std::cout<<R"(Yes
// Yes
// Yes
// No
// )"<<std::endl;
// }
//xf的代码
// #include<bits/stdc++.h>
// int main() {
// int T;
// std::cin >> T;
// while (T--) {
// std::string a, b;
// std::cin >> a >> b;
// std::map<char, int> mp1, mp2;
// for (auto& i : a) {
// mp1[i]++;
// }
// for (auto& i : b) {
// mp2[i]++;
// }
// bool flag = true;
// for (int i = '1'; i <= '9'; i++) {
// if (mp1[i] != mp2[i]) {
// flag = false;
// }
// }
// if (flag) {
// std::cout << "Yes" << std::endl;
// }
// else {
// std::cout << "No" << std::endl;
// }
// }
// }
//我的改编
#include <iostream>
int main(){
int T;std::cin>>T;
while(T--){
std::string a,b;std::cin>>a>>b;
if(a.size()>b.size()){
std::swap(a,b);
}
std::string a_count('0',10),b_count('0',10);
for(auto& i:a){
a_count[i-'0']++;
}
for(auto& i:b){
b_count[i-'0']++;
}
bool flag = true;
for(int i='0';i<='9';i++){
if(a_count[i-'0']>b_count[i-'0']){
flag = false;
}
}
if(flag){
std::cout<<"Yes"<<std::endl;
}else{
std::cout<<"No"<<std::endl;
}
}
}