#include <bits/stdc++.h>
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
using namespace std;
void solve() {
  string p, h;
  cin >> p >> h;
  swap(p, h);
  sort(h.begin(), h.end());
  for (long long i = 0; i + h.size() - 1 < p.size(); ++i) {
    string temp = p.substr(i, h.size());
    sort(temp.begin(), temp.end());
    if (temp == h) {
      cout << "YES\n";
      return;
    }
  }
  cout << "NO\n";
}
signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long t;
  cin >> t;
  while (t--) solve();
}
