#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ii = pair<int, int>;
vector<string::iterator> p[200];
int main() {
  ios::sync_with_stdio(false), cin.tie(nullptr);
  int t;
  cin >> t;
  while (t--) {
    string s, t;
    cin >> s >> t;
    for (auto& i : p) i.clear();
    for (auto it = s.begin(); it != s.end(); ++it) {
      p[(int)*it].push_back(it);
    }
    bool ok = true;
    for (char c : t) {
      if (p[(int)c].empty()) {
        ok = false;
      }
    }
    if (!ok) {
      cout << -1 << "\n";
      continue;
    }
    int cnt = 0;
    auto it = t.begin();
    while (it != t.end()) {
      auto it2 = s.begin();
      while (true) {
        auto niter = lower_bound(p[(int)*it].begin(), p[(int)*it].end(), it2);
        if (niter == p[(int)*it].end())
          break;
        else
          it2 = *niter;
        ++it, ++it2;
      }
      cnt++;
    }
    cout << cnt << "\n";
  }
}
