#include <bits/stdc++.h>
using namespace std;
string palin(string s) {
  string a = s;
  reverse(a.begin(), a.end());
  a = s + "#" + a;
  int c = 0, n = a.size();
  int dp[n + 1];
  for (int i = 1; i < a.size(); i++) {
    while (c != 0 && dp[c] != dp[i]) c = dp[c - 1];
    if (a[c] == a[i]) c++;
    dp[i] = c;
  }
  return a.substr(0, c);
}
int prime(long long n) {
  for (int i = 2; i <= sqrt(n); i++)
    if (n % i == 0) return 0;
  return 1;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int te;
  cin >> te;
  while (te--) {
    string s, t;
    cin >> s;
    cin >> t;
    vector<int> a[26];
    for (int i = 0; i < s.size(); i++) a[s[i] - 'a'].push_back(i);
    int d = -1, ans = 1;
    for (int i = 0; i < t.size(); i++) {
      char c = t[i];
      if (a[c - 'a'].size() == 0) {
        ans = -1;
        break;
      }
      int l = upper_bound(a[c - 'a'].begin(), a[c - 'a'].end(), d) -
              a[c - 'a'].begin();
      if (l == a[c - 'a'].size())
        d = -1, i--, ans++;
      else
        d = a[c - 'a'][l];
    }
    cout << ans << endl;
  }
  return 0;
}
