#include <bits/stdc++.h>
using namespace std;
const double PI = acos(-1);
const long long mod = 1e9 + 7;
const long long MOD = 998244353;
const long long N = 3e5 + 5, K = 105;
const int si = (1 << 20);
const long long M = 2000 + 5;
const double INFdb = 1e10;
const long long oo = 1e18;
int t;
void solve() {
  string s, t;
  cin >> s >> t;
  int ans = 1;
  vector<int> pos[26];
  for (int i = 0; i < s.size(); ++i) {
    pos[s[i] - 'a'].push_back(i);
  }
  int cur = -1;
  bool check = 1;
  for (int i = 0; i < t.size(); ++i) {
    int c = t[i] - 'a';
    if ((int)pos[c].size() == 0) {
      check = 0;
      break;
    }
    auto searchh = lower_bound((pos[c]).begin(), (pos[c]).end(), cur + 1);
    while (searchh == pos[c].end()) {
      ++ans;
      cur = -1;
      searchh = lower_bound((pos[c]).begin(), (pos[c]).end(), cur + 1);
    }
    cur = *searchh;
  }
  if (!check)
    cout << -1 << "\n";
  else
    cout << ans << "\n";
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(0);
  cin >> t;
  while (t--) {
    solve();
  }
  cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
  return 0;
}
