#include <bits/stdc++.h>
using namespace std;
using lli = long long;
using ld = long double;
using ii = pair<int, int>;
using vi = vector<int>;
using vii = vector<ii>;
const int N = 1e6 + 5;
string second, t;
void testCase() {
  cin >> second >> t;
  map<char, vi> pos;
  int cnt = 0;
  for (auto i = (0) - ((0) > (int(second.size())));
       i != (int(second.size())) - ((0) > (int(second.size())));
       i += 1 - 2 * ((0) > (int(second.size()))))
    pos[second[i]].push_back(i);
  int last = -1;
  for (char c : t) {
    if (pos[c].empty()) {
      cout << -1 << '\n';
      return;
    }
    auto cur = lower_bound(begin(pos[c]), end(pos[c]), last);
    if (cur == pos[c].end()) {
      cur = lower_bound(begin(pos[c]), end(pos[c]), -1);
      last = *cur + 1;
      cnt++;
    } else {
      last = *cur + 1;
      ;
    }
  }
  if (last != -1) cnt++;
  cout << cnt << '\n';
}
int main() {
  cin.tie(0)->sync_with_stdio(0), cout.tie(0);
  int tc;
  cin >> tc;
  while (tc--) testCase();
  return 0;
}
