#include <bits/stdc++.h>
const int N = 1e5 + 100;
const int M = 1e6 + 100;
const long long oo = 2e18;
long long n, m, k, t, q, h, a, b, d, c, e, w, x, y, z;
using namespace std;
string s, ts, zs;
set<int> second[250];
int toIndex(int pr, char x, int ind) {
  if (ind + 1 == ts.size()) return ind;
  if (second[ts[ind + 1]].upper_bound(pr) != second[ts[ind + 1]].end()) {
    return toIndex(*(second[ts[ind + 1]].upper_bound(pr)), ts[ind + 1],
                   ind + 1);
  }
  return ind;
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cin >> q;
  while (q--) {
    cin >> s >> ts;
    zs = "";
    for (char a = 'a'; a <= 'z'; a++) {
      second[a].clear();
    }
    for (int i = 0; i < s.size(); i++) {
      second[s[i]].insert(i);
    }
    int ans = 0;
    for (int i = 0; i < ts.size(); i++) {
      if (second[ts[i]].upper_bound(-1) == second[ts[i]].end()) {
        ans = -1;
        break;
      }
      i = toIndex(*(second[ts[i]].upper_bound(-1)), ts[i], i);
      ans++;
    }
    cout << ans << endl;
  }
  return 0;
}
