#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long t;
  cin >> t;
  while (t--) {
    string s1, s2;
    long long n, m, i, j, ans = 1, in = 0;
    cin >> s1;
    cin >> s2;
    n = s1.size();
    m = s2.size();
    int pos[n + 1][26];
    for (i = 0; i < 26; i++) pos[n][i] = -1;
    for (i = n - 1; i >= 0; i--) {
      for (j = 0; j < 26; j++) {
        if (s1[i] - 'a' == j)
          pos[i][j] = i;
        else
          pos[i][j] = pos[i + 1][j];
      }
    }
    for (i = 0; i < m; i++) {
      if (pos[0][s2[i] - 'a'] == -1) {
        ans = -1;
        break;
      }
    }
    if (ans == -1) {
      cout << -1 << "\n";
      continue;
    }
    for (i = 0; i < m; i++) {
      if (in == n) {
        ans++;
        in = 0;
      } else if (pos[in][s2[i] - 'a'] == -1) {
        ans++;
        in = 0;
      }
      in = pos[in][s2[i] - 'a'] + 1;
    }
    cout << ans << "\n";
  }
  return 0;
}
