#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  int tc;
  cin >> tc;
  while (tc--) {
    string s, t;
    cin >> s >> t;
    set<int> se(s.begin(), s.end());
    bool fail = false;
    for (auto x : t) {
      if (!se.count(x)) {
        fail = true;
      }
    }
    if (fail) {
      cout << -1 << "\n";
      continue;
    }
    vector<vector<int>> vec(30, vector<int>());
    for (int i = 0; i < s.size(); i++) {
      vec[s[i] - 'a'].push_back(i);
    }
    int ans = 0;
    for (int i = 0; i < t.size();) {
      ans++;
      int cur = -1;
      while (true) {
        auto it =
            upper_bound(vec[t[i] - 'a'].begin(), vec[t[i] - 'a'].end(), cur);
        if (it == vec[t[i] - 'a'].end()) break;
        cur = *it;
        i++;
        if (i >= t.size()) break;
      }
    }
    cout << ans << "\n";
  }
}
