#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7;
const long long INF = 9e18;
const int inf = 2147483647;
long long phi(long long n) {
  long long ans = n;
  for (long long i = 2; i * i <= n; i++) {
    if (n % i == 0) {
      ans = ans / i * (i - 1);
      while (n % i == 0) n /= i;
    }
  }
  if (n > 1) ans = ans / n * (n - 1);
  return ans;
}
long long qpow(long long a, long long b, long long mod) {
  long long r = 1;
  for (; b; b >>= 1) {
    if (b & 1) r = (r * a) % mod;
    a = (a * a) % mod;
  }
  return r;
}
long long C(int n, int m) {
  if (m < n - m) m = n - m;
  long long ans = 1;
  for (int i = m + 1; i <= n; i++) ans *= i;
  for (int i = 1; i <= n - m; i++) ans /= i;
  return ans;
}
const int N = 1e5 + 5;
char p[105], h[105];
int mp[26], a[26];
void work() {
  int T;
  scanf("%d", &T);
  while (T--) {
    scanf("%s%s", p + 1, h + 1);
    int n = strlen(p + 1), m = strlen(h + 1);
    if (n > m) {
      puts("NO");
      continue;
    }
    memset(a, 0, sizeof(a));
    for (int i = 1; i <= n; i++) a[p[i] - 'a']++;
    int ok = 1;
    for (int i = 1; i <= m; i++) {
      ok = 1;
      for (int j = 0; j < 26; j++) mp[j] = a[j];
      for (int j = i, cnt = 1; j <= m; j++) {
        if (cnt > n) break;
        cnt++;
        mp[h[j] - 'a']--;
      }
      for (int j = 0; j < 26; j++) {
        if (mp[j]) {
          ok = 0;
          break;
        }
      }
      if (ok) break;
    }
    puts(ok ? "YES" : "NO");
  }
}
int main() {
  work();
  return 0;
}
