#include <bits/stdc++.h>
using namespace std;
#pragma comment(linker, "/STACK:1024000000,1024000000")
inline long long read() {
  char tempt = getchar();
  long long x = 0, f = 0;
  while (tempt < '0' || tempt > '9') f |= tempt == '-', tempt = getchar();
  while (tempt >= '0' && tempt <= '9')
    x = x * 10 + tempt - '0', tempt = getchar();
  return f ? -x : x;
}
inline long long qmi(long long m, long long k, long long p) {
  long long res = 1 % p, t = m;
  while (k) {
    if (k & 1) res = res * t % p;
    t = t * t % p;
    k >>= 1;
  }
  return res;
}
const long long N = 1e5 + 10;
char s[N], t[N];
long long ne[N][26];
signed main() {
  long long T;
  cin >> T;
  for (register long long _ = 1; _ <= T; _++) {
    scanf("%s", s + 1);
    scanf("%s", t + 1);
    long long lens = strlen(s + 1);
    long long lent = strlen(t + 1);
    reverse(s + 1, s + 1 + lens);
    reverse(t + 1, t + 1 + lent);
    for (long long i = 0; i < 26; i++) ne[lens + 1][i] = lens + 1;
    for (long long i = lens; i; i--) {
      for (long long j = 0; j < 26; j++) ne[i][j] = ne[i + 1][j];
      ne[i][s[i] - 'a'] = i;
    }
    long long now = 1;
    bool flag = true;
    bool f = false;
    long long cnt = 0;
    for (long long i = 1; i <= lent; i++) {
      if (ne[now][t[i] - 'a'] > lens) {
        now = 1;
        if (f == true) {
          cnt++;
          i--;
          f = false;
        } else {
          flag = false;
          break;
        }
      } else {
        if (i == lent) cnt++;
        flag = true;
        f = true;
        now = ne[now][t[i] - 'a'] + 1;
      }
    }
    if (!flag)
      cout << -1 << endl;
    else
      cout << cnt << endl;
  }
}
