#include <bits/stdc++.h>
using namespace std;
char s[200005], t[200005];
vector<int> pos[200005];
int main() {
  int T;
  scanf("%d", &T);
  while (T--) {
    for (int i = 0; i <= 30; i++) pos[i].clear();
    scanf("%s%s", s, t);
    int l1 = strlen(s), l2 = strlen(t);
    int now = -1, ans = 0;
    for (int i = 0; i < l1; i++) pos[s[i] - 'a'].push_back(i);
    for (int i = 0; i < l2; i++) {
      int nxt =
          upper_bound(pos[t[i] - 'a'].begin(), pos[t[i] - 'a'].end(), now) -
          pos[t[i] - 'a'].begin();
      if (nxt == pos[t[i] - 'a'].size()) {
        if (now == -1) {
          ans = -1;
          break;
        } else {
          now = -1;
          ans++;
          i--;
        }
      } else
        now = pos[t[i] - 'a'][nxt];
    }
    if (ans != -1 && now != -1) ans++;
    printf("%d\n", ans);
  }
  return 0;
}
