#include <bits/stdc++.h>
using namespace std;
void solve() {
  string s, t;
  cin >> s >> t;
  int n = s.length();
  int m = t.length();
  long long int next[n + 5][26];
  for (int i = 0; i < n + 5; i++) {
    for (int j = 0; j < 26; j++) next[i][j] = 1e18 + 3;
  }
  for (int i = n - 1; i >= 0; i--) {
    for (int j = 0; j < 26; j++) {
      next[i][j] = next[i + 1][j];
    }
    next[i][s[i] - 'a'] = i;
  }
  long long int res = 1, pos = 0;
  for (int i = 0; i < m; i++) {
    if (pos == n) {
      pos = 0;
      res++;
    }
    if (next[pos][t[i] - 'a'] == 1e18 + 3) {
      pos = 0;
      res++;
      if (next[pos][t[i] - 'a'] == 1e18 + 3 && pos == 0) {
        res = 1e18 + 3;
        break;
      }
    }
    pos = 1 + next[pos][t[i] - 'a'];
  }
  if (res >= 1e18 + 3)
    cout << -1 << '\n';
  else
    cout << res << '\n';
}
int main() {
  int t;
  cin >> t;
  while (t--) solve();
  return 0;
}
