#include <bits/stdc++.h>
using namespace std;
vector<long long int> dp[26];
long long int now;
bool func(char ch) {
  long long int idx = ch - 'a';
  long long int sz = dp[idx].size();
  long long int f =
      upper_bound(dp[idx].begin(), dp[idx].end(), now) - dp[idx].begin();
  if (f == sz) return false;
  now = dp[idx][f];
  return true;
}
void solve() {
  for (long long int i = 0; i < 26; ++i) dp[i].clear();
  string s, t;
  cin >> s >> t;
  long long int n = s.size(), m = t.size();
  vector<long long int> mark(26, 0);
  for (long long int i = 0; i < n; ++i) dp[s[i] - 'a'].push_back(i);
  for (auto it : t) {
    mark[it - 'a'] = 1;
  }
  for (auto it : s) {
    mark[it - 'a'] = 0;
  }
  for (auto it : mark) {
    if (it) {
      cout << "-1"
           << "\n";
      return;
    }
  }
  long long int op = 0;
  for (long long int i = 0; i < m;) {
    now = -1;
    long long int j = i;
    while (j < m && func(t[j])) {
      j++;
    }
    if (i != j) {
      i = j;
      op++;
    }
  }
  cout << op << "\n";
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  long long int t;
  cin >> t;
  while (t--) solve();
}
