#include <bits/stdc++.h>
const unsigned int M = 1000000007;
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int t;
  cin >> t;
  while (t--) {
    string s, t;
    cin >> s >> t;
    vector<int> v[26];
    int i = 0, index = -1, cnt = 1, flag = 0;
    while (s[i] != '\0') {
      v[s[i] - 'a'].push_back(i);
      i++;
    }
    i = 0;
    while (t[i] != '\0') {
      auto it = upper_bound(v[t[i] - 'a'].begin(), v[t[i] - 'a'].end(), index);
      if (it == v[t[i] - 'a'].end()) {
        cnt++, index = -1;
        it = upper_bound(v[t[i] - 'a'].begin(), v[t[i] - 'a'].end(), index);
        if (it == v[t[i] - 'a'].end()) {
          flag = 1;
          break;
        } else
          index = *it;
      } else
        index = *it;
      i++;
    }
    if (flag)
      cout << -1 << endl;
    else
      cout << cnt << endl;
  }
  return 0;
}
