#include <bits/stdc++.h>
using namespace std;
int T;
char s[100005], t[100005];
int n, m;
int nxt[26][100005];
int main() {
  ios::sync_with_stdio(false);
  cin >> T;
  while (T--) {
    cin >> (s + 1) >> (t + 1);
    n = strlen(s + 1);
    m = strlen(t + 1);
    int lst;
    for (int c = 0; c < 26; ++c) {
      nxt[c][n + 1] = lst = n + 1;
      for (int i = n; i >= 0; --i) {
        nxt[c][i] = lst;
        if (s[i] == c + 'a') lst = i;
      }
    }
    int cur = 0, ans = 1;
    bool flag = 0;
    for (int i = 1; i <= m; ++i) {
      if (nxt[t[i] - 'a'][0] > n) {
        flag = 1;
        break;
      }
      if (nxt[t[i] - 'a'][cur] <= n)
        cur = nxt[t[i] - 'a'][cur];
      else
        ++ans, cur = nxt[t[i] - 'a'][0];
    }
    if (flag)
      cout << -1 << endl;
    else
      cout << ans << endl;
  }
  return 0;
}
