Pasha got a very beautiful string s for his birthday, the string consists of lowercase Latin letters. The letters in the string are numbered from 1 to |s| from left to right, where |s| is the length of the given string.Pasha didn't like his present very much so he decided to change it. After his birthday Pasha spent m days performing the following transformations on his string — each day he chose integer ai and reversed a piece of string (a segment) from position ai to position |s| - ai + 1. It is guaranteed that 2·ai ≤ |s|.You face the following task: determine what Pasha's string will look like after m days.

The first line of the input contains Pasha's string s of length from 2 to 2·105 characters, consisting of lowercase Latin letters. The second line contains a single integer m (1 ≤ m ≤ 105) —  the number of days when Pasha changed his string. The third line contains m space-separated elements ai (1 ≤ ai; 2·ai ≤ |s|) — the position from which Pasha started transforming the string on the i-th day.

In the first line of the output print what Pasha's string s will look like after m days.

function ProblemSolver() {
    this.HAS_TEST_CASES = false;
    this.INPUT_FILE_NAME = "test.in";
    this.OUTPUT_FILE_NAME = "out.txt";
    this.DO_OUTPUT_TO_FILE = false;
    this.CLEAR_ARRAY_PER_CASE = false;

	this.sortComparator = function( left , right ) {
		return left - right ;
	} ;

    this.solveCase = function() {
        var res , i , j , fl , cn , temp , len , len2 ;
        len = this.s.length ;
        res = "" ;
        for( i = 0 ; i < this.n ; i++ ) {
        	this.arr[ i ] = this.arr[ i ] - 1 ;
        }
        this.arr = this.arr.sort( this.sortComparator ) ;
        for( i = 0 ; i < len ; i++ ) {
        	this.brr[ i ] = this.s.charCodeAt( i ) ;
        }
        j = 0 ;
        cn = 0 ;
        len2 = Math.floor( len / 2 ) ;
        for( i = 0 ; i < len2 ; i++ ) {
        	while( j < this.n && this.arr[ j ] == i ) {
        		cn++ ;
        		j++ ;
        	}
        	if( cn % 2 == 0 ) {
        	}
        	else {
        		temp = this.brr[ i ] ;
        		this.brr[ i ] = this.brr[ len - i - 1 ] ;
        		this.brr[ len - i - 1 ] = temp ;
        	}
        }
        for( i = 0 ; i < len ; i++ ) {
        	res += String.fromCharCode( this.brr[ i ] ) ;
        }
        print( res );
    };

    this.init = function() {
        this.lim1 = 100010;
        this.lim2 = 110;
        this.cc = 1;
        this.ind = 1;
        this.n = 0;
        this.cn = 0;
        this.declareAndFillArrays();
    };

    this.getInput = function( irObj ) {
        var hasMoreInput , i;
        hasMoreInput = true;
        try {
            this.s = irObj.nextString();
            this.n = irObj.nextInt();
            this.arr = new Array() ;
            for( i = 0 ; i < this.n ; i++ ) {
                this.arr.push( irObj.nextInt() ) ;
            }
        }
        catch( ex ) {
            hasMoreInput = false;
        }
        return hasMoreInput;
    };

    this.clearArraysPerCase = function() {
        var i;
        this.arr = new Array();
        this.adj_list = new Array();
        for( i = 0 ; i < this.lim1 ; i++ ) {
            this.arr.push( 0 );
            this.adj_list.push( new Array() );
        }
    };

    this.clearPerCase = function() {
        this.cn = 0;
        this.cc++;
        if( this.CLEAR_ARRAY_PER_CASE == true ) {
            this.clearArraysPerCase() ;
        }
    };

    this.declareAndFillArrays = function() {
        var i , j;
        this.srr = new Array();
        this.vis = new Array();
        this.arr = new Array();
        this.brr = new Array();
        this.memo = new Array();
        this.done = new Array();
        this.adj_list = new Array();
        for( i = 0 ; i < this.lim1 ; i++ ) {
            this.srr.push( "" );
            this.vis.push( 0 );
            this.arr.push( 0 );
            this.brr.push( 0 );
            this.adj_list.push( new Array() );
        }
        for( i = 0 ; i < this.lim2 ; i++ ) {
            this.memo.push( new Array() );
            this.done.push( new Array() );
            for( j = 0 ; j < this.lim2 ; j++ ) {
                this.memo[ i ].push( -1 );
                this.done[ i ].push( 0 );
            }
        }
    };

    this.init();
}

function InputReader() {
    var self = this ;
    this.allLines = new Array();
    this.currrentLineNumber = 0;
    this.currrentCharacterIndex = 0;
    this.callBackFunction = null ;
    this.parentContext = null ;

    this.readAllLines = function() {
        var singleLine;
        while( true ) {
            try {
                singleLine = readline();
                if( singleLine == null ) {
                    break;
                }
            }
            catch( ex ) {
                break;
            }
            this.allLines.push( singleLine );
        }
    };

    this.readAllLinesFromRhino = function() {
        var brObj , line ;
        importPackage( java.io ) ;
        importPackage( java.lang ) ;
        brObj = new BufferedReader( new InputStreamReader( System[ 'in' ] ) ) ;
        this.allLines = [] ;
        while( true ) {
            line = brObj.readLine() ;
            if( line == null ) {
                break;
            }
            this.allLines.push( line ) ;
        }
    };

    this.readSingleLinesFromNodeJsJudgeServer = function( chunk ) {
        self.chunkData += chunk ;
    };

    this.readEndFromNodeJsJudgeServer = function() {
        self.parseRawData( self.chunkData ) ;
        self.parentContext.runCases() ;
    };

    this.readAllLinesFromNodeJsJudgeServer = function( parentContext ) {
        this.parentContext = parentContext ;
        process.stdin.resume() ;
        process.stdin.setEncoding( 'utf8' ) ;
        this.chunkData = '' ;
        process.stdin.on( 'data' , this.readSingleLinesFromNodeJsJudgeServer ) ;
        process.stdin.on( 'end' , this.readEndFromNodeJsJudgeServer ) ;
    };

    this.parseRawData = function( data ) {
        var len , i , currentString;
        len = data.length;
        currentString = "";
        this.allLines = [] ;
        for( i = 0 ; i < len ; i++ ) {
            if( data[ i ] == '\r' ) {
            }
            else if( data[ i ] == '\n' ) {
                this.allLines.push( currentString );
                currentString = "";
            }
            else {
                currentString += data[ i ];
            }
        }
        if( currentString != "" ) {
            this.allLines.push( currentString );
        }
    };

    this.readAllLinesFromFile = function( inputFileName ) {
        var currentDirectory , fsObj , inputFilePath , rawData;
        fsObj = require( 'fs' );
        currentDirectory = __dirname;
        inputFilePath = currentDirectory + "\\" + inputFileName;
        rawData = fsObj.readFileSync( inputFilePath , "utf8" );
        this.parseRawData( rawData );
    };

    this.next = function( flag ) {
        var len , i , startIdx , res , endIdx;
        if( flag == 0 ) {
            if( this.currrentCharacterIndex != 0 ) {
                this.currrentLineNumber++;
                this.currrentCharacterIndex = 0;
            }
            res = "";
            len = this.allLines[ this.currrentLineNumber ].length;
            if( typeof( len ) == 'function' ) {
                len = this.allLines[ this.currrentLineNumber ].length() ;
            }
            for( i = this.currrentCharacterIndex ; i < len ; i++ ) {
                res += '' + this.allLines[ this.currrentLineNumber ].charAt( i ) ;
            }
            this.currrentLineNumber++;
            this.currrentCharacterIndex = 0;
            return res;
        }
        while( true ) {
            if( this.currrentLineNumber >= this.allLines.length ) {
                throw new Error( "No more tokens available!" );
            }
            startIdx = -1;
            len = this.allLines[ this.currrentLineNumber ].length;
            if( typeof( len ) == 'function' ) {
                len = this.allLines[ this.currrentLineNumber ].length() ;
            }
            for( i = this.currrentCharacterIndex ; i < len ; i++ ) {
                if( this.allLines[ this.currrentLineNumber ].charCodeAt( i ) != ' '.charCodeAt( 0 ) ) {
                    startIdx = i;
                    break;
                }
            }
            if( startIdx == -1 ) {
                this.currrentLineNumber++;
                this.currrentCharacterIndex = 0;
                continue;
            }
            res = "";
            endIdx = len - 1 ;
            for( i = startIdx ; i < len ; i++ ) {
                if( this.allLines[ this.currrentLineNumber ].charCodeAt( i ) == ' '.charCodeAt( 0 ) ) {
                    endIdx = i;
                    break;
                }
                if( this.allLines[ this.currrentLineNumber ].charCodeAt( i ) >= 48 && this.allLines[ this.currrentLineNumber ].charCodeAt( i ) <= 57 ) {
                    res += '' + ( this.allLines[ this.currrentLineNumber ].charCodeAt( i ) - 48 ) ;
                }
                else {
                    res += '' + this.allLines[ this.currrentLineNumber ].charAt( i );
                }
            }
            this.currrentCharacterIndex = endIdx;
            if( endIdx == len - 1 ) {
                this.currrentLineNumber++;
                this.currrentCharacterIndex = 0;
            }
            return res;
        }
    };

    this.nextInt = function() {
        return parseInt( this.next( 1 ) );
    };

    this.nextDouble = function() {
        return parseFloat( this.next( 1 ) );
    };

    this.nextString = function() {
        return this.next( 1 );
    };

    this.nextLine = function() {
        return this.next( 0 );
    };
}

function FileOutputHandler() {
    this.resultantStringArray = new Array();

    this.addNewLine = function( newString ) {
        this.resultantStringArray.push( newString );
    };

    this.clearPercase = function() {
        this.resultantStringArray = new Array();
    };

    this.flushOutOutputToFile = function( outputFileName ) {
        var i , sz , res , currentDirectory , fsObj , outputFilePath;
        res = "";
        sz = this.resultantStringArray.length;
        for( i = 0 ; i < sz ; i++ ) {
            if( i != 0 ) {
                res += "\n";
            }
            res += this.resultantStringArray[ i ];
        }
        fsObj = require( 'fs' );
        currentDirectory = __dirname;
        outputFilePath = currentDirectory + "\\" + outputFileName;
        fsObj.writeFileSync( outputFilePath , res );
        this.clearPercase();
    };
}

function CodeExecutioner() {
    this.irObj = new InputReader();
    this.psObj = new ProblemSolver();
    this.fohObj = new FileOutputHandler();

    this.runCases = function() {
        if( this.psObj.HAS_TEST_CASES == true ) {
            testCases = this.irObj.nextInt();
            for( i = 0 ; i < testCases ; i++ ) {
                this.psObj.clearPerCase();
                this.psObj.getInput( this.irObj );
                this.psObj.solveCase();
            }
        }
        else {
            while( true ) {
                this.psObj.clearPerCase();
                hasMoreTestCases = this.psObj.getInput( this.irObj );
                if( hasMoreTestCases == false ) {
                    break;
                }
                this.psObj.solveCase();
            }
        }
        if( this.psObj.DO_OUTPUT_TO_FILE == true ) {
            this.fohObj.flushOutOutputToFile( this.psObj.OUTPUT_FILE_NAME );
        }
    };

    this.detectEnvironmentType = function() {
        var environmentType = null ;
        try {
            if( importPackage != null ) {
                environmentType = 'rhino' ;
            }
        }
        catch( ex1 ) {
            try {
                //for nodejs local server check
                if( __dirname != null && readline != null && typeof( readline ) != 'function' ) {
                    environmentType = 'local-node-js' ;
                }
            }
            catch( ex2 ) {
                try {
                    if( readline == null || typeof( readline ) != 'function' ) {
                        environmentType = 'server-node-js' ;
                    }
                    else {
                        try {
                            if( Map != null ) {
                                environmentType = 'spider-monkey' ;
                            }
                            else {
                                environmentType = 'javascript-v8' ;
                            }
                        }
                        catch( ex3 ) {
                            environmentType = 'javascript-v8' ;
                        }
                    }
                }
                catch( ex3 ) {
                    environmentType = 'server-node-js' ;
                }
            }
        }
        return environmentType ;
    };

    this.configureStreamsAndReadInput = function() {
        var testCases , i , hasMoreTestCases , isLocal , localContext , isNodeJsJudgeServer , environmentType ;
        isNodeJsJudgeServer = false ;
        environmentType = this.detectEnvironmentType() ;
        if( environmentType == 'local-node-js' ) {
            try {
                if( print == null || typeof( print ) != 'function' ) {
                    print = console.log;
                }
            }
            catch( ex ) {
                print = console.log;
            }
            if( this.psObj.DO_OUTPUT_TO_FILE == true ) {
                localContext = this.fohObj;
                print = function() {
                    localContext.addNewLine.apply( localContext , arguments );
                }
            }
            this.irObj.readAllLinesFromFile( this.psObj.INPUT_FILE_NAME );
            this.runCases() ;
        }
        else if( environmentType == 'server-node-js' ) {
            try {
                if( print == null || typeof( print ) != 'function' ) {
                    print = console.log;
                }
            }
            catch( ex ) {
                print = console.log;
            }
            this.irObj.readAllLinesFromNodeJsJudgeServer( this ) ;
        }
        else if( environmentType == 'javascript-v8' ) {
            this.irObj.readAllLines();
            this.runCases() ;
        }
        else if( environmentType == 'rhino' ) {
            this.irObj.readAllLinesFromRhino();
            this.runCases() ;
        }
        else if( environmentType == 'spider-monkey' ) {
            this.irObj.readAllLines();
            this.runCases() ;
        }
    };

    this.configureStreamsAndReadInput();
}

