#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vpii = vector<pair<int, int>>;
using pii = pair<int, int>;
using ll = long long;
using ld = long double;
void R() {}
template <class T, class... U>
inline void R(T &head, U &...tail) {
  cin >> head;
  R(tail...);
}
void W() {}
template <class T, class... U>
inline void W(const T &head, const U &...tail) {
  cout << head << (sizeof...(tail) ? ' ' : '\n');
  W(tail...);
}
template <class T>
void W(const vector<T> &x) {
  for (auto i = x.begin(); i != x.end(); cout << (*i++)) {
    if (i != x.cbegin()) cout << ' ';
  }
  cout << '\n';
}
template <class T>
inline void cmax(T &a, T b) {
  a = max(a, b);
}
template <class T>
inline void cmin(T &a, T b) {
  a = min(a, b);
}
mt19937 rng(time(0));
vector<int> pos[26];
char s[200005], t[100005];
int nxt[100005][26], d[100005][26];
void solve() {
  cin >> (s + 1) >> (t + 1);
  int n = strlen(s + 1);
  for (int i = (1); i <= (int32_t)(n); ++i)
    for (int j = (0); j < (int32_t)(26); ++j) nxt[i][j] = d[i][j] = 0;
  for (int i = (0); i < (int32_t)(26); ++i) pos[i].clear();
  int m = strlen(t + 1);
  for (int i = (n + 1); i <= (int32_t)(2 * n); ++i) s[i] = s[i - n];
  for (int i = (1); i <= (int32_t)(2 * n); ++i) pos[s[i] - 'a'].push_back(i);
  for (int i = (1); i <= (int32_t)(n); ++i) {
    for (int j = (0); j < (int32_t)(26); ++j) {
      if (int32_t(pos[j].size()) == 0) continue;
      int p = *upper_bound((pos[j]).begin(), (pos[j]).end(), i);
      if (p > n) {
        d[i][j]++;
        p -= n;
      }
      nxt[i][j] = p;
    }
  }
  int ok = 1;
  map<char, int> pa;
  for (int i = (1); i <= (int32_t)(n); ++i) pa[s[i]]++;
  for (int i = (1); i <= (int32_t)(m); ++i)
    if (pa.count(t[i]) == 0) ok = 0;
  if (!ok) {
    cout << -1 << '\n';
    return;
  }
  int ans = 1;
  int p;
  for (int j = (1); j <= (int32_t)(n); ++j)
    if (s[j] == t[1]) {
      p = j;
      break;
    }
  for (int i = (2); i <= (int32_t)(m); ++i) {
    ans += d[p][t[i] - 'a'];
    p = nxt[p][t[i] - 'a'];
  }
  cout << ans << '\n';
}
signed main() {
  ios::sync_with_stdio(false), cin.tie(0);
  int t;
  cin >> t;
  while (t--) solve();
  return 0;
}
