#include <bits/stdc++.h>
using namespace std;
const long long int mod = (int)1e9 + 7;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  ;
  int t, l, i, c, ans, p;
  string x, y;
  map<char, vector<int> > m;
  cin >> t;
  while (t--) {
    cin >> x >> y;
    ans = 0;
    l = x.length();
    m.clear();
    for (i = 0; i < l; i++) m[x[i]].push_back(i);
    l = y.length();
    c = -1;
    for (i = 0; i < l; i++) {
      if (m.find(y[i]) == m.end()) {
        ans = -1;
        break;
      } else {
        p = upper_bound(m[y[i]].begin(), m[y[i]].end(), c) - m[y[i]].begin();
        if (c == -1 || p == m[y[i]].size()) {
          c = m[y[i]][0];
          ans++;
        } else
          c = m[y[i]][p];
      }
    }
    cout << ans << "\n";
  }
  return 0;
}