new CodeExecutioner();

function ProblemSolver() {
    this.HAS_TEST_CASES = false;
    this.INPUT_FILE_NAME = "test.in";
    this.OUTPUT_FILE_NAME = "out.txt";
    this.DO_OUTPUT_TO_FILE = false;
    this.CLEAR_ARRAY_PER_CASE = false;

    this.solveCase = function() {
        var res , i , j , fl , cn , temp , len , len2 ;
        len = this.s.length ;
        res = "" ;
        for( i = 0 ; i < this.n ; i++ ) {
        	this.arr[ i ] = this.arr[ i ] - 1 ;
        }
        this.arr.sort() ;
        for( i = 0 ; i < len ; i++ ) {
        	this.brr[ i ] = this.s.charCodeAt( i ) ;
        }
        j = 0 ;
        cn = 0 ;
        len2 = Math.floor( len / 2 ) ;
        for( i = 0 ; i < len2 ; i++ ) {
        	while( j < this.n && this.arr[ j ] == i ) {
        		cn++ ;
        		j++ ;
        	}
        	if( cn % 2 == 0 ) {
        	}
        	else {
        		temp = this.brr[ i ] ;
        		this.brr[ i ] = this.brr[ len - i - 1 ] ;
        		this.brr[ len - i - 1 ] = temp ;
        	}
        }
        for( i = 0 ; i < len ; i++ ) {
        	res += String.fromCharCode( this.brr[ i ] ) ;
        }
        print( res );
    };

    this.init = function() {
        this.lim1 = 100010;
        this.lim2 = 110;
        this.cc = 1;
        this.ind = 1;
        this.n = 0;
        this.cn = 0;
        this.declareAndFillArrays();
    };

    this.getInput = function( irObj ) {
        var hasMoreInput , i;
        hasMoreInput = true;
        try {
            this.s = irObj.nextString();
            this.n = irObj.nextInt();
            this.arr = new Array() ;
            for( i = 0 ; i < this.n ; i++ ) {
                this.arr.push( irObj.nextInt() ) ;
            }
        }
        catch( ex ) {
            hasMoreInput = false;
        }
        return hasMoreInput;
    };

    this.clearArraysPerCase = function() {
        var i;
        this.arr = new Array();
        this.adj_list = new Array();
        for( i = 0 ; i < this.lim1 ; i++ ) {
            this.arr.push( 0 );
            this.adj_list.push( new Array() );
        }
    };

    this.clearPerCase = function() {
        this.cn = 0;
        this.cc++;
        if( this.CLEAR_ARRAY_PER_CASE == true ) {
            this.clearArraysPerCase() ;
        }
    };

    this.declareAndFillArrays = function() {
        var i , j;
        this.srr = new Array();
        this.vis = new Array();
        this.arr = new Array();
        this.brr = new Array();
        this.memo = new Array();
        this.done = new Array();
        this.adj_list = new Array();
        for( i = 0 ; i < this.lim1 ; i++ ) {
            this.srr.push( "" );
            this.vis.push( 0 );
            this.arr.push( 0 );
            this.brr.push( 0 );
            this.adj_list.push( new Array() );
        }
        for( i = 0 ; i < this.lim2 ; i++ ) {
            this.memo.push( new Array() );
            this.done.push( new Array() );
            for( j = 0 ; j < this.lim2 ; j++ ) {
                this.memo[ i ].push( -1 );
                this.done[ i ].push( 0 );
            }
        }
    };

    this.init();
}

function InputReader() {
    var self = this ;
    this.allLines = new Array();
    this.currrentLineNumber = 0;
    this.currrentCharacterIndex = 0;
    this.callBackFunction = null ;
    this.parentContext = null ;

    this.readAllLines = function() {
        var singleLine;
        while( true ) {
            try {
                singleLine = readline();
                if( singleLine == null ) {
                    break;
                }
            }
            catch( ex ) {
                break;
            }
            this.allLines.push( singleLine );
        }
    };

    this.readAllLinesFromRhino = function() {
        var brObj , line ;
        importPackage( java.io ) ;
        importPackage( java.lang ) ;
        brObj = new BufferedReader( new InputStreamReader( System[ 'in' ] ) ) ;
        this.allLines = [] ;
        while( true ) {
            line = brObj.readLine() ;
            if( line == null ) {
                break;
            }
            this.allLines.push( line ) ;
        }
    };

    this.readSingleLinesFromNodeJsJudgeServer = function( chunk ) {
        self.chunkData += chunk ;
    };

    this.readEndFromNodeJsJudgeServer = function() {
        self.parseRawData( self.chunkData ) ;
        self.parentContext.runCases() ;
    };

    this.readAllLinesFromNodeJsJudgeServer = function( parentContext ) {
        this.parentContext = parentContext ;
        process.stdin.resume() ;
        process.stdin.setEncoding( 'utf8' ) ;
        this.chunkData = '' ;
        process.stdin.on( 'data' , this.readSingleLinesFromNodeJsJudgeServer ) ;
        process.stdin.on( 'end' , this.readEndFromNodeJsJudgeServer ) ;
    };

    this.parseRawData = function( data ) {
        var len , i , currentString;
        len = data.length;
        currentString = "";
        this.allLines = [] ;
        for( i = 0 ; i < len ; i++ ) {
            if( data[ i ] == '\r' ) {
            }
            else if( data[ i ] == '\n' ) {
                this.allLines.push( currentString );
                currentString = "";
            }
            else {
                currentString += data[ i ];
            }
        }
        if( currentString != "" ) {
            this.allLines.push( currentString );
        }
    };

    this.readAllLinesFromFile = function( inputFileName ) {
        var currentDirectory , fsObj , inputFilePath , rawData;
        fsObj = require( 'fs' );
        currentDirectory = __dirname;
        inputFilePath = currentDirectory + "\\" + inputFileName;
        rawData = fsObj.readFileSync( inputFilePath , "utf8" );
        this.parseRawData( rawData );
    };

    this.next = function( flag ) {
        var len , i , startIdx , res , endIdx;
        if( flag == 0 ) {
            if( this.currrentCharacterIndex != 0 ) {
                this.currrentLineNumber++;
                this.currrentCharacterIndex = 0;
            }
            res = "";
            len = this.allLines[ this.currrentLineNumber ].length;
            if( typeof( len ) == 'function' ) {
                len = this.allLines[ this.currrentLineNumber ].length() ;
            }
            for( i = this.currrentCharacterIndex ; i < len ; i++ ) {
                res += '' + this.allLines[ this.currrentLineNumber ].charAt( i ) ;
            }
            this.currrentLineNumber++;
            this.currrentCharacterIndex = 0;
            return res;
        }
        while( true ) {
            if( this.currrentLineNumber >= this.allLines.length ) {
                throw new Error( "No more tokens available!" );
            }
            startIdx = -1;
            len = this.allLines[ this.currrentLineNumber ].length;
            if( typeof( len ) == 'function' ) {
                len = this.allLines[ this.currrentLineNumber ].length() ;
            }
            for( i = this.currrentCharacterIndex ; i < len ; i++ ) {
                if( this.allLines[ this.currrentLineNumber ].charCodeAt( i ) != ' '.charCodeAt( 0 ) ) {
                    startIdx = i;
                    break;
                }
            }
            if( startIdx == -1 ) {
                this.currrentLineNumber++;
                this.currrentCharacterIndex = 0;
                continue;
            }
            res = "";
            endIdx = len - 1 ;
            for( i = startIdx ; i < len ; i++ ) {
                if( this.allLines[ this.currrentLineNumber ].charCodeAt( i ) == ' '.charCodeAt( 0 ) ) {
                    endIdx = i;
                    break;
                }
                if( this.allLines[ this.currrentLineNumber ].charCodeAt( i ) >= 48 && this.allLines[ this.currrentLineNumber ].charCodeAt( i ) <= 57 ) {
                    res += '' + ( this.allLines[ this.currrentLineNumber ].charCodeAt( i ) - 48 ) ;
                }
                else {
                    res += '' + this.allLines[ this.currrentLineNumber ].charAt( i );
                }
            }
            this.currrentCharacterIndex = endIdx;
            if( endIdx == len - 1 ) {
                this.currrentLineNumber++;
                this.currrentCharacterIndex = 0;
            }
            return res;
        }
    };

    this.nextInt = function() {
        return parseInt( this.next( 1 ) );
    };

    this.nextDouble = function() {
        return parseFloat( this.next( 1 ) );
    };

    this.nextString = function() {
        return this.next( 1 );
    };

    this.nextLine = function() {
        return this.next( 0 );
    };
}

function FileOutputHandler() {
    this.resultantStringArray = new Array();

    this.addNewLine = function( newString ) {
        this.resultantStringArray.push( newString );
    };

    this.clearPercase = function() {
        this.resultantStringArray = new Array();
    };

    this.flushOutOutputToFile = function( outputFileName ) {
        var i , sz , res , currentDirectory , fsObj , outputFilePath;
        res = "";
        sz = this.resultantStringArray.length;
        for( i = 0 ; i < sz ; i++ ) {
            if( i != 0 ) {
                res += "\n";
            }
            res += this.resultantStringArray[ i ];
        }
        fsObj = require( 'fs' );
        currentDirectory = __dirname;
        outputFilePath = currentDirectory + "\\" + outputFileName;
        fsObj.writeFileSync( outputFilePath , res );
        this.clearPercase();
    };
}

