#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long T;
  cin >> T;
  while (T--) {
    string s, t;
    cin >> s >> t;
    bool ok = true;
    set<char> s1, t1;
    for (auto i : s) {
      s1.insert(i);
    }
    for (auto i : t) t1.insert(i);
    for (auto i : t1) {
      if (s1.find(i) == s1.end()) ok = false;
    }
    if (!ok) {
      cout << "-1\n";
      continue;
    }
    long long ans = 1, ind = 0, tlen = t.length(), slen = s.length();
    vector<vector<long long>> v(26, vector<long long>());
    for (long long i = 0; i < slen; i++) {
      v[s[i] - 'a'].push_back(i);
    }
    long long pos = *v[t[0] - 'a'].begin();
    for (long long i = 1; i < tlen; i++) {
      auto f = upper_bound(v[t[i] - 'a'].begin(), v[t[i] - 'a'].end(), pos);
      if (f == v[t[i] - 'a'].end()) {
        pos = -1;
        ans++;
        i--;
      } else {
        pos = *f;
      }
    }
    cout << ans << "\n";
  }
  return 0;
}
