function check_player() {

k = readline();

for (i = 0; i < k; i++) {

  res_arr = readline().split(' ');
  m = 0;

   res_arr = res_arr.map(arg => +arg);

  res_arr = [res_arr.slice(0, 2), res_arr.slice(2, 4)];

max1 = Math.max(res_arr[0][0], res_arr[0][1]);
max2 = Math.max(res_arr[1][0], res_arr[1][1]);

    if (max1 > max2) {

      min1 = Math.min(res_arr[0][0], res_arr[0][1]);

        if (max2 > min1) {

          print('Yes');

        } else {

          print('No');

        }

    } else {

      min2 = Math.min(res_arr[1][0], res_arr[1][1]);

        if (max1 > min2) {

            print('Yes');

        } else {

            print('No');

        }

    }

  }

}

check_player();

var testCase=+readline()
for(var i=0;i<testCase;i++){
    var sequence=readline().split(" ").map(node=>+node),counter=0
    var a=sequence.slice(0,2)
    var b=sequence.slice(-2)
    var aMax=a.reduce((a,b)=>Math.max(a,b))
    var bMax=b.reduce((a,b)=>Math.max(a,b))

    a.forEach((node)=>node>bMax?counter++:null)
    b.forEach((node)=>node>aMax?counter++:null)

    counter>1?print("NO"):print("YES")
}

var a = readline();
var arr = [];
var s = 0;
var s1 = 0;
var s2 = 0;
var s3 = 0;
var f = 0;
var f1 = 0;
var f2 = 0;
var f3 = 0;
var d = 0;
for(var i = 0; i < a; i++){
    arr[i] = readline().split(' ').map(i=>Number(i));
    s=arr[i][0];
    s1=arr[i][1];
    s2=arr[i][2];
    s3=arr[i][3];
    if(s>s1){
        f=s;
    }else{
        f=s1;
    }
    if(s2>s3){
        f1=s2
    }else{
        f1=s3
    }
    if(f<f1){
        f2=f;
    }else{
        f2=f1;
    }
    for(var j = 0; j < arr[i].length; j++){
        if(f2<arr[i][j]){
            f3++;
        }
    }
    if(f3==1){
        print("YES")
    }else{
        print("NO")
    }
    f3=0;
}

test = readline();
while(test--) {
players = readline().split(" ").map((x) => parseInt(x));

winner1 = Math.max(players[0], players[1]);
winner2 = Math.max(players[2], players[3]);

players.sort((a, b) => a - b);

print(players[3] == Math.max(winner1,winner2) && players[2] == Math.min(winner1,winner2) ? "YES" : "NO")
}

var t = readline();
    for(var i = 0 ; i < t ; i++){
        var s = readline().split(' '),
        s1 = s.slice(0,2).sort( (a,b) => {return a - b}),
        s2 = s.slice(2,4).sort( (a,b) => {return a - b}),
        highestSkills = s.sort( (a,b) => {return a - b}).slice(2,4);
        winners = [s1[1],s2[1]].sort( (a,b) => {return a - b});
        if(winners.toString() == highestSkills.toString()){
            print('YES');
        }
        else{
            print('NO');
        }
    }

t = +readline();
while (t--) {
  x = readline().split(" ").map(Number);
  winner1 = Math.max(x[0], x[1]);
  winner2 = Math.max(x[2], x[3]);
  losser1 = Math.min(x[0], x[1]);
  losser2 = Math.min(x[2], x[3]);
  wouldBig = Math.min(winner1, winner2);
  wouldSmoll = Math.max(losser1, losser2);
  if (wouldBig > wouldSmoll) {
    print("YES");
  } else {
    print("NO");
  }
}

// 1535 A - Playoff equo

// number of test case
var numTests = parseInt( readline() );

for (var numTest = 0; numTest < numTests; numTest++) {

    // input data
    var nums = readline().split(' ').map( e => parseInt(e));

    // two player più forti non stiano nella stessa squadra
    if( Math.max( nums[0],nums[1] ) >= Math.min( nums[2],nums[3] )  && Math.max( nums[2],nums[3] ) >= Math.min( nums[0],nums[1] ) ){
        print('YES');
    } else {
        print('NO');
    }

}

var number = parseInt(readline());
var first = 0;
var second = 0;

for(var i = 0; i < number; i++) {
    var counter = 0;
    var foo = readline();
    var fooSplited = foo.split(" ")
    if(parseInt(fooSplited[0]) > parseInt(fooSplited[1])) {
        first = parseInt(fooSplited[0]);
    } else {
        first = parseInt(fooSplited[1]);
    }

    if(parseInt(fooSplited[2]) > parseInt(fooSplited[3])) {
        second = parseInt(fooSplited[2]);
    } else {
        second = parseInt(fooSplited[3])
    }

    if(first > parseInt(fooSplited[2]) || first > parseInt(fooSplited[3])) {
        counter++;
    }

    if(second > parseInt(fooSplited[0]) || second > parseInt(fooSplited[1])) {
        counter++;
    }

    if(counter == 2) {
        print("YES");
    } else {
        print("NO")
    }

}

const arrMax = a => Math.max.apply(null, a);

const t = parseInt(readline());

for (var _ = 0; _ < t; _++) {
  var p = readline().split(' ').map(d => parseInt(d));
  var p_s = [...p];
  p_s.sort((a, b) => b - a);
  var fair = p_s.slice(0, 2);
  var actual = [];
  actual.push(arrMax(p.slice(0, 2)), arrMax(p.slice(2, 4)));
  actual.sort((a, b) => b - a);
  print(fair[0] === actual[0] && fair[1] === actual[1]? 'YES': 'NO');
}

'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 x = readline();

    for(let i = 0;i < x;i++){
        let array = readline().split(" ").map(x => parseInt(x));
        let a = array[0]>array[1]?array[0]:array[1];
        let b = array[2]>array[3]?array[2]:array[3];
        a < b ?
        a > array[2] || a > array[3] ? console.log('YES'): console.log('NO'):
        b > array[0] || b > array[1] ? console.log('YES'): console.log('NO');
    }
}

'use strict';
process.stdin.resume();
process.stdin.setEncoding('utf-8');
let input = '';
process.stdin.on('data', inputStdin => {
    input += inputStdin;
});
process.stdin.on('end', _ => {
    main(input);
});

function main(input) {
    var args = input.split("\n");
    const t = parseInt(args[0], 10);
    for (var i = 1; i <= t; i++) {
        var v = args[i].split(" ").map((n) => parseInt(n, 10));
        var v2 = v.concat();
        v2.sort(function (a, b) {
            if (a < b) return -1;
            if (a > b) return 1;
            return 0;
        });
        if (((v2[0] == v[0] && v2[1] == v[1])
            || (v2[0] == v[1] && v2[1] == v[0])
            || (v2[0] == v[2] && v2[1] == v[3])
            || (v2[0] == v[3] && v2[1] == v[2]))) {
            console.log("NO");
        } else {
            console.log("YES");
        }
    }
}

const os = require('os');

function winner(players_skills) {
    return Math.max(players_skills[0], players_skills[1])
}

function solution(input) {
    const champion = Math.max(winner(input.slice(0, 2)), winner(input.slice(2, 4)));
    const runner_up = Math.min(winner(input.slice(0, 2)), winner(input.slice(2, 4)));
    input.sort((a, b) => b - a);

    return input[0] === champion && input[1] === runner_up ? 'YES' : 'NO';
}

function parse(input_in_string) {
    return input_in_string.split(' ').map(Number);
}

let lines = '';

process.stdin.on('data', data => lines += data);

process.stdin.on('end', () => {
    const input = lines.split(os.EOL);
    const number_of_test_cases = Number(input.shift());
    for(let test_case = 1; test_case <= number_of_test_cases; test_case += 1) {
        console.log(solution(parse(input.shift())));
    }
});

module.exports = {solution}

const os = require('os');

function winner(players_skills) {
    return Math.max(...players_skills)
}

function looser(players_skills) {
    return Math.min(...players_skills)
}
function is_fair(semifinal_1, semifinal_2) {
    return winner(semifinal_1) > looser(semifinal_2) &&
        winner(semifinal_2) > looser(semifinal_1);
}

function solution(input) {
    return  is_fair(input.slice(0, 2), input.slice(2, 4))? 'YES' : 'NO';
}

function parse(input_in_string) {
    return input_in_string.split(' ').map(Number);
}

let lines = '';

process.stdin.on('data', data => lines += data);

process.stdin.on('end', () => {
    const input = lines.split(os.EOL);
    for(const _ of Array(Number(input.shift()))) {
        console.log(solution(parse(input.shift())));
    }
});

module.exports = {solution}

const os = require('os');

function winner(players_skills) {
    return Math.max(...players_skills)
}

function looser(players_skills) {
    return Math.min(...players_skills)
}
function is_fair(semifinal_1, semifinal_2) {
    return winner(semifinal_1) > looser(semifinal_2) &&
        winner(semifinal_2) > looser(semifinal_1);
}

function solution(input) {
    return  is_fair(input.slice(0, 2), input.slice(2, 4))? 'YES' : 'NO';
}

function parse(input_in_string) {
    return input_in_string.split(' ').map(Number);
}

let lines = '';

process.stdin.on('data', data => lines += data);

process.stdin.on('end', () => {
    const input = lines.split(os.EOL);
    const number_of_test_cases = Number(input.shift());
    for (let test_case = 1; test_case <= number_of_test_cases; test_case += 1) {
        console.log(solution(parse(input.shift())));
    }
});

module.exports = {solution}

let i = '';
process.stdin.on('data', c => i += c);
process.stdin.on('end', () => {
    const {EOL} = require('os');
    const lines = i.split(EOL); /*your input text, split by lines*/
    for(j = 1; j <= lines[0]; j++){
        var a = lines[j].split(' ')
        var x = Math.min(a[0], a[1])
        var c = Math.max(a[2], a[3])
        var v = Math.min(a[2], a[3]);
        var z = Math.max(a[0], a[1]);
        if(x <= c && v <= z){
            console.log('YES')
        }else {
            console.log('NO')
        }
    }
    });
//2 - 2 % 0 + 1
//2 - 2 % 0 - (0 - 1)
//xcvz
//2, min, *
//[2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47]; '15'

let i = '';
process.stdin.on('data', c => i += c);
process.stdin.on('end', () => {
    const {EOL} = require('os');
    const lines = i.split(EOL);
    for(var j = 1; j <= lines[0]; j++){
        var a = lines[j].split(' ');
        var x = Math.min(a[0],a[1]);
        var c = Math.max(a[2],a[3]);
        var v = Math.min(a[2],a[3]);
        var z = Math.max(a[0],a[1]);
        if (x <= c && v <= z){
            console.log('YES');
        } else{
            console.log("NO");
        }
    }
});

