#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  while (t--) {
    char h[101], p[101];
    cin >> p >> h;
    int lgH = strlen(h), lgP = strlen(p);
    int i = 0, found = 0;
    while (i < lgH) {
      char copie[101], *P;
      strcpy(copie, p);
      int j = i, cnt = 0;
      while (strchr(copie, h[j]) && j < i + lgP && j < lgH) {
        cnt++;
        P = strchr(copie, h[j]);
        int pos = P - copie;
        copie[pos] = '*';
        j++;
      }
      if (cnt == lgP) {
        found = 1;
        break;
      }
      i++;
    }
    if (found)
      cout << "YES\n";
    else
      cout << "NO\n";
  }
  return 0;
}
