#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  while (t--) {
    string a, b;
    cin >> a >> b;
    int n = a.length(), m = b.length();
    vector<vector<int>> dp(n + 1, vector<int>(26, INT_MAX));
    for (int i = n - 1; i >= 0; i--) {
      for (int j = 0; j < 26; j++) dp[i][j] = dp[i + 1][j];
      dp[i][a[i] - 'a'] = i;
    }
    int pos = 0, ans = 1;
    for (int i = 0; i < m; i++) {
      if (pos >= n || dp[pos][b[i] - 'a'] == INT_MAX) {
        ans++;
        pos = 0;
      }
      if (pos == 0 && dp[pos][b[i] - 'a'] == INT_MAX) {
        ans = -1;
        break;
      }
      pos = dp[pos][b[i] - 'a'] + 1;
    }
    cout << ans << "\n";
  }
  return 0;
}