function CodeExecutioner() {
    this.irObj = new InputReader();
    this.psObj = new ProblemSolver();
    this.fohObj = new FileOutputHandler();

    this.runCases = function() {
        if( this.psObj.HAS_TEST_CASES == true ) {
            testCases = this.irObj.nextInt();
            for( i = 0 ; i < testCases ; i++ ) {
                this.psObj.clearPerCase();
                this.psObj.getInput( this.irObj );
                this.psObj.solveCase();
            }
        }
        else {
            while( true ) {
                this.psObj.clearPerCase();
                hasMoreTestCases = this.psObj.getInput( this.irObj );
                if( hasMoreTestCases == false ) {
                    break;
                }
                this.psObj.solveCase();
            }
        }
        if( this.psObj.DO_OUTPUT_TO_FILE == true ) {
            this.fohObj.flushOutOutputToFile( this.psObj.OUTPUT_FILE_NAME );
        }
    };

    this.detectEnvironmentType = function() {
        var environmentType = null ;
        try {
            if( importPackage != null ) {
                environmentType = 'rhino' ;
            }
        }
        catch( ex1 ) {
            try {
                //for nodejs local server check
                if( __dirname != null && readline != null && typeof( readline ) != 'function' ) {
                    environmentType = 'local-node-js' ;
                }
            }
            catch( ex2 ) {
                try {
                    if( readline == null || typeof( readline ) != 'function' ) {
                        environmentType = 'server-node-js' ;
                    }
                    else {
                        try {
                            if( Map != null ) {
                                environmentType = 'spider-monkey' ;
                            }
                            else {
                                environmentType = 'javascript-v8' ;
                            }
                        }
                        catch( ex3 ) {
                            environmentType = 'javascript-v8' ;
                        }
                    }
                }
                catch( ex3 ) {
                    environmentType = 'server-node-js' ;
                }
            }
        }
        return environmentType ;
    };

    this.configureStreamsAndReadInput = function() {
        var testCases , i , hasMoreTestCases , isLocal , localContext , isNodeJsJudgeServer , environmentType ;
        isNodeJsJudgeServer = false ;
        environmentType = this.detectEnvironmentType() ;
        if( environmentType == 'local-node-js' ) {
            try {
                if( print == null || typeof( print ) != 'function' ) {
                    print = console.log;
                }
            }
            catch( ex ) {
                print = console.log;
            }
            if( this.psObj.DO_OUTPUT_TO_FILE == true ) {
                localContext = this.fohObj;
                print = function() {
                    localContext.addNewLine.apply( localContext , arguments );
                }
            }
            this.irObj.readAllLinesFromFile( this.psObj.INPUT_FILE_NAME );
            this.runCases() ;
        }
        else if( environmentType == 'server-node-js' ) {
            try {
                if( print == null || typeof( print ) != 'function' ) {
                    print = console.log;
                }
            }
            catch( ex ) {
                print = console.log;
            }
            this.irObj.readAllLinesFromNodeJsJudgeServer( this ) ;
        }
        else if( environmentType == 'javascript-v8' ) {
            this.irObj.readAllLines();
            this.runCases() ;
        }
        else if( environmentType == 'rhino' ) {
            this.irObj.readAllLinesFromRhino();
            this.runCases() ;
        }
        else if( environmentType == 'spider-monkey' ) {
            this.irObj.readAllLines();
            this.runCases() ;
        }
    };

    this.configureStreamsAndReadInput();
}

new CodeExecutioner();

function ProblemSolver() {
    this.HAS_TEST_CASES = false;
    this.INPUT_FILE_NAME = "test.in";
    this.OUTPUT_FILE_NAME = "out.txt";
    this.DO_OUTPUT_TO_FILE = false;
    this.CLEAR_ARRAY_PER_CASE = false;

	this.sortComparator = function( left , right ) {
		return left > right ;
	} ;

    this.solveCase = function() {
        var res , i , j , fl , cn , temp , len , len2 ;
        len = this.s.length ;
        res = "" ;
        this.arr.sort( this.sortComparator ) ;
        for( i = 0 ; i < this.n ; i++ ) {
        	this.arr[ i ] = this.arr[ i ] - 1 ;
        }
        for( i = 0 ; i < len ; i++ ) {
        	this.brr[ i ] = this.s.charCodeAt( i ) ;
        }
        j = 0 ;
        cn = 0 ;
        len2 = Math.floor( len / 2 ) ;
        for( i = 0 ; i < len2 ; i++ ) {
        	while( j < this.n && this.arr[ j ] == i ) {
        		cn++ ;
        		j++ ;
        	}
        	if( cn % 2 == 0 ) {
        	}
        	else {
        		temp = this.brr[ i ] ;
        		this.brr[ i ] = this.brr[ len - i - 1 ] ;
        		this.brr[ len - i - 1 ] = temp ;
        	}
        }
        for( i = 0 ; i < len ; i++ ) {
        	res += String.fromCharCode( this.brr[ i ] ) ;
        }
        print( res );
    };

    this.init = function() {
        this.lim1 = 100010;
        this.lim2 = 110;
        this.cc = 1;
        this.ind = 1;
        this.n = 0;
        this.cn = 0;
        this.declareAndFillArrays();
    };

    this.getInput = function( irObj ) {
        var hasMoreInput , i;
        hasMoreInput = true;
        try {
            this.s = irObj.nextString();
            this.n = irObj.nextInt();
            this.arr = new Array() ;
            for( i = 0 ; i < this.n ; i++ ) {
                this.arr.push( irObj.nextInt() ) ;
            }
        }
        catch( ex ) {
            hasMoreInput = false;
        }
        return hasMoreInput;
    };

    this.clearArraysPerCase = function() {
        var i;
        this.arr = new Array();
        this.adj_list = new Array();
        for( i = 0 ; i < this.lim1 ; i++ ) {
            this.arr.push( 0 );
            this.adj_list.push( new Array() );
        }
    };

    this.clearPerCase = function() {
        this.cn = 0;
        this.cc++;
        if( this.CLEAR_ARRAY_PER_CASE == true ) {
            this.clearArraysPerCase() ;
        }
    };

    this.declareAndFillArrays = function() {
        var i , j;
        this.srr = new Array();
        this.vis = new Array();
        this.arr = new Array();
        this.brr = new Array();
        this.memo = new Array();
        this.done = new Array();
        this.adj_list = new Array();
        for( i = 0 ; i < this.lim1 ; i++ ) {
            this.srr.push( "" );
            this.vis.push( 0 );
            this.arr.push( 0 );
            this.brr.push( 0 );
            this.adj_list.push( new Array() );
        }
        for( i = 0 ; i < this.lim2 ; i++ ) {
            this.memo.push( new Array() );
            this.done.push( new Array() );
            for( j = 0 ; j < this.lim2 ; j++ ) {
                this.memo[ i ].push( -1 );
                this.done[ i ].push( 0 );
            }
        }
    };

    this.init();
}

function InputReader() {
    var self = this ;
    this.allLines = new Array();
    this.currrentLineNumber = 0;
    this.currrentCharacterIndex = 0;
    this.callBackFunction = null ;
    this.parentContext = null ;

    this.readAllLines = function() {
        var singleLine;
        while( true ) {
            try {
                singleLine = readline();
                if( singleLine == null ) {
                    break;
                }
            }
            catch( ex ) {
                break;
            }
            this.allLines.push( singleLine );
        }
    };

    this.readAllLinesFromRhino = function() {
        var brObj , line ;
        importPackage( java.io ) ;
        importPackage( java.lang ) ;
        brObj = new BufferedReader( new InputStreamReader( System[ 'in' ] ) ) ;
        this.allLines = [] ;
        while( true ) {
            line = brObj.readLine() ;
            if( line == null ) {
                break;
            }
            this.allLines.push( line ) ;
        }
    };

    this.readSingleLinesFromNodeJsJudgeServer = function( chunk ) {
        self.chunkData += chunk ;
    };

    this.readEndFromNodeJsJudgeServer = function() {
        self.parseRawData( self.chunkData ) ;
        self.parentContext.runCases() ;
    };

    this.readAllLinesFromNodeJsJudgeServer = function( parentContext ) {
        this.parentContext = parentContext ;
        process.stdin.resume() ;
        process.stdin.setEncoding( 'utf8' ) ;
        this.chunkData = '' ;
        process.stdin.on( 'data' , this.readSingleLinesFromNodeJsJudgeServer ) ;
        process.stdin.on( 'end' , this.readEndFromNodeJsJudgeServer ) ;
    };

    this.parseRawData = function( data ) {
        var len , i , currentString;
        len = data.length;
        currentString = "";
        this.allLines = [] ;
        for( i = 0 ; i < len ; i++ ) {
            if( data[ i ] == '\r' ) {
            }
            else if( data[ i ] == '\n' ) {
                this.allLines.push( currentString );
                currentString = "";
            }
            else {
                currentString += data[ i ];
            }
        }
        if( currentString != "" ) {
            this.allLines.push( currentString );
        }
    };

    this.readAllLinesFromFile = function( inputFileName ) {
        var currentDirectory , fsObj , inputFilePath , rawData;
        fsObj = require( 'fs' );
        currentDirectory = __dirname;
        inputFilePath = currentDirectory + "\\" + inputFileName;
        rawData = fsObj.readFileSync( inputFilePath , "utf8" );
        this.parseRawData( rawData );
    };

    this.next = function( flag ) {
        var len , i , startIdx , res , endIdx;
        if( flag == 0 ) {
            if( this.currrentCharacterIndex != 0 ) {
                this.currrentLineNumber++;
                this.currrentCharacterIndex = 0;
            }
            res = "";
            len = this.allLines[ this.currrentLineNumber ].length;
            if( typeof( len ) == 'function' ) {
                len = this.allLines[ this.currrentLineNumber ].length() ;
            }
            for( i = this.currrentCharacterIndex ; i < len ; i++ ) {
                res += '' + this.allLines[ this.currrentLineNumber ].charAt( i ) ;
            }
            this.currrentLineNumber++;
            this.currrentCharacterIndex = 0;
            return res;
        }
        while( true ) {
            if( this.currrentLineNumber >= this.allLines.length ) {
                throw new Error( "No more tokens available!" );
            }
            startIdx = -1;
            len = this.allLines[ this.currrentLineNumber ].length;
            if( typeof( len ) == 'function' ) {
                len = this.allLines[ this.currrentLineNumber ].length() ;
            }
            for( i = this.currrentCharacterIndex ; i < len ; i++ ) {
                if( this.allLines[ this.currrentLineNumber ].charCodeAt( i ) != ' '.charCodeAt( 0 ) ) {
                    startIdx = i;
                    break;
                }
            }
            if( startIdx == -1 ) {
                this.currrentLineNumber++;
                this.currrentCharacterIndex = 0;
                continue;
            }
            res = "";
            endIdx = len - 1 ;
            for( i = startIdx ; i < len ; i++ ) {
                if( this.allLines[ this.currrentLineNumber ].charCodeAt( i ) == ' '.charCodeAt( 0 ) ) {
                    endIdx = i;
                    break;
                }
                if( this.allLines[ this.currrentLineNumber ].charCodeAt( i ) >= 48 && this.allLines[ this.currrentLineNumber ].charCodeAt( i ) <= 57 ) {
                    res += '' + ( this.allLines[ this.currrentLineNumber ].charCodeAt( i ) - 48 ) ;
                }
                else {
                    res += '' + this.allLines[ this.currrentLineNumber ].charAt( i );
                }
            }
            this.currrentCharacterIndex = endIdx;
            if( endIdx == len - 1 ) {
                this.currrentLineNumber++;
                this.currrentCharacterIndex = 0;
            }
            return res;
        }
    };

    this.nextInt = function() {
        return parseInt( this.next( 1 ) );
    };

    this.nextDouble = function() {
        return parseFloat( this.next( 1 ) );
    };

    this.nextString = function() {
        return this.next( 1 );
    };

    this.nextLine = function() {
        return this.next( 0 );
    };
}

function FileOutputHandler() {
    this.resultantStringArray = new Array();

    this.addNewLine = function( newString ) {
        this.resultantStringArray.push( newString );
    };

    this.clearPercase = function() {
        this.resultantStringArray = new Array();
    };

    this.flushOutOutputToFile = function( outputFileName ) {
        var i , sz , res , currentDirectory , fsObj , outputFilePath;
        res = "";
        sz = this.resultantStringArray.length;
        for( i = 0 ; i < sz ; i++ ) {
            if( i != 0 ) {
                res += "\n";
            }
            res += this.resultantStringArray[ i ];
        }
        fsObj = require( 'fs' );
        currentDirectory = __dirname;
        outputFilePath = currentDirectory + "\\" + outputFileName;
        fsObj.writeFileSync( outputFilePath , res );
        this.clearPercase();
    };
}

