#include <bits/stdc++.h>
using namespace std;
const int MOD = 1e9 + 7;
const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3f;
const double EPS = 1e-9;
const double PI = 3.14159265358979;
const int MAXN = 200 + 10;
const int MAXM = 2 + 10;
string s, t;
vector<int> pos[MAXN];
void solve() {
  int n = s.length(), m = t.length();
  for (int i = 'a'; i <= 'z'; i++) pos[i].clear();
  for (int i = 0; i < n; i++) {
    pos[s[i]].push_back(i);
  }
  int ans = 0, last = -1;
  for (int i = 0; i < m; i++) {
    int p = lower_bound(pos[t[i]].begin(), pos[t[i]].end(), last) -
            pos[t[i]].begin();
    if (last == -1 && p == pos[t[i]].size()) {
      printf("-1\n");
      return;
    } else if (p == pos[t[i]].size()) {
      last = -1;
      ans++;
      i--;
    } else {
      last = pos[t[i]][p] + 1;
    }
  }
  ans++;
  printf("%d\n", ans);
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int T;
  cin >> T;
  while (T--) {
    cin >> s >> t;
    solve();
  }
  return 0;
}
