#include <bits/stdc++.h>
#pragma GCC optimize(3, "Ofast", "inline")
using namespace std;
const long long maxn = (long long)1e6 + 5;
const long long mod = (long long)1e9 + 7;
const long long inf = 0x3f3f3f3f3f3f3f3f;
long long sum[30][105];
long long tot[30];
char s[maxn];
signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  ;
  long long T;
  cin >> T;
  while (T--) {
    string p;
    cin >> p >> (s + 1);
    memset(sum, 0, sizeof(sum));
    for (long long i = 0; i < 30; ++i) tot[i] = 0;
    for (auto &i : p) ++tot[i - 'a'];
    bool flag = false;
    s[0] = '#';
    for (long long i = 1; i < strlen(s); ++i) {
      for (long long j = 0; j < 26; ++j) sum[j][i] = sum[j][i - 1];
      sum[s[i] - 'a'][i]++;
      for (long long j = 0; j < i; ++j) {
        bool t = true;
        for (long long k = 0; k < 26; ++k) {
          if (sum[k][i] - sum[k][j] != tot[k]) {
            t = false;
            break;
          }
        }
        if (t) {
          flag = true;
          break;
        }
      }
    }
    if (flag)
      cout << "YES";
    else
      cout << "NO";
    cout << '\n';
  }
  return 0;
}
