#include <bits/stdc++.h>
using namespace std;
template <typename Arg1>
void debug_out(const char* name, Arg1&& arg1) {
  cout << name << " = " << arg1 << " ]" << '\n';
}
template <typename Arg1, typename... Args>
void debug_out(const char* names, Arg1&& arg1, Args&&... args) {
  const char* comma = strchr(names + 1, ',');
  cout.write(names, comma - names) << " = " << arg1 << ",";
  debug_out(comma + 1, args...);
}
mt19937_64 rang(
    chrono::high_resolution_clock::now().time_since_epoch().count());
const long long mod = 1e9 + 7;
const long long N = 3e5, M = N;
void Solve_main() {
  long long n, m, k;
  long long i, j;
  string s, t;
  cin >> s >> t;
  n = ((long long)(s).size());
  m = ((long long)(t).size());
  vector<set<long long>> flag(26);
  for (i = (0); i < (n); ++i) {
    flag[s[i] - 'a'].insert(i);
  }
  long long cnt = 1, prev = -1;
  for (i = (0); i < (m); ++i) {
    if (((long long)(flag[t[i] - 'a']).size()) == 0) {
      cout << -1 << '\n';
      return;
    }
    auto it = flag[t[i] - 'a'].upper_bound(prev);
    if (it == flag[t[i] - 'a'].end()) {
      cnt++;
      prev = -1;
      i--;
      continue;
    } else {
      prev = *it;
    }
  }
  cout << cnt << '\n';
}
int32_t main() {
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  srand(chrono::high_resolution_clock::now().time_since_epoch().count());
  long long tc = 1;
  cin >> tc;
  while (tc--) {
    Solve_main();
  }
  cerr << "[time:" << 1.0 * clock() / CLOCKS_PER_SEC << "s] ";
  return 0;
}