//xcvz

"use strict";

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

function print(x) {
  console.log(x);
}
let inputString = "";
let currentLine = 0;

process.stdin.on("data", (inputStdin) => {
  inputString += inputStdin;
});
process.stdin.on("end", () => {
  inputString = inputString.split("\n");
  main();
});
function readline() {
  return inputString[currentLine++];
}

// ********** Code Start **********

function main() {

const testcase=parseInt(readline());
let d=[];
for(let i=0;i<testcase;i++){

  let r=[];
  r.push(readline().split(" "));
  let x=Math.max(r[0][0],r[0][1]);
  let t=Math.min(r[0][0],r[0][1]);
  let z=Math.min(r[0][2],r[0][3]);
      let y=Math.max(r[0][2],r[0][3]);

      if(x>z && y>t) d.push("YES");

      else d.push("NO");

}
for(let i=0;i<testcase;i++){
  console.log(d[i]);

}

}

// Getting input via STDIN
const readline = require("readline");

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

const userInput = [];

inp.on("line", (data) => {
  userInput.push(data);
});

inp.on("close", () => {
  //start-here
  //Your code goes here … replace the below line with your code logic
var i=1;
 var t=userInput[0]
 while(i<=t)
 {
     dummy=userInput[i].split(' ')
     arr=dummy

     var bigger=Math.max(dummy[0],dummy[1])
     var bigger2=Math.max(dummy[2],dummy[3])

    arr.sort(function(a, b) {
  return a - b;
})
     var biggestno=arr[3]
     var biggestno2=arr[2]

     if(((bigger==biggestno)||(bigger==biggestno2))&&((bigger2==biggestno2)||(bigger2==biggestno)))
     {
         console.log('YES')
     }
     else{
         console.log('NO')
     }
     i++

 }
  //end-here
});

'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++];
}
//###########################################################

function myFunc(arr){
    let maxD, minD, maxE, minE;
    maxE = Math.max(arr[0], arr[1]);
    maxD = Math.max(arr[2], arr[3]);

    minE = Math.min(arr[0], arr[1]);
    minD = Math.min(arr[2], arr[3]);
    if(maxE > minD && maxD > minE){
        return 'YES';
    }
    return 'NO';
}

//###########################################################
function main() {

    const t = parseInt(readLine(), 10);

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

        // const line = readLine().split(' ');
        // const x = parseInt(line[0], 10);
        // const y = parseInt(line[1], 10);
        // const str = line[2].toString();

        const line = readLine().split(' ').map(p => +p);

        let result = myFunc(line);

        console.log(result);
    }

}

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

let c = 0;

rl.on("line", (d) => {
  if (c === 0) {
    c++;
    return;
  }

  const [a1, b1, c1, d1] = d.split(" ").map(Number);

  if (c1 > a1 && c1 > b1 && d1 > a1 && d1 > b1) {
    console.log("NO");
  } else if (c1 < a1 && c1 < b1 && d1 < a1 && d1 < b1) {
    console.log("NO");
  } else {
    console.log("YES");
  }

  c++;
});

rl.on("close", () => {});

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];
    for(var j = 1; j <= n; j++){
        var a = lines[j].split(' ');
        var win1 = Math.max(a[0],a[1]);
        var loss1 = Math.min(a[0],a[1]);
        var win2 = Math.max(a[2],a[3]);
        var loss2 = Math.min(a[2],a[3]);
        if (loss1 <= win2 && loss2 <= win1){
            console.log('YES');
        } else{
            console.log("NO");
        }
    }
});

let data = '';
process.stdin.on('data', c => data += c);

function* nextLine() {
	let lines = data.trim().split(/\n/g);
	for(let l of lines){
		yield l.trim();
	}
}

let nl = nextLine();

nl.elem = function(funParse) {
		return funParse(this.next().value);
	};

nl.array = function(funParse) {
		return this.next().value.split(/\s/g).map(funParse||(x => x));
	};

nl.num = function() {
		return nl.elem(Number);
	};

nl.nums = function() {
		return nl.array(Number);
	};

nl.line = function() {
		return this.next().value;
	};

const sol = () => {
	//your code this
	let t  = nl.num();
	let ans = [];
	for(let i = 0; i < t; i++){
		let a = nl.nums();
		let b = [a[0] > a[1]?a[0]:a[1], a[2] > a[3]?a[2]:a[3]];
		a.sort((x, y) => y - x);
		b.sort((x, y) => y - x);
		ans.push(a[0] === b[0] && a[1] === b[1]);

	}
	console.log(ans.map(e => e?'YES':'NO').join('\n'));
};

process.stdin.on('end', sol);

process.stdin.resume();

process.stdin.setEncoding('utf8');

var input = '';

process.stdin.on('data' , data=>{
    input += data;
});
process.stdin.on('end' , ()=>{
    main(input);
});

function main(input) {
    input = input.split("\n");
    let z = 0;
    let testCases = +input[z++];

    while(testCases--){
        let [a, b, c, d] = input[z++].trim().split(' ').map(Number);
        let max1 = Math.max(a, b);
        let max2 = Math.max(c, d);

        if((max1 > c || max1 > d) && (max2 > a || max2 > b)){
            console.log("Yes");
        }
        else{
            console.log("NO");
        }
    }
}

var timer = 0;
function dfs(v, prev) {
   var h = {};
   v.__h = h;
   h.tin = ++timer;
   h.up = [];
   var i = 0;
   var next = prev;
   while (next) {
      h.up[i] = next;
      next = next.__h.up[i++];
   }
   var children = v.childNodes;
   for (i = 0; i < children.length; i++) {
      dfs(children[i], v);
   }
   h.tout = ++timer;
}

function solve() {
   var a = readArray((x, i) => [i, Number(x)]);
   a.sort((x, y) => y[1] - x[1]);
   var half = (a.length >> 1);
   write((a[0][0] < half ^ a[1][0] >= half) ? 'NO' : 'YES');
}

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

function sortF(a, b) {
   if (a < b) {
      return -1;
   }
   if (a > b) {
      return 1;
   }
   return 0;
}

function readArray(f) {
   return read().split(' ').map(f);
}

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;

   var needWriteFile = false;

   var writeResult = '';
   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();
         if (needWriteFile) {
            fs.writeFile(path.join(__dirname, outTextName), writeResult, (err) => {
               err ? console.error(err) : console.log('good')
            });
         }
      });
   } else {
      MEMORY = fs.readFileSync(0, 'utf-8').split('\r\n');
      init();
   }
} else {
   init();
}

function write(value) {
   if (needWriteFile) {
      writeResult += value + '\n';
      return;
   }
   isNode ? console.log('' + value) : print('' + value);
}
function read() {
   return isNode ? MEMORY[MEMORY_INDEX++] : readline();
}
function readAll() {
   return isNode && MEMORY;
}

"use strict";
process.stdin.resume();
process.stdin.setEncoding("utf-8");

function print(x) {
  console.log(x);
}
let inputString = "";
let currentLine = 0;

process.stdin.on("data", (inputStdin) => {
  inputString += inputStdin;
});
process.stdin.on("end", () => {
  inputString = inputString.split("\n");
  main();
});
function readline() {
  return inputString[currentLine++];
}

// ********** Code Start **********

function main() {

  var t=parseInt(readline());
while(t--)
{
    var a=readline().split(' ').map(a=>parseInt(a))
    var b=Math.max(a[0],a[1])
    var c=Math.min(a[2],a[3])
    var d=Math.min(a[0],a[1])
    var e=Math.max(a[2],a[3])
    if(b<c || d>e)console.log("NO")
    else console.log("YES");

}

}

const fin = (arr) => {
	if (arr.length === 2) {
		return arr;
	}

	const next = [];
	for (let i=0; i<arr.length/2; i++) {
		next[i] = Math.max(arr[i*2], arr[i*2+1]);
	}

	return fin(next);
}

const solve = (arr) => {
	const final = fin(arr).sort((a, b) => b-a);
	const sorted = arr.sort((a, b) => b-a).slice(0, 2);

	return final[0] === sorted[0] &&
		final[1] === sorted[1] ? 'YES' : 'NO';
}

let input = '';
process.stdin.on('data', str => input += str)
process.stdin.on('end', () => {
	const [t, ...lines] = input.trim().split('\n');

	for (let i=0; i<t; i++) {
		console.log(solve(lines[i].split(' ').map(v => +v)));
	}
})

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

const input = [];
let currLine = 0;

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

rl.on("close", () => {
    main();
});

const read = () => {
    return input[currLine++];
};

const readArr = () => {
    return input[currLine++].split(" ").map(e=>parseInt(e));
};

const main = () => {

    const tc=parseInt(read());

    let i=0;
    while(i<tc){
        const arr=readArr();
        const sortedArr=[...arr].sort((a,b)=>{
            if(a<b){
                return -1;
            }
            return 1;
        });
        const first=sortedArr[3], second=sortedArr[2];
        let w1=0, w2=0;

        if(arr[0]>arr[1]){
            w1=arr[0];
        }
        else{
            w1=arr[1];
        }

        if(arr[2]>arr[3]){
            w2=arr[2];
        }
        else{
            w2=arr[3];
        }

        if((w1!=first && w1!=second) || (w2!=first && w2!=second)){
            console.log("NO");
        }
        else{
            console.log("YES");
        }

        i++;
    }

};

