#include <bits/stdc++.h>
using namespace std;
double sqr(double x) { return x * x; }
int const N = (int)2e6 + 1, INF = (int)1e9 + 1, MOD = (int)998244353;
long long mypow(long long a, long long b, long long mod) {
  long long rv = 1;
  while (b) {
    if (b % 2) rv = rv * a % mod;
    a = a * a % mod;
    b /= 2;
  }
  return rv;
}
int main() {
  int T;
  cin >> T;
  while (T--) {
    int ans = 0;
    string second, t;
    cin >> second >> t;
    int n = second.size();
    vector<vector<int>> pos(n + 1, vector<int>(26, -1));
    for (int i = n - 1; i >= 0; i--) {
      int x = second[i] - 'a';
      for (int j = 0; j < 26; j++) {
        pos[i][j] = pos[i + 1][j];
      }
      pos[i][x] = i;
    }
    int j = 0;
    bool foult = false;
    for (int i = 0; i < t.size(); i++) {
      int x = t[i] - 'a';
      if (pos[j][x] != -1)
        j = pos[j][x] + 1;
      else {
        if (j == 0) {
          foult = true;
          break;
        } else {
          ans++;
          j = 0;
          i--;
        }
      }
    }
    if (foult)
      cout << -1 << "\n";
    else
      cout << ans + 1 << "\n";
  }
  return 0;
}
