#include <bits/stdc++.h>
using namespace std;
map<char, int> mp, mp1;
string s, t;
void solve() {
  int ans = 1;
  map<char, vector<int> > pos;
  int pre = -1;
  for (int i = 0; i < s.size(); i++) {
    pos[s[i]].push_back(i + 1);
  }
  for (auto ch : t) {
    auto cur = upper_bound(pos[ch].begin(), pos[ch].end(), pre);
    if (cur == pos[ch].end()) {
      ans++;
      pre = pos[ch][0];
    } else
      pre = *cur;
  }
  cout << ans << endl;
}
int main(void) {
  int test;
  scanf("%d", &test);
  for (int cs = 1; cs <= test; cs++) {
    cin >> s >> t;
    bool ok = 0;
    for (int i = 0; i < s.size(); i += 1) {
      mp[s[i]]++;
    }
    for (int i = 0; i < t.size(); i += 1) {
      mp1[t[i]]++;
    }
    for (char ch = 'a'; ch <= 'z'; ch += 1) {
      if (mp1[ch] > 0 && mp[ch] == 0) {
        ok = 1;
        break;
      }
    }
    if (ok)
      puts("-1");
    else
      solve();
    mp.clear();
    mp1.clear();
  }
  return 0;
}
