#include <bits/stdc++.h>
const int maxn = 3e6 + 9;
int Read() {
  int x(0), f(1);
  char c = getchar();
  while (c < '0' || c > '9') {
    if (c == '-') f = -1;
    c = getchar();
  }
  while (c >= '0' && c <= '9') {
    x = (x << 3ll) + (x << 1ll) + c - '0';
    c = getchar();
  }
  return x * f;
}
int T, n;
int a[maxn], nxt[100009][30], nw[30];
char s[maxn], t[maxn];
int main() {
  T = Read();
  while (T--) {
    scanf(" %s", s + 1);
    scanf(" %s", t + 1);
    int len1(strlen(s + 1)), len2(strlen(t + 1));
    memset(nw, 0, sizeof(nw));
    for (int i = len1; i >= 0; --i) {
      for (int j = 0; j < 26; ++j) nxt[i][j] = nw[j];
      if (i) {
        nw[s[i] - 'a'] = i;
      }
    }
    int ans(1), flag(1), cc(0);
    for (int i = 1; i <= len2; ++i) {
      int x(t[i] - 'a');
      if (!nw[x]) {
        flag = 0;
        break;
      }
      if (nxt[cc][x])
        cc = nxt[cc][x];
      else
        ++ans, cc = nxt[0][x];
    }
    if (!flag)
      puts("-1");
    else
      printf("%d\n", ans);
  }
}
