#include <bits/stdc++.h>
using namespace std;
int n, q, ans, idx, idx2;
string s, t, test;
bool ok;
vector<vector<int> > adj(28);
int main() {
  cin >> q;
  while (q--) {
    cin >> s >> t;
    for (int i = 0; i < s.size(); ++i) {
      adj[s[i] - 'a'].push_back(i);
    }
    ok = true;
    idx = 0;
    vector<int>::iterator it;
    while (ok) {
      ok = false;
      idx2 = 0;
      for (int i = idx; i < t.size();) {
        it = lower_bound(adj[t[i] - 'a'].begin(), adj[t[i] - 'a'].end(), idx2);
        if (it != adj[t[i] - 'a'].end()) {
          test += t[i];
          ++idx;
          ++i;
          idx2 = *it + 1;
          ok = true;
        } else
          break;
      }
      ans += ok;
    }
    cout << (test == t ? ans : -1) << '\n';
    for (int i = 0; i < 28; ++i) adj[i].clear();
    test.clear();
    ans = 0;
  }
}
