#include <bits/stdc++.h>
using namespace std;
int T;
string s, t;
int z[100005][30];
int main() {
  cin >> T;
  while (T--) {
    cin >> s >> t;
    int n = s.length();
    int m = t.length();
    for (int i = 0; i < 26; i++) z[n][i] = -1;
    for (int i = n - 1; i >= 0; i--) {
      for (int j = 0; j < 26; j++) {
        if (s[i] - 'a' == j)
          z[i][j] = i;
        else
          z[i][j] = z[i + 1][j];
      }
    }
    int ans = 0, i = 0;
    while (i < m) {
      if (z[0][t[i] - 'a'] == -1) {
        ans = -1;
        break;
      }
      int cur = 0;
      while (i < m) {
        if (z[cur][t[i] - 'a'] == -1) break;
        cur = z[cur][t[i] - 'a'] + 1;
        i++;
      }
      ans++;
    }
    cout << ans << endl;
  }
  return 0;
}
