#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
const int alph = 256;
signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int q;
  cin >> q;
  while (q--) {
    string second, t;
    cin >> second >> t;
    vector<vector<int> > idxes(alph);
    for (int i = 0; i < second.size(); i++) {
      idxes[second[i]].push_back(i);
    }
    int ans = 0;
    for (int i = 0; i < t.size(); i++) {
      int j = i;
      int mxidx = -1;
      for (j; j < t.size(); j++) {
        int pos =
            upper_bound((idxes[t[j]]).begin(), (idxes[t[j]]).end(), mxidx) -
            idxes[t[j]].begin();
        if (pos == idxes[t[j]].size() || idxes[t[j]].size() == 0) {
          break;
        }
        mxidx = idxes[t[j]][pos];
      }
      if (j != t.size() && idxes[t[j]].size() == 0) {
        ans = -1;
        break;
      }
      i = j - 1;
      ans++;
    }
    cout << ans << '\n';
  }
  return 0;
}
