#include <bits/stdc++.h>
using namespace std;
long long n, m, x, y, z, k, sol, sum, ans, l, r, xx, yy, a[1000000], b[1000000];
vector<long long> v1;
vector<long long> v2;
pair<long long, pair<long long, long long> > pp[1000000];
pair<long long, long long> p[1000000];
map<long long, long long> ma;
string s1, s2, s;
char c;
int main() {
  cin >> m;
  while (m--) {
    cin >> s >> s1;
    map<char, long long> mm;
    bool b1 = 0;
    for (int i = 0; i < s1.size(); i++) {
      x = 0;
      b1 = 0;
      for (int tt = 0; tt < s.size(); tt++) mm[s[tt]]++;
      for (int q = i; q < s1.size(); q++) {
        if (mm[s1[q]] > 0) {
          mm[s1[q]]--;
          x = 1;
        } else if (x)
          break;
      }
      for (int tt = 0; tt < s.size(); tt++) {
        if (mm[s[tt]] != 0) {
          b1 = 1;
          mm[s[tt]] = 0;
        }
      }
      if (b1 == 0) {
        break;
      }
    }
    if (b1 == 0)
      cout << "YES" << endl;
    else
      cout << "NO" << endl;
  }
  return 0;
}