function CodeExecutioner() {
    this.irObj = new InputReader();
    this.psObj = new ProblemSolver();
    this.fohObj = new FileOutputHandler();

    this.runCases = function() {
        if( this.psObj.HAS_TEST_CASES == true ) {
            testCases = this.irObj.nextInt();
            for( i = 0 ; i < testCases ; i++ ) {
                this.psObj.clearPerCase();
                this.psObj.getInput( this.irObj );
                this.psObj.solveCase();
            }
        }
        else {
            while( true ) {
                this.psObj.clearPerCase();
                hasMoreTestCases = this.psObj.getInput( this.irObj );
                if( hasMoreTestCases == false ) {
                    break;
                }
                this.psObj.solveCase();
            }
        }
        if( this.psObj.DO_OUTPUT_TO_FILE == true ) {
            this.fohObj.flushOutOutputToFile( this.psObj.OUTPUT_FILE_NAME );
        }
    };

    this.detectEnvironmentType = function() {
        var environmentType = null ;
        try {
            if( importPackage != null ) {
                environmentType = 'rhino' ;
            }
        }
        catch( ex1 ) {
            try {
                //for nodejs local server check
                if( __dirname != null && readline != null && typeof( readline ) != 'function' ) {
                    environmentType = 'local-node-js' ;
                }
            }
            catch( ex2 ) {
                try {
                    if( readline == null || typeof( readline ) != 'function' ) {
                        environmentType = 'server-node-js' ;
                    }
                    else {
                        try {
                            if( Map != null ) {
                                environmentType = 'spider-monkey' ;
                            }
                            else {
                                environmentType = 'javascript-v8' ;
                            }
                        }
                        catch( ex3 ) {
                            environmentType = 'javascript-v8' ;
                        }
                    }
                }
                catch( ex3 ) {
                    environmentType = 'server-node-js' ;
                }
            }
        }
        return environmentType ;
    };

    this.configureStreamsAndReadInput = function() {
        var testCases , i , hasMoreTestCases , isLocal , localContext , isNodeJsJudgeServer , environmentType ;
        isNodeJsJudgeServer = false ;
        environmentType = this.detectEnvironmentType() ;
        if( environmentType == 'local-node-js' ) {
            try {
                if( print == null || typeof( print ) != 'function' ) {
                    print = console.log;
                }
            }
            catch( ex ) {
                print = console.log;
            }
            if( this.psObj.DO_OUTPUT_TO_FILE == true ) {
                localContext = this.fohObj;
                print = function() {
                    localContext.addNewLine.apply( localContext , arguments );
                }
            }
            this.irObj.readAllLinesFromFile( this.psObj.INPUT_FILE_NAME );
            this.runCases() ;
        }
        else if( environmentType == 'server-node-js' ) {
            try {
                if( print == null || typeof( print ) != 'function' ) {
                    print = console.log;
                }
            }
            catch( ex ) {
                print = console.log;
            }
            this.irObj.readAllLinesFromNodeJsJudgeServer( this ) ;
        }
        else if( environmentType == 'javascript-v8' ) {
            this.irObj.readAllLines();
            this.runCases() ;
        }
        else if( environmentType == 'rhino' ) {
            this.irObj.readAllLinesFromRhino();
            this.runCases() ;
        }
        else if( environmentType == 'spider-monkey' ) {
            this.irObj.readAllLines();
            this.runCases() ;
        }
    };

    this.configureStreamsAndReadInput();
}

new CodeExecutioner();


You are given a sequence $$$b_1, b_2, \ldots, b_n$$$. Find the lexicographically minimal permutation $$$a_1, a_2, \ldots, a_{2n}$$$ such that $$$b_i = \min(a_{2i-1}, a_{2i})$$$, or determine that it is impossible.

Each test contains one or more test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 100$$$). The first line of each test case consists of one integer $$$n$$$ — the number of elements in the sequence $$$b$$$ ($$$1 \le n \le 100$$$). The second line of each test case consists of $$$n$$$ different integers $$$b_1, \ldots, b_n$$$ — elements of the sequence $$$b$$$ ($$$1 \le b_i \le 2n$$$). It is guaranteed that the sum of $$$n$$$ by all test cases doesn't exceed $$$100$$$.

For each test case, if there is no appropriate permutation, print one number $$$-1$$$. Otherwise, print $$$2n$$$ integers $$$a_1, \ldots, a_{2n}$$$ — required lexicographically minimal permutation of numbers from $$$1$$$ to $$$2n$$$.

let i = ''
process.stdin.on('data', c => i += c)
process.stdin.on('end', () => {
    const {EOL} = require('os')
    const lines = i.split(EOL);

    function foo (data) {
        const dataSet = new Set(data);
        const result = [];
        const available = Array(data.length);
        for (let k = 1; k <= data.length * 2; k++) {
            available[k-1] = !dataSet.has(k);
        }

        let isValid = true;
        for (let i = 0; i < data.length; i++) {
            for (let r = data[i]; r <= available.length; r++) {
                if (available[r]) {
                    available[r] = false;
                    result.push(data[i]);
                    result.push(r+1);
                    break;
                } else if (r === available.length - 1 || r === available.length) {
                    return '-1';
                }
            }

        }

        return result.join(' ');

    }

    let testCount = 1;
    let answer = '';
    while(testCount <= +lines[0]) {
        let data = lines[testCount*2].split(" ").map(Number);
        let result = foo(data);
        answer += result +"\n";
        testCount++;
    }
    console.log(answer);
})


Limak is an old brown bear. He often plays poker with his friends. Today they went to a casino. There are n players (including Limak himself) and right now all of them have bids on the table. i-th of them has bid with size ai dollars.Each player can double his bid any number of times and triple his bid any number of times. The casino has a great jackpot for making all bids equal. Is it possible that Limak and his friends will win a jackpot?

First line of input contains an integer n (2 ≤ n ≤ 105), the number of players. The second line contains n integer numbers a1, a2, ..., an (1 ≤ ai ≤ 109) — the bids of players.

Print "Yes" (without the quotes) if players can make their bids become equal, or "No" otherwise.

NoteIn the first sample test first and third players should double their bids twice, second player should double his bid once and fourth player should both double and triple his bid.It can be shown that in the second sample test there is no way to make all bids equal.

function gcd(a, b) {
    [b, a] = [Math.min(Math.abs(a), Math.abs(b)), Math.max(Math.abs(a), Math.abs(b))]
    while (true) {
        if (!b) return a;
        a %= b;
        if (!a) return b;
        b %= a;
    }
}

const mainFunction = (lines) => {
    let arr = lines[1].split(" ").map(Number),
        res = arr[0]
    arr.forEach(qwe => {
        res = gcd(res, qwe)
    });
    for (let i of arr) {
        let qwe = Math.floor(i / res)
        while (qwe % 6 === 0 && qwe != 1) qwe /= 6;
        while (qwe % 2 === 0 && qwe != 1) qwe /= 2;
        while (qwe % 3 === 0 && qwe != 1) qwe /= 3;
        if (qwe != 1) {
            console.log("NO")
            return 0;
        }
    }
    console.log("YES")
}

const { EOL } = require('os')
if (__filename.substr(9, 4) != "azer") {
    let yourInputData = ''
    process.stdin.on('data', i => yourInputData += i)
    process.stdin.on('end', () => mainFunction(yourInputData.split(EOL)))
} else {
    const fileSystem = require("fs");
    mainFunction(fileSystem.readFileSync('input.txt', 'utf8').split(EOL))
}

function gcd(a, b) {
    [b, a] = [Math.min(Math.abs(a), Math.abs(b)), Math.max(Math.abs(a), Math.abs(b))]
    while (true) {
        if (!b) return a;
        a %= b;
        if (!a) return b;
        b %= a;
    }
}

const mainFunction = (lines) => {
    let arr = lines[1].split(" ").map(Number),
        res = arr[0]
    arr.forEach(qwe => {
        res = gcd(res, qwe)
    });
    while (res % 6 === 0 && res != 1) res /= 6;
    while (res % 2 === 0 && res != 1) res /= 2;
    while (res % 3 === 0 && res != 1) res /= 3;
    //console.log(res)
    for (let i of arr) {
        let two = 1,
            three = 1
        while (i % (two * 2) === 0) two *= 2;
        while (i % (three * 3) === 0) three *= 3;
        //console.log(res * two * three, i)
        if (res * two * three != i) {
            console.log("No")
            return 0
        }
    }
    console.log("Yes")
}

const { EOL } = require('os')
if (__filename.substr(9, 4) != "azer") {
    let yourInputData = ''
    process.stdin.on('data', i => yourInputData += i)
    process.stdin.on('end', () => mainFunction(yourInputData.split(EOL)))
} else {
    const fileSystem = require("fs");
    mainFunction(fileSystem.readFileSync('input.txt', 'utf8').split(EOL))
}

var n = +readline(), a = readline().split(" ").map(Number);
var check = true;

for(var i = 0; i < n; i++){
	for(;;){
		if(a[i] % 2 == 0){
			a[i] /= 2;
		}
		else{
			break;
		}
	}

	for(;;){
		if(a[i] % 3 == 0){
			a[i] /= 3;
		}
		else{
			break;
		}
	}
}

for(var i = 0; i < n-1; i++){
	if(a[i] != a[i+1]){
		write("No");
		check = false;
		break;
	}
}

if(check){
	write("Yes");
}

var n = +readline(), arr = readline().split(" ").map(Number);
for(var i =0;i<n;i++)
{
    x = arr[i];
    while(x%2==0){x/=2;}
    while(x%3==0){x/=3;}
    arr[i]=x;
}
arr.sort();
if(arr[0]===arr[n-1])
{
    write('Yes');
}
else
{
    write('No');
}

// Generated by CoffeeScript 1.10.0
(function() {
  var a, gcd, n;

  n = parseInt(readline());

  a = readline().split(' ').map(function(item) {
    return parseInt(item);
  });

  gcd = null;

  (function() {
    var i, j, len, v;
    for (i = j = 0, len = a.length; j < len; i = ++j) {
      v = a[i];
      while (v % 2 === 0) {
        v /= 2;
      }
      while (v % 3 === 0) {
        v /= 3;
      }
      if (gcd == null) {
        gcd = v;
      } else if (gcd !== v) {
        print('No');
        return;
      }
    }
    return print('Yes');
  })();

}).call(this);

function gcd(a, b) {
    [b, a] = [Math.min(Math.abs(a), Math.abs(b)), Math.max(Math.abs(a), Math.abs(b))]
    while (true) {
        if (!b) return a;
        a %= b;
        if (!a) return b;
        b %= a;
    }
}

const nok = (a, b) => a * b / gcd(a, b);

const mainFunction = (lines) => {
    let arr = lines[1].split(" ").map(Number),
        res = 1
    arr.forEach(qwe => {
        res = nok(res, qwe)
    });
    for (let i of arr) {
        let qwe = Math.floor(res / i)
        while (qwe % 6 === 0 && qwe != 1) qwe /= 6;
        while (qwe % 2 === 0 && qwe != 1) qwe /= 2;
        while (qwe % 3 === 0 && qwe != 1) qwe /= 3;
        if (qwe != 1) {
            console.log("NO")
            return 0;
        }
    }
    console.log("YES")
}

const { EOL } = require('os')
if (__filename.substr(9, 4) != "azer") {
    let yourInputData = ''
    process.stdin.on('data', i => yourInputData += i)
    process.stdin.on('end', () => mainFunction(yourInputData.split(EOL)))
} else {
    const fileSystem = require("fs");
    mainFunction(fileSystem.readFileSync('input.txt', 'utf8').split(EOL))
}

function gcd(a, b) {
    [b, a] = [Math.min(Math.abs(a), Math.abs(b)), Math.max(Math.abs(a), Math.abs(b))]
    while (true) {
        if (!b) return a;
        a %= b;
        if (!a) return b;
        b %= a;
    }
}

const mainFunction = (lines) => {
    let arr = lines[1].split(" ").map(Number),
        res = 1
    arr.forEach(qwe => {
        res = gcd(res, qwe)
    });
    for (let i of arr) {
        let qwe = Math.floor(i / res)
        while (qwe % 6 === 0 && qwe != 1) qwe /= 6;
        while (qwe % 2 === 0 && qwe != 1) qwe /= 2;
        while (qwe % 3 === 0 && qwe != 1) qwe /= 3;
        if (qwe != 1) {
            console.log("NO")
            return 0;
        }
    }
    console.log("YES")
}

const { EOL } = require('os')
if (__filename.substr(9, 4) != "azer") {
    let yourInputData = ''
    process.stdin.on('data', i => yourInputData += i)
    process.stdin.on('end', () => mainFunction(yourInputData.split(EOL)))
} else {
    const fileSystem = require("fs");
    mainFunction(fileSystem.readFileSync('input.txt', 'utf8').split(EOL))
}

function gcd(a, b) {
    [b, a] = [Math.min(Math.abs(a), Math.abs(b)), Math.max(Math.abs(a), Math.abs(b))]
    while (true) {
        if (!b) return a;
        a %= b;
        if (!a) return b;
        b %= a;
    }
}

