#include <bits/stdc++.h>
using namespace std;
const int MAXN = 2e5 + 5;
int T, nxt[MAXN][26];
char s[MAXN], ss[MAXN];
int main() {
  ios_base::sync_with_stdio(false);
  for (cin >> T; T--;) {
    cin >> s + 1 >> ss + 1;
    int len1 = strlen(s + 1), len2 = strlen(ss + 1);
    for (int j = 0; j < 26; j++) nxt[len1][j] = len1 + 1;
    for (int i = len1; i > 0; i--) {
      memcpy(nxt[i - 1], nxt[i], sizeof nxt[0]);
      nxt[i - 1][s[i] - 'a'] = i;
    }
    int p = 0, now = 1, cnt = 0, id;
    while (now <= len2) {
      id = ss[now] - 'a';
      if (nxt[p][id] == len1 + 1) {
        if (p == 0) {
          cnt = -1;
          break;
        }
        p = 0;
        cnt++;
      } else {
        now++;
        p = nxt[p][id];
      }
    }
    cout << (cnt == -1 ? -1 : cnt + (p != 0)) << '\n';
  }
}
