#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
inline bool cmp(pair<long long, long long> a, pair<long long, long long> b) {
  if (a.first == b.first) return a.second < b.second;
  return a.first > b.first;
}
int drx[8] = {-2, -2, -1, -1, 1, 1, 2, 2};
int dcy[8] = {-1, 1, -2, 2, -2, 2, -1, 1};
int dirx[4] = {-1, 0, 1, 0};
int diry[4] = {0, -1, 0, 1};
template <class T>
inline T gcd(T a, T b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}
template <class T>
inline T lcm(T a, T b) {
  return a * b / gcd<T>(a, b);
}
template <class T>
inline T power(T b, T p) {
  long long ans = 1;
  while (p--) ans *= b;
  return ans;
}
int main() {
  long long n, m, num, tc, t = 1;
  scanf("%lld", &tc);
  while (tc--) {
    string s, t;
    cin >> s >> t;
    long long ln = s.size();
    map<char, vector<long long> > mv;
    for (long long i = 0; i < ln; i++) mv[s[i]].push_back(i);
    ln = t.size();
    long long pos = 0, ans = 0, pre = 0;
    for (long long i = 0; i < ln; i++) {
      if (mv[t[i]].size() == 0) {
        ans = -1;
        break;
      }
      pos = upper_bound((mv[t[i]]).begin(), (mv[t[i]]).end(), pre) -
            mv[t[i]].begin();
      if (pos == mv[t[i]].size()) pos--;
      if (mv[t[i]][pos] <= pre || ans == 0) {
        pre = mv[t[i]][0];
        ans++;
      } else
        pre = mv[t[i]][pos];
    }
    cout << ans << endl;
  }
}
