var n = Number(readline());

var gears = readline().split(' ').map(Number);
var trueGears = [],
    res = 'NO';

Number.prototype.mod = function(n) {
    return ((this%n)+n)%n;
};

for (var i = 0; i < n; i++) {
    trueGears.push(i);
}

for (var j = 0; j < n; j++) {
    for (i = 0; i < gears.length; i++) {
        if ( i % 2 == 0 ) {
            gears[i]++;
        } else {
            gears[i]--;
        }

        gears[i] = gears[i].mod(n);
    }

    if ( arrayEqual(trueGears, gears) ) {
        res = 'YES';
        break;
    }
}

print( res );

function arrayEqual(arr1, arr2) {
    if ( arr1.length !== arr2.length ) {
        return false;
    }

    for (var i = 0; i < arr2.length; i++) {
        if ( arr2[i] !== arr1[i] ) {
            return false;
        }
    }

    return true;
};

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

    this.solveCase = function() {
        var res , i , j , fl , cn , a , b , c , d , e ;
        res = false ;
        a = 0 ;
        b = 0 ;
        for( i = 0 ; i < this.n ; i++ ) {
            c = this.arr[ i ] ;
            d = 0 ;
            if( b == 0 ) {
                while( true ) {
                    if( c == a ) {
                        break ;
                    }
                    d++ ;
                    c = ( c + 1 ) % this.n ;
                }
            }
            else {
                while( true ) {
                    if( c == a ) {
                        break ;
                    }
                    d++ ;
                    c = ( c - 1 + this.n ) % this.n ;
                }
            }
            this.brr[ i ] = d ;
            b = ! b ;
            a++ ;
        }
        a = 1 ;
        for( i = 1 ; i < this.n ; i++ ) {
            if( this.brr[ i ] != this.brr[ i - 1 ] ) {
                a = 0 ;
                break ;
            }
        }
        if( a == 1 ) {
            res = true ;
        }
        else {
            a = 0 ;
            b = 0 ;
            for( j = 0 ; j < 10000 ; j++ ) {
                e = 1 ;
                for( i = 0 ; i < this.n ; i++ ) {
                    c = this.arr[ i ] ;
                    if( b == 0 ) {
                        this.arr[ i ] = ( this.arr[ i ] + 1 ) % this.n ;
                    }
                    else {
                        this.arr[ i ] = ( this.arr[ i ] - 1 + this.n ) % this.n ;
                    }
                    if( this.arr[ i ] != i ) {
                        e = 0 ;
                    }
                    b = ! b ;
                    a++ ;
                }
                if( e == 1 ) {
                    res = true ;
                    break ;
                }
            }
        }
        if( res == true ) {
            print( 'Yes' ) ;
        }
        else {
            print( 'No' ) ;
        }
    } ;

    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.n = irObj.nextInt() ;
            this.arr = [] ;
            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.adjList = new Array() ;
        for( i = 0 ; i < this.lim1 ; i++ ) {
            this.arr.push( 0 ) ;
            this.adjList.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.adjList = 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.adjList.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 ;
        if( currentDirectory.indexOf( 'D:' ) != -1 ) {
            //on windows
            inputFilePath = currentDirectory + '\\' + inputFileName ;
        }
        else {
            //on linux
            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 ;
        if( currentDirectory.indexOf( 'D:' ) != -1 ) {
            //on windows
            outputFilePath = currentDirectory + '\\' + outputFileName ;
        }
        else {
            //on linux
            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() {
		var testCases , hasMoreTestCases , i ;
        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 && ( __dirname.indexOf( 'D:') != -1 || __dirname.indexOf( '/media/') != -1 ) ) {
                    environmentType = 'local-node-js' ;
                }
                else {
                    environmentType = 'server-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 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 = "sample.in" ;
    this.OUTPUT_FILE_NAME = "sample.out" ;
    this.DO_OUTPUT_TO_FILE = false ;
    this.CLEAR_ARRAY_PER_CASE = false ;

    this.solveCase = function() {
        var res , i , j , fl , cn , a , b , c , d , e ;
        res = false ;
        a = 0 ;
        b = 0 ;
        for( i = 0 ; i < this.n ; i++ ) {
            c = this.arr[ i ] ;
            d = 0 ;
            if( b == 0 ) {
                while( true ) {
                    if( c == a ) {
                        break ;
                    }
                    d++ ;
                    c = ( c + 1 ) % this.n ;
                }
            }
            else {
                while( true ) {
                    if( c == a ) {
                        break ;
                    }
                    d++ ;
                    c = ( c - 1 + this.n ) % this.n ;
                }
            }
            this.brr[ i ] = d ;
            b = ! b ;
            a++ ;
        }
        a = 1 ;
        for( i = 1 ; i < this.n ; i++ ) {
            if( this.brr[ i ] != this.brr[ i - 1 ] ) {
                a = 0 ;
                break ;
            }
        }
        if( a == 1 ) {
            res = true ;
        }
        else {
        }
        if( res == true ) {
            print( 'Yes' ) ;
        }
        else {
            print( 'No' ) ;
        }
    } ;

    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.n = irObj.nextInt() ;
            this.arr = [] ;
            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.adjList = new Array() ;
        for( i = 0 ; i < this.lim1 ; i++ ) {
            this.arr.push( 0 ) ;
            this.adjList.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.adjList = 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.adjList.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 ;
        if( currentDirectory.indexOf( 'D:' ) != -1 ) {
            //on windows
            inputFilePath = currentDirectory + '\\' + inputFileName ;
        }
        else {
            //on linux
            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 ;
        if( currentDirectory.indexOf( 'D:' ) != -1 ) {
            //on windows
            outputFilePath = currentDirectory + '\\' + outputFileName ;
        }
        else {
            //on linux
            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() {
		var testCases , hasMoreTestCases , i ;
        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 && ( __dirname.indexOf( 'D:') != -1 || __dirname.indexOf( '/media/') != -1 ) ) {
                    environmentType = 'local-node-js' ;
                }
                else {
                    environmentType = 'server-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 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() ;

var n = parseInt(readline());
var actives = readline().split(' ').map(function(a){
	return parseInt(a);
});

function is_finished() {
	for (var i = 0; i < n; i++) {
		if (actives[i] != i) {
			return false
		}
	}
	return true;
}

function action() {
	for (var i = 0; i < n; i++) {
		if (i % 2) {
			actives[i]--;
		} else {
			actives[i]++;
		}
		if (actives[i] < 0) {
			actives[i] = n-1;
		}
		actives[i] = actives[i] % n;
	}
}

var finished = false;

for (var i = 0; i < n; i++) {
	if (is_finished()) {
		print('Yes');
		finished=true;
		break;
	}
	action();
}
if (!finished) {
	print('No');
}


function split(v) {
   var pos = v.indexOf(' ');
   return [+v.substr(0, pos), +v.substr(pos + 1)]
}

var fl = readline().split(' ').map(v=>+v);
var persCnt = fl[0];
var pairsCnt = fl[1];

var persons = [], scores = [], all1 = 0, all2 = 0;
for(var i = 0; i < persCnt; i++) {
    var rl = split(readline());
    persons.push([i, rl[0], rl[1], rl[1] - rl[0], 0]);

    all2 += rl[1]
}

for(i = 0; i < pairsCnt; i++) {
    var pair = split(readline());
    var person1 = persons[pair[0] - 1];
    var person2 = persons[pair[1] - 1];
    var sum = person1[3] > person2[3]
        ? person1[1] + person2[2]
        : person1[2] + person2[1]

    person1[4] -= sum
    person2[4] -= sum
}

scores.length = persCnt;

persons.sort((a, b) => a[3] > b[3] ? -1 : 1);
for(var i = 0; i < persCnt; i++) {
    var person = persons[i]
    all2-=person[2]
    scores[person[0]] =
        person[1] * (persCnt - i - 1) +
        person[2] * i
        + all2 + all1
        + person[4]

    all1+=person[1]
}

print(scores.join(' '));

        'use strict';

        const first_line = readline().split(' ').map(Number);
        const n = first_line[0];
        const m = first_line[1];

        const ans = new Array(n);

        const x = new Array(n);
        const y = new Array(n);
        const diff = new Array(n);
        for (let i = 0; i < n; i++) {
            const line = readline().split(' ').map(Number);
            x[i] = line[0];
            y[i] = line[1];

            diff[i] = [y[i] - x[i], i];
        }

        diff.sort(function(lhs, rhs) {return (lhs[0] !== rhs[0]) ? lhs[0] - rhs[0] : lhs[1] - rhs[1]});

        const prefsum = new Array(n + 1);
        prefsum[0] = 0;
        for (let i = 0; i < n; i++) {
            const id = diff[i][1];
            prefsum[i + 1] = prefsum[i] + y[id];
        }

        const suffsum = new Array(n + 1);
        suffsum[n] = 0;
        for (let i = n - 1; i >= 0; i--) {
            const id = diff[i][1];
            suffsum[i] = suffsum[i + 1] + x[id];
        }

        for (let i = 0; i < n; i++) {
            const id = diff[i][1];
            ans[id] = prefsum[i] + x[id] * i + suffsum[i + 1] + y[id] * (n - i - 1);
        }

        for (let i = 0; i < m; i++) {
            const line = readline().split(' ').map(Number);
            const v = line[0] - 1;
            const u = line[1] - 1;
            const score = Math.min(x[v] + y[u], x[u] + y[v]);
            ans[v] -= score;
            ans[u] -= score;
        }

        print(ans.join(' '));


let input = ''

process.stdin.on('data', (x) => input += x)

process.stdin.on('end', () => {
  input.trim().split('\n').slice(1).map((x) => parseInt(x)).forEach((n) => {
    console.log([...new Array(n)].map(() => 1).join(' '))
  })
})

let inputString = "";
let currentLine = 0;
process.stdin.on("data", (data) => {
  inputString += data;
});
process.stdin.on("end", function () {
  inputString = inputString
    .trim()
    .split("\n")
    .map((str) => str.trim());
  main();
});
function readLine() {
  return inputString[currentLine++];
}

// utils
const MOD = 1e9 + 7;
const mod = (n) => ((n % MOD) + MOD) % MOD;
const add = (a, b) => mod(mod(a) + mod(b));
const sub = (a, b) => mod(mod(a) - mod(b));
function mul() {
  for (var a = arguments, r = a[0], i = a.length; --i; )
    r = ((((r >> 16) * a[i]) % MOD) * 65536 + (r & 65535) * a[i]) % MOD;
  return r;
}
function inv(b) {
  for (var a = MOD, u = 0, v = 1, t; b; v = t)
    (t = (a / b) | 0), (a -= t * b), (u -= t * v), (t = a), (a = b), (b = t), (t = u), (u = v);
  u %= MOD;
  return u < 0 ? u + MOD : u;
}
function pow(base, n) {
  if (n === 0) return 1;
  let p = pow(base, Math.floor(n / 2));
  let res = mul(mod(p), mod(p));
  if (n % 2 === 1) res = mul(mod(res), base);
  return res;
}
function highestOneBit(i) {
  i |= i >> 1;
  i |= i >> 2;
  i |= i >> 4;
  i |= i >> 8;
  i |= i >> 16;
  return i - (i >>> 1);
}
function permutation(arr, len, store = "", permutations = []) {
  if (store.length === len) {
    permutations.push(store);
    return;
  }
  for (let i = 0; i < arr.length; i++) {
    const newArr = [...arr];
    const newChar = newArr.splice(i, 1);
    permutation(newArr, len, store.concat(newChar), permutations);
  }
  return permutations;
}

function main() {
  let t = +readLine();
  while (t--) {
    const len = +readLine();
    const arr = Array(len).fill(1);
    console.log(arr.join(" "));
  }
}

//Don't have to see. start------------------------------------------
var read = require('readline').createInterface({
	input: process.stdin, output: process.stdout
});
var obj; var inLine = [];
read.on('line', function(input){inLine.push(input);});
read.on('close', function(){
	obj = init(inLine);
	console.error('\n↑入力 ↓出力');
	Main();
});
function makeClone(obj){return (obj instanceof Set) ? new Set(Array.from(obj)) : JSON.parse(JSON.stringify(obj));}
function nextInt(){return myconv(next(),1);} function nextStrArray(){return myconv(next(),2);}
function nextIntArray(){return myconv(next(),4);} function nextCharArray(){return myconv(next(),6);}
function next(){return obj.next();} function hasNext(){return obj.hasNext();}
function init(input){
	return {
		list : input, index : 0, max : input.length,
		hasNext : function(){return (this.index < this.max);},
		next : function(){if(this.hasNext()){return this.list[this.index++];}else{throw 'ArrayIndexOutOfBoundsException ‚There is no more input';}}
	};
}
function myout(s){console.log(s);}
function myerr(s){console.error('debug:' + require('util').inspect(s,false,null));}
//param "no" is
//unknown or outlier : return i. 1: parseInt.
//2: split space. 4: split space and parseInt.
//6: split 1 character. 7: split 1 character and parseInt.
//8: join space. 9: join nextline. 0: join no character.
function myconv(i,no){try{switch(no){case 1:return parseInt(i);case 2:return i.split(' ');case 4:return i.split(' ').map(Number);case 6:return i.split('');case 7:return i.split('').map(Number);case 8:return i.join(' ');case 9:return i.join('\n');case 0:return i.join('');default:return i;}}catch(e){return i;}}

//Don't have to see. end------------------------------------------
function Main(){
	var t = nextInt();
	var output = new Array(t);
	for(var i = 0; i < t; i++){
		var N = nextInt();
		var s = new Array(N).fill(1);
		output[i] = myconv(s, 8);
	}
	myout(myconv(output, 9));
}

(()=>{"use strict";var t={675:(t,e)=>{Object.defineProperty(e,"__esModule",{value:!0}),Array.numbersMatrix=(t,e,r)=>{let n=[];null==t&&(e=t),null==r&&(r=0);for(let i=0;i<t;++i){let t=[];for(let n=0;n<e;++n)t.push(r);n.push(t)}return n},Array.prototype.sortAsc=function(){return this.sort(((t,e)=>t-e))},Array.prototype.sortDesc=function(){return this.sort(((t,e)=>e-t))},Array.prototype.max=function(){if(0==this.length)return 0;let t=this[0];for(let e=1;e<this.length;++e)t=Math.max(t,this[e]);return t},Array.prototype.min=function(){if(0==this.length)return 0;let t=this[0];for(let e=1;e<this.length;++e)t=Math.min(t,this[e]);return t},Array.prototype.sum=function(){let t=0;for(let e=0;e<this.length;++e)t+=this[e];return t},Array.prototype.modSum=function(t){let e=0;for(let r=0;r<this.length;++r)e+=this[r],e%=t;return e},Array.prototype.avg=function(){return this.sum()/this.length},Array.prototype.groupBy=function(t){let e=new Map;for(let r=0;r<this.length;++r){const n=t(this[r]);e.has(n)?e.get(n).push(this[r]):e.set(n,[this[r]])}return e},Array.prototype.deepCopy=function(){let t=[];if(0==this.length)return t;let e=!1;Array.isArray(this[0])&&(e=!0);for(let r=0;r<this.length;++r)e?t.push(this[r].deepCopy()):t.push(this[r]);return t},Array.prototype.transpose=function(){let t=[];if(0==this.length)return[[]];for(let e=0;e<this[0].length;++e){let r=[];for(let t=0;t<this.length;++t)r.push(this[t][e]);t.push(r)}return t},Array.prototype.toString=function(){if(0==this.length)return"";if(!Array.isArray(this[0]))return this.join(" ");let t="";for(let e=0;e<this.length;++e)t+=this[e].join(" "),e!=this.length-1&&(t+="\n");return t}},312:function(t,e,r){var n=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});const i=n(r(747));let o="",s=[],u=0,l="";const p="local"===process.argv[2],a=t=>{if(p){if(s=i.default.readFileSync("input.txt").toString().trim().split("\n").map((t=>t.trim())),t(),i.default.writeFileSync("output.txt",l),console.log(l),i.default.readFileSync("expected.txt").toString().trim()==l.trim()){const{exec:t}=r(129);t("osascript -e 'display notification \"✅ AC!!\"'")}}else process.stdin.resume(),process.stdin.setEncoding("utf-8"),process.stdin.on("data",(t=>{o+=t})),process.stdin.on("end",(e=>{s=o.trim().split("\n").map((t=>t.trim())),t(),console.log(l)}))};function h(){return s[u++]}function f(){return h().split(" ").map((t=>parseFloat(t)))}function c(){return h().split("")}e.default={runMain:a,runEachTest:t=>{a((()=>{let[e]=f();for(;e>0;)t(),e--}))},readline:h,nextNumbers:f,nextBigNumbers:function(){return h().split(" ").map((t=>BigInt(t)))},nextNumbersMatrix:function(t){let e=[];for(let r=0;r<t;++r)e.push(f());return e},nextCharacters:c,nextCharacterMatrix:function(t){let e=[];for(let r=0;r<t;++r)e.push(c());return e},nextIntervalArray:function(t){let e=[];for(let r=0;r<t;++r){const[t,r]=f();e.push({a:t,b:r})}return e},put:function(t){l+=t},puts:function(t){l+=t+"\n"},debug:function(t){p&&console.log(t)}}},965:function(t,e,r){var n=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0}),r(675);const i=n(r(312));i.default.runEachTest((function(){let[t]=i.default.nextNumbers();i.default.puts("1 ".repeat(t))}))},129:t=>{t.exports=require("child_process")},747:t=>{t.exports=require("fs")}},e={};!function r(n){if(e[n])return e[n].exports;var i=e[n]={exports:{}};return t[n].call(i.exports,i,i.exports,r),i.exports}(965)})();

// Solution written in typescript and compiled via webpack. Original source code below
// Happy Hacking 😜

// import './array'
//
// import io from './io'
//
// function main() {
//   let [n] = io.nextNumbers()
//
//   io.puts("1 ".repeat(n))
// }
//
// io.runEachTest(main)
// // io.runMain(main)

'use strict';

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();
    });

    main();
});

