#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 10;
char s[maxn], t[maxn];
int T, strs, strt;
vector<int> a[30];
int main() {
  scanf("%d", &T);
  while (T--) {
    for (int i = 0; i < 30; i++) a[i].clear();
    memset(s, 0, strlen(s));
    memset(t, 0, strlen(t));
    scanf("%s%s", s + 1, t + 1);
    strs = strlen(s + 1);
    strt = strlen(t + 1);
    for (int i = 1; i <= strs; i++) a[s[i] - 'a'].push_back(i);
    for (int i = 0; i < 30; i++) a[i].push_back(strs + 1);
    int now = -1, cnt = 1, check = 0;
    for (int i = 1; i <= strt; i++) {
      if (a[t[i] - 'a'].size() == 1) {
        puts("-1");
        check = 1;
        break;
      }
      int pos = upper_bound(a[t[i] - 'a'].begin(), a[t[i] - 'a'].end(), now) -
                a[t[i] - 'a'].begin();
      if (a[t[i] - 'a'][pos] == strs + 1)
        cnt++, now = a[t[i] - 'a'][0];
      else
        now = a[t[i] - 'a'][pos];
    }
    if (check == 0) printf("%d\n", cnt);
  }
}
