#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  string ch, bh;
  cin >> t;
  while (t--) {
    cin >> ch;
    cin >> bh;
    int len = ch.size();
    int len2 = bh.size();
    sort(ch.begin(), ch.end());
    if (len2 < len) {
      cout << "NO\n";
      continue;
    }
    int f = 0;
    string ans = "";
    for (int i = 0; i < len; i++) {
      ans += bh[i];
    }
    string anss = "";
    anss = ans;
    sort(anss.begin(), anss.end());
    if (anss == ch)
      cout << "YES\n";
    else {
      for (int i = len; i < len2; i++) {
        ans.erase(0, 1);
        ans += bh[i];
        anss = ans;
        sort(anss.begin(), anss.end());
        if (anss == ch) {
          f = 1;
          break;
        }
      }
      if (f == 0)
        cout << "NO\n";
      else
        cout << "YES\n";
    }
    ans.clear();
  }
  return 0;
}
