#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long int t;
  cin >> t;
  while (t--) {
    string s, t;
    cin >> s >> t;
    vector<long long int> adj[30];
    long long int i, x, ans = 0, flag = 0, k, j;
    for (i = 0; i < s.length(); i++) {
      x = s[i] - 'a';
      adj[x].push_back(i);
    }
    for (i = 0; i < t.length(); i++) {
      x = t[i] - 'a';
      flag = 0;
      if (adj[x].size() == 0) {
        ans = -1;
        break;
      }
      j = 0;
      ans++;
      while (!flag && i < t.length()) {
        k = lower_bound(adj[t[i] - 'a'].begin(), adj[t[i] - 'a'].end(), j) -
            adj[t[i] - 'a'].begin();
        if (k < adj[t[i] - 'a'].size()) {
          j = adj[t[i] - 'a'][k] + 1;
          i++;
        } else {
          flag = 1;
        }
      }
      i--;
    }
    cout << ans << endl;
  }
  return 0;
}
