#include <bits/stdc++.h>
using namespace std;
const long long mod = 2e8 + 7;
const long long N = 1e5 + 7;
long long n, cnt, a, b, x;
set<long long> st;
long long arr[N];
string s, t;
map<char, set<int>> m;
int res() {
  int ans = 1;
  int pos = -1;
  for (auto ch : t) {
    if (m.count(ch) == 0) return -1;
    auto it = m[ch].upper_bound(pos);
    if (it == m[ch].end()) {
      ++ans;
      it = m[ch].begin();
    }
    pos = *it;
  }
  return ans;
}
int main() {
  int q;
  cin >> q;
  while (q--) {
    cin >> s >> t;
    for (int i = 0; i < s.size(); ++i) {
      m[s[i]].insert(i);
    }
    cout << res() << "\n";
    m.clear();
  }
}
