import java.io.*;
import java.util.*;

public class magictrick {
    
    public static void main ( String[] args ) throws Exception {
	BufferedReader in = new BufferedReader( new InputStreamReader( System.in ));
	int S = Integer.parseInt( in.readLine() );
	for( int s=1; s<=S; s++ ){
	    System.out.println( "Scenario #" + s + ":" );
	    
	    //--- Parse and collect.
	    boolean[] reached = new boolean[150000];
	    int n = 0, last = 0;
	    Set outcomes = new TreeSet();
	    for( int p=0; p<3; p++ ){
		String text = in.readLine().toLowerCase();
		text = text.replaceAll( "[^a-zA-Z]+", " " ).trim();
		String[] words = text.split( " " );
		for( int i=0; i<words.length && outcomes.size()<=3; i++, n++ ){
		    String word = words[i];
		    if( p==0  ||  p==1  &&  reached[n] ){
			int next = n + word.length();
			reached[next] = true;
			last = Math.max( last, next );
		    }
		    if( p==2  && reached[n] )
			outcomes.add( word );
		}
	    }
	    
	    //--- Handle outside.
	    if( last >= n )
		outcomes.add( "-outside-" );
	    
	    //--- Answer.
	    if( outcomes.size() > 3 ){
		System.out.println( "-too many-" );
	    } else {
		Iterator it = outcomes.iterator();
		while( it.hasNext() )
		    System.out.println( it.next() );
	    }
	    System.out.println();
	}
    }
}
