#include <bits/stdc++.h>
using namespace std;
const int INF = 0x3f3f3f3f;
void solve() {
  string s, r;
  cin >> s >> r;
  int n = s.size();
  int m = r.size();
  vector<int> v[26];
  for (int i = 0; i < n; i++) {
    v[s[i] - 'a'].push_back(i);
  }
  int rc[26];
  memset(rc, 0, sizeof rc);
  for (int i = 0; i < m; i++) {
    rc[r[i] - 'a']++;
  }
  bool yes = true;
  for (int i = 0; i < 26; i++) {
    if (rc[i] > 0 && (int)v[i].size() == 0) {
      yes = false;
      break;
    }
  }
  if (!yes) {
    cout << -1 << '\n';
    return;
  }
  int ans = 1;
  int pos = 0;
  for (int i = 0; i < m; i++) {
    int c = r[i] - 'a';
    auto it = lower_bound(v[c].begin(), v[c].end(), pos);
    if (it != v[c].end()) {
      int ind = distance(v[c].begin(), it);
      int se = v[c][ind];
      if (se < pos) {
        pos = se;
        ans++;
      } else {
        pos = se;
      }
    } else {
      ans++;
      pos = v[c][0];
    }
    pos++;
    if (pos == n) {
      pos = 0;
      if (i != m - 1) ans++;
    }
  }
  cout << ans << '\n';
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int t;
  cin >> t;
  while (t--) solve();
  return 0;
}
