#include <bits/stdc++.h>
using namespace std;
int n;
char s[100009], t[100009];
int nxt[100009][27], ls, lt;
int run(int last) {
  if (nxt[0][t[last] - 'a'] == 0) return -1;
  int q = 0;
  for (int i = last; i <= lt; i++) {
    q = nxt[q][t[i] - 'a'];
    if (q == 0) return i;
  }
  return -999;
}
int main() {
  int e;
  cin >> e;
  while (e--) {
    int ans = 0;
    scanf("%s%s", s + 1, t + 1);
    ls = strlen(s + 1), lt = strlen(t + 1);
    for (int i = ls - 1; i >= 0; i--) {
      int w = s[i + 1] - 'a';
      for (int j = 0; j <= 25; j++) nxt[i][j] = nxt[i + 1][j];
      nxt[i][w] = i + 1;
    }
    int zz = 1;
    while (1) {
      ans++;
      zz = run(zz);
      if (zz == -1 || zz == -999) break;
    }
    if (zz == -1)
      cout << -1 << endl;
    else
      cout << ans << endl;
    for (int i = 0; i <= ls; i++)
      for (int j = 0; j <= 25; j++) nxt[i][j] = 0;
  }
}
