#include <bits/stdc++.h>
using namespace std;
const long long INF = 0x3f3f3f3f;
const long long inf = pow(10, 9);
long long modulo = pow(10, 9) + 7;
void deal() {
  long long t;
  cin >> t;
  while (t--) {
    map<char, vector<long long> > all;
    string a, b;
    cin >> a >> b;
    for (long long i = 0; i < a.length(); i++) {
      all[a[i]].push_back(i);
    }
    long long lst = -1;
    long long sy = 1;
    for (long long i = 0; i < b.length(); i++) {
      auto it = upper_bound(all[b[i]].begin(), all[b[i]].end(), lst);
      if (it == all[b[i]].end()) {
        lst = -1;
        ++sy;
        auto it = upper_bound(all[b[i]].begin(), all[b[i]].end(), lst);
        if (it == all[b[i]].end()) {
          sy = -1;
          break;
        }
        lst = *it;
      } else {
        lst = *it;
      }
    }
    cout << sy << '\n';
  }
}
int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  deal();
}