const mainFunction = (lines) => {
    let arr = lines[1].split(" ").map(Number),
        res = 1
    arr.forEach(qwe => {
        res = gcd(res, qwe)
    });
    while (res % 6 === 0 && res != 1) res /= 6;
    while (res % 2 === 0 && res != 1) res /= 2;
    while (res % 3 === 0 && res != 1) res /= 3;
    for (let i of arr) {
        let two = 1,
            three = 1
        while (i % (two * 2) === 0) two *= 2;
        while (i % (three * 3) === 0) three *= 3;
        if (res * two * three != i) {
            console.log("NO")
            return 0
        }
    }
    console.log("YES")
}

const { EOL } = require('os')
if (__filename.substr(9, 4) != "azer") {
    let yourInputData = ''
    process.stdin.on('data', i => yourInputData += i)
    process.stdin.on('end', () => mainFunction(yourInputData.split(EOL)))
} else {
    const fileSystem = require("fs");
    mainFunction(fileSystem.readFileSync('input.txt', 'utf8').split(EOL))
}

function factorization(a){
	var da = {1:true};
	for(var i = 2; i < a; i++){
		if( a%i == 0 ){
			da[i] = true;
			a = a/i;
			i = 1;
		}
	}
	da[a] = true;
	return da;
}

function NOD(A){
	var n = A.length, x = Math.abs(A[0]);
	for (var i = 1; i < n; i++){
		var y = Math.abs(A[i]);
		while (x && y){ x > y ? x %= y : y %= x; }
		x += y;
	}
	return x;
}

var n = +readline(), a = readline().split(" ").map(Number);
var nod, x, check = true,fact;

for(i = 0; i < n; i++){
	if(a[i] == 1 || a[i] == 2 || a[i] == 3){
		a.splice(i,1);
	}
}

if(a.length == 0){
	write("Yes");
}
else if(a.length == 1){
	fact = factorization(a[0]);

	if(Object.keys(fact).length == 2){
		if(fact[2] == undefined && fact[3] == undefined){
			write("No");
		}
		else{
			write("Yes");
		}
	}
	else if(Object.keys(fact).length == 3){
		if(fact[2] && fact[3]){
			write("Yes");
		}
		else{
			write("Yes");
		}
	}
	else{
		write("No");
	}
}
else{
	nod = NOD(a);

	if(nod == 1){
		for(i = 0; i < a.length; i++){
			fact = factorization(a[i]);
			if(Object.keys(fact).length == 1){
				continue;
			}
			else if(Object.keys(fact).length == 2){
				if(fact[2] == undefined && fact[3] == undefined){
					write("No");
					check = false;
					break;
				}
				else{
					continue;
				}
			}
			else if(Object.keys(fact).length == 3){
				if(fact[2] && fact[3]){
					continue;
				}
				else{
					write("No");
					check = false;
					break;
				}
			}
			else{
				write("No");
				check = false;
				break;
			}
		}

		if(check){
			write("Yes");
		}
	}
	else{
		for(i = 0; i < a.length; i++){
			x = a[i] / nod;

			if(((x % 2) != 0) && ((x % 3) != 0)){
				write("No");
				check = false;
				break;
			}
		}

		if(check){
			write("Yes");
		}
	}
}

function NOD(A){
	var n = A.length, x = Math.abs(A[0]);
	for (var i = 1; i < n; i++){
		var y = Math.abs(A[i]);
		while (x && y){ x > y ? x %= y : y %= x; }
		x += y;
	}
	return x;
}

var n = +readline(), a = readline().split(" ").map(Number);
var nod, x, check = true;

nod = NOD(a);

for(i = 0; i < n; i++){
	x = a[i] / nod;

	if(x == 1){
		continue;
	}

	if(((x % 2) != 0) && ((x % 3) != 0)){
		write("No");
		check = false;
		break;
	}
}

if(check){
	write("Yes");
}

function factorization(a){
	var da = {1:true};
	for(var i = 2; i < a; i++){
		if( a%i == 0 ){
			da[i] = true;
			a = a/i;
			i = 1;
		}
	}
	da[a] = true;
	return da;
}

function NOD(A){
	var n = A.length, x = Math.abs(A[0]);
	for (var i = 1; i < n; i++){
		var y = Math.abs(A[i]);
		while (x && y){ x > y ? x %= y : y %= x; }
		x += y;
	}
	return x;
}

var n = +readline(), a = readline().split(" ").map(Number);
var nod, x, check = true,fact;

nod = NOD(a);

if(nod == 1){
	for(i = 0; i < n; i++){
		fact = factorization(a[i]);
		if(Object.keys(fact).length == 1){
			continue;
		}
		else if(Object.keys(fact).length == 2){
			if(fact[2] == undefined || fact[3] == undefined){
				write("No");
				check = false;
				break;
			}
			else{
				continue;
			}
		}
		else if(Object.keys(fact).length == 3){
			if(fact[2] && fact[3]){
				continue;
			}
			else{
				write("No");
				check = false;
				break;
			}
		}
		else{
			write("No");
			check = false;
			break;
		}
	}

	if(check){
		write("Yes");
	}
}
else{
	for(i = 0; i < n; i++){
		x = a[i] / nod;

		if(((x % 2) != 0) && ((x % 3) != 0)){
			write("No");
			check = false;
			break;
		}
	}

	if(check){
		write("Yes");
	}
}

function NOD(A){
	var n = A.length, x = Math.abs(A[0]);
	for (var i = 1; i < n; i++){
		var y = Math.abs(A[i]);
		while (x && y){ x > y ? x %= y : y %= x; }
		x += y;
	}
	return x;
}

var n = +readline(), a = readline().split(" ").map(Number);
var nod, x, check = true;

nod = NOD(a);

for(i = 0; i < n; i++){
	x = a[i] / nod;

	if(((x % 2) != 0) && ((x % 3) != 0)){
		write("No");
		check = false;
		break;
	}
}

if(check){
	write("Yes");
}

function factorization(a){
	var da = {1:true};
	for(var i = 2; i < a; i++){
		if( a%i == 0 ){
			da[i] = true;
			a = a/i;
			i = 1;
		}
	}
	da[a] = true;
	return da;
}

function NOD(A){
	var n = A.length, x = Math.abs(A[0]);
	for (var i = 1; i < n; i++){
		var y = Math.abs(A[i]);
		while (x && y){ x > y ? x %= y : y %= x; }
		x += y;
	}
	return x;
}

var n = +readline(), a = readline().split(" ").map(Number);
var nod, x, check = true,fact;

nod = NOD(a);

if(nod == 1){
	for(i = 0; i < n; i++){
		fact = factorization(a[i]);
		if(Object.keys(fact).length == 1){
			continue;
		}
		else if(Object.keys(fact).length == 2){
			if(fact[2] == undefined && fact[3] == undefined){
				write("No");
				check = false;
				break;
			}
			else{
				continue;
			}
		}
		else if(Object.keys(fact).length == 3){
			if(fact[2] && fact[3]){
				continue;
			}
			else{
				write("No");
				check = false;
				break;
			}
		}
		else{
			write("No");
			check = false;
			break;
		}
	}

	if(check){
		write("Yes");
	}
}
else{
	for(i = 0; i < n; i++){
		x = a[i] / nod;

		if(((x % 2) != 0) && ((x % 3) != 0)){
			write("No");
			check = false;
			break;
		}
	}

	if(check){
		write("Yes");
	}
}

function factorization(a){
	var da = {1:true};
	for(var i = 2; i < a; i++){
		if( a%i == 0 ){
			da[i] = true;
			a = a/i;
			i = 1;
		}
	}
	da[a] = true;
	return da;
}

function NOD(A){
	var n = A.length, x = Math.abs(A[0]);
	for (var i = 1; i < n; i++){
		var y = Math.abs(A[i]);
		while (x && y){ x > y ? x %= y : y %= x; }
		x += y;
	}
	return x;
}

var n = +readline(), a = readline().split(" ").map(Number);
var nod, x, check = true,fact;

nod = NOD(a);

if(nod == 1){
	for(i = 0; i < n; i++){
		if(a[i] == 2 || a[i] == 3){
			continue;
		}
		else{
			fact = factorization(a[i]);
			if(Object.keys(fact).length == 2){
				if(fact[2] == undefined || fact[3] == undefined){
					write("No");
					check = false;
					break;
				}
				else{
					continue;
				}
			}
			else if(Object.keys(fact).length == 3){
				if(fact[2] && fact[3]){
					continue;
				}
				else{
					write("No");
					check = false;
					break;
				}
			}
			else{
				write("No");
				check = false;
				break;
			}
		}
	}

	if(check){
		write("Yes");
	}
}
else{
	for(i = 0; i < n; i++){
		x = a[i] / nod;

		if(((x % 2) != 0) && ((x % 3) != 0)){
			write("No");
			check = false;
			break;
		}
	}

	if(check){
		write("Yes");
	}
}

var n = +readline(), a = readline().split(" ").map(Number);
var check = true;

for(var i = 0; i < n; i++){
	for(;;){
		if(a[i] % 2 == 0){
			a[i] /= 2;
		}
		else{
			break;
		}
	}

	for(;;){
		if(a[i] % 3 == 0){
			a[i] /= 3;
		}
		else{
			break;
		}
	}
}

for(var i = 0; i < n-1; i++){
	if(a[i] != a[i+1]){
		write("No");
		check = false;
	}
}

if(check){
	write("Yes");
}

// Generated by CoffeeScript 1.10.0
(function() {
  var a, gcd, n;

  n = parseInt(readline());

  a = readline().split(' ').map(function(item) {
    return parseInt(item);
  });

  gcd = null;

  (function() {
    var i, j, len, v;
    for (i = j = 0, len = a.length; j < len; i = ++j) {
      v = a[i];
      while (v % 2 === 0) {
        v /= 2;
      }
      while (v % 3 === 0) {
        v /= 3;
      }
      if (gcd == null) {
        gcd = v;
      } else if (gcd !== v) {
        print('No');
        return;
      }
      print(v);
    }
    return print('Yes');
  })();

}).call(this);


Bob is a pirate looking for the greatest treasure the world has ever seen. The treasure is located at the point $$$T$$$, which coordinates to be found out.Bob travelled around the world and collected clues of the treasure location at $$$n$$$ obelisks. These clues were in an ancient language, and he has only decrypted them at home. Since he does not know which clue belongs to which obelisk, finding the treasure might pose a challenge. Can you help him?As everyone knows, the world is a two-dimensional plane. The $$$i$$$-th obelisk is at integer coordinates $$$(x_i, y_i)$$$. The $$$j$$$-th clue consists of $$$2$$$ integers $$$(a_j, b_j)$$$ and belongs to the obelisk $$$p_j$$$, where $$$p$$$ is some (unknown) permutation on $$$n$$$ elements. It means that the treasure is located at $$$T=(x_{p_j} + a_j, y_{p_j} + b_j)$$$. This point $$$T$$$ is the same for all clues.In other words, each clue belongs to exactly one of the obelisks, and each obelisk has exactly one clue that belongs to it. A clue represents the vector from the obelisk to the treasure. The clues must be distributed among the obelisks in such a way that they all point to the same position of the treasure.Your task is to find the coordinates of the treasure. If there are multiple solutions, you may print any of them.Note that you don't need to find the permutation. Permutations are used only in order to explain the problem.

The first line contains an integer $$$n$$$ ($$$1 \leq n \leq 1000$$$) — the number of obelisks, that is also equal to the number of clues. Each of the next $$$n$$$ lines contains two integers $$$x_i$$$, $$$y_i$$$ ($$$-10^6 \leq x_i, y_i \leq 10^6$$$) — the coordinates of the $$$i$$$-th obelisk. All coordinates are distinct, that is $$$x_i \neq x_j$$$ or $$$y_i \neq y_j$$$ will be satisfied for every $$$(i, j)$$$ such that $$$i \neq j$$$.  Each of the next $$$n$$$ lines contains two integers $$$a_i$$$, $$$b_i$$$ ($$$-2 \cdot 10^6 \leq a_i, b_i \leq 2 \cdot 10^6$$$) — the direction of the $$$i$$$-th clue. All coordinates are distinct, that is $$$a_i \neq a_j$$$ or $$$b_i \neq b_j$$$ will be satisfied for every $$$(i, j)$$$ such that $$$i \neq j$$$.  It is guaranteed that there exists a permutation $$$p$$$, such that for all $$$i,j$$$ it holds $$$\left(x_{p_i} + a_i, y_{p_i} + b_i\right) = \left(x_{p_j} + a_j, y_{p_j} + b_j\right)$$$.