function readline() {
    return inputString[currentLine++];
}
/**
3
1
2
4

**/

function gcd(a, b) {
    if (!b) {
        return a;
    }

    return gcd(b, a % b);
};

function lcm(a, b) {
    return (a / gcd(a, b) * b);
}

function main() {
    let n = Number(readline());

    for(let r=0;r<n;r++) {
        solve();
    }

}

function solve() {
    let n = Number(readline());
    let a = [];
    let j = 1;

    for(let i=1;i<=n;i++) {
        a.push(j);
    }

    console.log(a.join(" "));

}

var t = readline();
var a = [];
var b = [];
for (var i = 0; i < t; i++) {
    b.push(readline());
}
for (var i = 0; i < t; i++) {
    for (var j = 0; j < b[i]; j++) {
        a.push(1);
    }
    for (var j = 0; j < a.length; j++) {
        write(a[j] + " ");
    }
    a = [];
    write("\n");
}

var t = +readline();

for (var i = 0; i < t; i++) {
  var l = +readline();
  var res = [];

  for (var j = 0; j < l; j++) {
    res[j] = 1;
  }

    print(res.toString().replace(/\,/g, ' '));
}

var tc = parseInt(readline());
for(; tc--; ){
    var n = parseInt(readline());
    for(var i=0; i<n; i++) write(1 +' ');
}

