#include <bits/stdc++.h>
using namespace std;
const int N = 100000 + 5;
char s[N], t[N];
int nxt[N][26], lst[N];
int T;
int main() {
  scanf("%d", &T);
  while (T--) {
    scanf("%s%s", s + 1, t + 1);
    int len_s = strlen(s + 1), len_t = strlen(t + 1);
    for (int i = 0; i <= len_s; i++)
      for (int j = 0; j < 26; j++) nxt[i][j] = len_s + 1;
    for (int i = 0; i < 26; i++) lst[i] = len_s + 1;
    for (int i = len_s; i >= 0; i--) {
      for (int j = 0; j < 26; j++) nxt[i][j] = lst[j];
      if (i) lst[s[i] - 'a'] = i;
    }
    int ans = 0, now_s = 0, now_t = 1;
    while (1) {
      if (nxt[now_s][t[now_t] - 'a'] == len_s + 1) break;
      ans++;
      while (now_s != len_s + 1 && now_t != len_t + 1) {
        now_s = nxt[now_s][t[now_t] - 'a'];
        now_t += 1;
        if (now_s == len_s + 1) now_t--;
      }
      if (now_t == len_t + 1) break;
      now_s = 0;
    }
    if (now_t == len_t + 1)
      printf("%d\n", ans);
    else
      printf("-1\n");
  }
  return 0;
}
