#include <bits/stdc++.h>
using namespace std;
char a[110], b[110];
int pass[35], win[35];
bool compare() {
  for (int i = 0; i <= 26; i++)
    if (pass[i] != win[i]) return false;
  return true;
}
int main() {
  int t, l1, l2, p;
  bool ban;
  scanf("%d ", &t);
  while (t > 0) {
    gets(a);
    gets(b);
    l1 = strlen(a);
    l2 = strlen(b);
    if (l2 >= l1) {
      for (int i = 0; i < 27; i++) {
        pass[i] = 0;
        win[i] = 0;
      }
      for (int i = 0; i < l1; i++) pass[a[i] - 'a']++;
      for (int i = 0; i < l1; i++) win[b[i] - 'a']++;
      p = 0;
      ban = compare();
      for (int i = l1; ban == false && i < l2; i++) {
        win[b[i] - 'a']++;
        win[b[p] - 'a']--;
        p++;
        ban = compare();
      }
      if (ban == true)
        printf("YES\n");
      else
        printf("NO\n");
    } else
      printf("NO\n");
    t--;
  }
  return 0;
}
