#include <bits/stdc++.h>
using namespace std;
const int N = 200009;
int tc;
string s, t;
int arr[N][26];
int main() {
  int n, ans, pos;
  cin >> tc;
  while (tc--) {
    cin >> s >> t;
    ans = 1;
    pos = 0;
    n = s.size();
    for (int i = 0; i < (n + 1); i++) {
      for (int j = 0; j < 26; j++) {
        arr[i][j] = -1;
      }
    }
    for (int i = s.size() - 1; i >= 0; i--) {
      for (int j = 0; j < 26; j++) {
        arr[i][j] = arr[i + 1][j];
        arr[i][s[i] - 'a'] = i;
      }
    }
    for (int i = 0; i < t.size(); i++) {
      if (arr[pos][t[i] - 'a'] == -1) {
        pos = 0;
        ans++;
      }
      if (arr[pos][t[i] - 'a'] != -1) {
        pos = arr[pos][t[i] - 'a'] + 1;
      }
      if (arr[pos][t[i] - 'a'] == -1 and pos == 0) {
        ans = -1;
        break;
      }
    }
    cout << ans << "\n";
  }
}
