#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  while (t--) {
    string s;
    string t;
    cin >> s >> t;
    int ans = 1;
    int last = INT_MIN;
    vector<int> v[26];
    int dp[2][26];
    for (int i = 0; i < s.length(); i++) {
      v[s[i] - 'a'].push_back(i);
    }
    for (int i = 0; i < 26; i++) {
      dp[0][i] = v[i].size();
      dp[1][i] = 0;
    }
    for (int i = 0; i < t.length(); i++) {
      if (v[t[i] - 'a'].empty()) {
        ans = -1;
        break;
      } else {
        int temp = dp[1][t[i] - 'a'];
        vector<int>::iterator lower, l;
        l = v[t[i] - 'a'].begin() + temp;
        lower = lower_bound(l, v[t[i] - 'a'].end(), last);
        if (lower - v[t[i] - 'a'].begin() == dp[0][t[i] - 'a']) {
          ans++;
          last = v[t[i] - 'a'][0];
          for (int j = 0; j < 26; j++) dp[1][j] = 0;
          dp[1][t[i] - 'a'] = 1;
        } else {
          last = v[t[i] - 'a'][lower - v[t[i] - 'a'].begin()];
          dp[1][t[i] - 'a'] = lower - v[t[i] - 'a'].begin() + 1;
        }
      }
    }
    cout << ans << endl;
  }
  return 0;
}