'use strict';

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();
    });

    main();
});

function readline() {
    return inputString[currentLine++];
}
/**
3
1
2
4

**/

function gcd(a, b) {
    if (!b) {
        return a;
    }

    return gcd(b, a % b);
};

function lcm(a, b) {
    return (a / gcd(a, b) * b);
}

function main() {
    let n = Number(readline());

    for(let r=0;r<n;r++) {
        solve();
    }

}

function solve() {
    let n = Number(readline());
    let a = [];
    let j = 1;

    for(let i=1;i<=n;i++) {
        a.push(j);
        j = j + 2;
    }

    console.log(a.join(" "));

}

(function() {
    var t = +readline()

    function checker(arr) {
        var sum = 0
        arr.map(item => sum += item)
        if (sum % arr.length === 0) {
           return true
        } else {
            return false
        }
    }

    function geter(arr) {
        var arr2 = []
        arr.map((item,index) => {
            if (index !== arr.length - 2) {
                arr2.push(item)
            }
        })
        var flag = checker(arr2)
        return flag
    }

    for (var i = 0; i < t; i++) {

        var n = +readline()
        var arr = []

        if (n % 2 === 0) {
             var num = 2
            for (j = 0; j < n; j++) {
                arr.push(num)
                num += 2
                var tempArr = arr
                var flag = geter(arr)
                if (!flag) {
                    while (!flag) {
                        tempArr = tempArr.filter((el,i) => i !== arr.length - 1)
                        num += 1
                        tempArr.push(num)
                        flag = geter(tempArr)
                    }
                    arr = tempArr
                }
            }
        } else {
            var num = 1
            for (j = 0; j < n; j++) {
                arr.push(num)
                num += 2
                var tempArr = arr
                var flag = geter(arr)
                if (!flag) {
                    while (!flag) {
                        tempArr = tempArr.filter((el,i) => i !== arr.length - 1)
                        num += 1
                        tempArr.push(num)
                        flag = geter(tempArr)
                    }
                    arr = tempArr
                }
            }
        }
        print(arr)
    }

}())

var t = +readline();

