#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int t, i, j, cnt, k, lo, hi, mid;
  cin >> t;
  while (t--) {
    string s, t;
    cin >> s >> t;
    vector<long long int> v[26];
    for (i = 0; s[i]; i++) {
      v[s[i] - 'a'].push_back(i);
    }
    bool flag = true;
    cnt = 1;
    j = -1;
    for (i = 0; t[i]; i++) {
      k = -1;
      lo = 0;
      hi = (int)v[t[i] - 'a'].size() - 1;
      while (lo <= hi) {
        mid = (lo + hi) / 2LL;
        if (v[t[i] - 'a'][mid] > j) {
          k = v[t[i] - 'a'][mid];
          hi = mid - 1;
        } else {
          lo = mid + 1;
        }
      }
      if (j == -1 and k == -1) {
        flag = false;
        break;
      } else if (k != -1) {
        j = k;
      } else {
        j = -1;
        i--;
        cnt++;
      }
    }
    if (!flag) cnt = -1;
    cout << cnt << "\n";
  }
  return 0;
}
