#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int t = 1;
  cin >> t;
  while (t--) {
    string s, t;
    cin >> s >> t;
    long long int ns = s.length();
    long long int nt = t.length();
    vector<vector<long long int> > cs(26);
    for (long long int i = 0; i < ns; i++) {
      cs[s[i] - 'a'].push_back(i);
    }
    long long int start = -1;
    long long int ans = 1;
    long long int f = 0;
    for (long long int i = 0; i < nt; i++) {
      if (cs[t[i] - 'a'].empty()) {
        f = 1;
        break;
      } else {
        auto it =
            lower_bound(cs[t[i] - 'a'].begin(), cs[t[i] - 'a'].end(), start);
        if (it == cs[t[i] - 'a'].end()) {
          ans += 1;
          start = *(cs[t[i] - 'a'].begin());
        } else if (*it == start) {
          it++;
          if (it == cs[t[i] - 'a'].end()) {
            ans += 1;
            start = *(cs[t[i] - 'a'].begin());
          } else {
            start = *it;
          }
        } else {
          start = *it;
        }
      }
    }
    if (f == 1) {
      cout << -1 << "\n";
    } else {
      cout << ans << "\n";
    }
  }
}
