#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7, N = 2e6 + 7, M = 2e6 + 7, INF = INT_MAX / 10;
long long powe(long long x, long long y) {
  x = x % mod, y = y % (mod - 1);
  long long ans = 1;
  while (y > 0) {
    if (y & 1) {
      ans = (1ll * x * ans) % mod;
    }
    y >>= 1;
    x = (1ll * x * x) % mod;
  }
  return ans;
}
void solve() {
  string s, t;
  cin >> s >> t;
  vector<vector<int>> pos(26);
  for (int i = 0; i < (int)s.length(); i++) {
    pos[s[i] - 'a'].push_back(i);
  }
  int ctr = 0, off;
  bool poss = true;
  off = -1;
  ctr = 1;
  for (int i = 0; i < (int)t.length() && poss;) {
    if (pos[t[i] - 'a'].size() == 0) {
      poss = false;
      break;
    }
    off = lower_bound(pos[t[i] - 'a'].begin(), pos[t[i] - 'a'].end(), off + 1) -
          pos[t[i] - 'a'].begin();
    if (off == (int)pos[t[i] - 'a'].size()) {
      ctr++;
      off = -1;
      continue;
    }
    off = pos[t[i] - 'a'][off];
    i++;
  }
  if (poss) {
    cout << ctr << "\n";
  } else
    cout << "-1\n";
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  int t = 1;
  cin >> t;
  while (t--) {
    solve();
  }
  return 0;
}
