#include <bits/stdc++.h>
using namespace std;
int NEXT_RIGHT[100000 + 5][30];
int main() {
  int t;
  cin >> t;
  for (int j = 0; j <= 100000 + 2; j++)
    for (int g = 0; g <= 27; g++) NEXT_RIGHT[j][g] = -1;
  for (int i = 1; i <= t; i++) {
    string s1;
    string s2;
    cin >> s1 >> s2;
    s1 = " " + s1;
    for (int j = s1.length() - 1; j >= 0; j--) {
      int letter = int(s1[j]) - 97;
      for (int g = j - 1; g >= 0; g--) {
        if (s1[g] - 97 == letter) {
          NEXT_RIGHT[g][letter] = j;
          g = -1;
        } else
          NEXT_RIGHT[g][letter] = j;
      }
    }
    bool ok = 1;
    int res = 0;
    int pos = s1.length();
    for (int j = 0; j < s2.length(); j++) {
      int letter = int(s2[j]) - 97;
      if (NEXT_RIGHT[pos][letter] == -1) {
        pos = NEXT_RIGHT[0][letter];
        if (pos == -1) {
          cout << -1 << endl;
          ok = 0;
          j = s2.length() + 10;
        }
        res++;
      } else {
        pos = NEXT_RIGHT[pos][letter];
        if (pos == -1) {
          cout << -1 << endl;
          ok = 0;
          j = s2.length() + 10;
        }
      }
    }
    if (ok) cout << res << endl;
    for (int j = 0; j <= s1.length(); j++)
      for (int g = 0; g <= 27; g++) NEXT_RIGHT[j][g] = -1;
  }
  return 0;
}
