#include <bits/stdc++.h>
using namespace std;
long long int mod = 1000000007;
void __print(long long int x) { cerr << x; }
void __print(unsigned x) { cerr << x; }
void __print(unsigned long x) { cerr << x; }
void __print(unsigned long long x) { cerr << x; }
void __print(float x) { cerr << x; }
void __print(double x) { cerr << x; }
void __print(long double x) { cerr << x; }
void __print(char x) { cerr << '\'' << x << '\''; }
void __print(const char *x) { cerr << '\"' << x << '\"'; }
void __print(const string &x) { cerr << '\"' << x << '\"'; }
void __print(bool x) { cerr << (x ? "true" : "false"); }
template <typename Th, typename V>
void __print(const pair<Th, V> &x) {
  cerr << '{';
  __print(x.first);
  cerr << ',';
  __print(x.second);
  cerr << '}';
}
template <typename Th>
void __print(const Th &x) {
  long long int f = 0;
  cerr << '{';
  for (auto &i : x) cerr << (f++ ? "," : ""), __print(i);
  cerr << "}";
}
void _print() { cerr << "]\n"; }
template <typename Th, typename... V>
void _print(Th t, V... v) {
  __print(t);
  if (sizeof...(v)) cerr << ", ";
  _print(v...);
}
long long int parent[100000 + 7];
void make_parent() {
  long long int i;
  for (i = 0; i < 100000 + 7; i++) {
    parent[i] = i;
  }
}
long long int find_parent(long long int x) {
  if (x == parent[x]) return x;
  parent[x] = find_parent(parent[x]);
  return parent[x];
}
void unionn(long long int x, long long int y) {
  long long int px = find_parent(x);
  long long int py = find_parent(y);
  if (px == py) return;
  if (px < py)
    parent[py] = px;
  else
    parent[px] = py;
}
long long int aa[200005], st[4 * 200005];
void build(long long int node, long long int start, long long int end) {
  if (start == end) {
    st[node] = aa[start];
    return;
  }
  long long int mid = (start + end) / 2;
  build(2 * node + 1, start, mid);
  build(2 * node + 2, mid + 1, end);
  st[node] = st[2 * node + 1] + st[2 * node + 2];
}
long long int query(long long int node, long long int start, long long int end,
                    long long int l, long long int r) {
  if (l <= start && end <= r) return st[node];
  if (r < start || l > end) return 0;
  long long int mid = (start + end) / 2;
  long long int child1 = query(2 * node + 1, start, mid, l, r);
  long long int child2 = query(2 * node + 2, mid + 1, end, l, r);
  return (child1 + child2);
}
void update(long long int node, long long int start, long long int end,
            long long int index, long long int val) {
  if (start == end) {
    st[node] = val;
    aa[index] = val;
  } else {
    long long int mid = (start + end) / 2;
    if (start <= index && index <= mid)
      update(2 * node + 1, start, mid, index, val);
    else
      update(2 * node + 2, mid + 1, end, index, val);
    st[node] = st[2 * node + 1] + st[2 * node + 2];
  }
}
bool prime[10000001];
void sieveFunction(long long int maxLimit) {
  memset(prime, true, sizeof(prime));
  prime[0] = prime[1] = false;
  for (long long int i = 2; i <= maxLimit; i++) {
    if (prime[i]) {
      for (long long int j = 2 * i; j < maxLimit; j += i) prime[j] = false;
    }
  }
}
long long int modpower(long long int a, long long int n) {
  long long int r;
  if (n == 0) return 1;
  if (n == 1) return a;
  r = modpower(a, n / 2);
  if (n % 2 == 0)
    return ((r) % mod) * ((r) % mod) % mod;
  else
    return ((((r) % mod) * ((r) % mod)) % mod) * ((a) % mod) % mod;
}
void primeFactors(long long int n) {
  while (n % 2 == 0) {
    cout << 2 << " ";
    n = n / 2;
  }
  for (long long int i = 3; i <= sqrt(n); i = i + 2) {
    while (n % i == 0) {
      cout << i << " ";
      n = n / i;
    }
  }
  if (n > 2) cout << n << " ";
}
void binary_rock() {
  string a, b;
  cin >> a >> b;
  long long int n, m;
  n = a.size();
  m = b.size();
  long long int i, j, k, l;
  vector<long long int> mp[26];
  for (i = 0; i < n; i++) {
    long long int x = a[i] - 'a';
    mp[x].push_back(i);
  }
  long long int pre = -2;
  long long int ans = 1;
  for (i = 0; i < m; i++) {
    long long int x = b[i] - 'a';
    if (mp[x].size() == 0) {
      cout << "-1" << endl;
      return;
    }
    auto it = lower_bound(mp[x].begin(), mp[x].end(), pre);
    if ((it != mp[x].end())) {
      if ((*it) == pre) it++;
    }
    if (it == mp[x].end()) {
      pre = -2;
      ans++;
      i--;
    } else {
      long long int xt = *(it);
      pre = xt;
    }
  }
  cout << ans << endl;
}
signed main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  clock_t t1 = clock();
  long long int t = 1;
  cin >> t;
  while (t--) {
    binary_rock();
  }
  clock_t t2 = clock();
  return 0;
}
