#include <bits/stdc++.h>
using namespace std;
const int mod = 1000000007;
int main() {
  ios::sync_with_stdio(0), cin.tie(0);
  long long int t;
  cin >> t;
  while (t--) {
    string s, t;
    cin >> s >> t;
    vector<long long int> m[26];
    vector<long long int>::iterator it;
    for (long long int i = 0; i < s.length(); i++) {
      m[s[i] - 'a'].push_back(i);
    }
    long long int f = 0;
    long long int ans = 0, last_index = 0;
    long long int i = 0, j = 0;
    while (i < t.length()) {
      last_index = 0;
      for (j = i; j < t.length(); j++) {
        it =
            lower_bound(m[t[j] - 'a'].begin(), m[t[j] - 'a'].end(), last_index);
        if (it == m[t[j] - 'a'].end()) {
          break;
        }
        last_index = *it + 1;
      }
      if (i == j) f = 1;
      if (f == 1) break;
      ans++;
      i = j;
    }
    if (f == 1)
      cout << -1 << endl;
    else
      cout << ans << endl;
  }
}
