#include <bits/stdc++.h>
using namespace std;
int mod = 1e9 + 7;
void cp() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
}
void solve() {
  string s, t;
  cin >> s >> t;
  unordered_set<char> set;
  for (auto c : s) set.insert(c);
  for (auto c : t) {
    if (set.find(c) == set.end()) {
      cout << -1 << endl;
      return;
    }
  }
  vector<long long> chars[26];
  for (long long i = 0; i < s.size(); i++) chars[s[i] - 'a'].push_back(i);
  long long k = 0;
  long long ans = 1;
  for (long long i = 0; i < t.size(); i++) {
    char c = t[i] - 'a';
    long long idx =
        lower_bound((chars[c]).begin(), (chars[c]).end(), k) - chars[c].begin();
    if (idx == chars[c].size()) {
      k = 0;
      i--;
      ans++;
    } else
      k = chars[c][idx] + 1;
  }
  cout << ans << endl;
}
int32_t main() {
  cp();
  long long t = 1;
  cin >> t;
  while (t--) solve();
  return 0;
}
