#include <bits/stdc++.h>
using namespace std;
long long mod = 1000000007;
const long long num = 1000000000;
int main() {
  long long q = 1;
  cin >> q;
  while (q--) {
    string s, t;
    cin >> s;
    cin >> t;
    string z = "";
    long long count = 1;
    int flag = 1;
    long long cnt = 0;
    map<char, set<long long> > ind;
    for (int c = 'a'; c <= 'z'; c++) {
      ind[c] = set<long long>();
    }
    for (int i = 0; i < s.length(); i++) {
      ind[s[i]].insert(i);
    }
    long long curr = -1;
    for (int i = 0; i < t.length(); i++) {
      if (!ind[t[i]].size()) {
        flag = 0;
        break;
      } else {
        auto it = ind[t[i]].upper_bound(curr);
        long long j;
        if (it == ind[t[i]].end()) {
          count++;
          it = ind[t[i]].begin();
        }
        j = (*it);
        curr = j;
      }
    }
    if (flag)
      cout << count << endl;
    else
      cout << -1 << endl;
  }
  return 0;
}
