#include <bits/stdc++.h>
using namespace std;
const int mod = 1e9 + 7;
int main() {
  int t;
  cin >> t;
  while (t-- > 0) {
    string s, t;
    cin >> s >> t;
    int sa[26];
    memset(sa, 0, sizeof(sa));
    int st[26];
    memset(st, 0, sizeof(st));
    for (int i = 0; i < s.length(); i++) {
      sa[s[i] - 97]++;
    }
    for (int i = 0; i < t.length(); i++) {
      st[t[i] - 97]++;
    }
    bool flag = true;
    for (int i = 0; i < 26; i++) {
      if (st[i] > 0 && sa[i] == 0) {
        flag = false;
        break;
      }
    }
    if (flag == false) {
      cout << "-1\n";
      continue;
    }
    int n = s.length(), m = t.length();
    int alph[s.length()][26];
    memset(alph, 0, sizeof(alph));
    alph[n - 1][s[n - 1] - 97] = n - 1;
    for (int i = n - 2; i >= 0; i--) {
      for (int j = 0; j < 26; j++) {
        alph[i][j] = alph[i + 1][j];
      }
      alph[i][s[i] - 97] = i;
    }
    int ind = 0, c = 0, is = 0;
    vector<int> inds;
    inds.push_back(0);
    while (ind < m) {
      int x = t[ind] - 97;
      if (s[is] == t[ind]) {
        ind++;
        if (ind < m && is < n - 1)
          is = alph[is + 1][t[ind] - 97];
        else if (ind < m) {
          is = 0;
          c++;
        }
        if (ind == m) break;
      } else {
        is = alph[is][x];
        if (is == 0) c++;
      }
      inds.push_back(is);
    }
    c = 0;
    for (int i = 0; i < inds.size(); i++) {
      if (inds[i] == 0) c++;
    }
    cout << c << "\n";
  }
}
