#include <bits/stdc++.h>
using namespace std;
int main() {
  int t, i;
  cin >> t;
  for (; t > 0; t--) {
    string s, t;
    cin >> s >> t;
    int s1 = s.length(), t1 = t.length(), ans = 0, f = 0;
    vector<int> v[26];
    for (i = 0; i < s1; i++) v[s[i] - 'a'].push_back(i);
    i = 0;
    while (i < t1) {
      int c = -1;
      while (i < t1) {
        auto k = upper_bound(v[t[i] - 'a'].begin(), v[t[i] - 'a'].end(), c) -
                 v[t[i] - 'a'].begin();
        if (k == v[t[i] - 'a'].size()) {
          break;
        }
        c = v[t[i] - 'a'][k];
        i++;
      }
      if (c == -1) {
        f = 1;
        break;
      }
      ans++;
    }
    if (f == 1)
      cout << -1 << endl;
    else
      cout << ans << endl;
  }
  return 0;
}
