#include <bits/stdc++.h>
using namespace std;
void solve() {
  string s, h;
  cin >> s;
  int ct[26] = {0};
  for (int i = 0; i < s.size(); i++) ct[s[i] - 'a']++;
  cin >> h;
  int cnt, maxx = 0;
  for (int i = 0; i < h.size(); i++) {
    cnt = 0;
    int copy[26] = {0};
    for (int j = i; j < h.size(); j++) {
      if (ct[h[j] - 'a'] > 0 && copy[h[j] - 'a'] < ct[h[j] - 'a']) {
        cnt++;
        copy[h[j] - 'a']++;
      } else {
        maxx = max(cnt, maxx);
        cnt = 0;
      }
    }
    if (cnt > maxx) {
      maxx = cnt;
    }
  }
  if (maxx == s.size())
    cout << "YES\n";
  else
    cout << "NO\n";
}
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long int t;
  cin >> t;
  while (t--) {
    solve();
  }
}
