#include <bits/stdc++.h>
using namespace std;
int NR[100004][26];
int main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  int tt;
  string s, t;
  cin >> tt;
  while (tt--) {
    cin >> s >> t;
    for (int j = 0; j < 26; j++) {
      NR[s.length()][j] = 1e9;
    }
    for (int i = s.length() - 1; i >= 0; i--) {
      for (int j = 0; j < 26; j++) NR[i][j] = NR[i + 1][j];
      NR[i][s[i] - 'a'] = i;
    }
    int ans = 1;
    int pos = 0;
    for (int i = 0; i < t.length();) {
      if (NR[pos][t[i] - 'a'] == 1e9 && pos == 0) {
        ans = -1;
        break;
      }
      if (NR[pos][t[i] - 'a'] != 1e9) {
        pos = NR[pos][t[i] - 'a'] + 1;
        i++;
      } else {
        ans++;
        pos = 0;
      }
    }
    cout << ans << endl;
  }
  return 0;
}
