#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);
  int test;
  cin >> test;
  while (test--) {
    string s, t;
    cin >> s >> t;
    int n = s.length();
    vector<vector<int>> last(n + 1, vector<int>(26));
    for (int i = n; i >= 0; i--) {
      for (int j = 0; j < 26; j++) {
        if (i < n) {
          last[i][j] = last[i + 1][j];
        } else {
          last[i][j] = -1;
        }
      }
      if (i < n) {
        last[i][s[i] - 'a'] = i + 1;
      }
    }
    int result = 1;
    int current = 0;
    bool ok = true;
    for (char c : t) {
      current = last[current][c - 'a'];
      if (current == -1) {
        current = last[0][c - 'a'];
        if (current == -1) {
          ok = false;
          break;
        }
        result++;
      }
    }
    if (ok) {
      cout << result;
    } else {
      cout << -1;
    }
    cout << '\n';
  }
  return 0;
}
