#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  while (t--) {
    string s, p;
    bool k = 0;
    cin >> s >> p;
    sort(s.begin(), s.end());
    for (int i = 0; i < p.length(); i++) {
      string z = "";
      for (int j = i; j < s.length() + i; j++) {
        z += p[j];
      }
      sort(z.begin(), z.end());
      if (s == z) k = 1;
    }
    if (k)
      cout << "YES";
    else
      cout << "NO";
    cout << endl;
  }
  return 0;
}