///////////////////////////////// pre-define ////////////////////////////////////////////////////////////////////////////////
const pr = console.log;
const mi = Math.min;
const mx = Math.max;
const mxll = (...args) => args.reduce((m, e) => e > m ? e : m);
const mill = (...args) => args.reduce((m, e) => e < m ? e : m);
const sqll = (v) => { if (v < 0n) throw 'negative input'; if (v < 2n) return v; const dfs = (n, x0) => { let x1 = ((n / x0) + x0) >> 1n; if (x0 === x1 || x0 === (x1 - 1n)) return x0; return dfs(n, x1); }; return dfs(v, 1n); }; // has >> 0
const abs = Math.abs;
const fl = Math.floor;
const ce = Math.ceil;
const sq = Math.sqrt;
const lge = Math.log;
const lg10 = Math.log10;
const ll = BigInt;
const combination = (m, n) => { return factorial(m, n) / factorial(n, n); };
const factorial = (m, n) => { let num = 1n; let cnt = 0; for (let i = ll(m); i > 0; i--) { if (cnt == n) break; num *= i; cnt++; } return num; };
const gcd = (a, b) => b == 0 ? a : gcd(b, a % b);
const lcm = (a, b) => (a / gcd(a, b)) * b;
const bitCount = (n) => { n = n - ((n >> 1) & 0x55555555); n = (n & 0x33333333) + ((n >> 2) & 0x33333333); return ((n + (n >> 4) & 0xF0F0F0F) * 0x1010101) >> 24; };
const powmod = (a, b, mod) => { let r = 1n; while (b > 0n) { if (b % 2n == 1) r = r * a % mod; b >>= 1n; a = a * a % mod; } return r; };
const amax = (a) => mx.apply(Math, a);
const amin = (a) => mi.apply(Math, a);
const sm = (a) => a.reduce(((x, y) => x + y), 0);
const aeq = (a, b) => JSON.stringify(a) == JSON.stringify(b);
const swap = (a, i, j) => [a[i], a[j]] = [a[j], a[i]];
const stin = (a) => a.sort((x, y) => x - y);
const stde = (a) => a.sort((x, y) => y - x);
const sortPart = (a, k) => { let l = a.slice(0, k); l.sort((x, y) => x - y); let r = a.slice(k); return l.concat(r); }; // sort first kth
const initialize2DArrayNew = (m, n) => { let data = []; for (let i = 0; i < m; i++) { let tmp = Array(n).fill(0); data.push(tmp); } return data; };
const stmkey_in = (m) => new Map([...m].sort((x, y) => x[0] - y[0]));
const stmkey_de = (m) => new Map([...m].sort((x, y) => y[0] - x[0]));
const stmvalue_in = (m) => new Map([...m].sort((x, y) => x[1] - y[1]));
const stmvalue_de = (m) => new Map([...m].sort((x, y) => y[1] - x[1]));
const counter = (a_or_s) => { let map = new Map(); for (const i of a_or_s) map.set(i, map.get(i) + 1 || 1); return map; };
const counter_value_in_indexA_in = (a_or_s) => { let m = new Map(); let n = a_or_s.length; for (let i = 0; i < n; i++) { if (!m.has(a_or_s[i])) m.set(a_or_s[i], []); m.get(a_or_s[i]).push(i); } return m; };
const counter_value_in_indexA_de = (a_or_s) => { let m = new Map(); let n = a_or_s.length; for (let i = 0; i < n; i++) { if (!m.has(a_or_s[i])) m.set(a_or_s[i], []); m.get(a_or_s[i]).unshift(i); } return m; };
const reverse2 = (s) => { let res = ""; for (let i = s.length - 1; i >= 0; i--) { res += s[i]; } return res; };
const isPalindrome = (s) => { let n = s.length; let i = 0; let j = n - 1; while (i < j) { if (s[i++] != s[j--]) return false; } return true; };
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

const solve = (a, b, c, d) => {
    let A = [a, b, c, d];
    stde(A);
    let should = [A[0], A[1]];
    let actual = [mx(a, b), mx(c, d)];
    stin(should);
    stin(actual);
    // pr(should, actual);
    let res = should[0] == actual[0] && should[1] == actual[1];
    pr(res ? 'YES' : 'NO');
};

const main = () => {
    const readline = require('readline');
    const rl = readline.createInterface({
        input: process.stdin,
        output: process.stdout
    });
    let input = [];
    rl.on('line', (line) => {
        input.push(line.split(" ").map(x => Number(x)));
    });
    rl.on('close', () => {
        let t = input[0][0];
        let i = 1;
        while (t--) {
            solve(input[i][0], input[i][1], input[i][2], input[i][3]);
            i++;
        }
    });
};

main()

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
    } 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(arr) {
    const [max1,max2] = arr.slice(0).sort((a,b)=>a-b).reverse()
    if((max1 === arr[0] || max1 === arr[1]) && (max2 === arr[2] || max2 === arr[3])){
        console.log('YES')
    } else if((max1 === arr[2] || max1 === arr[3]) && (max2 === arr[0] || max2 === arr[1])){
        console.log('YES')
    } else {
        console.log('NO')
    }
}

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

var readline = require('readline');

var rl = readline.createInterface({
    input: process.stdin,
    output: process.stdout
});
var lines = [];
rl.on('line', function(input) {
    lines.push(input);
});
rl.on('close', function() {
    var t = parseInt(lines[0]);
    var l = 1;
    for (var i = 0; i < t; i++) {
        console.log(solve(lines[l++]));
    }
});

function solve(str) {
    const skills = str.split(' ').map(Number)
    const [a, b, c, d] = skills
    const p = Math.max(a, b)
    const q = Math.max(c, d)

    skills.sort((a, b) => b - a)

    const [m, n] = skills
    let fair
    if (p > q) {
        fair = p === m && q === n
    } else {
        fair = q === m && p === n
    }
    return fair ? 'YES' : 'NO'
}

//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 if(code == 'long'){
			ret[i] = BigInt(next());
		}else{
			ret[i] = next();
		}
	}
	return ret;
}
function nextIntArray(size){return nextArray(size, 'int');} function nextStrArray(size){return nextArray(size, 'str');} function nextLongArray(size){return nextArray(size, 'long');}
function nextCharArray(){return myconv(next(),6);}
function next(){return obj.next();} function hasNext(){return obj.hasNext();} function nextInt(){return myconv(next(),1);} function nextLong(){return BigInt(next());}
function getCountMap(list){
	var map = {};
	for(var i = 0; i < list.length; i++){
		if(map[list[i]] == null){
			map[list[i]] = 0;
		}
		map[list[i]]++;
	}
	return map;
}
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();
	while(hasNext()){
		var s = nextIntArray(4);
		var tmp = makeClone(s);
		var L = Math.max(s[0], s[1]);
		var R = Math.max(s[2], s[3]);
		tmp.sort(function(a,b){
			return b - a;
		});
		if((tmp[0] == L || tmp[0] == R) && (tmp[1] == L || tmp[1] == R)){
			myout("YES");
		}else{
			myout("NO");
		}
	}
}

var testCase=+readline()
for(var i=0;i<testCase;i++){
    var sequence=readline().split(" ").map(node=>+node),counter=0

    var aMax=sequence.slice(0,2).reduce((a,b)=>Math.max(a,b))
    var b=sequence.slice(-2)

    b.forEach(node=>node>aMax?counter++:null)

    counter===0||counter===2?print("NO"):print("YES")
}

'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 x = readline();

    for(let i = 0;i < x;i++){
        let array = readline().split
        console.log(array)
        // let a = array[0]>array[1]?array[0]:array[1];
        // let b = array[2]>array[3]?array[2]:array[3];
        // a < b ?
        // a > array[2] || a > array[3] ? console.log('YES'): console.log('NO'):
        // b > array[0] || b > array[1] ? console.log('YES'): console.log('NO');
    }
}

'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 x = readline();

    for(let i = 0;i < x;i++){
        let array = readline().split(' ');
        let a = array[0]>array[1]?array[0]:array[1];
        let b = array[2]>array[3]?array[2]:array[3];
        a < b ?
        a > array[2] || a > array[3] ? console.log('YES'): console.log('NO'):
        b > array[0] || b > array[1] ? console.log('YES'): console.log('NO');
    }
}

'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 x = readline();

    for(let i = 0;i < x;i++){
        let array = readline().split(' ');
        let a = array[0]>array[1]?array[0]:array[1];
        let b = array[2]>array[3]?array[2]:array[3];
        a < b ?
        a > array[2] || a > array[3] ? console.log('YES'): console.log('NO'):
        b > array[0] || b > array[1] ? console.log('YES'): console.log('NO')
    }
}

'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 x = readline();

    for(let i = 0;i < x;i++){
        let array = readline().split(' ');
        let a = array[0]>array[1]?array[0]:array[1];
        let b = array[2]>array[3]?array[2]:array[3];
        a < b ?
        a < array[2] && a < array[3] ? console.log('NO'): console.log('YES'):
        b < array[0] && b < array[1] ? console.log('NO'): console.log('YES')
    }
}

'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 x = readline();

    for(let i = 0;i < x;i++){
        let array = readline().split(' ');
        let a = array[0]>array[1]?array[0]:array[1];
        let b = array[2]>array[3]?array[2]:array[3];
        a < b ?
        a < array[2] && a < array[3] ? console.log('YES'): console.log('NO'):
        b < array[0] && b < array[1] ? console.log('YES'): console.log('NO')
    }
}

'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 x = readline();

    for(let i = 0;i < x;i++){
        let array = readline().split(' ');
        let a = array[0]>array[1]?array[0]:array[1];
        let b = array[2]>array[3]?array[2]:array[3];
        a < b ?
        a < array[2] || a < array[3] ? console.log('NO'):console.log('YES'):
        b < array[0] || array[1]?console.log('NO'):console.log('YES')
    }
}

'use strict';
process.stdin.resume();
process.stdin.setEncoding('utf-8');
let input = '';
process.stdin.on('data', inputStdin => {
    input += inputStdin;
});
process.stdin.on('end', _ => {
    main(input);
});

function main(input) {
    var args = input.split("\n");
    const t = parseInt(args[0], 10);
    for (var i = 1; i <= t; i++) {
        var v = args[i].split(" ").map((n) => parseInt(n, 10));
        var v2 = v.concat();
        v2.sort();
        if (((v2[0] == v[0] && v2[1] == v[1])
            || (v2[0] == v[1] && v2[1] == v[0])
            || (v2[0] == v[2] && v2[1] == v[3])
            || (v2[0] == v[3] && v2[1] == v[2]))) {
            console.log("NO");
        } else {
            console.log("YES");
        }
    }
}

'use strict';
process.stdin.resume();
process.stdin.setEncoding('utf-8');
let input = '';
process.stdin.on('data', inputStdin => {
    input += inputStdin;
});
process.stdin.on('end', _ => {
    main(input);
});

function main(input) {
    var args = input.split("\n");
    const t = parseInt(args[0], 10);
    for (var i = 1; i <= t; i++) {
        var v = args[i].split(" ").map((n) => parseInt(n, 10));
        var v2 = v.concat();
        v2.sort();
        if (((v[0] == v2[0] && v[1] == v2[1])
            || (v[0] == v2[1] && v[1] == v2[0])
            || (v[0] == v2[2] && v[1] == v2[3])
            || (v[0] == v2[3] && v[1] == v2[2]))) {
            console.log("NO");
        } else {
            console.log("YES");
        }
    }
}

const os = require('os');

function winner(players_skills) {
    return Math.max(players_skills[0], players_skills[1])
}

function solution(input) {
    const champion = Math.max(winner(input.slice(0, 2)), winner(input.slice(2, 4)));
    const runner_up = Math.min(winner(input.slice(0, 2)), winner(input.slice(2, 4)));
    console.log({champion, runner_up});
    input.sort((a, b) => b - a);

    return input[0] === champion && input[1] === runner_up ? 'YES' : 'NO';
}

