#include <bits/stdc++.h>
using namespace std;
void solve() {
  string S, T;
  cin >> S >> T;
  vector<long long int> indexes[26];
  for (int i = 0; i < S.size(); ++i) {
    indexes[S[i] - 'a'].emplace_back(i);
  }
  long long int moves = 0;
  long long int last = -1;
  int i = 0;
  while (i < T.size()) {
    if (indexes[T[i] - 'a'].empty()) {
      cout << "-1\n";
      return;
    }
    if (upper_bound(indexes[T[i] - 'a'].begin(), indexes[T[i] - 'a'].end(),
                    last) -
            indexes[T[i] - 'a'].begin() <
        indexes[T[i] - 'a'].size()) {
      last = *upper_bound(indexes[T[i] - 'a'].begin(),
                          indexes[T[i] - 'a'].end(), last);
      ++i;
      if (i == T.size()) {
        moves++;
      }
    } else {
      moves++;
      last = -1;
    }
  }
  cout << moves << '\n';
}
int32_t main() {
  int tst;
  cin >> tst;
  while (tst--) {
    solve();
  }
}
