#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  int tr;
  cin >> tr;
  while (tr--) {
    vector<vector<int>> g(26);
    string s, t;
    cin >> s >> t;
    for (int i = 0; i < (int)s.length(); ++i) {
      g[s[i] - 'a'].push_back(i);
    }
    int idx = -1;
    int res = 1;
    for (auto x : t) {
      int u = x - 'a';
      auto it = upper_bound(g[u].begin(), g[u].end(), idx);
      if (it == g[u].end()) {
        res++;
        idx = -1;
        it = upper_bound(g[u].begin(), g[u].end(), idx);
        if (it == g[u].end()) {
          res = -1;
          break;
        }
        idx = *it;
      } else {
        idx = *it;
      }
    }
    cout << res << '\n';
  }
  return 0;
}
