#include <bits/stdc++.h>
using namespace std;
map<int, int> mp, x[1000005];
int main() {
  int t1;
  cin >> t1;
  while (t1--) {
    string s, t;
    cin >> s >> t;
    mp.clear();
    for (int i = 0; i < s.size(); i++) mp[s[i]]++;
    bool q = true;
    for (int i = 0; i < t.size(); i++) {
      if (mp[t[i]] == 0) {
        q = false;
        break;
      }
    }
    if (q == false) {
      cout << -1 << endl;
      continue;
    }
    for (int j = 100005; j >= 1; j--) x[j].clear();
    for (int i = s.size() - 1; i >= 0; i--) {
      for (int j = 1; j <= 26; j++) x[i + 1][j] = x[i + 2][j];
      x[i + 1][s[i] - 'a' + 1] = i + 1;
    }
    int in = 0, ans = 0;
    while (in < t.size()) {
      ans++;
      int ind = 0;
      while (true) {
        if (x[ind + 1][t[in] - 'a' + 1] == 0) break;
        ind = x[ind + 1][t[in] - 'a' + 1];
        in++;
        if (in >= t.size()) break;
      }
      if (in >= t.size()) break;
    }
    cout << ans << endl;
  }
}