for (var i = 0; i < t; i++) {
  var l = +readline();
  var res = [];

  if (l === 1) {
    var num = Math.floor(Math.random() * (100 - 1) + 1);

    if (num % 2 !== 0) {
      num++;
    }

    print(num.toString().replace(/\,/g, ' '));
  } else {
    for (var j = 0; j < l; j++) {
      var num = Math.floor(Math.random() * (100 - 0) + 0);

      while (num % l !== 0) {
        num = Math.floor(Math.random() * (100 - 0) + 0);
      }

      res[j] = num;
    }

    print(res.toString().replace(/\,/g, ' '));
  }
}

var t = +readline();

for (var i = 0; i < t; i++) {
  var l = +readline();
  var res = [];

  if (l === 1) {
    var num = Math.floor(Math.random() * (100 - 1) + 1);

    if (num % 2 !== 0) {
      num++;
    }

    print(num.toString().replace(/\,/g, ' '));
  } else {
    for (var j = 0; j < l; j++) {
      var num = Math.floor(Math.random() * (100 - 1) + 1);

      while (num % l !== 0) {
        num = Math.floor(Math.random() * (100 - 1) + 1);
      }

      res[j] = num;
    }

    print(res.toString().replace(/\,/g, ' '));
  }
}

var t = +readline();

for (var i = 0; i < t; i++) {
  var l = +readline();
  var res = [];

  if (l === 1) {
    var num = Math.floor(Math.random() * (100 - 0) + 0);

    if (num % 2 !== 0) {
      num++;
    }

    print(num.toString().replace(/\,/g, ' '));
  } else {
    for (var j = 0; j < l; j++) {
      var num = Math.floor(Math.random() * (100 - 0) + 0);

      if (num % 2 === 0) {
        num++;
      }

      res[j] = num;
    }

    print(res.toString().replace(/\,/g, ' '));
  }
}


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

let input = "";
process.stdin.on("data", data => input += data);
process.stdin.on("end", () => {
	const nonDecrease = (a, b) => a - b;
	const [n, ...rest] = input.trim().split("\n");
	const [left, right] = [rest
		.map(line => line.split(" ").map(Number))]
		.map(x => [
			x.map(x => x[0]).sort(nonDecrease),
			x.map(x => x[1]).sort(nonDecrease)
		])[0];
	console.log(left.map((v, i) => Math.max(v, right[i])).reduce((a, b) => a + b) + Number(n));
});

n = +readline();
left = []
right = [];
for (i = 0;i<n;i++){
    num = readline().split(' ').map(Number);
    left.push(num[0]);
    right.push(num[1]);
}
left = left.sort((a,b)=>a-b);
right = right.sort((a,b)=>a-b);
ans = 0;
for (i = 0;i<n;i++){
    ans += Math.max(left[i],right[i]);
}
print(ans+n);


const readline = require('readline')

const rl = readline.createInterface({
    input: process.stdin,
    output: process.stdout
})
const lines = []
rl.on('line', (input) => {
    lines.push(input);
})
rl.on('close', () => {
// (function() {
    // const lines = require('fs').readFileSync('test.in', 'utf8').split('\n')
    let l = 0;
    let t = +lines[l++]
    const output = []
    for (let i = 0; i < t; i++) {
        const arr = lines[l++].trim().split(' ').map(Number)
        output[i] = solve(arr)
    }
    console.log(output.join('\n'))
// })()
})

function solve(arr) {
    const n = arr.shift()
    const pair = ['12', '23', '31']
    const sorted = arr.map((x, i) => [x, pair[i]])
        .sort((a, b) => a[0] - b[0])
    const [a, b, c] = sorted.map(x => x[0])
    const [sa, sb, sc] = sorted.map(x => x[1])
    const va = getv(sa, sb)
    const vb = getv(sa, sc)
    const vc = getv(sb, sc)
// console.log(sa, sb, sc)
// return
    if (c > a + b || (a + b - c) & 1) return 'NO'
    const share = (a + b - c) / 2
// console.log('share', share)
    const edges = []
    let now = 3
    let lca = fill(va, share)
    if (share === a) {
        fixLast(va)
        lca = va
    }
    fill(lca, a - share)
    fixLast(vb)
    fill(lca, b - share)
    fixLast(vc)
    if (now <= n) {
        fill(va, n - now)
    } else {
        return 'NO'
    }
    function fill(u, d) {
        while (d--) {
            const v = ++now
            edges.push([u, v])
            u = v
        }
        return u
    }
    function fixLast(u) {
        edges[edges.length - 1][1] = u
        now--
    }
    return 'YES\n' + edges.map(x => x.join(' ')).join('\n')
}
function getv(sa, sb) {
    for (let x of [1,2,3]) {
        if (sa.indexOf(x) >= 0 && sb.indexOf(x) >= 0) return x
    }
}

var n;
    var a;

    function logNodes(x, y) {
        print(x + ' ' + y);
    }

    var tests = parseInt(readline());
    for (var t=0; t<tests;t++) {
        var nd = readline().split(' ').map(x=>parseInt(x));
        n = nd[0];
        a = [];
        a.push([nd[1], 1, 2]);
        a.push([nd[2], 2, 3]);
        a.push([nd[3], 1, 3]);
        a.sort((b, c) => c[0] - b[0]);

        var x, y ,z;
        x = a[0][0];
        y = a[1][0];
        z = a[2][0];
        var br = (y+z) - x;
        if (br & 1 || br < 0) {
            print('NO');
            continue;
        }
        br = br / 2;
        if (n < a[0][0] + 1 + br) {
            print('NO');
            continue;
        }
        print('YES');
        if (a[1][1] == a[0][2] || a[1][2] == a[0][2]) {
            var temp = a[0][1];
            a[0][1] = a[0][2];
            a[0][2] = temp;
        }
        var nodes = [1, 2, 3];
        var brNode = nodes.filter(x => x != a[0][1] && x != a[0][2])[0];

        var brStart = brNode;
        var reserve = 4;
        for (var i = 0; i < br; i++) {
            logNodes(reserve, brStart);
            brStart = reserve;
            reserve++;
        }
        var lineNode = a[0][1];
        for (var i = 0; i < (y - br - 1); i++) {
            logNodes(lineNode, reserve);
            lineNode = reserve;
            reserve++;
        }
        logNodes(lineNode, brStart);
        lineNode = brStart;
        for (var i = 0; i < (z - br - 1); i++) {
            logNodes(lineNode, reserve);
            lineNode = reserve;
            reserve++;
        }
        logNodes(lineNode, a[0][2]);
        lineNode = a[0][2];
        while( reserve <= n ) {
            logNodes(lineNode, reserve);
            lineNode = reserve;
            reserve++;
        }
    }