Output a single line containing two integers $$$T_x, T_y$$$ — the coordinates of the treasure. If there are multiple answers, you may print any of them.

NoteAs $$$n = 2$$$, we can consider all permutations on two elements. If $$$p = [1, 2]$$$, then the obelisk $$$(2, 5)$$$ holds the clue $$$(7, -2)$$$, which means that the treasure is hidden at $$$(9, 3)$$$. The second obelisk $$$(-6, 4)$$$ would give the clue $$$(-1,-3)$$$ and the treasure at $$$(-7, 1)$$$. However, both obelisks must give the same location, hence this is clearly not the correct permutation.If the hidden permutation is $$$[2, 1]$$$, then the first clue belongs to the second obelisk and the second clue belongs to the first obelisk. Hence $$$(-6, 4) + (7, -2) = (2,5) + (-1,-3) = (1, 2)$$$, so $$$T = (1,2)$$$ is the location of the treasure.  In the second sample, the hidden permutation is $$$[2, 3, 4, 1]$$$.

//var input = readline()
var t = parseInt(readline());

var x = 0, y = 0;
for(var i=0; i<t*2; i++) {
    var ar = readline().split(' ').map(x => parseInt(x));
    var a = ar[0], b = ar[1];
    x += a , y += b;
}
print(x/t  +' '+  y/t);

//

//var input = readline()
var t = readline()

var x = 0, y = 0
for(var i=0; i<t; i++) {
    var ar = readline().split(' ')
    var a = ar[0]
    var b = ar[1]
    x += parseInt(a)
    y += parseInt(b)
}
//print(x +' '+ y)

var x2 = 0, y2 = 0
for(var i=0; i<t; i++) {
    var arr = readline().split(' ')
    var c = arr[0]
    var d = arr[1]
    x2 += parseInt(c)
    y2 += parseInt(d)
}
//print(x2 +' '+ y2)

print((x+x2)/t  +' '+  (y+y2)/t)

//var input = readline()
var t = readline()

var x = 0, y = 0
for(var i=0; i<t*2; i++) {
    var ar = readline().split(' ')
    var a = ar[0]
    var b = ar[1]
    x += parseInt(a)
    y += parseInt(b)
}
print(x/t  +' '+  y/t)

const rl = require('readline')

const readline = rl.createInterface({input: process.stdin})

let n, obelisks = [], clues = [], numLines = 0
readline.on('line', line => {
	if (numLines == 0) {
		n = parseInt(line)
	} else {
		const coordinate = line.split(' ').map(Number);
		[obelisks, clues][numLines > n ? 1 : 0].push({
			x: coordinate[0],
			y: coordinate[1]
		})
	}
	numLines++
}).on('close', () => {
	const p = obelisks.sort((a, b) => a.x - b.x || a.y - b.y).shift()
	const q = clues.sort((a, b) => b.x - a.x || b.y - a.y).shift()
	console.log(`${p.x + q.x} ${p.y + q.y}`)
})

// https://codeforces.com/contest/1091/problem/B
// Big O:
// Time complexity:
// Space complexity:

// Read input
var readline = require("readline");
var rl = readline.createInterface({
    input: process.stdin,
    output: process.stdout
});

let numberOfObelisks;
let obelisksCoordinates = [];
let cluesCoordinates = [];
rl.on('line', (input) => {
    if (numberOfObelisks) {
        const isReadingObelisksCoordinates = obelisksCoordinates.length < numberOfObelisks;
        if (isReadingObelisksCoordinates) {
            obelisksCoordinates.push(getCoordinate(input));
        } else {
            cluesCoordinates.push(getCoordinate(input));
        }
    } else {
        numberOfObelisks = parseInt(input);
    }

    if (cluesCoordinates.length === numberOfObelisks) {
        console.log(findTreasure(obelisksCoordinates, cluesCoordinates));
        rl.close();
    }
});

function getCoordinate(input) {
    const positions = input.split(" ").map(Number);
    const coordinate = new Coordinate(positions[0], positions[1]);
    return coordinate;
}

// Problem
class Coordinate {
    constructor(x, y) {
        this.x = x;
        this.y = y;
    }

    addCoordinate(coordinate) {
        return new Coordinate(this.x + coordinate.x, this.y + coordinate.y);
    }

    equal(coordinate) {
        return this.x === coordinate.x && this.y === coordinate.y;
    }

    toString() {
        return `${this.x}, ${this.y}`;
    }
}

function findTreasure(obelisksCoordinates, cluesCoordinates) {
    const cluesDictionary = getCluesDictionary(cluesCoordinates);

    for (let clue of cluesCoordinates) {
        const firstObelisk = obelisksCoordinates[0];
        const treasure = firstObelisk.addCoordinate(clue);
        const treasureFound = treasureMatch(treasure, obelisksCoordinates, cluesDictionary);
        if (treasureFound) {
            return `${treasure.x} ${treasure.y}`;
        }
    }

    return "";
}

function treasureMatch(treasure, obelisksCoordinates, cluesDictionary) {
    for (let obelisk of obelisksCoordinates) {
        const x = treasure.x - obelisk.x;
        const y = treasure.y - obelisk.y;

        const possibleClue = new Coordinate(x, y);
        if (cluesDictionary[possibleClue.toString()] === undefined) {
            return false;
        }
    }

    return true;
}

function getCluesDictionary(cluesCoordinates) {
    const cluesDictionary = {};
    for (let i = 0; i < cluesCoordinates.length; i++) {
        const currentClue = cluesCoordinates[i].toString();
        cluesDictionary[currentClue] = i;
    }

    return cluesDictionary;
}

// console.log(findTreasure([new Coordinate(2, 5), new Coordinate(-6, 4)], [new Coordinate(7, -2), new Coordinate(-1, -3)]))

// https://codeforces.com/contest/1091/problem/B
// Big O:
// Time complexity: O(n^2)
// Space complexity: O(n)

// Read input
var readline = require("readline");
var rl = readline.createInterface({
    input: process.stdin,
    output: process.stdout
});

let numberOfObelisks;
let obelisksCoordinates = [];
let cluesCoordinates = [];
rl.on('line', (input) => {
    if (!numberOfObelisks) {
        numberOfObelisks = parseInt(input);
        return;
    }

    readCoordinates(input);

    if (cluesCoordinates.length === numberOfObelisks) {
        console.log(findTreasure(obelisksCoordinates, cluesCoordinates));
        rl.close();
    }
});

function readCoordinates(input) {
    const isReadingObelisksCoordinates = obelisksCoordinates.length < numberOfObelisks;
    if (isReadingObelisksCoordinates) {
        obelisksCoordinates.push(getCoordinate(input));
    } else {
        cluesCoordinates.push(getCoordinate(input));
    }
}

function getCoordinate(input) {
    const positions = input.split(" ").map(Number);
    const coordinate = new Coordinate(positions[0], positions[1]);
    return coordinate;
}

// Problem
class Coordinate {
    constructor(x, y) {
        this.x = x;
        this.y = y;
    }

    addCoordinate(coordinate) {
        return new Coordinate(this.x + coordinate.x, this.y + coordinate.y);
    }

    equal(coordinate) {
        return this.x === coordinate.x && this.y === coordinate.y;
    }

    toString() {
        return `${this.x} ${this.y}`;
    }
}

function findTreasure(obelisksCoordinates, cluesCoordinates) {
    const cluesIndexes = getCluesIndexes(cluesCoordinates);
    const firstObelisk = obelisksCoordinates[0];

    for (let clue of cluesCoordinates) {
        const treasureCoordinate = firstObelisk.addCoordinate(clue);
        const treasureFound = isTreasureAtCoordinate(treasureCoordinate, obelisksCoordinates, cluesIndexes);
        if (treasureFound) {
            return treasureCoordinate.toString();
        }
    }

    return "";
}

function getCluesIndexes(cluesCoordinates) {
    const cluesDictionary = {};
    for (let i = 0; i < cluesCoordinates.length; i++) {
        const currentClue = cluesCoordinates[i].toString();
        cluesDictionary[currentClue] = i;
    }

    return cluesDictionary;
}

function isTreasureAtCoordinate(treasureCoordinate, obelisksCoordinates, cluesIndexes) {
    for (let obelisk of obelisksCoordinates) {
        // Check if there is a clue that points to the treasure for the current obelisk
        const x = treasureCoordinate.x - obelisk.x;
        const y = treasureCoordinate.y - obelisk.y;
        const possibleClue = new Coordinate(x, y);
        if (cluesIndexes[possibleClue.toString()] === undefined) {
            return false;
        }
    }

    return true;
}

// https://codeforces.com/contest/1091/problem/B
// Big O:
// Time complexity: O(n^2)
// Space complexity: O(n)

// Read input
var readline = require("readline");
var rl = readline.createInterface({
    input: process.stdin,
    output: process.stdout
});

let numberOfObelisks;
let obelisksCoordinates = [];
let cluesCoordinates = [];
rl.on('line', (input) => {
    if (!numberOfObelisks) {
        numberOfObelisks = parseInt(input);
        return;
    }

    readCoordinates(input);

    if (cluesCoordinates.length === numberOfObelisks) {
        console.log(findTreasure(obelisksCoordinates, cluesCoordinates));
        rl.close();
    }
});

function readCoordinates(input) {
    const isReadingObelisksCoordinates = obelisksCoordinates.length < numberOfObelisks;
    if (isReadingObelisksCoordinates) {
        obelisksCoordinates.push(getCoordinate(input));
    } else {
        cluesCoordinates.push(getCoordinate(input));
    }
}

function getCoordinate(input) {
    const positions = input.split(" ").map(Number);
    const coordinate = new Coordinate(positions[0], positions[1]);
    return coordinate;
}

// Problem
class Coordinate {
    constructor(x, y) {
        this.x = x;
        this.y = y;
    }

    addCoordinate(coordinate) {
        return new Coordinate(this.x + coordinate.x, this.y + coordinate.y);
    }

    equal(coordinate) {
        return this.x === coordinate.x && this.y === coordinate.y;
    }

    toString() {
        return `${this.x} ${this.y}`;
    }
}

function findTreasure(obelisksCoordinates, cluesCoordinates) {
    const cluesIndexes = getCluesIndexes(cluesCoordinates);
    const firstObelisk = obelisksCoordinates.shift();

    for (let clue of cluesCoordinates) {
        const treasureCoordinate = firstObelisk.addCoordinate(clue);
        const treasureFound = isTreasureAtCoordinate(treasureCoordinate, obelisksCoordinates, cluesIndexes);
        if (treasureFound) {
            return treasureCoordinate.toString();
        }
    }

    return "";
}

function getCluesIndexes(cluesCoordinates) {
    const cluesDictionary = {};
    for (let i = 0; i < cluesCoordinates.length; i++) {
        const currentClue = cluesCoordinates[i].toString();
        cluesDictionary[currentClue] = i;
    }

    return cluesDictionary;
}

function isTreasureAtCoordinate(treasureCoordinate, obelisksCoordinates, cluesIndexes) {
    for (let obelisk of obelisksCoordinates) {
        // Check if there is a clue that points to the treasure for the current obelisk
        const x = treasureCoordinate.x - obelisk.x;
        const y = treasureCoordinate.y - obelisk.y;
        const possibleClue = new Coordinate(x, y);
        if (cluesIndexes[possibleClue.toString()] === undefined) {
            return false;
        }
    }

    return true;
}


