#include <bits/stdc++.h>
using namespace std;
template <class T>
void read(T& num) {
  char CH;
  bool F = false;
  for (CH = getchar(); CH < '0' || CH > '9'; F = CH == '-', CH = getchar())
    ;
  for (num = 0; CH >= '0' && CH <= '9';
       num = num * 10 + CH - '0', CH = getchar())
    ;
  F && (num = -num);
}
const int maxn = 1e5 + 5;
const int maxm = 3e6 + 100;
const int inf = 1e9;
const long long INF = ~0ULL >> 1;
const long long mod = 100000;
long long gcd(long long a, long long b) { return b == 0 ? a : gcd(b, a % b); }
inline long long mul(long long a, long long b) {
  long long c = a * b - (long long)((long double)a * b / mod + 0.5) * mod;
  return c < 0 ? c + mod : c;
}
char s1[maxn], s2[maxn];
vector<int> v[30];
int main() {
  int t;
  read(t);
  while (t--) {
    scanf("%s %s", s1, s2);
    for (int i = 0; i < 26; i++) v[i].clear();
    int len1 = strlen(s1), len2 = strlen(s2);
    for (int i = 0; i < len1; i++) {
      v[s1[i] - 'a'].push_back(i);
    }
    int la = -1, ans = 1;
    for (int i = 0; i < len2; i++) {
      int k = v[s2[i] - 'a'].size();
      if (k == 0) {
        ans = -1;
        break;
      }
      if (v[s2[i] - 'a'][k - 1] < la + 1) {
        la = -1;
        ans++;
      }
      int c =
          *lower_bound(v[s2[i] - 'a'].begin(), v[s2[i] - 'a'].end(), la + 1);
      la = c;
    }
    printf("%d\n", ans);
  }
  return 0;
}
