#include <bits/stdc++.h>
using namespace std;
const int N = 1e5;
int n, x;
string s;
string t;
int _next[N + 10][30];
int main() {
  ios::sync_with_stdio(0), cin.tie(0);
  int T;
  cin >> T;
  while (T--) {
    cin >> s;
    cin >> t;
    int len = s.size();
    for (int i = 0; i < 26; i++) _next[len][i] = -1;
    for (int i = len - 1; i >= 0; i--) {
      for (int j = 0; j < 26; j++) _next[i][j] = _next[i + 1][j];
      int key = s[i] - 'a';
      _next[i][key] = i + 1;
    }
    len = t.size();
    int ans = 1;
    int cur = 0;
    bool ok = true;
    for (int i = 0; i < len; i++) {
      int kk = t[i] - 'a';
      if (_next[cur][kk] != -1) {
        cur = _next[cur][kk];
      } else {
        ans++;
        cur = 0;
        if (_next[0][kk] == -1) {
          ok = false;
          break;
        }
        cur = _next[cur][kk];
      }
    }
    if (!ok)
      cout << -1 << endl;
    else
      cout << ans << endl;
  }
  return 0;
}
