#include <bits/stdc++.h>
using namespace std;
const int MAXM = 1e5 + 5;
const int MAXN = 1e6 + 5;
const int INF = 1e7 + 9;
const int MOD = 1e9 + 9;
const int MX = 1e9;
const int X[] = {1, -1, 0, 0}, Y[] = {0, 0, 1, -1};
int main() {
  int q;
  cin >> q;
  while (q--) {
    string s, t;
    cin >> s >> t;
    sort(s.begin(), s.end());
    bool ok = false;
    for (int i = 0; i < t.size(); ++i) {
      string v = t.substr(i, s.size());
      sort(v.begin(), v.end());
      if (v == s) {
        ok = true;
        puts("YES");
        break;
      }
    }
    if (!ok) puts("NO");
  }
}
