#include <bits/stdc++.h>
#pragma GCC optimize(3)
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma comment(linker, "/stack:200000000")
using namespace std;
void io() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);
}
vector<long long> vec;
int num[26];
long long T, n, m, x, cnt;
int a[200100][26];
long long __gcd(long long a, long long b) {
  return b == 0 ? a : __gcd(b, a % b);
}
void init() {
  for (long long i = 0; i <= 25; ++i) num[i] = -1;
}
vector<long long> rs;
void solve() {
  string s = " ", t, ss;
  cin >> ss >> t;
  init();
  int len = t.length();
  for (long long i = 0; i <= (ss.length() - 1); ++i) s.push_back(ss[i]);
  for (int i = s.length() - 1; i >= 0; i--) {
    for (long long j = 0; j <= 25; ++j) a[i][j] = num[j];
    if (i) num[s[i] - 'a'] = i;
  }
  long long cc = 0, ans = 0, it = 0;
  while (max(it + 1, ans) <= len) {
    while (it < len && a[cc][t[it] - 'a'] != -1) cc = a[cc][t[it++] - 'a'];
    cc = 0, ++ans;
  }
  if (ans > len) ans = -1;
  rs.emplace_back(ans);
}
int main() {
  io();
  cin >> T;
  while (T--) solve();
  for (auto i : rs) cout << i << '\n';
}
