#include <bits/stdc++.h>
using namespace std;
const double PI = acos(-1.0);
const double eps = 1e-6;
const long long mod = 1e9 + 7;
const int inf = 0x3f3f3f3f;
const int maxn = 2e5 + 10;
const int maxm = 100 + 10;
string s1, s2;
int nex[maxn][30];
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  ;
  int t;
  cin >> t;
  while (t--) {
    cin >> s1 >> s2;
    s1 = " " + s1;
    s2 = " " + s2;
    for (int i = 1; i < s1.size() * 2; i++) {
      for (int j = 0; j <= 26; j++) nex[i][j] = 0;
    }
    int ne = -1;
    int nec = -1;
    for (int i = s1.size() - 1; i >= 1; i--) {
      int c = s1[i] - 'a';
      for (int j = 0; j < 26; j++) {
        if (j == nec) {
          nex[i][j] = ne;
          continue;
        }
        nex[i][j] = nex[i + 1][j];
      }
      nec = c;
      ne = i;
    }
    int ans = 1;
    int j = 1;
    int flag = 0;
    int f = 0;
    for (int i = 1; i < s2.size();) {
      int c = s2[i] - 'a';
      if (s1[j] != s2[i]) {
        if (nex[j][c] == 0 && j == 1) {
          flag = 1;
          break;
        } else if (nex[j][c] == 0) {
          j = 1;
          ans++;
          continue;
        }
        j = nex[j][c];
      } else {
        if (i == s2.size() - 1) break;
        int cc = s2[i + 1] - 'a';
        j = nex[j][cc];
        if (j == 0 && i + 1 < s2.size()) {
          j = 1;
          ans++;
        }
        i++;
      }
    }
    if (flag == 1)
      cout << "-1" << endl;
    else
      cout << ans << endl;
  }
}
