#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<ll, ll>;
const ll MOD = 1e9 + 7, N = 1e5 + 10;
void test() {
  string s, t;
  cin >> s >> t;
  vector<ll> pos[26];
  for (ll i = 0; i < s.length(); i++) {
    pos[s[i] - 'a'].push_back(i);
  }
  ll ans = 1;
  ll cur = -1;
  for (ll i = 0; i < t.length(); i++) {
    if (pos[t[i] - 'a'].empty()) {
      cout << "-1\n";
      return;
    }
    auto k = upper_bound(pos[t[i] - 'a'].begin(), pos[t[i] - 'a'].end(), cur);
    if (k == pos[t[i] - 'a'].end()) {
      ans++;
      cur = -1;
      i--;
    } else {
      cur = *k;
    }
  }
  cout << ans << '\n';
  return;
}
int32_t main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  ll tt = 1;
  cin >> tt;
  for (ll i = 0; i < tt; i++) test();
  return 0;
}