function parse(input_in_string) {
    return input_in_string.split(' ').map(Number);
}

let lines = '';

process.stdin.on('data', data => lines += data);

process.stdin.on('end', () => {
    const input = lines.split(os.EOL);
    const number_of_test_cases = Number(input.shift());
    for(let test_case = 1; test_case <= number_of_test_cases; test_case += 1) {
        console.log(solution(parse(input.shift())));
    }
});

module.exports = {solution}

const os = require('os');

function winner(players_skills) {
    return Math.max(players_skills[0], players_skills[1])
}

function solution(input) {
    const champion = Math.max(winner(input.slice(0, 2)), winner(input.slice(2, 4)));
    const runner_up = Math.min(winner(input.slice(0, 2)), winner(input.slice(0, 2)));
    input.sort((a, b) => b - a);

    return input[0] === champion && input[1] === runner_up ? 'YES' : 'NO';
}

function parse(input_in_string) {
    return input_in_string.split(' ').map(Number);
}

let lines = '';

process.stdin.on('data', data => lines += data);

process.stdin.on('end', () => {
    const input = lines.split(os.EOL);
    const number_of_test_cases = Number(input.shift());
    for(let test_case = 1; test_case <= number_of_test_cases; test_case += 1) {
        console.log(solution(parse(input.shift())));
    }
});

module.exports = {solution}

const os = require('os');

function winner(players_skills) {
    return Math.max(players_skills[0], players_skills[1])
}

function solution(input) {
    const champion = Math.max(winner(input.slice(0, 2)), winner(input.slice(2, 4)));
    const runner_up = Math.min(winner(input.slice(0, 2)), winner(input.slice(0, 2)));
    input.sort((a, b) => b - a);

    return input[0] === champion && input[1] === runner_up ? 'YES' : 'NO';
}

function parse(input_in_string) {
    return input_in_string.split(' ').map(Number);
}

let lines = '';

process.stdin.on('data', data => lines += data);

process.stdin.on('end', () => {
    const input = lines.split(os.EOL);
    input.shift();
    while (input.length !== 0) {
        console.log(solution(parse(input.shift())));
    }
});

module.exports = {solution}

let i = '';
process.stdin.on('data', c => i += c);
process.stdin.on('end', () => {
    const {EOL} = require('os');
    const lines = i.split(EOL); /*your input text, split by lines*/
    for(j = 1; j <= lines[0]; j++){
        var a = lines[j].split(' ')
        var x = Math.min(a[0], a[1])
        var c = Math.max(a[2], a[3])
        var v = Math.max(a[0], a[1])
        var z = Math.min(a[2], a[3])
        if(x <= c && v <= z){
            console.log('YES')
        }else {
            console.log('NO')
        }
    }
    });
//2 - 2 % 0 + 1
//2 - 2 % 0 - (0 - 1)
//xcvz
//2, min, *
//[2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47]; '15'

"use strict";

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

function print(x) {
  console.log(x);
}
let inputString = "";
let currentLine = 0;

process.stdin.on("data", (inputStdin) => {
  inputString += inputStdin;
});
process.stdin.on("end", () => {
  inputString = inputString.split("\n");
  main();
});
function readline() {
  return inputString[currentLine++];
}

// ********** Code Start **********

function main() {

const testcase=parseInt(readline());
let r=[];
for(let i=0;i<testcase;i++){
for(let i=0;i<4;i++){

  r[i]=+(readline());

}
let x=Math.max(r[0],r[1]);
let t=Math.min(r[0],r[1]);
let z=Math.min(r[2],r[3]);
    let y=Math.max(r[2],r[3]);

    if(x>z && y>t) console.log('YES');

    else console.log("NO");

}

}

"use strict";

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

function print(x) {
  console.log(x);
}
let inputString = "";
let currentLine = 0;

process.stdin.on("data", (inputStdin) => {
  inputString += inputStdin;
});
process.stdin.on("end", () => {
  inputString = inputString.split("\n");
  main();
});
function readline() {
  return inputString[currentLine++];
}

// ********** Code Start **********

function main() {

const testcase=parseInt(readline());
let r=[];
for(let i=0;i<testcase;i++){
for(let i=0;i<4;i++){

  r[i]=+(readline());

}
}

    let x=Math.max(r[0],r[1]);
let t=Math.min(r[0],r[1]);
let z=Math.min(r[2],r[3]);
    let y=Math.max(r[2],r[3]);

    if(x>z && y>t) console.log('YES');

    else console.log("NO");

}

// Getting input via STDIN
const readline = require("readline");

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

const userInput = [];

inp.on("line", (data) => {
  userInput.push(data);
});

inp.on("close", () => {
  //start-here
  //Your code goes here … replace the below line with your code logic
var i=1;
 var t=userInput[0]
 while(i<=t)
 {
     dummy=userInput[i].split(' ')
     arr=dummy

     var bigger=Math.max(dummy[0],dummy[1])

     if(dummy[2]<dummy[3]){
         var bigger2=dummy[3]
     }
     else if(dummy[2]>dummy[3]){
         bigger2=dummy[2]
     }

    var sortedarr=arr.sort()
     var biggestno=sortedarr[3]
     var biggestno2=sortedarr[2]
     if(((bigger==biggestno)||(bigger==biggestno2))&&((bigger2==biggestno2)||(bigger2==biggestno)))
     {
         console.log('YES')
     }
     else{
         console.log('NO')
     }
     i++

 }
  //end-here
});


const readline = require('readline');

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

const readInput = (function* () {
	const n = Number(yield);
	const a = (yield).trim().split(' ').map(Number);
	rl.close();
	let to = 0;
	let days = 0;
	for (let i = 0; i < n; i++) {
		to = Math.max(to, a[i]);
		if (to == a[i] && to == i + 1) days++;
	}
	console.log(days);
})();

readInput.next();

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

const n = Number(readline());
const pages = readline().split(" ").slice(0, n).map(x => Number(x));
var max = 0;
var count = 0;
for (var i = 0; i < n; i++) {
  var next = pages[i];
  if (next > max) max = next;
  if (max <= i + 1) count++;
}
print(count);

var n = readline();
var a = readline().split(' ');
a=a.slice(0,n);

var days=0;
var max=Number.MIN_VALUE;
var changed=false;
for(var i=0; i<n; i++){
    if(Number(a[i])>max) {
        max=Number(a[i]);
        changed=true;
    }
    if(Number(a[i])==max && max==(i+1) && changed){
        days++;
        changed=false;
    }
}
print(days);

var n = readline();
var a = readline().split(' ');
a=a.slice(0,n);

var days=0;
var max=Number.MIN_VALUE;
var changed=false;
for(var i=0; i<n; i++){
    if(Number(a[i])>max) {
        max=Number(a[i]);
        changed=true;
    }
    if(max==(i+1) && changed){
        days++;
        changed=false;
    }
}
print(days);

var len = parseInt(readline());
var pagesArr = readline().split(' ').map(_=>{return parseInt(_)});

var curLastPage = 0;
var readTimes = 0;
for (var index = 0; index < len;index ++) {
    if (pagesArr[index] > curLastPage) {
        curLastPage = pagesArr[index];
    }
    if (curLastPage == index + 1) {
        readTimes ++;
    }
}
print(readTimes);

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

let inputString = '';
let currentLine = 0;

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

process.stdin.on('end', function() {
    inputString = inputString
        .replace(/\s*$/, '')
        .split('\n')
        .map(str => str.replace(/\s*$/, ''));

    console.log(getDays(inputString[1].split(' ').map(i => parseInt(i, 10))));
});

function getDays(arr) {
    let stack = [];
    let count = 0;
    for (let i = 0; i < arr.length; i++) {
        stack.push(arr[i]);

        while(stack[stack.length - 1] <= i + 1) {
            stack.pop();
        }

        if (stack.length === 0) {
            count++;
        }
    }

    return count;
}

const n = Number(readline());
const pages = readline().split(" ").slice(0, n).map(x => Number(x));
var max = 0;
var count = 0;
for (var i = 1; i <= n; i++) {
  next = pages[i];
  if (next > max) max = next;
  if (max <= i) count++;
}
print(count);

var n = readline();
var a = readline().split(' ');
a=a.slice(0,n);

var days=0;
var max=Number.MIN_VALUE;
for(var i=0; i<n; i++){
    if(a[i]>max) max=a[i];
    if(max>(i+1)){
        continue;
    }
    days++;
}
print(days);

var n = readline();
var a = readline().split(' ');
a=a.slice(0,n);

var days=0;
var max=Number.MIN_VALUE;
for(var i=0; i<n; i++){
    if(a[i]>max) max=a[i];
    if(Number(a[i])>(i+1) || max>(i+1)){
        continue;
    }
    days++;
}
print(days);

var n = readline();
var a = readline().split(' ');
a=a.slice(0,n);

var days=0;
var max=Number.MIN_VALUE;
var changed=false;
for(var i=0; i<n; i++){
    if(Number(a[i])>max) {
        max=Number(a[i]);
        changed=true;
    }
    if(Number(a[i])==max && max==(i+1) && changed){
        print(a[i]+" "+max)
        days++;
        changed=false;
    }
}
print(days);

var n = readline();
var a = readline().split(' ');
a=a.slice(0,n);

var days=0;
var max=Number.MIN_VALUE;
for(var i=0; i<n; i++){
    if(Number(a[i])>max) {
        max=Number(a[i]);
        var changed=true;
    }
    if(Number(a[i])==max && changed){
        days++;
        changed=false;
    }
}
print(days);


var tc = parseInt(readline());
for (; tc--;){
    var Ar = readline().split(' ').map(x => +x);
    var n = Ar[0], m = Ar[1];
    print(n - 1 + ' ' + m);
}

const solve = (x, y) => {
    console.log(x - 1 + " " + y);
};

const main = () => {
    const readline = require('readline');
    const rl = readline.createInterface({
        input: process.stdin,
        output: process.stdout
    });
    let input = [];
    rl.on('line', (line) => {
        input.push(line.split(" ").map(x => Number(x)));
    });
    rl.on('close', () => {
        let t = input[0][0];
        let i = 1;
        while (t > 0) {
            solve(input[i][0], input[i][1]);
            t--;
            i++;
        }
    });
};

main()

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 [a, b] = readLine().split(" ").map(Number);
    if (a === b) {
      console.log(`${a - 1} ${b}`);
    } else if (a > b) {
      console.log(`${a - 1} ${b}`);
    } else {
      console.log(`${a - 1} ${b}`);
    }
  }
}

