#include <bits/stdc++.h>
using namespace std;
int main() {
  string li, ne;
  int n;
  cin >> n;
  while (n--) {
    cin >> li >> ne;
    int x = li.size();
    int y = ne.size();
    bool r = false;
    for (int i = 0; i < y - x + 1; ++i) {
      bool flag = true;
      vector<int> vex(26, 0);
      for (char c : li) vex[c - 'a'] += 1;
      for (int j = 0; j < x; ++j) vex[ne[i + j] - 'a'] -= 1;
      for (int c : vex)
        if (c) flag = false;
      r |= flag;
    }
    cout << (r ? "YES\n" : "NO\n");
  }
  return 0;
}