Recently Polycarp noticed that some of the buttons of his keyboard are malfunctioning. For simplicity, we assume that Polycarp's keyboard contains $$$26$$$ buttons (one for each letter of the Latin alphabet). Each button is either working fine or malfunctioning. To check which buttons need replacement, Polycarp pressed some buttons in sequence, and a string $$$s$$$ appeared on the screen. When Polycarp presses a button with character $$$c$$$, one of the following events happened:  if the button was working correctly, a character $$$c$$$ appeared at the end of the string Polycarp was typing;  if the button was malfunctioning, two characters $$$c$$$ appeared at the end of the string. For example, suppose the buttons corresponding to characters a and c are working correctly, and the button corresponding to b is malfunctioning. If Polycarp presses the buttons in the order a, b, a, c, a, b, a, then the string he is typing changes as follows: a $$$\rightarrow$$$ abb $$$\rightarrow$$$ abba $$$\rightarrow$$$ abbac $$$\rightarrow$$$ abbaca $$$\rightarrow$$$ abbacabb $$$\rightarrow$$$ abbacabba.You are given a string $$$s$$$ which appeared on the screen after Polycarp pressed some buttons. Help Polycarp to determine which buttons are working correctly for sure (that is, this string could not appear on the screen if any of these buttons was malfunctioning).You may assume that the buttons don't start malfunctioning when Polycarp types the string: each button either works correctly throughout the whole process, or malfunctions throughout the whole process.

The first line contains one integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases in the input. Then the test cases follow. Each test case is represented by one line containing a string $$$s$$$ consisting of no less than $$$1$$$ and no more than $$$500$$$ lowercase Latin letters.

For each test case, print one line containing a string $$$res$$$. The string $$$res$$$ should contain all characters which correspond to buttons that work correctly in alphabetical order, without any separators or repetitions. If all buttons may malfunction, $$$res$$$ should be empty.

process.stdin.resume();
process.stdin.setEncoding('utf8');

var input= '', readline, print;

process.stdin.on('data', function(chunk) {
    input+=chunk;
});

process.stdin.on('end', function() {
    input = input.split('\n');
    var inputLineIndex = 0;
    readline = function(){return inputLineIndex>=input.length?undefined:input[inputLineIndex++]};
    process.exit(main() || 0);
});
function main()
{
    let n = Number(readline());
        while(n--) {
            let a = Array.from(readline());
            let liters = new Set();
            while(a.length > 0) {
                if(a[0] == a[1]) {
                    a.splice(0, 2);
                } else {
                    liters.add(a[0]);
                    a.splice(0, 1);
                }
            }
            liters=Array.from(liters);
            liters.sort();
            for(let l of liters)
            {
                process.stdout.write(l);
            }
            process.stdout.write('\n');
        }
    return 0;
}

process.stdin.resume();
process.stdin.setEncoding('utf8');

// your code goes here
let input = "";
process.stdin.on("data", x => input += x);
process.stdin.on("end", () => {
	console.log(input
		.split("\n")
		.filter(x => x !== "")
		.filter((_, i) => i !== 0)
		.map(string =>
			[...new Set([...string.match(/(.)\1{0,}/g)
				.filter(x => x.length % 2 !== 0)
				.join("")])].sort().join("")
		)
		.join("\n"));
});

function answer (input) {
    var charArr = input.split('');
    var res = [];
    for (var i =0;i < charArr.length; i++){
        if (charArr[i] === charArr[i+1]) {
            i++;
        } else {
            res.push(charArr[i]);
        }
    }
    return [...new Set(res.sort())].join("")
}

var t = parseInt(readline());
var output = '';
for (var i = 0; i < t; i++) {
    var str = readline();
    output += answer(str) + '\n';
}
write(output);

function answer (input) {
    var charArr = input.split('');
    var res = [];
    var currentStreak = 1;
    for (var i = 1; i < charArr.length; i++) {
        if (charArr[i] === charArr[i - 1]) {
            currentStreak++;
        } else {
            res.push(charArr[i - 1] + '-' + currentStreak);
            currentStreak = 1;
        }
    }
    res.push(charArr[charArr.length - 1] + '-' + currentStreak);

    var answer = [];
    res.forEach(elem => {
        if (parseInt(elem.split('-')[1]) % 2 === 1) {
            answer.push(elem.split('')[0]);
        }
    });
    return [...new Set(answer)].sort().join('');
}

var t = parseInt(readline());
var output = '';
for (var i = 0; i < t; i++) {
    var str = readline();
    output += answer(str) + '\n';
}
write(output);

process.stdin.resume();
process.stdin.setEncoding('utf8');

var input= '', readline, print;

process.stdin.on('data', function(chunk) {
    input+=chunk;
});

process.stdin.on('end', function() {
    input = input.split('\n');
    var inputLineIndex = 0;
    readline = function(){return inputLineIndex>=input.length?undefined:input[inputLineIndex++]};
    process.exit(main() || 0);
});
function main()
{
    let n = Number(readline());
        while(n--) {
            let a = Array.from(readline());
            let liters = new Set();
            while(a.length > 0) {
                if(a[0] == a[1]) {
                    a.splice(0, 2);
                } else {
                    liters.add(a[0]);
                    a.splice(0, 1);
                }
            }
            for(let l of liters)
            {
                process.stdout.write(l);
            }
            process.stdout.write('\n');
        }
    return 0;
}

process.stdin.resume();
process.stdin.setEncoding('utf8');

var input= '', readline, print;

process.stdin.on('data', function(chunk) {
    input+=chunk;
});

process.stdin.on('end', function() {
    input = input.split('\n');
    var inputLineIndex = 0;
    readline = function(){return inputLineIndex>=input.length?undefined:input[inputLineIndex++]};
    process.exit(main() || 0);
});
function main()
{
    let n = Number(readline());
        while(n--) {
            let a = Array.from(readline());
            let liters = [];
            while(a.length > 0) {
                if(a[0] == a[1]) {
                    a.splice(0, 2);
                } else {
                    liters.push(a[0]);
                    a.splice(0, 1);
                }
            }
            liters.sort((a, b) => {
                return a.charCodeAt(0) - b.charCodeAt(0);
            })
            for(let l of liters)
            {
                process.stdout.write(l);
            }
            process.stdout.write('\n');
        }
    return 0;
}

var testCases = readline();
while(testCases--){
    var input = readline();
     var output = "";
   for (var i =0;i< input.length  ;i++) {
        var curr = input[i];
         var next = input[i+1];
        if (curr === next) {
         i++;
        } else {
            output+=curr;
        }
   }
  output = output.split("").sort().join("");
   print(output);
}

function answer (input) {
    var charArr = input.split('');
    var res = [];
    for (var i =0;i < charArr.length; i++){
        if (charArr[i] === charArr[i+1]) {
            i++;
        } else {
            res.push(charArr[i]);
        }
    }
    return res.sort().join("")
}

var t = parseInt(readline());
var output = '';
for (var i = 0; i < t; i++) {
    var str = readline();
    output += answer(str) + '\n';
}
write(output);

var testCases = readline();
while(testCases--){
    var input = readline();
     var output = "";
   for (var i =0;i< input.length  ;i++) {
        var curr = input[i];
         var next = input[i+1];
        if (curr === next) {
         i++
        } else {
            output+=curr;
        }
   }
  output = output.split("").sort().join("");
   print(output);
}

function answer (input) {
    var charArr = input.split('');
    var res = [];
    for (var i =0;i < charArr.length; i++){
        if (charArr[i] === charArr[i+1]) {
            i++;
        } else {
            res.push(charArr[i]);
        }
    }
    return res.sort().join("")
}

var t = parseInt(readline());
var output = '';
for (var i = 0; i < t; i++) {
    var str = readline();
    print(str)
    output += answer(str) + '\n';
}
write(output);

var testCases = readline();
var input1 = readline();
var input2 = readline();
var input3 = readline();
var input4 = readline();
var inputs = [input1,input2,input3,input4];

inputs.forEach(function (input) {
    var start = 0;
    var output = "";
   for (var i =0;i< input.length ;i++) {
        var curr = input[i];
        if (curr !== input[i+1]) {
         output+=curr;
        }
   }
   print(output);
});

var testCases = readline();
var input1 = readline();
var input2 = readline();
var input3 = readline();
var input4 = readline();
var inputs = [input1,input2,input3,input4];

inputs.forEach(function (input) {
    var output = "";
   for (var i =0;i< input.length  ;i++) {
        var curr = input[i];
         var next = input[i+1];
        if (curr === next) {
         i++
        } else {
            output+=curr;
        }
   }
  output = output.split("").sort().join("");
   print(output);
});

const testCases = readline();
const input1 = readline();
const input2 = readline();
const input3 = readline();
const input4 = readline();
const inputs = [input1,input2,input3,input4];
inputs.forEach(input => print(input))

function answer (input) {
    var charArr = input.split('');
    write(charArr)
    var res = [];
    for (var i =0;i < charArr.length; i++){
        if (charArr[i] === charArr[i+1]) {
            i++;
        } else {
            res.push(charArr[i]);
        }
    }
    return res.sort().join("")
}

var t = parseInt(readline());
var output = '';
for (var i = 0; i < t; i++) {
    var str = readline();
    output += answer(str) + '\n';
}
write(output);

var testCases = readline();
var input1 = readline();
var input2 = readline();
var input3 = readline();
var input4 = readline();
var inputs = [input1,input2,input3,input4];

inputs.forEach(function (input) {
    var start = 0;
    var output = "";
   for (var i =0;i< input.length  ;i++) {
        var curr = input[i];
         var next = input[i+1];
        if (curr === next) {
         i++
        } else {
            output+=curr;
        }
   }
   output.split("").sort();
   print(output);
});

function answer (input) {
    var charArr = input.split('');
    var res = [];
    for (var i =0;i < charArr.length; i++){
        if (charArr[i] === charArr[i+1]) {
            i++;
        } else {
            res.push(charArr[i]);
        }
    }
    return res.sort().join("")
}

var t = parseInt(readline());
var output = '';
for (var i = 0; i < t; i++) {
    var str = readline();
    write(str)
    output += answer(str) + '\n';
}
write(output);

var testCases = readline();
var input1 = readline();
var input2 = readline();
var input3 = readline();
var input4 = readline();
var inputs = [input1,input2,input3,input4];

inputs.forEach(function (input) {
    var start = 0;
    var output = "";
   for (var i =0;i< input.length  ;i++) {
        var curr = input[i];
         var next = input[i+1];
        if (curr === next) {
         i++
        } else {
            output+=curr;
        }
   }
  output = output.split("").sort().join("");
   print(output);
});

var testCases = readline();
var input1 = readline();
var input2 = readline();
var input3 = readline();
var input4 = readline();
var inputs = [input1,input2,input3,input4];

inputs.forEach(function (input) {
    var start = 0;
    var output = "";
   for (var i =0;i< input.length  ;i++) {
        var curr = input[i];
         var next = input[i+1];
        if (curr === next) {
         i++
        } else {
            output+=curr;
        }
   }
  output = output.split("").sort();
   print(output);
});


A mad scientist Dr.Jubal has made a competitive programming task. Try to solve it!You are given integers $$$n,k$$$. Construct a grid $$$A$$$ with size $$$n \times n$$$ consisting of integers $$$0$$$ and $$$1$$$. The very important condition should be satisfied: the sum of all elements in the grid is exactly $$$k$$$. In other words, the number of $$$1$$$ in the grid is equal to $$$k$$$.Let's define:  $$$A_{i,j}$$$ as the integer in the $$$i$$$-th row and the $$$j$$$-th column.  $$$R_i = A_{i,1}+A_{i,2}+...+A_{i,n}$$$ (for all $$$1 \le i \le n$$$).  $$$C_j = A_{1,j}+A_{2,j}+...+A_{n,j}$$$ (for all $$$1 \le j \le n$$$).  In other words, $$$R_i$$$ are row sums and $$$C_j$$$ are column sums of the grid $$$A$$$.  For the grid $$$A$$$ let's define the value $$$f(A) = (\max(R)-\min(R))^2 + (\max(C)-\min(C))^2$$$ (here for an integer sequence $$$X$$$ we define $$$\max(X)$$$ as the maximum value in $$$X$$$ and $$$\min(X)$$$ as the minimum value in $$$X$$$). Find any grid $$$A$$$, which satisfies the following condition. Among such grids find any, for which the value $$$f(A)$$$ is the minimum possible. Among such tables, you can find any.

The input consists of multiple test cases. The first line contains a single integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases. Next $$$t$$$ lines contain descriptions of test cases. For each test case the only line contains two integers $$$n$$$, $$$k$$$ $$$(1 \le n \le 300, 0 \le k \le n^2)$$$. It is guaranteed that the sum of $$$n^2$$$ for all test cases does not exceed $$$10^5$$$.

