#include <bits/stdc++.h>
using namespace std;
int arr[26][100005];
int main() {
  ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
  ;
  int q;
  cin >> q;
  while (q--) {
    int index[30] = {0}, ans = 0;
    string s, t;
    cin >> s >> t;
    int len = t.size();
    for (int i = 0; i < s.size(); i++) {
      arr[s[i] - 'a'][index[s[i] - 'a']] = i + 1;
      index[s[i] - 'a']++;
    }
    for (int i = 0; i < len; i++) {
      if (index[t[i] - 'a'] < 1) {
        ans = -1;
        break;
      }
      int cnt = 1, last = arr[t[i] - 'a'][0];
      while ((i + cnt < len)) {
        int pos = (t[i + cnt] - 'a');
        if (index[pos] == 0) break;
        int new_last = *upper_bound(arr[pos], arr[pos] + index[pos], last);
        if (new_last <= last) break;
        last = new_last;
        cnt++;
      }
      ans++;
      i += cnt - 1;
    }
    cout << ans << endl;
    for (int i = 0; i < 26; i++)
      for (int j = 0; j < index[i]; j++) arr[i][j] = 0;
  }
  return 0;
}
