#include <bits/stdc++.h>   #pragma GCC optimize( O3 )   #pragma GCC target( sse4 )   using namespace std;   template <class T>   bool ckmin(T& a, const T& b) {     return b < a ? a = b, 1 : 0;   }   template <class T>   bool ckmax(T& a, const T& b) {     return a < b ? a = b, 1 : 0;   }   mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());   const int mod = 1e9 + 7;   const char nl =   n ;   const int N = int(2e5) + 99;   const int INF = int(1e9) + 99;   long long add(long long x, long long y) {     x += y;     if (x >= mod) return x - mod;     return x;   }   long long sub(long long x, long long y) {     x -= y;     if (x < 0) return x + mod;     return x;   }   long long mult(long long x, long long y) { return (x * y) % mod; }   long long bin_pow(long long x, long long p) {     if (p == 0) return 1;     if (p & 1) return mult(x, bin_pow(x, p - 1));     return bin_pow(mult(x, x), p / 2);   }   long long rev(long long x) { return bin_pow(x, mod - 2); }   long long gcd(long long x, long long y) { return (y == 0 ? x : gcd(y, x % y)); }   long long lcm(long long x, long long y) { return (x / gcd(x, y)) * y; }   string s, t;   int nxt[N][26];   void solve() {     int tc;     cin >> tc;     while (tc--) {       cin >> s >> t;       for (int i = 0; i < ((int)(s).size() + 5); i++) {         for (int j = 0; j < (26); j++) {           nxt[i][j] = INF;         }       }       for (int i = (int)(s).size() - 1; i >= 0; --i) {         for (int j = 0; j < (26); j++) {           nxt[i][j] = nxt[i + 1][j];         }         nxt[i][s[i] -  a ] = i;       }       int res = 1, pos = 0;       for (int i = 0; i < ((int)(t).size()); i++) {         if (pos == (int)(s).size()) {           pos = 0;           res++;         }         if (nxt[pos][t[i] -  a ] == INF) {           pos = 0;           ++res;         }         if (nxt[pos][t[i] -  a ] == INF && pos == 0) {           res = INF;           break;         }         pos = nxt[pos][t[i] -  a ] + 1;       }       if (res >= INF) {         cout << -1 << nl;       } else {         cout << res << nl;       }     }   }   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     solve();     return 0;   }   