For each test case, firstly print the minimum possible value of $$$f(A)$$$ among all tables, for which the condition is satisfied. After that, print $$$n$$$ lines contain $$$n$$$ characters each. The $$$j$$$-th character in the $$$i$$$-th line should be equal to $$$A_{i,j}$$$. If there are multiple answers you can print any.

NoteIn the first test case, the sum of all elements in the grid is equal to $$$2$$$, so the condition is satisfied. $$$R_1 = 1, R_2 = 1$$$ and $$$C_1 = 1, C_2 = 1$$$. Then, $$$f(A) = (1-1)^2 + (1-1)^2 = 0$$$, which is the minimum possible value of $$$f(A)$$$.In the second test case, the sum of all elements in the grid is equal to $$$8$$$, so the condition is satisfied. $$$R_1 = 3, R_2 = 3, R_3 = 2$$$ and $$$C_1 = 3, C_2 = 2, C_3 = 3$$$. Then, $$$f(A) = (3-2)^2 + (3-2)^2 = 2$$$. It can be proven, that it is the minimum possible value of $$$f(A)$$$.

const process = require('process');

let inp = "";
process.stdin.on('data', chunk => inp += chunk);
process.stdin.on('end', () => {
    inp = inp.split('\n');
    let ic = 0;
    for (let ntest = +inp[ic++]; ntest--; ) {
        let [n, r] = inp[ic++].trim().split(' ').map(x => +x);
        let a = [];
        for (let i = 0; i < n; ++i) {
            let row = [];
            for (let f = 0;f < n; ++f) row.push(0);
            a.push(row);
        }

        let d = Math.floor(r / n);
        for (let r = 0; r < n; ++r) {
            for (let i = 0; i < d; ++i) {
                let c = (r + i) % n;
                a[r][c] = 1;
            }
        }
        let rem = r % n;
        for (let i = 0; i < rem; ++i) {
            let c = (i + d) % n;
            a[i][c] = 1;
        }

        console.log(rem ? 2 : 0);
        console.log(a.map(row => row.join('')).join('\n'));
    }
});

process.stdin.resume();
process.stdin.setEncoding('utf-8');

let inputString = '';
let currentLine = 0;

process.stdin.on('data', inputStdin => {
    inputString += inputStdin;
});

process.stdin.on('end', _ => {
    inputString = inputString.trim().split('\n').map(string => {
        return string.trim();
    });

    D();
});

function readline() {
    return inputString[currentLine++];
}

function pi(a) {
    return parseInt(a);
}

function ti(a){
    for(let i = 0; i < a.length; i++)
        a[i] = pi(a[i]);

    return a;
}

function C(){
    let [n,m] = ti(readline().split(' '));
    let a = ti(readline().split(' '));
    let b = ti(readline().split(' '));
    let o = new Array(10);
    let z = new Array(10);
    o.fill(0);
    z.fill(0);
    for(let i = 0; i < m; i++){
        let t = 1;
        for(let j = 0; j < 10; j++){
            if(b[i] & t !== 0)
                o[j] = 1;
            else
                z[j] = 1;

            t << 1;
        }
    }

    let c = new Array(10);
    for(let i = 0; i < n; i++){
        let t = 1;
        for(let j = 0; j < 10; j++){
            if(a[i] & t !== 0){
                if(z[j] === 1)
                    c[j] = 0;
                else
                    c[j] = 1;
            }
            t << 1;
        }
    }

    let res = 0;
    for(let i = 9; i >= 0; i--){
        res += pi(c[i])*Math.pow(2,9-i);
    }
    console.log(res);
}

function B(){
    let t = pi(readline());
    while(t){
        t--;
        let [n,k,z] = ti(readline().split(' '));
        let a = ti(readline().split(' '));

        // pre -> 0,1 -> right,left
        let dp = new Array(z+1);
        for(let i = 0; i < z+1; i++){
            dp[i] = new Array(n);
            dp[i].fill(-1);
        }

        let solve = (i,j,index,pre) => {
            if(index < 0 || index >= n)
                return 0;
            if(i > k)
                return 0;
            if(dp[j][index] !== -1)
                return dp[j][index];
            if(pre){
                return dp[j][index] = a[index] + solve(i+1, j, index+1, 0);
            }else{
                return dp[j][index] = a[index] + Math.max(j < z ? solve(i+1,j+1,index-1,1) : 0, solve(i+1,j,index+1,0));
            }
        }

        console.log(solve(0,0,0,1));
    }
}

function D(){
    let t = pi(readline());
    while(t){
        t--;
        let [n,k] = ti(readline().split(' '));
        let mat = new Array(n);
        for(let i = 0; i < n; i++)
            mat[i] = new Array(n);

        let x = Math.floor(k/n);
        let i = 0;
        let j = 0;
        let c = 0;
        while(i < n){
            while(c < x){
                if(j+c >= n)
                    mat[i][j+c-n] = 1;
                else
                    mat[i][j+c] = 1;
                c++;
            }
            c = 0;
            i++;
            j++;
        }

        for(let i = 0; i < n; i++)
            for(let j = 0; j < n; j++)
                if(mat[i][j] === undefined)
                    mat[i][j] = 0;

        if(k%n !== 0){
            let m = k%n;
            let st = -1;
            for(let i = 0; i < n; i++){
                if(mat[0][i] === 0){
                    st = i;
                    break;
                }
            }
            for(let i = 0; i < n; i++){
                if(m === 0)
                    break;
                for(let j = 0; j < n; j++){
                    if(mat[i][j] === 0 && j === st){
                        mat[i][j] = 1;
                        st += 1;
                        if(st >= n) st = 0;
                        m -= 1;
                        break;
                    }
                }
            }
        }

        if(k%n === 0)
            console.log(0);
        else
            console.log(2);
        for(let i = 0; i < n; i++)
            console.log(mat[i].join(''));
    }
}

function solve() {
   var nk = read().split(' ').map(Number);
   var n = nk[0];
   var k = nk[1];
   var ans = [];
   var r = [];
   var c = [];
   for (var i = 0; i < n; i++) {
      r.push(0);
      c.push(0);
      ans.push([]);
      for (var j = 0; j < n; j++) {
         ans[i].push(0);
      }
   }
   var mr = n - 1;
   var mc = n - 1;
   while (k) {
      k--;
      mr = (mr + 1) % n;
      mc = (mc + 1) % n;
      if (ans[mr][mc]) {
         mc = (mc + 1) % n;
      }
      ans[mr][mc] = 1;
      r[mr]++;
      c[mc]++;
   }
   var minr = r[0];
   var maxr = r[0];
   var minc = c[0];
   var maxc = c[0];
   for (var i = 0; i < n; i++) {
      if (r[i] > maxr) {
         maxr = r[i];
      }
      if (r[i] < minr) {
         minr = r[i];
      }
      if (c[i] > maxc) {
         maxc = c[i];
      }
      if (c[i] < minc) {
         minc = c[i];
      }
   }
   write((maxr - minr) * (maxr - minr) + (maxc - minc) * (maxc - minc));
   for (var i = 0; i < n; i++) {
      write(ans[i].join(''));
   }
}

function init() {
   var T;
   T = 1;
   T = Number(read());
   for (var t = 0; t < T; t++) {
      solve();
   }
}

var isNode = typeof console !== 'undefined';
var MEMORY = [];
var MEMORY_INDEX = 0;
if (isNode) {
   var fs = require('fs');
   var path = require('path');

   var inTextName;
   var outTextName;
   if (process.argv.length === 5) {
      inTextName = process.argv[3];
      outTextName = process.argv[4];
   }

   if (inTextName) {
      fs.readFile(path.join(__dirname, inTextName), 'utf8', (err, data) => {
         MEMORY = data.split('\r\n');
         init();
      });
   } else {
      var RL = require('readline').createInterface({
         input : process.stdin,
         output : process.stdout
      });

      RL.on('line', (line) => {
         MEMORY.push(line);
      });

      RL.on('close', init);
   }
} else {
   init();
}

function write(value) {
   isNode ? console.log(value) : print(value);
}
function read() {
   return isNode ? MEMORY[MEMORY_INDEX++] : readline();
}

const process = require('process');

let inp = "";
process.stdin.on('data', chunk => inp += chunk);
process.stdin.on('end', () => {
    inp = inp.split('\n');
    let ic = 0;
    for (let ntest = +inp[ic++]; ntest--; ) {
        let [n, r] = inp[ic++].trim().split(' ').map(x => +x);
        let a = [];
        for (let i = 0; i < n; ++i) {
            let row = [];
            for (let f = 0;f < n; ++f) row.push(0);
            a.push(row);
        }

        let d = Math.floor(r / n);
        for (let r = 0; r < n; ++r) {
            for (let i = 0; i < d; ++i) {
                let c = (r + i) % n;
                a[r][c] = 1;
            }
        }
        let rem = r % n;
        for (let i = 0; i < rem; ++i) {
            let c = (i + d) % n;
            a[i][c] = 1;
        }

        console.log(rem ? 2 : 0);
        console.log(a.map(row => row.join(' ')).join('\n'));
    }
});


You have a string $$$s$$$ of length $$$n$$$ consisting of only characters > and <. You may do some operations with this string, for each operation you have to choose some character that still remains in the string. If you choose a character >, the character that comes right after it is deleted (if the character you chose was the last one, nothing happens). If you choose a character <, the character that comes right before it is deleted (if the character you chose was the first one, nothing happens).For example, if we choose character > in string > > < >, the string will become to > > >. And if we choose character < in string > <, the string will become to <.The string is good if there is a sequence of operations such that after performing it only one character will remain in the string. For example, the strings >, > > are good. Before applying the operations, you may remove any number of characters from the given string (possibly none, possibly up to $$$n - 1$$$, but not the whole string). You need to calculate the minimum number of characters to be deleted from string $$$s$$$ so that it becomes good.

The first line contains one integer $$$t$$$ ($$$1 \le t \le 100$$$) – the number of test cases. Each test case is represented by two lines. The first line of $$$i$$$-th test case contains one integer $$$n$$$ ($$$1 \le n \le 100$$$) – the length of string $$$s$$$. The second line of $$$i$$$-th test case contains string $$$s$$$, consisting of only characters > and <.

For each test case print one line. For $$$i$$$-th test case print the minimum number of characters to be deleted from string $$$s$$$ so that it becomes good.

NoteIn the first test case we can delete any character in string <>.In the second test case we don't need to delete any characters. The string > < < is good, because we can perform the following sequence of operations: > < < $$$\rightarrow$$$ < < $$$\rightarrow$$$ <.

const readline = require('readline');

const rl = readline.createInterface({
	input: process.stdin,
	setEncoding: 'utf8',
	terminal: false
});

const readInput = (function* () {
	const t = Number(yield);
	let a = [];
	for (let i = 0; i < t; i++) {
		const n = Number(yield);
		const s = (yield).trim();
		let x = 0;
		const half = Math.floor(n / 2);
		for (let j = 0; j < half; j++) {
			if (s[j] == '<' && s[n - j - 1] == '>') x++;
			else break;
		}
		a.push(x);
	}
	rl.close();
	console.log(a.join('\n'));
})();

readInput.next();

rl.on('line', (line) => {
	readInput.next(line);
});

const readline = require('readline');

const rl = readline.createInterface({
	input: process.stdin,
	setEncoding: 'utf8',
	terminal: false
});

const readInput = (function* () {
	const t = Number(yield);
	let a = [];
	for (let i = 0; i < t; i++) {
		const n = Number(yield);
		const s = (yield).trim();
		let x = 0;
		if (s[0] == '<' && s[n - 1] == '>') x++;
		a.push(x);
	}
	rl.close();
	console.log(a.join('\n'));
})();

readInput.next();

rl.on('line', (line) => {
	readInput.next(line);
});

const readline = require('readline');

const rl = readline.createInterface({
	input: process.stdin,
	setEncoding: 'utf8',
	terminal: false
});

const readInput = (function* () {
	const t = Number(yield);
	let a = [];
	for (let i = 0; i < t; i++) {
		const n = Number(yield);
		const s = (yield).trim();
		let x = 0;
		if (n % 2 == 0 && s[0] == '<' && s[n - 1] == '>') x++;
		a.push(x);
	}
	rl.close();
	console.log(a.join('\n'));
})();

readInput.next();

rl.on('line', (line) => {
	readInput.next(line);
});