var n;
    var a;

    function logNodes(x, y) {
        print(x + ' ' + y);
    }

    var tests = parseInt(readline());
    for (var t=0; t<tests;t++) {
        var nd = readline().split(' ').map(x=>parseInt(x));
        n = nd[0];
        a = [];
        a.push([nd[1], 1, 2]);
        a.push([nd[2], 2, 3]);
        a.push([nd[3], 1, 3]);
        a.sort((b, c) => c[0] - b[0]);

        var x, y ,z;
        x = a[0][0];
        y = a[1][0];
        z = a[2][0];
        var br = (y+z) - x;
        if (br & 1 || br < 0) {
            print('NO');
            continue;
        }
        br = br / 2;
        if (n < a[0][0] + 1 + br) {
            print('NO');
            continue;
        }
        print('YES');
        if (a[1][1] == a[0][2] || a[1][2] == a[0][2]) {
            var temp = a[0][1];
            a[0][1] = a[0][2];
            a[0][2] = temp;
        }
        var nodes = [1, 2, 3];
        var brNode = nodes.filter(x => x != a[0][1] && x != a[0][2])[0];

        var brStart = brNode;
        var reserve = 4;
        for (var i = 0; i < br; i++) {
            logNodes(reserve, brNode);
            brStart = reserve;
            reserve++;
        }
        var lineNode = a[0][1];
        for (var i = 0; i < (y - br - 1); i++) {
            logNodes(lineNode, reserve);
            lineNode = reserve;
            reserve++;
        }
        logNodes(lineNode, brStart);
        lineNode = brStart;
        for (var i = 0; i < (z - br - 1); i++) {
            logNodes(lineNode, reserve);
            lineNode = reserve;
            reserve++;
        }
        logNodes(lineNode, a[0][2]);
        lineNode = a[0][2];
        while( reserve <= n ) {
            logNodes(lineNode, reserve);
            lineNode = reserve;
            reserve++;
        }
    }

var n;
    var a;

    function logNodes(x, y) {
        print(x + ' ' + y);
    }

    var tests = parseInt(readline());
    for (var t=0; t<tests;t++) {
        var nd = readline().split(' ').map(x=>parseInt(x));
        n = nd[0];
        a = [];
        a.push([nd[1], 1, 2]);
        a.push([nd[2], 2, 3]);
        a.push([nd[3], 1, 3]);
        a.sort((b, c) => c[0] - b[0]);

        var x, y ,z;
        x = a[0][0];
        y = a[1][0];
        z = a[2][0];
        var br = (y+z) - x;
        if (br & 1 || br < 0) {
            print('NO');
            continue;
        }
        br = br / 2;
        if (n - 2 < (a - 1) + br) {
            print('NO');
            continue;
        }
        print('YES');
        if (a[1][1] == a[0][2] || a[1][2] == a[0][2]) {
            var temp = a[0][1];
            a[0][1] = a[0][2];
            a[0][2] = temp;
        }
        var nodes = [1, 2, 3];
        var brNode = nodes.filter(x => x != a[0][1] && x != a[0][2])[0];

        var brStart = brNode;
        var reserve = 4;
        for (var i = 0; i < br; i++) {
            logNodes(reserve, brNode);
            brStart = reserve;
            reserve++;
        }
        var lineNode = a[0][1];
        for (var i = 0; i < (y - br - 1); i++) {
            logNodes(lineNode, reserve);
            lineNode = reserve;
            reserve++;
        }
        logNodes(lineNode, brStart);
        lineNode = brStart;
        for (var i = 0; i < (z - br - 1); i++) {
            logNodes(lineNode, reserve);
            lineNode = reserve;
            reserve++;
        }
        logNodes(lineNode, a[0][2]);
        lineNode = a[0][2];
        while( reserve <= n ) {
            logNodes(lineNode, reserve);
            lineNode = reserve;
            reserve++;
        }
    }

const readline = require('readline')

const rl = readline.createInterface({
    input: process.stdin,
    output: process.stdout
})
const lines = []
rl.on('line', (input) => {
    lines.push(input);
})
rl.on('close', () => {
// (function() {
    // const lines = require('fs').readFileSync('test.in', 'utf8').split('\n')
    let l = 0;
    let t = +lines[l++]
    const output = []
    for (let i = 0; i < t; i++) {
        const arr = lines[l++].trim().split(' ').map(Number)
        output[i] = solve(arr)
    }
    console.log(output.join('\n'))
// })()
})

function solve(arr) {
    const n = arr.shift()
    const pair = ['12', '23', '31']
    const sorted = arr.map((x, i) => [x, pair[i]])
        .sort((a, b) => a[0] - b[0])
    const [a, b, c] = sorted.map(x => x[0])
    const [sa, sb, sc] = sorted.map(x => x[1])
    const va = getv(sa, sb)
    const vb = getv(sa, sc)
    const vc = getv(sb, sc)
// console.log(sa, sb, sc)
// return
    if (c > a + b || (a + b - c) & 1) return 'NO'
    const share = (a + b - c) / 2
// console.log('share', share)
    const edges = []
    let now = 3
    let lca = fill(va, share)
    if (share === a) {
        fixLast(va)
        lca = va
    }
    fill(lca, a - share)
    fixLast(vb)
    fill(lca, b - share)
    fixLast(vc)
    if (now < n) {
        fill(va, n - now)
    }
    function fill(u, d) {
        while (d--) {
            const v = ++now
            edges.push([u, v])
            u = v
        }
        return u
    }
    function fixLast(u) {
        edges[edges.length - 1][1] = u
        now--
    }
    return 'YES\n' + edges.map(x => x.join(' ')).join('\n')
}
function getv(sa, sb) {
    for (let x of [1,2,3]) {
        if (sa.indexOf(x) >= 0 && sb.indexOf(x) >= 0) return x
    }
}


function checkValue(value) {
  return value != 1;
}
function getNextIdx (n, restArgs) {
    var arr = [];
    arr[3000] = 0;
    var i;
    for (i=0;i<n;i++) {
        arr[restArgs[i]-1] = 1;
    }
    return (arr.findIndex(checkValue) +1);
}
var n = readline();
print(getNextIdx(n, readline().split(" ")));

const readline = require('readline');

const rl = readline.createInterface({
    input: process.stdin,
    output: process.stdout
});

var N = -1;

rl.on('line', function (input) {

    if (N == -1) {
        N = parseInt(input);
    }
    else {
        var tests = [];
        tests = input.split(' ').map(item => { return parseInt(item); });
        tests.sort(sortNumber);
        /*console.log("*************");
        tests.forEach(element => {
            rl.write(element + ", ");
        });
        console.log("************");
        */
        var i = 0;
        for (i = 0; i < N; i++)
            if (i + 1 != tests[i]) break;

        console.log(i + 1);
        rl.close();
    }
}
)

function sortNumber(a, b) {
    return a - b;
  }

const readline = require('readline');

const rl = readline.createInterface({
    input: process.stdin,
    output: process.stdout
});

var N = -1;

rl.on('line', function (input) {

    if (N == -1) {
        N = parseInt(input);
    }
    else {
        var tests = [];
        tests = input.split(' ').map(item => { return parseInt(item); });
        //tests.sort(sortNumber);
        tests.sort((a,b)=>{return a-b;});
        /*console.log("*************");
        tests.forEach(element => {
            rl.write(element + ", ");
        });
        console.log("************");
        */
        var i = 0;
        for (i = 0; i < N; i++)
            if (i + 1 != tests[i]) break;

        console.log(i + 1);
        rl.close();
    }
}
)
/*
function sortNumber(a, b) {
    return a - b;
  }*/

function trim(s) {
	return s.replace(/^\s+|\s+$/gm, '');
}

function tokenize(s) {
	return trim(s).split(/\s+/);
}

function tokenizeIntegers(s) {
	var tokens = tokenize(s);
	for (var i = 0; i < tokens.length; i += 1) {
		tokens[i] = parseInt(tokens[i]);
	};
	return tokens;
}

