//prewritten code: https://github.com/antma/algo
import std.algorithm;
import std.array;
import std.conv;
import std.math;
import std.range;
import std.stdio;
import std.string;
import std.traits;

int test () {
  auto s = readln.strip;
  auto t = readln.strip;
  immutable l = s.length.to!int;
  auto next = new int[26][l+1];
  next[l][] = l;
  foreach_reverse (i; 0 .. l) {
    next[i][] = next[i+1][];
    immutable k = s[i].to!int - 97;
    next[i][k] = i;
  }
  foreach (c; t) {
    immutable k = c.to!int - 97;
    if (next[0][k] >= l) return -1;
  }
  int i, res;
  foreach (c; t) {
    immutable k = c.to!int - 97;
    while (true) {
      i = next[i][k];
      if (i >= l) {
        ++res;
        i = 0;
      } else {
        break;
      }
    }
    ++i;
  }
  res++;
  return res;
}


void main() {
  immutable nt = readln.strip.to!int; 
  foreach (tid; 0 .. nt) {
    writeln (test ());
  }
}

