#include <bits/stdc++.h>
using namespace std;
long long int power(long long int a, long long int b) {
  long long int res = 1;
  a %= 1000000007;
  assert(b >= 0);
  for (; b; b >>= 1) {
    if (b & 1) res = res * a % 1000000007;
    a = a * a % 1000000007;
  }
  return res;
}
long long int modInverse(long long int a) { return power(a, 1000000007 - 2); }
const int N = 500023;
bool vis[N];
void solve() {
  string s, t;
  cin >> s;
  cin >> t;
  vector<int> adj[30];
  for (int i = 0; i < s.length(); i++) {
    adj[s[i] - 'a'].push_back(i + 1);
  }
  long long int last = 0;
  long long int ans = 0;
  long long int loop = 0;
  for (int i = 0; i < t.length(); i++) {
    char ch = t[i];
    if (adj[ch - 'a'].size() == 0) {
      cout << -1 << '\n';
      return;
    }
    auto it = upper_bound((adj[ch - 'a']).begin(), (adj[ch - 'a']).end(), last);
    if (it == (adj[ch - 'a'].end())) {
      ans++;
      last = 0;
      i--;
    } else {
      last = (*it);
    }
  }
  ans++;
  cout << ans << '\n';
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int T = 1;
  cin >> T;
  int t = 0;
  while (t++ < T) {
    solve();
  }
  cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC
       << "ms\n";
}
