#include <bits/stdc++.h>
using namespace std;
int nxt[100005][30];
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int t;
  cin >> t;
  while (t--) {
    string s, t;
    cin >> s >> t;
    int sz = (int)s.size();
    memset(nxt[sz], -1, sizeof nxt[sz]);
    for (int i = sz - 1; i >= 0; i--) {
      for (int j = 0; j < 26; j++) nxt[i][j] = nxt[i + 1][j];
      nxt[i][s[i] - 'a'] = i;
    }
    int ans = 1, idx = 0;
    for (char c : t) {
      if (nxt[idx][c - 'a'] == -1) {
        if (nxt[0][c - 'a'] == -1) {
          ans = -1;
          break;
        }
        ans++;
        idx = 0;
      }
      idx = nxt[idx][c - 'a'] + 1;
    }
    cout << ans << endl;
  }
  return 0;
}
