#include <bits/stdc++.h>
using namespace std;
int find(vector<int> &v, int x) {
  int l = 0, r = v.size() - 1;
  while (l <= r) {
    int mid = (l + r) / 2;
    if ((mid == l || v[mid - 1] <= x) && v[mid] > x) return v[mid];
    if (v[mid] <= x)
      l = mid + 1;
    else
      r = mid - 1;
  }
  return -1;
}
int main() {
  int t;
  cin >> t;
  while (t--) {
    string s, t;
    cin >> s >> t;
    map<char, vector<int> > mp;
    for (int i = 0; i < s.size(); i++) mp[s[i]].push_back(i);
    int cnt = 1, prev = -1, flag = 1;
    for (int i = 0; i < t.size(); i++) {
      if (mp.count(t[i]) == 0) {
        flag = 0;
        break;
      }
      int it = find(mp[t[i]], prev);
      if (it == -1)
        prev = -1, cnt++, i--;
      else
        prev = it;
    }
    if (flag)
      cout << cnt << endl;
    else
      cout << -1 << endl;
  }
  return 0;
}
