#include <bits/stdc++.h>
using namespace std;
const long long mod = 1000000007;
const long double PI = 3.141592653589793;
const long long maxn = 100005;
long long x, y, z, n, k;
void _print(long long t) { cerr << t; }
void _print(string t) { cerr << t; }
void _print(char t) { cerr << t; }
void _print(long double t) { cerr << t; }
void _print(double t) { cerr << t; }
template <class T, class V>
void _print(pair<T, V> p);
template <class T>
void _print(vector<T> v);
template <class T>
void _print(set<T> v);
template <class T, class V>
void _print(map<T, V> v);
template <class T>
void _print(multiset<T> v);
template <class T, class V>
void _print(pair<T, V> p) {
  cerr << "{";
  _print(p.first);
  cerr << ",";
  _print(p.second);
  cerr << "}";
}
template <class T>
void _print(vector<T> v) {
  cerr << "[ ";
  for (T i : v) {
    _print(i);
    cerr << " ";
  }
  cerr << "]";
}
template <class T>
void _print(set<T> v) {
  cerr << "[ ";
  for (T i : v) {
    _print(i);
    cerr << " ";
  }
  cerr << "]";
}
template <class T>
void _print(multiset<T> v) {
  cerr << "[ ";
  for (T i : v) {
    _print(i);
    cerr << " ";
  }
  cerr << "]";
}
template <class T, class V>
void _print(map<T, V> v) {
  cerr << "[ ";
  for (auto i : v) {
    _print(i);
    cerr << " ";
  }
  cerr << "]";
}
void solve() {
  string s, t;
  cin >> s >> t;
  long long f[26];
  memset(f, 0, sizeof(f));
  long long n = (long long)s.size(), m = (long long)t.size();
  vector<vector<long long>> v(26);
  for (long long i = 0; i <= n - 1; i++) {
    f[s[i] - 'a']++;
    v[s[i] - 'a'].push_back(i);
  }
  for (long long i = 0; i <= m - 1; i++) {
    if (f[t[i] - 'a'] == 0) {
      cout << -1 << "\n";
      return;
    }
  }
  long long ans = 1, last = -1;
  for (long long i = 0; i <= m - 1; i++) {
    long long prev = last;
    long long val = t[i] - 'a';
    long long pos =
        lower_bound(v[val].begin(), v[val].end(), last + 1) - v[val].begin();
    if (pos == v[val].size()) {
      ans++;
      last = v[val][0];
    } else {
      last = v[val][pos];
    }
  }
  cout << ans << "\n";
}
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  cout << setprecision(15) << fixed;
  long long t;
  t = 1;
  cin >> t;
  while (t--) {
    solve();
  }
  return 0;
}
