#include <bits/stdc++.h>
using namespace std;
const int maxN = 1e5 + 2;
void solve() {
  string s, st;
  cin >> s >> st;
  int n = s.length();
  int d[255];
  for (char h = 'a'; h <= 'z'; h++) d[h] = n + 1;
  int f[n + 2][26];
  memset(f, 0, sizeof(f));
  for (int i = n; i > 0; i--) {
    for (char h = 'a'; h <= 'z'; h++) {
      f[i][(int)h - 'a'] = d[h];
    }
    d[(int)s[i - 1]] = i;
  }
  for (char h = 'a'; h <= 'z'; h++) {
    f[0][(int)h - 'a'] = d[h];
  }
  int k = 0, res = 1;
  for (int i = 0; i < st.length(); i++) {
    int temp = f[k][(int)st[i] - 'a'];
    if (temp == n + 1) {
      k = 0;
      res++;
    }
    temp = f[k][(int)st[i] - 'a'];
    if (temp == n + 1) {
      cout << -1 << '\n';
      return;
    } else
      k = temp;
  }
  cout << res << '\n';
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(nullptr);
  cout.tie(nullptr);
  int test;
  cin >> test;
  while (test--) solve();
}