//Don't have to see. start------------------------------------------
var read = require('readline').createInterface({
	input: process.stdin, output: process.stdout
});
var obj; var inLine = []; var outputList = [];
read.on('line', function(input){
	var tmp = input.split(' ');
	for(var i = 0; i < tmp.length; i++){
		inLine.push(tmp[i]);
	}
});
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';}}
	};
}
function myout(s){outputList.push(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();
	for(var i = 0; i < t; i++){
		var x = nextInt() - 1;
		var y = nextInt();
		myout(x + " " + y);
	}
}

(()=>{"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],h=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 a(){return s[u++]}function f(){return a().split(" ").map((t=>parseFloat(t)))}function c(){return a().split("")}e.default={runMain:h,runEachTest:t=>{h((()=>{let[e]=f();for(;e>0;)t(),e--}))},readline:a,nextNumbers:f,nextBigNumbers:function(){return a().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,e]=i.default.nextNumbers();t--,i.default.puts(t+" "+e)}))},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 cnt = (x: number, y: number, p1: boolean, running: boolean) => {
//     // io.debug([x, y, p1, running])
//
//     if (y == 0) {
//       return [x, 0]
//     }
//
//     if (x == 0) {
//       return [0, y]
//     }
//
//     if (!running) {
//       if (p1) {
//         return cnt(x - 1, y, !p1, true)
//       } else {
//         return cnt(x, y - 1, !p1, true)
//       }
//     }
//
//     let candidate1 = [0, 0]
//
//     if (p1) {
//       candidate1 = cnt(x - 1, y, !p1, true)
//     } else {
//       candidate1 = cnt(x, y - 1, !p1, true)
//     }
//
//     let candidate2 = [0, 0]
//
//     if (p1) {
//       candidate2 = cnt(x, y, !p1, false)
//       candidate2[1]++
//     } else {
//       candidate2 = cnt(x, y, !p1, false)
//       candidate2[0]++
//     }
//
//     // io.debug(candidate1)
//     // io.debug(candidate2)
//
//     if (p1) {
//       if (candidate1[0] == candidate2[0]) {
//         return [candidate1[0], [candidate1[1], candidate2[1]].max()]
//       }
//
//       if (candidate1[0] > candidate2[0]) {
//         return candidate1
//       } else {
//         return candidate2
//       }
//     } else {
//       if (candidate1[1] == candidate2[1]) {
//         return [[candidate1[0], candidate2[0]].max(), candidate1[1]]
//       }
//
//       if (candidate1[1] > candidate2[1]) {
//         return candidate1
//       } else {
//         return candidate2
//       }
//     }
//   }
//
//   let [x, y] = io.nextNumbers()
//
//   // let n = 10
//
//   // for (let x = 1; x <= n; ++x) {
//   //   for (let y = 1; y <= n; ++y) {
//   //     io.puts(x + " " + y + " :" + cnt(x, y, true, false))
//   //   }
//   // }
//
//   x--
//
//   io.puts(x + " " + y)
// }
//
// io.runEachTest(main)
// // io.runMain(main)

/*
 * File Created: Monday, 30th November 2020 3:31:00 pm
 * Author: Lukas Rimkus
 */

'use-strict'

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

let data = '';
let currentLine = 0;

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

process.stdin.on('end', () =>{
    data = data.replace(/\s*$/, '')
    .split('\n')
    .map(str => str.replace(/\s*$/, ''));

    let testCases = parseInt(data.shift());

    while(testCases--) {

        const n = data.shift().split(' ').map(Number)

        const res = c(n[0], n[1]);

        console.log(res[0], res[1])
    }
});

function get_ints() {
    return data.shift().split(' ').map(Number);
}

function readLine() {
        return data[currentLine++];
}

function a(num)
{
    return num.length ;
}

function b(goal)
{

    function jump1(y,k)
    {
        return y + k;
    }
    function jump2(y)
    {
        return y - 1;
    }

    let sum = 0;

    let jumps = 0;

    let arr = [];

    while(sum < goal)
    {
        jumps++;

        arr.push(jumps);

        sum = sum + jumps;
    }

    if(sum === goal)
    {
        return arr.length;
    }
    else
    {
        let current_pos = sum;

        // that's how many steps back;
        let diference = current_pos - goal;

        console.log(arr, arr.length, sum, diference)

        for(let i = 0 ; i < arr.length; i++)
        {
            if((arr[i] + 1) === diference)
            {
                return arr.length;
            }
        }
       return arr.length + 1;
    }
}

function c(x,y)
{
    const arr = new Array(2);

    arr[0] = x - 1;

    arr[1] = y
    return arr;
}

module.exports = c;

'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 x = readline();
  var answer = []

  Array(Number(x)).fill(1).map((t, i) => {
    var line = readline();
    var x = Number(line.split(' ')[0])
    var y = Number(line.split(' ')[1])
    return console.log(x - 1, y)
    if (x == 0 && y === 0) return console.log(0, 0)
    if (y > x) {
      return console.log(0, y - x + 1)
    }
    if (x === y) return console.log(0, 1)
    return console.log(x - 1, y)

  })

}

const solve = (x, y) => {
    if (x >= y) {
        console.log(x - 1 + " " + y);
        return;
    } else {
        console.log(x - 1 + " " + (y - x + 1));
        return;
    }
};

const main = () => {
    const readline = require('readline');
    const rl = readline.createInterface({
        input: process.stdin,
        output: process.stdout
    });
    let input = [];
    rl.on('line', (line) => {
        input.push(line.split(" ").map(x => Number(x)));
    });
    rl.on('close', () => {
        let t = input[0][0];
        let i = 1;
        while (t > 0) {
            solve(input[i][0], input[i][1]);
            t--;
            i++;
        }
    });
};

main()

const solve = (x, y) => {
    if (x >= y) {
        console.log(x - 1 + " " + y);
    } else {
        console.log(x - 1 + " " + (y - x + 1));
    }
};

const main = () => {
    const readline = require('readline');
    const rl = readline.createInterface({
        input: process.stdin,
        output: process.stdout
    });
    let input = [];
    rl.on('line', (line) => {
        input.push(line.split(" ").map(x => Number(x)));
    });
    rl.on('close', () => {
        let t = input[0][0];
        let i = 1;
        while (t > 0) {
            solve(input[i][0], input[i][1]);
            t--;
            i++;
        }
    });
};

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++];
}

// Make a Snippet for the code above this and then write your logic in main();

