#include <bits/stdc++.h>
using namespace std;
void solve() {
  string s, t;
  cin >> s >> t;
  long long arr[26][s.length() + 1];
  memset(arr, -1, sizeof(arr));
  for (long long i = s.length() - 1; i >= 0; i--) {
    for (long long j = 0; j < 26; j++) {
      arr[j][i] = arr[j][i + 1];
    }
    arr[s[i] - 'a'][i] = i;
  }
  long long cnt = 1, curr = 0;
  for (long long i = 0; i < t.size(); i++) {
    if (arr[t[i] - 'a'][0] == -1) {
      cout << "-1\n";
      return;
    }
    if (arr[t[i] - 'a'][curr] == -1) {
      cnt++;
      curr = 0;
    }
    curr = arr[t[i] - 'a'][curr] + 1;
  }
  cout << cnt << "\n";
}
int32_t main() {
  long long t;
  cin >> t;
  while (t--) {
    solve();
  }
  return 0;
}
