#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 10;
char a[N], b[N];
int s[N][26];
void init() {
  int n = strlen(a + 1);
  memset(s, 0, sizeof(s));
  for (int i = n; i >= 1; i--) {
    for (int j = 0; j < 26; j++) {
      s[i - 1][j] = s[i][j];
    }
    s[i - 1][a[i] - 'a'] = i;
  }
}
int main() {
  int T;
  cin >> T;
  while (T--) {
    scanf("%s %s", a + 1, b + 1);
    init();
    int flg = 0;
    int p = 0;
    int ans = 1;
    for (int i = 1; i <= strlen(b + 1); i++) {
      int t = b[i] - 'a';
      int tt = s[p][t];
      if (tt == 0 && p == 0) {
        flg = 1;
        break;
      }
      if (tt == 0) {
        i--;
        ans++;
        p = 0;
      } else {
        p = tt;
      }
    }
    if (flg == 1) {
      printf("-1\n");
      continue;
    }
    printf("%d\n", ans);
  }
  return 0;
}