function main() {
	var n = parseInt(readline());
	var previous = tokenizeIntegers(readline());
	var seen = new Array(3001);
	for (var i = 0; i < n; ++i) {
		seen[previous[i]] = true;
	}
	for (i = 1; seen[i]; ++i) {
	}
	print(i);
}

main();

'use strict'

const N = readline()
let lll = readline().split(' ').map(v => parseInt(v)).sort((a, b) => a - b)
if (lll[0] != 1) {
  print(1)
} else {
  for (var i = 1; i < lll.length; i++) {
    if (lll[i] - lll[i - 1] != 1) break
  }
  print(i + 1)
}

const readline = require('readline');

const rl = readline.createInterface({
    input: process.stdin,
    output: process.stdout
});

var N = -1;

rl.on('line', function (input) {

    if (N == -1) {
        N = parseInt(input);
    }
    else {
        var tests = [];
        tests = input.split(' ').map(item => { return parseInt(item); });
        tests.sort();
        var i = 0;
        for (i = 0; i < N; i++)
            if (i + 1 != tests[i]) break;

        console.log(i + 1);
        rl.close();
    }
}
)

function checkValue(value) {
  return value != 1;
}
function getNextIdx (n, restArgs) {
    var arr = [];
    var i;
    for (i=0;i<n;i++) {
        arr[restArgs[i]-1] = 1;
    }
    return (arr.findIndex(checkValue) +1);
}
var n = readline();
print(getNextIdx(n, readline().split(" ")));

function checkValue(value) {
  return value != 1;
}
function getNextIdx (n, restArgs) {
    var arr = [];
    var i;
    for (i=0;i<n;i++) {
        arr[restArgs[i]-1] = 1;
    }
    print(arr);
    return (arr.findIndex(checkValue) +1);
}
var n = readline();
print(getNextIdx(n, readline().split(" ")));

function trim(s) {
	return s.replace(/^\s+|\s+$/gm, '');
}

function tokenize(s) {
	return trim(s).split(/\s+/);
}

function tokenizeIntegers(s) {
	var tokens = tokenize(s);
	for (var i = 0; i < tokens.length; i += 1) {
		tokens[i] = parseInt(tokens[i]);
	};
	return tokens;
}

function main() {
	var n = parseInt(readline());
	var previous = tokenizeIntegers(readline());
	var seen = new Array(3001);
	for (var i = 0; i < n; ++i) {
		seen[i] = true;
	}
	for (i = 1; seen[i]; ++i) {
	}
	print(i);
}

main();

'use strict'

const N = readline()
let lll = readline().split(' ').map(v => parseInt(v)).sort((a, b) => a - b)
for (var i = 1; i < lll.length; i++) {
  if (lll[i] - lll[i - 1] != 1) break
}
print(i + 1)


//Don't have to see. start------------------------------------------
var read = require('readline').createInterface({
	input: process.stdin, output: process.stdout
});
var obj; var inLine = []; var outputList = [];var retcode = new Set();
read.on('line', function(input){
	var tmp = input.split(' ');
	for(var i = 0; i < tmp.length; i++){
		inLine.push(tmp[i]);
		if(i == tmp.length - 1){
			retcode.add(inLine.length);
		}
	}
});
read.on('close', function(){
	obj = init(inLine);
	console.error('\n↑入力 ↓出力');
	Main();
	console.log(myconv(outputList, 9));
});
function makeClone(obj){return (obj instanceof Set) ? new Set(Array.from(obj)) : JSON.parse(JSON.stringify(obj));}
function nextArray(size, code){
	var ret = new Array(size);
	for(var i = 0; i < size; i++){
		if(code == 'int'){
			ret[i] = nextInt();
		}else{
			ret[i] = next();
		}
	}
	return ret;
}
function nextIntArray(size){return nextArray(size, 'int');} function nextStrArray(size){return nextArray(size, 'str');}
function nextCharArray(){return myconv(next(),6);}
function next(){return obj.next();} function hasNext(){return obj.hasNext();} function nextInt(){return myconv(next(),1);}
function init(input){
	return {
		list : input, index : 0, max : input.length,
		hasNext : function(){return (this.index < this.max);},
		next : function(){if(this.hasNext()){return this.list[this.index++];}else{throw 'ArrayIndexOutOfBoundsException ‚There is no more input';}},
		isReturn : function(){return retcode.has(this.index);}
	};
}
function myout(s){outputList.push(s);}
function myerr(s){console.error('debug:' + require('util').inspect(s,false,null));}
function isReturn(){return obj.isReturn();}
//param "no" is
//unknown or outlier : return i. 1: parseInt.
//2: split space. 4: split space and parseInt.
//6: split 1 character. 7: split 1 character and parseInt.
//8: join space. 9: join nextline. 0: join no character.
function myconv(i,no){try{switch(no){case 1:return parseInt(i);case 2:return i.split(' ');case 4:return i.split(' ').map(Number);case 6:return i.split('');case 7:return i.split('').map(Number);case 8:return i.join(' ');case 9:return i.join('\n');case 0:return i.join('');default:return i;}}catch(e){return i;}}

//Don't have to see. end------------------------------------------
function Main(){
	var t = nextInt();
	for(var i = 0; i < t; i++){
		var N = nextInt();
		var w1 = nextInt();
		var w2 = nextInt();
		var b1 = N - w1;
		var b2 = N - w2;
		var w = nextInt();
		var b = nextInt();
		if(w1 % 2 != w2 % 2){
			if(w1 > w2){
				w1--;
			}else{
				w2--;
			}
		}
		if(b1 % 2 != b2 % 2){
			if(b1 > b2){
				b1--;
			}else{
				b2--;
			}
		}
		var L = w1 + w2;
		var R = b1 + b2;
		if(L < w * 2 || R < b * 2){
			myout("NO");
		}else{
			myout("YES");
		}
	}
}

process.stdin.resume();
process.stdin.setEncoding("utf8");
let standardInputString = "";
let currentLine = 0;
function readLine() {
  return standardInputString[currentLine++];
}
process.stdin.on("data", (rawData) => {
  standardInputString += rawData;
});
process.stdin.on("end", (_) => {
  standardInputString = standardInputString
    .trim()
    .split("\n")
    .map((line) => {
      return line.trim();
    });
  main();
});

function main() {
  const numArray = (a) => a.split(" ").map((line) => +line),
    cl = console.log,
    rl = readLine,
    tc = rl();

  for (let i = 0; i < tc; i++) {
    const [n, k1, k2] = numArray(rl());
    const [w, b] = numArray(rl());
    solution(n, k1, k2, w, b);
  }
  /************************Solution****************************************/
  function solution(n, k1, k2, w, b) {
    // cl(n, k1, k2, w, b);
    const whiteArea = k1 + k2;
    const blackArea = 2 * n - whiteArea;

    // console.log("solution", w, whiteArea, b, blackArea);
    if (w * 2 <= whiteArea && b * 2 <= blackArea) {
      cl("yes");
    } else {
      cl("no");
    }
  }
}

