#include <bits/stdc++.h>
using namespace std;
const long long INF = 0x7fffffffffffffff;
const int inf = 0x7fffffff;
const int N = 1e5 + 5;
clock_t start, finish;
void time_in() { start = clock(); }
void time_out() {
  finish = clock();
  double tim = (double)(finish - start) / CLOCKS_PER_SEC;
  printf("Running time is %lf\n", tim);
}
inline long long mul(long long a, long long b) {
  long long s = 0;
  while (b) {
    if (b & 1) s = (s + a) % 1000000007;
    a = (a << 1) % 1000000007;
    b >>= 1;
  }
  return s % 1000000007;
}
inline long long pow_mul(long long a, long long b) {
  long long s = 1;
  while (b) {
    if (b & 1) s = mul(s, a);
    a = mul(a, a);
    b >>= 1;
  }
  return s;
}
inline long long poww(long long a, long long b) {
  long long s = 1;
  while (b) {
    if (b & 1) s = (s * a) % 1000000007;
    a = (a * a) % 1000000007;
    b >>= 1;
  }
  return s % 1000000007;
}
inline bool read(int &ret) {
  char c = getchar();
  int sgn;
  if (c == EOF) return 0;
  while (c != '-' && (c < '0' || c > '9')) c = getchar();
  sgn = ((c == '-') ? -1 : 1);
  ret = ((c == '-') ? 0 : (c - '0'));
  while (c = getchar(), c >= '0' && c <= '9') ret = ret * 10 + (c - '0');
  ret *= sgn;
  return 1;
}
inline void write(int x) {
  if (x > 9) write(x / 10);
  putchar(x % 10 + '0');
}
inline long long phi(long long x) {
  long long ans = x;
  for (long long i = 2; i * i <= x; i++)
    if (x % i == 0) {
      ans -= ans / i;
      while (x % i == 0) x /= i;
    }
  if (x > 1) ans -= ans / x;
  return ans;
}
inline long long inv(long long down) {
  return down == 1
             ? 1
             : ((1000000007 - 1000000007 / down) * inv(1000000007 % down)) %
                   1000000007;
}
int t, cas;
int n, m, k;
char s[N], ss[N];
int a[26][N];
int cn[30];
int find(int x, int w) {
  int l = 0, r = cn[x] - 1;
  int ans = -1;
  while (l <= r) {
    int mid = (l + r) >> 1;
    if (a[x][mid] >= w) {
      ans = a[x][mid] + 1;
      r = mid - 1;
    } else {
      l = mid + 1;
    }
  }
  return ans;
}
int main() {
  scanf("%d", &t);
  while (t--) {
    memset(cn, 0, sizeof(cn));
    scanf("%s%s", s, ss);
    n = strlen(s);
    m = strlen(ss);
    for (int i = 0; i < n; i++) {
      int x = s[i] - 'a';
      a[x][cn[x]++] = i;
    }
    int v = 0, ans = 1;
    for (int i = 0; i < m; i++) {
      int x = ss[i] - 'a';
      if (cn[x] == 0) {
        printf("-1\n");
        goto e;
      }
      int y = find(x, v);
      if (y == -1) {
        ans++;
        v = find(x, 0);
      } else
        v = y;
    }
    printf("%d\n", ans);
  e:;
  }
}
