#include <bits/stdc++.h>
using namespace std;
int main(int argc, char const *argv[]) {
  int n, i, j, k, c, lens, lent;
  cin >> n;
  int Res[n];
  char s[1000001];
  char t[1000001];
  for (int p = 0; p < n; p++) {
    cin >> s;
    cin >> t;
    lens = strlen(s);
    Res[p] = 1;
    c = 0;
    for (i = 0; t[i]; i++) {
      for (k = c; s[k] && s[k] != t[i]; k++)
        ;
      if (!s[k]) {
        Res[p] = -1;
        break;
      } else {
        if (t[i + 1]) {
          k++;
          for (1; s[k] && s[k] != t[i + 1]; k++)
            ;
          if (!s[k]) {
            Res[p]++;
            c = 0;
          } else
            c = i + 1;
        }
      }
    }
  }
  for (int p = 0; p < n; p++) {
    cout << Res[p] << endl;
  }
  return 0;
}
