#include <bits/stdc++.h>
using namespace std;
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) {
  cerr << name << " : " << arg1 << '\n';
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << " : " << arg1 << " | ";
  __f(comma + 1, args...);
}
int inf = 0x3f3f3f3f;
long long infl = 0x3f3f3f3f3f3f3f3fLL;
long double infd = 1.0 / 0.0;
const long long MOD = 1e9 + 7;
const long double pi = 2 * acos(0.0);
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int tt = 1;
  cin >> tt;
  for (int tcs = 1; tcs < tt + 1; tcs++) {
    string s, t;
    cin >> s >> t;
    vector<set<int>> v(26);
    for (int i = 0; i < (int)s.size(); i++) v[s[i] - 'a'].insert(i);
    int ans = 0;
    for (auto c : t)
      if ((int)v[c - 'a'].size() == 0) {
        ans = -1;
        break;
      }
    if (ans) {
      cout << ans << '\n';
      continue;
    }
    int i = 0;
    int pos = -1;
    while (i < (int)t.size()) {
      int f = t[i++] - 'a';
      auto x = v[f].upper_bound(pos);
      if (x == v[f].end()) {
        ans++;
        pos = -1;
        i--;
        continue;
      }
      pos = *x;
    }
    if (pos == -1)
      ;
    else
      ans++;
    cout << ans << '\n';
  }
  return 0;
}
