#include <bits/stdc++.h>
using namespace std;
const long long int mod = 1e9 + 7;
const long long int INF = 3e18;
const double EPSILON = 1e-9;
const int N = 200005;
int main() {
  cin.tie(NULL), cout.sync_with_stdio(true);
  int tt;
  cin >> tt;
  while (tt--) {
    string a, b;
    cin >> a >> b;
    vector<int> fr[30];
    for (int i = 0; i < (int)a.size(); i++) {
      fr[a[i] - 'a'].push_back(i);
    }
    int pos = 0, ans = 1, valid = 1;
    for (int i = 0; i < (int)b.size(); i++) {
      char c = b[i];
      auto it = lower_bound(fr[c - 'a'].begin(), fr[c - 'a'].end(), pos);
      if (it == fr[c - 'a'].end()) {
        pos = 0;
        ans++;
        it = lower_bound(fr[c - 'a'].begin(), fr[c - 'a'].end(), pos);
        if (it == fr[c - 'a'].end())
          valid = 0;
        else
          pos = fr[c - 'a'][(it - fr[c - 'a'].begin())] + 1;
      } else {
        pos = fr[c - 'a'][(it - fr[c - 'a'].begin())] + 1;
      }
      if (!valid) break;
    }
    if (!valid) ans = -1;
    cout << ans << "\n";
  }
  return 0;
}
