#include <bits/stdc++.h>
using namespace std;
const int oo = 1e9 + 5;
const long long ooll = 1e18;
const int MOD = 1e9 + 7;
const int N = 2e6 + 5;
int v[N];
void solve() {
  int ans = 1, m, n, i, j, k;
  string s, t;
  cin >> s >> t;
  m = s.length();
  n = t.length();
  vector<vector<int>> nxt(m, vector<int>(26, -1));
  s = s + s;
  for (i = m - 2; i >= 0; i--) {
    for (j = 0; j < 26; j++) {
      char now = ('a' + j);
      nxt[i][j] = nxt[i + 1][j];
      if (s[i + 1] == now) {
        if (nxt[i][j] == -1)
          nxt[i][j] = i + 1;
        else
          nxt[i][j] = min(nxt[i][j], i + 1);
      }
    }
  }
  vector<int> pres(26, -1);
  for (i = 0; i < m; i++) {
    if (pres[s[i] - 'a'] == -1) pres[s[i] - 'a'] = i;
    for (j = 0; j < 26; j++) {
      if (pres[j] != -1) {
        if (nxt[i][j] == -1)
          nxt[i][j] = pres[j] + m;
        else
          nxt[i][j] = min(nxt[i][j], pres[j] + m);
      }
    }
  }
  int cur = -1;
  for (i = 0; i < n; i++) {
    if (i == 0) {
      for (j = 0; j < m; j++)
        if (s[j] == t[i]) break;
      if (j >= m) {
        cout << "-1\n";
        return;
      }
      cur = j;
      ans = 1;
    } else {
      cur = nxt[cur][t[i] - 'a'];
      if (cur == -1) {
        cout << "-1\n";
        return;
      }
      if (cur >= m) {
        cur -= m;
        ans++;
      }
    }
  }
  cout << ans << '\n';
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int t = 1;
  cin >> t;
  while (t--) solve();
  return 0;
}
