#include <bits/stdc++.h>
using namespace std;
using ull = unsigned long long;
const int INF = (int)1e9;
const long long IINF = LLONG_MAX;
const int maxn = 10000005;
long long modexpo(long long a, long long b) {
  int ans = 1LL;
  while (b > 0) {
    if (b & 1) ans = (ans * a);
    a = (a * a);
    b >>= 1;
  }
  return ans;
}
int main() {
  int t;
  cin >> t;
  while (t--) {
    string s, t;
    cin >> s >> t;
    vector<int> dp[26];
    for (int i = 0; i < s.length(); i++) {
      dp[s[i] - 'a'].push_back(i);
    }
    int find = 1;
    int cur = -1;
    int cost = 0;
    for (int i = 0; i < t.length(); i++) {
      if (cur == -1) {
        if (dp[t[i] - 'a'].size() == 0) {
          find = 0;
          break;
        } else {
          cur = dp[t[i] - 'a'][0];
        }
      } else {
        int idx = t[i] - 'a';
        if (dp[idx].size() == 0) {
          find = 0;
          break;
        } else {
          int curidx = upper_bound(dp[idx].begin(), dp[idx].end(), cur) -
                       dp[idx].begin();
          if (curidx != dp[idx].size()) {
            cur = dp[idx][curidx];
          } else {
            cost++;
            cur = dp[idx][0];
          }
        }
      }
    }
    if (!find) {
      cout << -1;
    } else
      cout << cost + 1;
    cout << endl;
  }
}
