#include <bits/stdc++.h>
char a[1000010];
char b[1000010];
int main() {
  int T;
  scanf("%d\n", &T);
  while (T--) {
    scanf("%s\n%s\n", a, b);
    int alen = strlen(a);
    int blen = strlen(b);
    int i;
    int cur = 0;
    int sw = 1;
    for (i = 0; i < blen; i++) {
      if (alen > blen) {
        sw = 0;
        break;
      }
      if (b[i] == a[cur])
        cur++;
      else {
        if (b[i] == a[cur - 1])
          continue;
        else {
          sw = 0;
          break;
        }
      }
    }
    if (cur == alen && sw == 1)
      sw = 1;
    else
      sw = 0;
    if (sw == 1)
      printf("YES\n");
    else
      printf("NO\n");
  }
  return 0;
}
