#include <bits/stdc++.h>
using namespace std;
long long mult(long long a, long long b, long long p = 1000000007) {
  return ((a % p) * (b % p)) % p;
}
long long add(long long a, long long b, long long p = 1000000007) {
  return (a % p + b % p) % p;
}
long long fpow(long long n, long long k, long long p = 1000000007) {
  long long r = 1;
  for (; k; k >>= 1LL) {
    if (k & 1LL) r = mult(r, n, p);
    n = mult(n, n, p);
  }
  return r;
}
long long inv(long long a, long long p = 1000000007) {
  return fpow(a, p - 2, p);
}
void self_max(int &a, int &b) { a = max(a, b); }
void self_min(int &a, int &b) { a = min(a, b); }
bool isPrime(long int n) {
  if (n <= 1) return false;
  if (n <= 3) return true;
  if (n % 2 == 0 || n % 3 == 0) return false;
  for (int i = 5; i * i <= n; i = i + 6)
    if (n % i == 0 || n % (i + 2) == 0) return false;
  return true;
}
long long power(int first, unsigned int second, int p) {
  long long res = 1;
  first = first % p;
  while (second > 0) {
    if (second & 1) res = (res * first) % p;
    second = second >> 1;
    first = (first * first) % p;
  }
  return res;
}
void solve() {
  string s1, s2;
  cin >> s1 >> s2;
  int n = s1.length();
  int m = s2.length();
  vector<int> pos[26];
  for (int i = 0; i < n; i++) {
    pos[s1[i] - 'a'].push_back(i);
  }
  int ans = 0, p, flag = 0, k;
  for (int i = 0; i < m; i++) {
    if ((int)pos[s2[i] - 'a'].size() == 0) {
      cout << -1 << '\n';
      return;
    } else if (flag == 0) {
      p = pos[s2[i] - 'a'][0];
      flag = 1;
    } else {
      auto t =
          upper_bound((pos[s2[i] - 'a']).begin(), (pos[s2[i] - 'a']).end(), p);
      k = t - pos[s2[i] - 'a'].begin();
      if (k == (int)pos[s2[i] - 'a'].size()) {
        ans++;
        i--;
        flag = 0;
      }
      p = pos[s2[i] - 'a'][k];
    }
  }
  ans++;
  cout << ans << '\n';
}
int main() {
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(20);
  cin.tie(0);
  cout.tie(0);
  int t = 1;
  cin >> t;
  while (t--) {
    solve();
  }
}
