#include <bits/stdc++.h>
using namespace std;
void solve() {
  string second, t;
  cin >> second >> t;
  int n = second.size(), m = t.size(), ans = 0;
  int dp[n][26];
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < 26; j++) dp[i][j] = -1;
  }
  dp[0][second[0] - 'a'] = 0;
  for (int i = 1; i < n; i++) {
    dp[i][second[i] - 'a'] = i;
    for (int j = 0; j < 26; j++) {
      if (j != second[i] - 'a') dp[i][j] = dp[i - 1][j];
    }
  }
  int i = m - 1;
  while (i >= 0) {
    int x = t[i] - 'a';
    int j = dp[n - 1][x];
    if (j == -1) {
      cout << -1 << endl;
      return;
    }
    i--;
    while (j >= 0 && i >= 0) {
      if (j == 0) break;
      x = t[i] - 'a';
      j = dp[j - 1][x];
      if (j != -1) i--;
    }
    ans++;
  }
  cout << ans << endl;
}
int main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0), cerr.tie(0);
  ;
  int t = 1;
  cin >> t;
  while (t--) solve();
}
