#include <bits/stdc++.h>
using namespace std;
using Int = long long;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int T;
  cin >> T;
  while (T--) {
    string S, T;
    cin >> S >> T;
    vector<array<int, 26>> jump(S.size());
    array<int, 26> table;
    for (int t = 0; t < 26; t++) table[t] = -1;
    for (int i = S.size() - 1; i >= 0; i--) {
      jump[i] = table;
      table[S[i] - 'a'] = i;
    }
    int cnt = 0;
    bool ok = true;
    int pos = 0;
    while (pos < T.size()) {
      cnt++;
      int curr = table[T[pos] - 'a'];
      if (curr == -1) {
        ok = false;
        break;
      }
      pos++;
      while (pos < T.size() && curr != -1) {
        curr = jump[curr][T[pos] - 'a'];
        if (curr != -1) pos++;
      }
    }
    if (ok) {
      cout << cnt << '\n';
    } else {
      cout << -1 << '\n';
    }
  }
  return 0;
}
