#include <bits/stdc++.h>
using namespace std;
char s[100001], t[100001];
int ss[100001][30];
int main() {
  int c, ns, nt, i, j, rez, ct, n, q;
  scanf("%d", &q);
  getchar();
  while (q--) {
    c = getchar();
    ns = nt = 0;
    while (isalpha(c)) {
      s[++ns] = c;
      c = getchar();
    }
    c = getchar();
    while (isalpha(c)) {
      t[++nt] = c;
      c = getchar();
    }
    for (j = 0; j < 30; j++) ss[ns][j] = ns + 1;
    for (i = ns; i > 0; i--) {
      if (i != ns)
        for (j = 0; j < 30; j++) ss[i][j] = ss[i + 1][j];
      ss[i][s[i] - 'a'] = i;
    }
    rez = 0;
    for (i = 1, ct = 1; i <= nt;) {
      if (ss[1][t[i] - 'a'] == ns + 1) {
        rez = -2;
        break;
      }
      if (ct > ns || ss[ct][t[i] - 'a'] == ns + 1)
        rez++, ct = 1;
      else {
        ct = ss[ct][t[i] - 'a'];
        i++;
        ct++;
      }
    }
    rez++;
    printf("%d\n", rez);
    for (i = 1; i <= ns; i++) {
      s[i] = 0;
      for (j = 0; j < 30; j++) ss[i][j] = 0;
    }
    for (i = 1; i <= nt; i++) t[i] = 0;
  }
  return 0;
}