var a = function(a, b, c){
    if(a < b){
    var temp = a;
        a = b;
        b = temp;
    }
    a -= b;
    var a2 = a / 2;
    var b2 = c - b;
    if(a2 >= b2){
        return true;
    }else{
        return false;
    }
};
let i = '';
process.stdin.on('data', c => i += c);
process.stdin.on('end', () => {
    const {EOL} = require('os');
    const lines = i.split(EOL);
    var n = lines[0];
    var e = 0;
    for(var j = 1; j <= n * 2; j++){
        if(j % 2 == 1){
            e = lines[j].split(' ').map(Number);
        }else{
            var k = lines[j].split(' ').map(Number);
            var N = e[0];
            var k1 = e[1];
            var k2 = e[2];
            var w = k[0];
            var b = k[1];
            b1 = N - k1;
            b2 = N - k2;
            if(a(k1, k2, w) === true && a(b1, b2, b) === true){
                console.log('YES');
            }else{
                console.log('NO');
            }
        }
    }
});

process.stdin.setEncoding('utf-8')
const readline = require('readline')

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

let count = -1
let inputArr = []

rl.on('line', data => {
    if (count === -1) {
        count = +data * 2
    } else if (count !== 0) {
        inputArr.push(data.trim())
        count--
    }
    // max number 2^(53) - 1 ~~ 10^(15)
    if (count === 0) {
        inputArr = inputArr.map(i => i.split(' ').map(j => +j))
        main()
        process.exit(0)
    }
})

function solve([n, k1, k2], [w, b]) {
    const wArea = k1 + k2, bArea = (2 * n) - (k1 + k2)
    let res = false
    if (k1 % 2 === k2 % 2) {
        if (wArea >= w * 2 && bArea >= b * 2) res = true
    } else {
        if (wArea - 1 >= w * 2 && bArea - 1 >= b * 2) res = true
    }
    res ? console.log('YES') : console.log('NO')
}

function main() {
    for (let i = 0; i < inputArr.length; i += 2) solve(inputArr[i], inputArr[i + 1])
}

'use strict';

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();
  });

  main();
});

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

// Make a Snippet for the code above this and then write your logic in main();
var mod = 1000000000n + 7n
var maxN = 10e6 + 1

function main() {
  var x = parseInt(readline())

  Array(parseInt(x)).fill(1).map((t, iii) => {
    // var n = parseInt(readline())
    var [n, k1, k2] = readline().split(' ').map((x, iii) => {
      return parseInt(x)
    });
    var [w, b] = readline().split(' ').map((x, iii) => {
      return parseInt(x)
    });

    // if ((k1 + k2) % 2 !== 0) return console.log('NO')
// console.log(w * 2 <= (k1 + k2), b * 2 <= (n - k1 + n - k2))
    if ((w * 2 <= (k1 + k2) )&& (b * 2 <= (n - k1 + n - k2))) return console.log('YES')
    console.log('NO')
    // var a = readline().split(' ').map((x, iii) => {
    //   return parseInt(x)
    // });

  });
}

function getInt(num){
    return parseInt(num, 10)
}

var t = parseInt(readline(), 10);

for(var i = 0; i<t; i++){
    var line1 = readline().split(' ').map(getInt);
    var line2 = readline().split(' ').map(getInt);
    print(solution(line1[0], line1[1], line1[2], line2[0], line2[1]));
}
function solution(n, k1, k2, w, b){
    if(w + b > n){
        return 'NO';
    }
    if(k1 < k2){
        var temp;
        temp = k1;
        k1=k2;
        k2 =temp;
    }
    var ws = k2;
    var bs = n-k1;

    if(ws >= w && bs>=b){
        return 'YES';
    }
    b = Math.max(b - bs, 0);
    w = Math.max(w - ws, 0);

    n = n - bs - ws;
    var rest = Math.floor(n/2);
    if(b <= rest && w<=rest){
        return 'YES'
    }
    return 'NO';

}

process.stdin.resume();
process.stdin.setEncoding("utf8");
let standardInputString = "";
let currentLine = 0;
function readLine() {
  return standardInputString[currentLine++];
}
process.stdin.on("data", (rawData) => {
  standardInputString += rawData;
});
process.stdin.on("end", (_) => {
  standardInputString = standardInputString
    .trim()
    .split("\n")
    .map((line) => {
      return line.trim();
    });
  main();
});

function main() {
  const numArray = (a) => a.split("").map((line) => +line),
    cl = console.log,
    rl = readLine,
    tc = rl();

  for (let i = 0; i < tc; i++) {
    const [n, k1, k2] = numArray(rl());
    const [w, b] = numArray(rl());
    solution(n, k1, k2, w, b);
  }
  /************************Solution****************************************/
  function solution(n, k1, k2, w, b) {
    const whiteArea = k1 + k2;
    const blackArea = 2 * n - whiteArea;

    // console.log("solution", w, whiteArea, b, blackArea);
    if (w <= whiteArea && b <= blackArea) {
      cl("yes");
    } else {
      cl("no");
    }
  }
}


// Q: https://codeforces.com/contest/1339/problem/B

const readline = require('readline');

let input = [];

const rl = readline.createInterface({
	input: process.stdin,
	output: process.stdout,
});

rl.on('line', lineInput => {
	input.push(lineInput);
});

rl.on('close', () => {
	const test = parseInt(input[0]);
	let sum = 0;
	for (let t=0; t < test; t++) {
		let ans = true;
		let n = parseInt(input[sum+t+1]);
		let arr1 = input[t+sum+2].split(' ').map((a) => parseInt(a));
		let arr2 = [];
		if (n == 1) {
			if ((arr1[0] < arr1[1])) {
				ans = false;
			}
		} else {
			for (let i = 1; i < n; i++) {
				arr2 = input[t+sum+2+i].split(' ').map((a) => parseInt(a));
				if ((arr2[0] < arr1[0]) || (arr2[1] < arr1[1]) || (arr2[0] < arr2[1]) || (arr1[0] < arr1[1]) || (arr2[0] - arr1[0] < arr2[1] - arr1[1])) {
					ans = false;
					break;
				}
				if (arr1[0] === arr2[0] && arr2[1] > arr1[1]) {
					ans = false;
					break;
				}
				arr1 = [...arr2];
			}
		}

		console.log(ans ? 'YES' : 'NO');
		sum += n;
	}
});

let i = '';
let lines;
process.stdin.on('data', (c) => (i += c));
process.stdin.on('end', () => {
  const { EOL } = require('os');
  lines = i.split(EOL); /*your input text, split by lines*/
  main();
});

function solve(n, a) {
  if (a[0][0] < a[0][1]) return 'NO';
  for(let i = 1; i < n; ++i) {
    const x = a[i][0] - a[i - 1][0];
    const y = a[i][1] - a[i - 1][1];
    if (x < 0 || y < 0) return 'NO';
    if (x < y) return 'NO';
  }
  return 'YES';
}

function main() {
  let currentLine = 0;
  const readLine = (_) => lines[currentLine++].split(' ').map((val) => parseInt(val));

  const test = readLine()[0];
  for (let t = 1; t <= test; ++t) {
    const n = readLine()[0];
    let a = [];
    for(let i = 0; i < n; ++i) a.push(readLine());
    console.log(solve(n, a));
  }
}

'use strict';

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();
    });

    main();
});

function readline() {
    return inputString[currentLine++];
}
// Make a Snippet for the code above this and then write your logic in main();

