#include <bits/stdc++.h>
using namespace std;
void solve() {
  string s, t;
  cin >> s >> t;
  vector<int> need(26, 0);
  for (auto c : s) need[c - 'a']++;
  for (int i = 0; i < (int)(t.size()); i++) {
    vector<int> cnt(26, 0);
    for (int j = i; j < (int)(t.size()); j++) {
      ++cnt[t[j] - 'a'];
      if (cnt == need) {
        cout << "YES" << endl;
        return;
      }
    }
  }
  cout << "NO" << endl;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int _t;
  cin >> _t;
  for (int _q = 0; _q < _t; _q++) solve();
  return 0;
}
