#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using pi = pair<int, int>;
const int mod = 1e9 + 9;
const ll inf = ll(1e18);
const double PI = acos(-1), eps = 1e-9;
const int mxa = 1e7;
void init() {}
const int mxn = 2e5, mxm = 1000;
string second, t;
void solve() {
  cin >> second >> t;
  vi cnt[26] = {};
  for (int i = 0; i < (int)(second).size(); ++i)
    cnt[second[i] - 'a'].push_back(i);
  int ans = 0, cur = 1e5 + 5;
  for (int i = 0; i < (int)(t).size(); ++i) {
    int a = t[i] - 'a';
    if (cnt[a].empty()) {
      cout << "-1\n";
      return;
    }
    int it = upper_bound(cnt[a].begin(), cnt[a].end(), cur) - cnt[a].begin();
    if (it == (int)(cnt[a]).size()) {
      ++ans;
      cur = cnt[a].front();
    } else
      cur = cnt[a][it];
  }
  cout << ans << '\n';
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int t;
  cin >> t;
  while (t-- > 0) solve();
}