function main() {
    const cases = readline();
    var i, j;
    for (i = 0; i < cases; i++) {
        const n = readline();
        var terminate = false;
        var lastX = 0;
        var lastY = 0;
        for (j = 0; j < n; j++) {
            const line = readline();
// console.log('x' +line+'\n');
            var x = parseInt(line.split(" ")[0]);
            var y = parseInt(line.split(" ")[1]);
// console.log("* "+x+" "+y+" "+((!terminate) && ((y > x) || ((y-lastY) > (x-lastX))))+"\n");
            if((!terminate) && ((x < lastX) || (y < lastY) || (y > x) || ((y-lastY) > (x-lastX)))) {
                process.stdout.write("NO\n");
                terminate = true;
            }

            lastX = x;
            lastY = y;
        }

        !terminate && process.stdout.write("YES\n");
    }
}

t = +readline();
out = '';
while (t-->0){
    n = +readline();
    attemps = 0;
    clears = 0;
    possible = true;
    while (n-->0){
        p = readline().split(' ').map(Number);
        if (!possible){
            continue;
        }
        if (p[0] < attemps || p[1] < clears || p[0] - attemps < p[1] - clears){
            possible = false;
        }
        attemps = p[0];
        clears = p[1];
    }
    out += possible?"YES\n":"NO\n";
}
print(out);

// Q: https://codeforces.com/contest/1339/problem/B

const readline = require('readline');

let input = [];

const rl = readline.createInterface({
	input: process.stdin,
	output: process.stdout,
});

rl.on('line', lineInput => {
	input.push(lineInput);
});

rl.on('close', () => {
	const test = parseInt(input[0]);
	let sum = 0;
	for (let t=0; t < test; t++) {
		let ans = true;
		let n = parseInt(input[sum+t+1]);
		let arr1 = input[t+sum+2].split(' ').map((a) => parseInt(a));
		let arr2 = [];
		if (n == 1) {
			if ((arr1[0] < arr1[1])) {
				ans = false;
			}
		} else {
			for (let i = 1; i < n; i++) {
				arr2 = input[t+sum+2+i].split(' ').map((a) => parseInt(a));
				if ((arr2[0] < arr1[0]) || (arr2[1] < arr1[1]) || (arr2[0] < arr2[1]) || (arr1[0] < arr1[1])) {
					ans = false;
					break;
				}
				arr1 = [...arr2];
			}
		}

		console.log(ans ? 'YES' : 'NO');
		sum += n;
	}
});

// Q: https://codeforces.com/contest/1339/problem/B

const readline = require('readline');

let input = [];

const rl = readline.createInterface({
	input: process.stdin,
	output: process.stdout,
});

rl.on('line', lineInput => {
	input.push(lineInput);
});

rl.on('close', () => {
	const test = parseInt(input[0]);
	let sum = 0;
	for (let t=0; t < test; t++) {
		let ans = true;
		let n = parseInt(input[sum+t+1]);
		let arr1 = input[t+sum+2].split(' ').map((a) => parseInt(a));
		let arr2 = [];
		if (n == 1) {
			if ((arr1[0] < arr1[1])) {
				ans = false;
			}
		} else {
			for (let i = 1; i < n; i++) {
				arr2 = input[t+sum+2+i].split(' ').map((a) => parseInt(a));
				if ((arr2[0] < arr1[0]) || (arr2[1] < arr1[1]) || (arr2[0] < arr2[1]) || (arr1[0] < arr1[1]) || (arr1[0] == arr2[0] && arr2[1] > arr1[0])) {
					ans = false;
					break;
				}
				arr1 = [...arr2];
			}
		}

		console.log(ans ? 'YES' : 'NO');
		sum += n;
	}
});

// Q: https://codeforces.com/contest/1339/problem/B

const readline = require('readline');

let input = [];

const rl = readline.createInterface({
	input: process.stdin,
	output: process.stdout,
});

rl.on('line', lineInput => {
	input.push(lineInput);
});

rl.on('close', () => {
	const test = parseInt(input[0]);
	let sum = 0;
	for (let t=0; t < test; t++) {
		let ans = true;
		let n = parseInt(input[sum+t+1]);
		let arr1 = input[t+sum+2].split(' ').map((a) => parseInt(a));
		let arr2 = [];
		if (n == 1) {
			if ((arr1[0] < arr1[1])) {
				ans = false;
			}
		} else {
			for (let i = 1; i < n; i++) {
				arr2 = input[t+sum+2+i].split(' ').map((a) => parseInt(a));
				if ((arr2[0] < arr1[0]) || (arr2[1] < arr1[1]) || (arr2[0] < arr2[1]) || (arr1[0] < arr1[1])) {
					ans = false;
					break;
				}
				if (arr1[0] === arr2[0] && arr2[1] > arr1[1]) {
					ans = false;
					break;
				}
				arr1 = [...arr2];
			}
		}

		console.log(ans ? 'YES' : 'NO');
		sum += n;
	}
});

// Q: https://codeforces.com/contest/1339/problem/B

const readline = require('readline');

let input = [];

const rl = readline.createInterface({
	input: process.stdin,
	output: process.stdout,
});

rl.on('line', lineInput => {
	input.push(lineInput);
});

rl.on('close', () => {
	const test = parseInt(input[0]);
	let sum = 0;
	for (let t=0; t < test; t++) {
		let ans = true;
		let n = parseInt(input[sum+t+1]);
		let arr1 = input[t+sum+2].split(' ').map((a) => parseInt(a));
		let arr2 = [];
		for (let i = 1; i < n; i++) {
			arr2 = input[t+sum+2+i].split(' ').map((a) => parseInt(a));
			if ((arr2[0] < arr1[0]) || (arr2[1] < arr1[1]) || (arr2[0] < arr2[1]) || (arr1[0] < arr1[1])) {
				ans = false;
				break;
			}
			arr1 = [...arr2];
		}
		console.log(ans ? 'YES' : 'NO');
		sum += n;
	}
});

let i = '';
let lines;
process.stdin.on('data', (c) => (i += c));
process.stdin.on('end', () => {
  const { EOL } = require('os');
  lines = i.split(EOL); /*your input text, split by lines*/
  main();
});

function solve(n, a) {
  for(let i = 1; i < n; ++i) {
    if (a[i][1] < a[i - 1][1]) return 'NO';
    if (a[i][0] < a[i - 1][0]) return 'NO';
    if (a[i][1] > a[i - 1][1] && a[i][0] === a[i - 1][0]) return 'NO';
  }
  return 'YES';
}

function main() {
  let currentLine = 0;
  const readLine = (_) => lines[currentLine++].split(' ').map((val) => parseInt(val));

  const test = readLine()[0];
  for (let t = 1; t <= test; ++t) {
    const n = readLine()[0];
    let a = [];
    for(let i = 0; i < n; ++i) a.push(readLine());
    console.log(solve(n, a));
  }
}

'use strict';

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();
    });

    main();
});

function readline() {
    return inputString[currentLine++];
}
// Make a Snippet for the code above this and then write your logic in main();

function main() {
    const cases = readline();
    var i, j;
    for (i = 0; i < cases; i++) {
        const n = readline();
        var terminte = false;
        var lastX = 0;
        var lastY = 0;
        loop1: for (j = 0; j < n; j++) {
            const line = readline();

            var x = line.split(" ")[0];
            var y = line.split(" ")[1];

            if(!terminte && (y > x || (y-lastY) > (x-lastX))) {
                process.stdout.write("NO\n");
                terminte = true;
            }

            lastX = x;
            lastY = y;
        }

        terminte ? process.stdout.write("YES\n") : null;
    }
}