#include#include int cont; char st1[100],st2[100],ans[100]; void build(int n,char *s1,char *s2,char *s) { if(n<=0) return; int p=strchr(s1,s2[n-1])-s1; ans[cont++]=s2[n-1]; build(p,s1,s2,s); build(n-p-1,s1+p+1,s2+p,s+p); } int main() { int t; scanf("%d",&t); while(t--) { cont=0; scanf("%s%s",st1,st2); int len=strlen(st1); build(len,st1,st2,ans); ans[len]='\0'; printf("%s\n",ans); } return 0; }