#include <bits/stdc++.h>
using namespace std;
long long fact(long long n) {
  if (n == 0) {
    return 1;
  }
  return (n * fact(n - 1)) % 1000000007;
}
long long power(long long x, long long y) {
  long long out = 1;
  while (y > 0) {
    if (y & 1) out = (out * x) % 1000000007;
    y = y >> 1;
    x = (x * x) % 1000000007;
  }
  return out % 1000000007;
}
long long inverse(long long a) { return power(a, 1000000007 - 2); }
long long gcd(long long a, long long b) {
  if (b == 0) {
    return a;
  }
  gcd(b, a % b);
}
long long a[2000000];
void sieve() {
  long long i, j;
  for (i = 2; i < 1000001; i++) {
    if (a[i] == 0) {
      for (j = i * i; j < 1000001; j += i) {
        a[j] = 1;
      }
    }
  }
}
bool compar(const pair<long long, long long> &a,
            const pair<long long, long long> &b) {
  if (a.first == b.first)
    return (a.second < b.second);
  else
    return (a.first < b.first);
}
void comp() {
  long long i, j, k, l, m, x, y;
  string s, t;
  unordered_map<char, vector<int> > m1;
  cin >> s >> t;
  for (i = 0; i < s.length(); i++) {
    m1[s[i]].push_back(i);
  }
  for (i = 0; i < t.length(); i++) {
    if (m1[t[i]].size() == 0) {
      cout << -1 << endl;
      return;
    }
  }
  vector<int> temp;
  int count = 1, ind = -1;
  int low, high, mid, temp1;
  reverse(t.begin(), t.end());
  for (i = 0; i < t.length(); i++) {
    if (ind == -1) {
      temp = m1[t[i]];
      ind = temp[temp.size() - 1];
    } else {
      temp1 = -1;
      low = 0;
      high = m1[t[i]].size() - 1;
      while (low <= high) {
        mid = (low + high) / 2;
        if (m1[t[i]][mid] >= ind) {
          high = mid - 1;
        } else {
          temp1 = m1[t[i]][mid];
          low = mid + 1;
        }
      }
      if (temp1 == -1) {
        count++;
        ind = m1[t[i]][m1[t[i]].size() - 1];
      } else {
        ind = temp1;
      }
    }
  }
  cout << count << endl;
}
int main() {
  ios_base::sync_with_stdio(false), cin.tie(0);
  long long i = 0, t;
  long long n;
  cin >> t;
  while (t--) {
    comp();
  }
}
