#include <bits/stdc++.h>
using namespace std;
template <typename T>
inline void read(T &r) {
  static char c;
  r = 0;
  int f = 1;
  for (c = getchar(); c < '0' || c > '9'; c = getchar())
    if (c == '-') f = -1;
  for (; c >= '0' && c <= '9';
       r = (r << 1) + (r << 3) + (c ^ 48), c = getchar())
    ;
  r *= f;
}
const int N = 1e5 + 105;
int a[30] = {0}, b[30] = {0};
void solve() {
  string s, t;
  cin >> s >> t;
  memset(a, 0, sizeof(a)), memset(b, 0, sizeof(b));
  for (auto i : s) {
    a[i - 'a'] = 1;
  }
  for (auto i : t) {
    b[i - 'a'] = 1;
  }
  int f = 1;
  for (int i = 0; i < (int)29; ++i) {
    if (!a[i] && b[i]) f = 0;
  }
  if (!f) {
    cout << -1 << '\n';
    return;
  }
  set<int> second[30];
  for (int i = 0; i < (int)s.size(); ++i) {
    second[s[i] - 'a'].insert(i);
  }
  int pos = N, ans = 0;
  for (int i = 0; i < (int)t.size(); ++i) {
    auto flag = second[t[i] - 'a'].upper_bound(pos);
    if (flag == second[t[i] - 'a'].end()) {
      ++ans;
      pos = *second[t[i] - 'a'].begin();
    } else {
      pos = *flag;
    }
  }
  cout << ans << '\n';
}
int main() {
  int t = 1;
  cin >> t;
  while (t--) {
    solve();
  }
}
