#include <bits/stdc++.h>
using namespace std;
vector<long long> vis(26, 0), ans;
void dfs(long long i, long long p, vector<set<long long>> &g) {
  vis[i] = 1;
  ans.push_back(i);
  for (auto x : g[i]) {
    if (x == p) continue;
    dfs(x, i, g);
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long t;
  cin >> t;
  while (t--) {
    string S, T;
    cin >> S >> T;
    int N = S.size();
    vector<vector<long long>> v(26, vector<long long>());
    bool ok = true;
    for (int i = 0; i < N; i++) v[S[i] - 'a'].push_back(i);
    int pos = -1, ans = 1;
    long long tlen = T.size();
    for (long long i = 0; i < tlen; i++) {
      if (v[T[i] - 'a'].empty()) {
        cout << -1 << '\n';
        ok = false;
        break;
      }
      auto f = upper_bound(v[T[i] - 'a'].begin(), v[T[i] - 'a'].end(), pos);
      if (f == v[T[i] - 'a'].end()) {
        ans++;
        pos = *v[T[i] - 'a'].begin();
      } else {
        pos = *f;
      }
    }
    if (ok) cout << ans << '\n';
  }
  return 0;
}
