#include <bits/stdc++.h>
using namespace std;
const int INF = 1e9 + 100;
const long long int INF64 = (1LL << 61) + 100;
const long long int MOD = 1000 * 1000 * 1000 + 7;
long long int bpow(long long int a, long long int b) {
  if (b == 0) return 1;
  if (b == 1) return a % MOD;
  long long int r = bpow(a, b >> 1);
  r = (r * r) % MOD;
  return (r * (((b & 1) ? a : 1) % MOD)) % MOD;
}
long long int multInverse(long long int a) { return bpow(a, MOD - 2); }
long long int modMult(long long int a, long long int b) {
  return (a * b) % MOD;
}
long long int modSub(long long int a, long long int b) {
  a += MOD;
  long long int r = a - b;
  if (r >= MOD) return r - MOD;
  return r;
}
long long int modAdd(long long int a, long long int b) {
  long long int r = a + b;
  if (r >= MOD) return r - MOD;
  return r;
}
vector<int> poses[30];
int solveTest() {
  for (int i = 0; i < 30; i++) poses[i].resize(0);
  string s, t;
  cin >> s >> t;
  int n = s.length(), m = t.length();
  s = "#" + s;
  t = "#" + t;
  for (int i = 1; i <= n; i++) poses[s[i] - 'a'].push_back(i);
  for (int i = 1; i <= m; i++)
    if (poses[t[i] - 'a'].size() == 0) return -1;
  for (int i = 0; i < 30; i++) poses[i].push_back(INF);
  int ans = 0;
  int curPos = 0;
  for (int i = 1; i <= m;) {
    curPos = *upper_bound(poses[t[i] - 'a'].begin(), poses[t[i] - 'a'].end(),
                          curPos);
    if (curPos == INF) {
      curPos = 0;
      ans++;
      continue;
    }
    i++;
  }
  ans++;
  return ans;
}
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int tt;
  cin >> tt;
  while (tt--) {
    cout << solveTest() << "\n";
  }
  return 0;
}