function main() {
  const x = readline();
  var answer = []

  Array(Number(x)).fill(1).map((t, i) => {
    var line = readline();
    var x = line.split(' ')[0]
    var y = line.split(' ')[1]
    if (y > x) {
      if (x === 0) return console.log(0, y)
      return console.log(0, y - x + 1)
    }
    if (x === y) return console.log(0, 1)
    if (y === 0) return console.log(x, 0)
    return console.log(x - y, 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();

function main() {
  const x = readline();
  var answer = []

  Array(Number(x)).fill(1).map((t, i) => {
    var line = readline();
    var x = Number(line.split(' ')[0])
    var y = Number(line.split(' ')[1])
    if(x==0 && y===0) return console.log(0, 0)
    if (y > x) {
      return console.log(0, y - x + 1)
    }
    if (x === y) return console.log(0, 1)
    return console.log(x-1, y)

  })

}

'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 x = readline();
  var answer = []

  Array(Number(x)).fill(1).map((t, i) => {
    var line = readline();
    var x = Number(line.split(' ')[0])
    var y = Number(line.split(' ')[1])
    if(x==0 && y===0) return console.log(0, 0)
    if (y > x) {
      if (x === 0) return console.log(0, y)
      return console.log(0, y - x + 1)
    }
    if (x === y) return console.log(0, 1)
    if (y === 0) return console.log(x, 0)
    return console.log(x - y, 1)

  })

}


var nk = readline();
var t = readline();

var n = nk.split(" ")[0];
var k = nk.split(" ")[1];

var equal = "";
for (var i = 0; i < t.length - 1; i ++) {
    var firstSub = t.substring(0, i + 1);
    var secondSub = t.substring(t.length - i - 1, t.length);

    if (firstSub === secondSub) {
      equal = firstSub;
    }
  }

var result = t;
for (var i = 1; i < k; i ++) {
    if (equal !== "") {
        result += t.substring(equal.length, t.length);
    } else {
        result += t;
    }
}

write(result);

function main() {
  const is = new Scanner();
  const [n, k] = is.nextArray(Number);
  const word = is.nextLine();
  const auxRev = word.slice();
  let characters = 0;
  for (let i = 1, j = word.length - 1; i < n && j > 0; i += 1, j -= 1) {
    if (word.slice(0, i) === auxRev.slice(j))
      characters = i;
  }
  const aux = word.slice(characters);
  let answer = word;
  for (let i = 1; i < k; i += 1)
    answer += aux;
  console.log(answer);
}

/*
 *  Api Scanner
 */
class Scanner {
  constructor() {
    this.index = -1;
    this.lines = stdinInput.trim().split('\n'); // eslint-disable-line
  }

  nextLine() {
    this.index += 1;
    return this.lines[this.index].trim();
  }

  nextInt() {
    return parseInt(this.nextLine(), 10);
  }

  nextDouble() {
    return parseFloat(this.nextLine());
  }

  nextArray(fn = String) {
    const array = this.nextLine().split(' ');
    if (fn !== String)
      array.forEach((item, index, arr) => { arr[index] = fn(item); } );
    return array;
  }

  hasNext() {
    return this.index < this.lines.length;
  }
}

let stdinInput = '';
process.stdin.resume();
process.stdin.setEncoding('utf-8');
process.stdin.on('data', (input) => { stdinInput += input; });
process.stdin.on('end', () => { main(); });

var firstLine = readline();
var n = firstLine.split(" ")[0];
var k = firstLine.split(" ")[1];
var string = readline();

print(output(string, k, n))

function output(string, k, n) {
    var p = n - 1;
    var l = 0;
    var ans = 0;
    for (var i = p - 1; i >= 0; i--) {
        if (ans === 0) {
            for (var j = i; j >= 0; j--) {
                if (string[j] === string[p]) {
                    p--;
                    l++;
                    if (j === 0) {
                        ans = l;
                    }
                } else {
                    p = n - 1;
                    l = 0;
                    break;
                }
            }
        } else {
            break;
        }
    }

    for (var i = 1; i <= k - 1; i++) {
        for (var j = l; j < n; j++) {
            string += string[j];
        }
    }
    return string;
}

var args = readline().split(' ');
var str = readline();

args = args.map((n) => parseInt(n, 10));

var len = args[0];
var repeat = args[1];

var i = 1;
var mark = 0;
while (i < len) {
    var prefix = str.substring(0, i);
    var suffix = str.substring(len - i);
    if (prefix === suffix) {
        mark = i;
    }
    i++;
}

const res = [];
const substr = str.substring(mark);

res.push(str.substring(0, mark));

for (var j = 0;j < repeat;j++) {
    res.push(substr);
}

print(res.join(''));

var a = readline().split(" ");
var n = a[1];
var str = readline();
var firstP = str.slice(1);
var secondP = str.slice(0, str.length - 1);
var i,
    bool = false;
for(i = 1; i <= str.length - 1; i++){
    if(firstP == secondP){
        bool = true;
        break;
    } else{
        firstP = firstP.slice(1);
        secondP = secondP.slice(0, secondP.length - 1);
    }
}
var mainText;
if(bool){
    mainText = str.slice(secondP.length);
} else{
    mainText = str;
}
var lastResult = str;
for(i = 1; i <= n-1; i++){
    lastResult += mainText;
}
print(lastResult);

'use strict';

var newLine = readline().split(' ').map(function (number) {
  return parseInt(number);
});

var amount = newLine[1];
var word = readline();

var getWordPart = function getWordPart(mode, word, amount) {

  if (word.length / 2 >= amount - 0.5) {

    var part = mode === 'begin' ? word.slice(0, amount) : word.slice(-amount);
    return part;
  }

  return false;
};

var getMaxAmount = function getMaxAmount(word) {

  var maxAmount = 0;

  for (var counter = 0; counter < word.length; counter++) {
    var beginPart = getWordPart('begin', word, counter + 1);
    var endPart = getWordPart('end', word, counter + 1);

    if (beginPart && beginPart === endPart) {
      if (isSameSymbols(replaceParts(word, beginPart, '*'), '*')) {
        return -(counter + 1);
      }
      maxAmount = counter + 1;
    }
  }

  // console.log(maxAmount)
  return maxAmount;
};

var isSameSymbols = function isSameSymbols(word, letter) {

  for (var i = 0; i < word.length; i++) {

    if (letter !== word[i]) {
      return false;
    }
  }

  // console.log('SAME')
  return true;
};

var replaceParts = function replaceParts(word, part, symbol) {

  var wordLength = word.length;

  for (var i = 0; i < wordLength / part.length + 1; i++) {
    word = word.replace(part, symbol);
  }

  // console.log('replaceParts', part, word);
  return word;
};

var addPart = function addPart(part, amount) {
  var result = '';

  while (amount > 0) {
    result += part;
    amount--;
  }

  return result;
};

var isPalindrom = function isPalindrom(word) {

  if (word[0] === word[word.length - 1]) {
    if (word.length <= 1) return true;
    return isPalindrom(word.slice(1, word.length - 1));
  }

  return false;
};

var partLength = getMaxAmount(word);
var begin = '';
var h = partLength > 0 && word.length >= 6 && word[0] === word[word.length - 1] && !isSameSymbols(word, word[0]) && isPalindrom(word);

// console.log(partLength);
if (h) {
  begin = word[0];
  partLength = getMaxAmount(word.slice(1));
  word = word.slice(1);
}

write(begin + word + addPart(word.slice(partLength), amount - 1));

function main() {
  const is = new Scanner();
  const [n, k] = is.nextArray(Number);
  const word = is.nextLine();
  let answer = word, aux;
  for (let c = 1; c < k; c += 1) {
    aux = word.slice();
    for (let i = 0, j = n - 1; i < n && j >= 0; i++, j--)
      if (word[j] === aux[i]) {
        aux = word.slice(1);
      } else {
        break;
      }
    answer += aux;
  }

  console.log(answer);
}

/*
 *  Api Scanner
 */
class Scanner {
  constructor() {
    this.index = -1;
    this.lines = stdinInput.trim().split('\n'); // eslint-disable-line
  }

  nextLine() {
    this.index += 1;
    return this.lines[this.index].trim();
  }

  nextInt() {
    return parseInt(this.nextLine(), 10);
  }

  nextDouble() {
    return parseFloat(this.nextLine());
  }

  nextArray(fn = String) {
    const array = this.nextLine().split(' ');
    if (fn !== String)
      array.forEach((item, index, arr) => { arr[index] = fn(item); } );
    return array;
  }

  hasNext() {
    return this.index < this.lines.length;
  }
}

let stdinInput = '';
process.stdin.resume();
process.stdin.setEncoding('utf-8');
process.stdin.on('data', (input) => { stdinInput += input; });
process.stdin.on('end', () => { main(); });

'use strict';

var newLine = readline().split(' ').map(function (number) {
  return parseInt(number);
});

var amount = newLine[1];
var word = readline();

var getWordPart = function getWordPart(mode, word, amount) {

  if (word.length / 2 >= amount - 0.5) {

    var part = mode === 'begin' ? word.slice(0, amount) : word.slice(-amount);
    return part;
  }

  return false;
};

var getMaxAmount = function getMaxAmount(word) {

  // console.log(word)

  var maxAmount = 0;

  for (var counter = 0; counter < word.length; counter++) {
    var beginPart = getWordPart('begin', word, counter + 1);
    var endPart = getWordPart('end', word, counter + 1);

    if (beginPart && beginPart === endPart) {
      if (isSameSymbols(replaceParts(word, beginPart, '*'), '*')) {
        return -(counter + 1);
      }
      maxAmount = counter + 1;
    }
  }

  // console.log(maxAmount)
  return maxAmount;
};

var isSameSymbols = function isSameSymbols(word, letter) {

  for (var i = 0; i < word.length; i++) {

    if (letter !== word[i]) {
      return false;
    }
  }

  return true;
};

var replaceParts = function replaceParts(word, part, symbol) {

  for (var i = 0; i < word.length / symbol.length + 1; i++) {
    word = word.replace(part, symbol);
  }

  // console.log('replaceParts', word);
  return word;
};

var addPart = function addPart(part, amount) {
  var result = '';

  while (amount > 0) {
    result += part;
    amount--;
  }

  return result;
};

var isPalindrom = function isPalindrom(word) {

  if (word[0] === word[word.length - 1]) {
    if (word.length <= 1) return true;
    return isPalindrom(word.slice(1, word.length - 1));
  }

  return false;
};

// let partLength = 0;
// let begin = '';
// let h =
//     word.length >= 6 &&
//     word[0] === word[word.length -1] &&
//     !isSameSymbols(word, word[0]) &&
//     isPalindrom(word);

// if(h){
//   begin = word[0];
//   partLength = getMaxAmount(word.slice(1));
//   word = word.slice(1);
// } else {
//   partLength = getMaxAmount(word);
// }

var partLength = getMaxAmount(word);
var a1 = word + addPart(word.slice(partLength), amount - 1);
partLength = getMaxAmount(word.slice(1));
var a2 = word[0];
word = word.slice(1);
a2 += word + addPart(word.slice(partLength), amount - 1);

write(a1.length > a2.length ? a2 : a1);

'use strict';

var newLine = readline().split(' ').map(function (number) {
  return parseInt(number);
});

var amount = newLine[1];
var word = readline();

var getWordPart = function getWordPart(mode, word, amount) {

  if (word.length / 2 >= amount - 0.5) {

    var part = mode === 'begin' ? word.slice(0, amount) : word.slice(-amount);
    return part;
  }

  return false;
};

var getMaxAmount = function getMaxAmount(word) {

  // console.log(word)

  var maxAmount = 0;

  for (var counter = 0; counter < word.length; counter++) {
    var beginPart = getWordPart('begin', word, counter + 1);
    var endPart = getWordPart('end', word, counter + 1);

    if (beginPart && beginPart === endPart) {
      if (isSameSymbols(replaceParts(word, beginPart, '*'), '*')) {
        return -(counter + 1);
      }
      maxAmount = counter + 1;
    }
  }

  // console.log(maxAmount)
  return maxAmount;
};

var isSameSymbols = function isSameSymbols(word, letter) {

  for (var i = 0; i < word.length; i++) {

    if (letter !== word[i]) {
      return false;
    }
  }

  return true;
};

var replaceParts = function replaceParts(word, part, symbol) {

  for (var i = 0; i < word.length / symbol.length + 1; i++) {
    word = word.replace(part, symbol);
  }

  // console.log('replaceParts', word);
  return word;
};

var addPart = function addPart(part, amount) {
  var result = '';

  while (amount > 0) {
    result += part;
    amount--;
  }

  return result;
};

var isPalindrom = function isPalindrom(word) {

  if (word[0] === word[word.length - 1]) {
    if (word.length <= 1) return true;
    return isPalindrom(word.slice(1, word.length - 1));
  }

  return false;
};

// let partLength = 0;
// let begin = '';
// let h =
//     word.length >= 6 &&
//     word[0] === word[word.length -1] &&
//     !isSameSymbols(word, word[0]) &&
//     isPalindrom(word);

// if(h){
//   begin = word[0];
//   partLength = getMaxAmount(word.slice(1));
//   word = word.slice(1);
// } else {
//   partLength = getMaxAmount(word);
// }

var partLength = getMaxAmount(word);
var a1 = word + addPart(word.slice(partLength), amount - 1);
partLength = getMaxAmount(word.slice(1));
var a2 = word[0];
word = word.slice(1);
a2 += word + addPart(word.slice(partLength), amount - 1);

write(a1.length > a2.length ? a1 : a2);

'use strict';

var newLine = readline().split(' ').map(function (number) {
  return parseInt(number);
});

var amount = newLine[1];
var word = readline();

var getWordPart = function getWordPart(mode, word, amount) {

  if (word.length / 2 >= amount - 0.5) {

    var part = mode === 'begin' ? word.slice(0, amount) : word.slice(-amount);
    return part;
  }

  return false;
};

var getMaxAmount = function getMaxAmount(word) {

  var maxAmount = 0;

  for (var counter = 0; counter < word.length; counter++) {
    var beginPart = getWordPart('begin', word, counter + 1);
    var endPart = getWordPart('end', word, counter + 1);

    if (beginPart && beginPart === endPart) {
      if (isSameSymbols(replaceParts(word, beginPart, '*'))) {
        return -(counter + 1);
      }
      maxAmount = counter + 1;
    }
  }

  return maxAmount;
};

var isSameSymbols = function isSameSymbols(word, letter) {

  for (var i = 0; i < word.length; i++) {

    if (letter !== word[i]) {
      return false;
    }
  }

  return true;
};

var replaceParts = function replaceParts(word, part, symbol) {

  while (word.length > word.replace(part, symbol).length) {
    word = word.replace(part, symbol);
  }

  return word;
};

var addPart = function addPart(part, amount) {
  var result = '';

  while (amount > 0) {
    result += part;
    amount--;
  }

  return result;
};

var partLength = getMaxAmount(word);
write(word + addPart(word.slice(partLength), amount - 1));

'use strict';

var newLine = readline().split(' ').map(function (number) {
  return parseInt(number);
});

var amount = newLine[1];
var word = readline();

var getWordPart = function getWordPart(mode, word, amount) {

  if (word.length / 2 >= amount - 0.5) {

    var part = mode === 'begin' ? word.slice(0, amount) : word.slice(-amount);
    return part;
  }

  return false;
};

var getMaxAmount = function getMaxAmount(word) {

  // console.log(word)

  var maxAmount = 0;

  for (var counter = 0; counter < word.length; counter++) {
    var beginPart = getWordPart('begin', word, counter + 1);
    var endPart = getWordPart('end', word, counter + 1);

    if (beginPart && beginPart === endPart) {
      if (isSameSymbols(replaceParts(word, beginPart, '*'), '*')) {
        return -(counter + 1);
      }
      maxAmount = counter + 1;
    }
  }

  // console.log(maxAmount)
  return maxAmount;
};

var isSameSymbols = function isSameSymbols(word, letter) {

  for (var i = 0; i < word.length; i++) {

    if (letter !== word[i]) {
      return false;
    }
  }

  return true;
};

var replaceParts = function replaceParts(word, part, symbol) {

  for (var i = 0; i < word.length / symbol.length + 1; i++) {
    word = word.replace(part, symbol);
  }

  // console.log('replaceParts', word);
  return word;
};

var addPart = function addPart(part, amount) {
  var result = '';

  while (amount > 0) {
    result += part;
    amount--;
  }

  return result;
};

var isPalindrom = function isPalindrom(word) {

  if (word[0] === word[word.length - 1]) {
    if (word.length <= 1) return true;
    return isPalindrom(word.slice(1, word.length - 1));
  }

  return false;
};

var partLength = 0;
var begin = '';
var test = !isSameSymbols(word, word[0]) && word.length >= 6 && word[0] === word[word.length - 1];
if (test) {
  begin = word[0];
  partLength = getMaxAmount(word.slice(1));
  word = word.slice(1);
} else {
  partLength = getMaxAmount(word);
}

write(begin + word + addPart(word.slice(partLength), amount - 1));

'use strict';

var newLine = readline().split(' ').map(function (number) {
  return parseInt(number);
});

var amount = newLine[1];
var word = readline();

var getWordPart = function getWordPart(mode, word, amount) {

  if (word.length / 2 >= amount - 0.5) {

    var part = mode === 'begin' ? word.slice(0, amount) : word.slice(-amount);
    return part;
  }

  return false;
};

var getMaxAmount = function getMaxAmount(word) {

  var maxAmount = 0;

  for (var counter = 0; counter < word.length; counter++) {
    var beginPart = getWordPart('begin', word, counter + 1);
    var endPart = getWordPart('end', word, counter + 1);

    if (beginPart && beginPart === endPart) {
      if (isSameSymbols(replaceParts(word, beginPart, '*'), '*')) {
        return -(counter + 1);
      }
      maxAmount = counter + 1;
    }
  }

  return maxAmount;
};

var isSameSymbols = function isSameSymbols(word, letter) {

  for (var i = 0; i < word.length; i++) {

    if (letter !== word[i]) {
      return false;
    }
  }

  return true;
};

var replaceParts = function replaceParts(word, part, symbol) {

  while (word.length > word.replace(part, symbol).length) {
    word = word.replace(part, symbol);
  }

  return word;
};

var addPart = function addPart(part, amount) {
  var result = '';

  while (amount > 0) {
    result += part;
    amount--;
  }

  return result;
};

var isPalindrom = function isPalindrom(word) {

  if (word[0] === word[word.length - 1]) {
    if (word.length <= 1) return true;
    return isPalindrom(word.slice(1, word.length - 1));
  }

  return false;
};

var partLength = getMaxAmount(word.length >= 5 && isPalindrom(word) ? word.slice(1) : word);
write(word + addPart(word.slice(partLength), amount - 1));

'use strict';

var newLine = readline().split(' ').map(function (number) {
  return parseInt(number);
});

var amount = newLine[1];
var word = readline();

var getWordPart = function getWordPart(mode, word, amount) {

  if (word.length / 2 >= amount - 0.5) {

    var part = mode === 'begin' ? word.slice(0, amount) : word.slice(-amount);
    return part;
  }

  return false;
};

var getMaxAmount = function getMaxAmount(word) {

  var maxAmount = 0;

  for (var counter = 0; counter < word.length; counter++) {
    var beginPart = getWordPart('begin', word, counter + 1);
    var endPart = getWordPart('end', word, counter + 1);

    if (beginPart && beginPart === endPart) {
      if (isSameSymbols(replaceParts(word, beginPart, '*'), '*')) {
        return -(counter + 1);
      }
      maxAmount = counter + 1;
    }
  }

  return maxAmount;
};

var isSameSymbols = function isSameSymbols(word, letter) {

  for (var i = 0; i < word.length; i++) {

    if (letter !== word[i]) {
      return false;
    }
  }

  return true;
};

var replaceParts = function replaceParts(word, part, symbol) {

  while (word.length > word.replace(part, symbol).length) {
    word = word.replace(part, symbol);
  }

  return word;
};

var addPart = function addPart(part, amount) {
  var result = '';

  while (amount > 0) {
    result += part;
    amount--;
  }

  return result;
};

var isPalindrom = function isPalindrom(word) {

  if (word[0] === word[word.length - 1]) {
    if (word.length <= 1) return true;
    return isPalindrom(word.slice(1, word.length - 1));
  }

  return false;
};

var partLength = getMaxAmount(isPalindrom(word) ? word.slice(1) : word);
write(word + addPart(word.slice(partLength), amount - 1));

'use strict';

var newLine = readline().split(' ').map(function (number) {
  return parseInt(number);
});

var amount = newLine[1];
var word = readline();

var getWordPart = function getWordPart(mode, word, amount) {

  if (word.length / 2 >= amount - 0.5) {

    var part = mode === 'begin' ? word.slice(0, amount) : word.slice(-amount);
    return part;
  }

  return false;
};

var getMaxAmount = function getMaxAmount(word) {

  var maxAmount = 0;

  for (var counter = 0; counter < word.length; counter++) {
    if (getWordPart('begin', word, counter + 1) && getWordPart('begin', word, counter + 1) && getWordPart('begin', word, counter + 1) === getWordPart('end', word, counter + 1)) {
      maxAmount = counter + 1;
    }
  }

  return maxAmount;
};

var isSameLetters = function isSameLetters(word) {
  var letter = word[0];

  for (var i = 0; i < word.length; i++) {

    if (letter !== word[i]) {
      return false;
    }
  }

  return true;
};

var a = function a(part, amount) {
  var result = '';

  for (var i = 0; i < amount; i++) {
    result += part;
  }

  return result;
};

var replaceParts = function replaceParts(word, part) {

  while (word.length > word.replace(part, 'a').length) {
    word = word.replace(part, 'a');
  }

  return word;
};

if (isSameLetters(word)) {
  write(word + a(word[0], amount - 1));
} else {
  var partLength = getMaxAmount(word);

  if (isSameLetters(replaceParts(word, word.slice(-partLength)))) {
    write(word + a(word.slice(-partLength), amount - 1));
  } else {
    write(word + a(word.slice(partLength), amount - 1));
  }
}

'use strict';

var newLine = readline().split(' ').map(function (number) {
  return parseInt(number);
});

var amount = newLine[1];
var word = readline();

var getWordPart = function getWordPart(mode, word, amount) {

  if (word.length / 2 >= amount - 0.5) {

    var part = mode === 'begin' ? word.slice(0, amount) : word.slice(-amount);
    return part;
  }

  return false;
};

var getMaxAmount = function getMaxAmount(word) {

  // console.log(word)

  var maxAmount = 0;

  for (var counter = 0; counter < word.length; counter++) {
    var beginPart = getWordPart('begin', word, counter + 1);
    var endPart = getWordPart('end', word, counter + 1);

    if (beginPart && beginPart === endPart) {
      if (isSameSymbols(replaceParts(word, beginPart, '*'), '*')) {
        return -(counter + 1);
      }
      maxAmount = counter + 1;
    }
  }

  // console.log(maxAmount)
  return maxAmount;
};

var isSameSymbols = function isSameSymbols(word, letter) {

  for (var i = 0; i < word.length; i++) {

    if (letter !== word[i]) {
      return false;
    }
  }

  return true;
};

var replaceParts = function replaceParts(word, part, symbol) {

  for (var i = 0; i < word.length / symbol.length + 1; i++) {
    word = word.replace(part, symbol);
  }

  // console.log('replaceParts', word);
  return word;
};

var addPart = function addPart(part, amount) {
  var result = '';

  while (amount > 0) {
    result += part;
    amount--;
  }

  return result;
};

var isPalindrom = function isPalindrom(word) {

  if (word[0] === word[word.length - 1]) {
    if (word.length <= 1) return true;
    return isPalindrom(word.slice(1, word.length - 1));
  }

  return false;
};

var partLength = 0;
if (!isSameSymbols(word, word[0]) && word.length >= 6 && word[0] === word[word.length - 1]) {
  partLength = getMaxAmount(word.slice(1));
} else {
  partLength = getMaxAmount(word);
}

write(word + addPart(word.slice(partLength), amount - 1));

'use strict';

var newLine = readline().split(' ').map(function (number) {
  return parseInt(number);
});

var amount = newLine[1];
var word = readline();

var getWordPart = function getWordPart(mode, word, amount) {

  if (word.length / 2 >= amount - 0.5) {

    var part = mode === 'begin' ? word.slice(0, amount) : word.slice(-amount);
    return part;
  }

  return false;
};

var getMaxAmount = function getMaxAmount(word) {

  var maxAmount = 0;

  for (var counter = 0; counter < word.length; counter++) {
    var beginPart = getWordPart('begin', word, counter + 1);
    var endPart = getWordPart('end', word, counter + 1);

    if (beginPart && beginPart === endPart) {
      if (isSameSymbols(replaceParts(word, beginPart, '*'), '*')) {
        return -(counter + 1);
      }
      maxAmount = counter + 1;
    }
  }

  // console.log(maxAmount)
  return maxAmount;
};

var isSameSymbols = function isSameSymbols(word, letter) {

  for (var i = 0; i < word.length; i++) {

    if (letter !== word[i]) {
      return false;
    }
  }

  // console.log('SAME')
  return true;
};

var replaceParts = function replaceParts(word, part, symbol) {

  for (var i = 0; i < word.length / part.length + 1; i++) {
    word = word.replace(part, symbol);
  }

  // console.log('replaceParts', part, word);
  return word;
};

var addPart = function addPart(part, amount) {
  var result = '';

  while (amount > 0) {
    result += part;
    amount--;
  }

  return result;
};

var isPalindrom = function isPalindrom(word) {

  if (word[0] === word[word.length - 1]) {
    if (word.length <= 1) return true;
    return isPalindrom(word.slice(1, word.length - 1));
  }

  return false;
};

var partLength = getMaxAmount(word);
var begin = '';
var h = partLength > 0 && word.length >= 6 && word[0] === word[word.length - 1] && !isSameSymbols(word, word[0]) && isPalindrom(word);

// console.log(partLength);
if (h) {
  begin = word[0];
  partLength = getMaxAmount(word.slice(1));
  word = word.slice(1);
}

write(begin + word + addPart(word.slice(partLength), amount - 1));

'use strict';

var newLine = readline().split(' ').map(function (number) {
  return parseInt(number);
});

var amount = newLine[1];
var word = readline();

var getWordPart = function getWordPart(mode, word, amount) {

  if (word.length / 2 >= amount - 0.5) {

    var part = mode === 'begin' ? word.slice(0, amount) : word.slice(-amount);
    return part;
  }

  return false;
};

var getMaxAmount = function getMaxAmount(word) {

  // console.log(word)

  var maxAmount = 0;

  for (var counter = 0; counter < word.length; counter++) {
    var beginPart = getWordPart('begin', word, counter + 1);
    var endPart = getWordPart('end', word, counter + 1);

    if (beginPart && beginPart === endPart) {
      if (isSameSymbols(replaceParts(word, beginPart, '*'), '*')) {
        return -(counter + 1);
      }
      maxAmount = counter + 1;
    }
  }

  // console.log(maxAmount)
  return maxAmount;
};

var isSameSymbols = function isSameSymbols(word, letter) {

  for (var i = 0; i < word.length; i++) {

    if (letter !== word[i]) {
      return false;
    }
  }

  return true;
};

var replaceParts = function replaceParts(word, part, symbol) {

  for (var i = 0; i < word.length / symbol.length + 1; i++) {
    word = word.replace(part, symbol);
  }

  // console.log('replaceParts', word);
  return word;
};

var addPart = function addPart(part, amount) {
  var result = '';

  while (amount > 0) {
    result += part;
    amount--;
  }

  return result;
};

var isPalindrom = function isPalindrom(word) {

  if (word[0] === word[word.length - 1]) {
    if (word.length <= 1) return true;
    return isPalindrom(word.slice(1, word.length - 1));
  }

  return false;
};

var partLength = 0;
var begin = '';
var h = word.length >= 6 && word[0] === word[word.length - 1] && !isSameSymbols(word, word[0]) && isPalindrom(word);

if (h) {
  begin = word[0];
  partLength = getMaxAmount(word.slice(1));
  word = word.slice(1);
} else {
  partLength = getMaxAmount(word);
}

write(begin + word + addPart(word.slice(partLength), amount - 1));

'use strict';

var newLine = readline().split(' ').map(function (number) {
  return parseInt(number);
});

var amount = newLine[1];
var word = readline();

var getWordPart = function getWordPart(mode, word, amount) {

  if (word.length / 2 >= amount - 0.5) {

    var part = mode === 'begin' ? word.slice(0, amount) : word.slice(-amount);
    return part;
  }

  return false;
};

var getMaxAmount = function getMaxAmount(word) {

  var maxAmount = 0;

  for (var counter = 0; counter < word.length; counter++) {
    if (getWordPart('begin', word, counter + 1) && getWordPart('begin', word, counter + 1) && getWordPart('begin', word, counter + 1) === getWordPart('end', word, counter + 1)) {
      maxAmount = counter + 1;
    }
  }

  return maxAmount;
};

var isSameLetters = function isSameLetters(word) {
  var letter = word[0];

  for (var i = 0; i < word.length; i++) {

    if (letter !== word[i]) {
      return false;
    }
  }

  return true;
};

var a = function a(part, amount) {
  var result = '';

  for (var i = 0; i < amount; i++) {
    result += part;
  }

  return result;
};

if (isSameLetters(word)) {
  write(word + a(word[0], amount - 1));
} else {
  var partLength = getMaxAmount(word);
  write(word + a(word.slice(partLength), amount - 1));
}

var firstLine = readline();
var n = firstLine.split(" ")[0];
var k = firstLine.split(" ")[1];
var string = readline();

print(output(string, k, n))

function output(string, k, n) {
    var p = n - 1;
    var l = 0;
    for (var i = p - 1; i >= 0; i--) {
        if (string[p] === string[i]) {
            p--;
            l++;
        } else if (string[n-1] === string[i] && string[p+1] === string[i+1]) {
            p = n - 2;
            l = 1;
        } else {
            p = n - 1;
            l = 0;
        }
    }

    for (var i = 1; i <= k - 1; i++) {
        for (var j = l; j < n; j++) {
            string += string[j];
        }
    }
    return string;
}

var firstLine = readline();
var n = firstLine.split(" ")[0];
var k = firstLine.split(" ")[1];
var string = readline();

print(output(string, k))

function output(string, k) {
    var p = 0;
    var t = 0;
    for (var i = 1; i < string.length; i++) {
        if (string[p] !== string[i+p]) {
            p = 0;
            t = i;
        } else {
            p++;
            break;
        }
    }
    var u = string.length;
    if (t + 1 === u) {
        t = 0;
    }
    for (var o = 0; o < k - 1; o++) {
        for (var i = t; i < u; i++) {
            string = string + string[i];
        }
    }
    return string;
}

var firstLine = readline();
var n = firstLine.split(" ")[0];
var k = firstLine.split(" ")[1];
var string = readline();

print(output(string, k))

function output(string, k) {
    var p = 0;
    var t = 0;
    for (var i = 1; i < string.length; i++) {
        print (p, i, string[p], string[i])
        if (string[p] !== string[i]) {
            print (string[p-1], string[i])
            if (string[p-1] === string[i]) {
                p = 1;
                t = i - 1;
            } else {
                p = 0;
                t = i;
            }
        } else {
            p++;
        }
    }
    print(t)
    var u = string.length;
    for (var o = 0; o < k - 1; o++) {
        for (var i = u-t-1; i < u; i++) {
            string = string + string[i];
        }
    }
    return string;
}

var firstLine = readline();
var n = firstLine.split(" ")[0];
var k = firstLine.split(" ")[1];
var string = readline();

print(output(string, k))

function output(string, k) {
    var p = 0;
    var t = 0;
    for (var i = 1; i < string.length; i++) {
        if (string[p] !== string[i]) {
            if (string[p-1] === string[i]) {
                p = 1;
                t = i - 1;
            } else {
                p = 0;
                t = i;
            }
        } else {
            p++;
        }
    }
    var u = string.length;
    for (var o = 0; o < k - 1; o++) {
        for (var i = u-t-1; i < u; i++) {
            string = string + string[i];
        }
    }
    return string;
}

var firstLine = readline();
var n = firstLine.split(" ")[0];
var k = firstLine.split(" ")[1];
var string = readline();

print(output(string, k))

function output(string, k) {
    var p = 0;
    var t = 0;
    for (var i = 1; i < string.length; i++) {

        if (string[p] !== string[i+p]) {
            p = 0;
            t = i;
        } else {
            p++;
        }
    }
    var u = string.length;
    if (t + 1 === u) {
        t = 0;
    }
    for (var o = 0; o < k - 1; o++) {
        for (var i = t; i < u; i++) {
            string = string + string[i];
        }
    }
    return string;
}

var firstLine = readline();
var n = firstLine.split(" ")[0];
var k = firstLine.split(" ")[1];
var string = readline();

print(output(string, k))

function output(string, k) {
    var p = 0;
    var t = 0;
    for (var i = 1; i < string.length; i++) {
        if (string[p] !== string[i]) {
            p = 0;
            t = i;
        } else {
            p++;
        }
    }
    var u = string.length;
    for (var o = 0; o < k - 1; o++) {
        for (var i = u-t-1; i < u; i++) {
            string = string + string[i];
        }
    }
    return string;
}

var args = readline().split(' ');
var str = readline();

args = args.map((n) => parseInt(n, 10));

var len = args[0];
var repeat = args[1];

var i = 0;
var mid = parseInt(len / 2);
while (i < mid) {
    if (str[i] !== str[len - i - 1]) {
        break;
    }
    i++;
}

const res = []
const substr = str.substring(i);

res.push(str.substring(0, i));
for (var j = 0;j < repeat;j++) {
    res.push(substr);
}

print(res.join(''));

var a = readline().split("");
var n = a[1];
var str = readline();
var firstP = str.slice(1);
var secondP = str.slice(0, str.length - 1);
var i,
    bool = false;
for(i = 1; i <= str.length - 1; i++){
    if(firstP == secondP){
        bool = true;
        break;
    } else{
        firstP = firstP.slice(1);
        secondP = secondP.slice(0, secondP.length - 1);
    }
}
var mainText;
if(bool){
    mainText = str.slice(secondP.length);
} else{
    mainText = str;
}
var lastResult = str;
for(i = 1; i <= n-1; i++){
    lastResult += mainText;
}
print(lastResult);

function myFunc(t, n){

    var firstP = t.slice(1);
    var secondP = t.slice(0, t.length - 1);
    var i,
        bool = false;
    for(i = 1; i <= t.length - 1; i++){
        if(firstP == secondP){
            bool = true;
            break;
        } else{
            firstP = firstP.slice(1);
            secondP = secondP.slice(0, secondP.length - 1);
        }
    }
    var mainText;
    if(bool){
        mainText = t.slice(secondP.length);
    } else{
        mainText = t;
    }
    var lastResult = t;
    for(i = 1; i <= n-1; i++){
        lastResult += mainText;
    }
    return lastResult;
}
myFunc(readline());

var nk = readline();
var t = readline();

var n = nk.split(" ")[0];
var k = nk.split(" ")[1];

var equal = "";
for (var i = 0; i < Math.floor(t.length / 2); i ++) {
  var firstSub = t.substring(0, i + 1);
  var secondSub = t.substring(t.length - i - 1, t.length);
  if (firstSub === secondSub) {
    equal = firstSub;
  } else {
    break;
  }
}

var result = t;
for (var i = 1; i < k; i ++) {
    if (equal !== "") {
        result += t.substring(equal.length, t.length);
    } else {
        result += t;
    }
}

write(result);