#include <bits/stdc++.h>
using namespace std;
inline void fast() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
}
const long long int mod = (long long int)(998244353);
long long int pmod(long long int x, long long int n) {
  long long int r = 1;
  while (n > 0) {
    if (n & 1LL) r = (r * x) % mod;
    x = (x * x) % mod;
    n = n / 2;
  }
  return r % mod;
}
const int N = (int)(1e5) + 5;
void solve() {
  string s, t;
  cin >> s >> t;
  bool a[160] = {0};
  set<int> p[160];
  for (int i = 0; i < s.size(); i++) {
    a[s[i]] = 1;
    p[s[i]].insert(i);
  }
  int z = -1;
  int ct = 1;
  for (int i = 0; i < t.size(); i++) {
    if (p[t[i]].empty()) {
      ct = -1;
      break;
    }
    auto it = p[t[i]].upper_bound(z);
    if (it == p[t[i]].end()) {
      i--;
      ct++;
      z = -1;
    } else {
      z = (*it);
    }
  }
  cout << ct << "\n";
}
int main() {
  fast();
  int ty;
  cin >> ty;
  while (ty--) solve();
}
