#include <bits/stdc++.h>
using namespace std;
const int mod = 1e9 + 7;
const int maxn = 1e6 + 10;
const int maxm = 3e5 + 10;
const long long INF = 0x3f3f3f3f;
inline long long read() {
  register long long x = 0, w = 0;
  register char ch = 0;
  while (!isdigit(ch)) {
    w |= ch == '-';
    ch = getchar();
  }
  while (isdigit(ch)) x = (x << 3) + (x << 1) + (ch ^ 48), ch = getchar();
  return w ? -x : x;
}
inline void write(register int x) {
  if (x < 0) putchar('-'), x = -x;
  if (x > 9) write(x / 10);
  putchar(x % 10 + '0');
}
char s[maxm];
char p[maxm];
int main() {
  register int t = read();
  while (t--) {
    register vector<int> v[30];
    scanf(" %s", s);
    scanf(" %s", p);
    register int ls = strlen(s);
    register int lp = strlen(p);
    for (register int i = 0; i < ls; ++i) {
      v[s[i] - 'a'].push_back(i);
    }
    register int ans = 1;
    register int temp = -1;
    register int i = 0, j = 0;
    while (i < lp) {
      register int ch = p[i] - 'a';
      if (v[ch].size() == 0) {
        puts("-1");
        break;
      }
      register int l = v[ch].size();
      register int j =
          upper_bound(v[ch].begin(), v[ch].end(), temp) - v[ch].begin();
      if (j < l)
        temp = v[ch][j], ++i;
      else
        ++ans, temp = -1;
    }
    if (i < lp)
      continue;
    else
      write(ans), puts("");
  }
  return 0;
}
