process.stdin .resume ( ) ;
process.stdin .setEncoding ( 'utf8' ) ;
// your code goes here
let card;
let cards = [ [ 1 , 2 , 3 , 4 ] , [ 1 , 5 , 6 , 7 ] , [ 1 , 8 , 9 , 10 ] , [ 1 , 11 , 12 , 13 ] , [ 2 , 5 , 8 , 11 ] , [ 2 , 6 , 9 , 12 ] , [ 2 , 7 , 10 , 13 ] , [ 3 , 5 , 9 , 13 ] , [ 3 , 6 , 10 , 11 ] , [ 3 , 7 , 8 , 12 ] , [ 4 , 5 , 10 , 12 ] , [ 4 , 6 , 8 , 13 ] , [ 4 , 7 , 9 , 11 ] ] ;
const num = [ 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 , 10 , 11 , 12 , 13 ]
.map ( a => [ a, Math .random ( ) ] )
.sort ( ( a, b) => a[ 1 ] - b[ 1 ] )
.map ( a => a[ 0 ] ) ;
for ( let index = 0 ; index < cards.length ; index++ ) {
card = cards[ index] ;
cards[ index] = card.map ( a => num[ a- 1 ] )
.map ( a => [ a, Math .random ( ) ] )
.sort ( ( a, b) => a[ 1 ] - b[ 1 ] )
.map ( a => a[ 0 ] ) ;
}
cards = cards.map ( a => [ a, Math .random ( ) ] ) .sort ( ( a, b) => a[ 1 ] - b[ 1 ] ) .map ( a => a[ 0 ] ) ;
for ( card of Array .from ( cards) ) { console.log ( card) ; }
cHJvY2Vzcy5zdGRpbi5yZXN1bWUoKTsKcHJvY2Vzcy5zdGRpbi5zZXRFbmNvZGluZygndXRmOCcpOwoKLy8geW91ciBjb2RlIGdvZXMgaGVyZQpsZXQgY2FyZDsKbGV0IGNhcmRzID0gW1sxLDIsMyw0XSxbMSw1LDYsN10sWzEsOCw5LDEwXSxbMSwxMSwxMiwxM10sWzIsNSw4LDExXSxbMiw2LDksMTJdLFsyLDcsMTAsMTNdLFszLDUsOSwxM10sWzMsNiwxMCwxMV0sWzMsNyw4LDEyXSxbNCw1LDEwLDEyXSxbNCw2LDgsMTNdLFs0LDcsOSwxMV1dOwoKY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