#include <bits/stdc++.h>
using namespace std;
string s, t;
int nxt[100010][30];
void gao() {
  cin >> s >> t;
  int n = s.length();
  int m = t.length();
  for (int i = 0; i < 26; i++) nxt[n][i] = n;
  for (int i = n - 1; i >= 0; i--) {
    for (int j = 0; j < 26; j++) {
      if (s[i] - 'a' == j)
        nxt[i][j] = i;
      else
        nxt[i][j] = nxt[i + 1][j];
    }
  }
  int ans = 0, pos = 0, i = 0;
  while (i < m) {
    int c = t[i] - 'a';
    if (nxt[0][c] == n) {
      printf("-1\n");
      return;
    }
    pos = 0;
    while (i < m) {
      int c = t[i] - 'a';
      if (nxt[pos][c] == n) break;
      pos = nxt[pos][c] + 1;
      i++;
    }
    ans++;
  }
  printf("%d\n", ans);
}
int main() {
  int n;
  cin >> n;
  while (n--) gao();
  return 0;
}
