#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
using namespace std;
template <typename T1, typename T2>
inline void chmin(T1& a, T2 b) {
  if (a > b) a = b;
}
template <typename T1, typename T2>
inline void chmax(T1& a, T2 b) {
  if (a < b) a = b;
}
const long long MOD = 1e9 + 7;
const long long MAX = 200020;
const double pi = acos(-1);
const double EPS = 1e-12;
const long long INF = 1e18;
const long long INT_INF = 1e9;
long long nxt[200020][30];
void solve() {
  string S;
  cin >> S;
  string T;
  cin >> T;
  map<char, long long> mp;
  long long N = S.size(), M = T.size();
  for (long long i = 0; i < N; ++i) mp[S[i]]++;
  for (long long i = 0; i < M; ++i) {
    if (!mp.count(T[i])) {
      cout << (-1) << '\n';
      return;
    }
  }
  S = S + S;
  for (long long i = 0; i < 2 * N + 1; ++i)
    for (long long j = 0; j < 26; ++j) nxt[i][j] = 0;
  for (long long i = 2 * N - 1; i >= 0; --i) {
    for (long long j = 0; j < 26; ++j) nxt[i][j] = nxt[i + 1][j];
    nxt[i][S[i] - 'a'] = i + 1;
  }
  long long ans = 1;
  long long idx = 0;
  for (long long i = 0; i < M; ++i) {
    long long nx = nxt[idx][T[i] - 'a'];
    if (nx > N) {
      ans += 1;
      idx = nx -= N;
    } else {
      idx = nx;
    }
  }
  cout << (ans) << '\n';
}
signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  long long q;
  cin >> q;
  while (q--) solve();
}
