n=int(input())
while n!=0:
s1 = "".join(sorted(input()))
s2 = "".join(sorted(input()))
if len(s1) == len(s2):
if s1 in s2:
print("Yes")
else:
print("No")
else:
print("No")
n-=1
n=int(input())
while n!=0:
s1 = "".join(sorted(input()))
s2 = "".join(sorted(input()))
if len(s1) == len(s2):
if s1 in s2:
print("Yes")
else:
print("No")
else:
print("No")
n-=1