#include <bits/stdc++.h>
using namespace std;
ifstream fin("AAtest.in.txt");
int q, jad[26][100005], vas;
string s, t;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cerr.tie(0);
  cin >> q;
  while (q--) {
    cin >> s >> t;
    int i = 0;
    for (char c : s) jad[c - 'a'][i++]++;
    int n = s.size();
    for (int(i) = (0); ((i)) < ((26)); ((i))++)
      for (int j = n - 1; j >= 0; j--)
        jad[i][j] = jad[i][j] ? j + 1 : jad[i][j + 1];
    i = 0;
    vas = 1;
    bool ei = 0;
    for (char c : t) {
      if (jad[c - 'a'][i]) {
        i = jad[c - 'a'][i];
        continue;
      }
      vas++;
      if (jad[c - 'a'][0]) {
        i = jad[c - 'a'][0];
        continue;
      }
      ei = 1;
      break;
    }
    if (ei)
      cout << -1 << endl;
    else
      cout << vas << endl;
    for (int(i) = (0); ((i)) < ((26)); ((i))++)
      for (int(j) = (0); ((j)) < ((n)); ((j))++) jad[i][j] = 0;
  }
}
