#include <bits/stdc++.h>
using namespace std;
vector<int> p[30];
int bs(int idx, int i, int j, int x) {
  if (i == j) {
    if (p[idx][i] > x) return p[idx][i];
    return -1;
  }
  int mid = (i + j) / 2;
  if (p[idx][mid] > x) return bs(idx, i, mid, x);
  return bs(idx, mid + 1, j, x);
}
int main() {
  ios_base ::sync_with_stdio(false);
  int ts;
  cin >> ts;
  string s, t;
  int last, cnt;
  bool flag;
  int x, idx;
  while (ts--) {
    cin >> s >> t;
    for (int i = 0; i < 26; i++) p[i].clear();
    for (int i = 0; i < (int)s.size(); i++) {
      p[s[i] - 'a'].push_back(i);
    }
    last = -1;
    cnt = 1;
    flag = true;
    for (int i = 0; i < (int)t.size(); i++) {
      x = t[i] - 'a';
      if ((int)p[x].size() == 0) {
        flag = false;
        break;
      }
      idx = bs(x, 0, (int)p[x].size() - 1, last);
      if (idx == -1) {
        cnt++;
        i--;
        last = -1;
      } else
        last = idx;
    }
    if (!flag)
      cout << -1 << endl;
    else
      cout << cnt << endl;
  }
  return 0;
}
