Two T-shirt sizes are given: $$$a$$$ and $$$b$$$. The T-shirt size is either a string M or a string consisting of several (possibly zero) characters X and one of the characters S or L.For example, strings M, XXL, S, XXXXXXXS could be the size of some T-shirts. And the strings XM, LL, SX are not sizes.The letter M stands for medium, S for small, L for large. The letter X refers to the degree of size (from eXtra). For example, XXL is extra-extra-large (bigger than XL, and smaller than XXXL).You need to compare two given sizes of T-shirts $$$a$$$ and $$$b$$$.The T-shirts are compared as follows:   any small size (no matter how many letters X) is smaller than the medium size and any large size;  any large size (regardless of the number of letters X) is larger than the medium size and any small size;  the more letters X before S, the smaller the size;  the more letters X in front of L, the larger the size. For example:   XXXS < XS  XXXL > XL  XL > M  XXL = XXL  XXXXXS < M  XL > XXXS

The first line of the input contains a single integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. Each test case consists of one line, in which $$$a$$$ and $$$b$$$ T-shirt sizes are written. The lengths of the strings corresponding to the T-shirt sizes do not exceed $$$50$$$. It is guaranteed that all sizes are correct.

For each test case, print on a separate line the result of comparing $$$a$$$ and $$$b$$$ T-shirt sizes (lines "<", ">" or "=" without quotes).

6

XXXS XS

XXXL XL

XL M

XXL XXL

XXXXXS M

L M

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();
  });
  solve();
});
function readline() {
  return inputString[currentLine++];
}

function solve() {
  var t = readline();
  for (var k = 0; k < t; k++) {
    var T = readline();
    var phrase = T.toLowerCase().trim().split(' ');
    phrase[0] = 'x' + phrase[0];
    phrase[1] = 'x' + phrase[1];
    if (phrase[0] == phrase[1]) {
      process.stdout.write('=\n');
      continue;
    }
    if ((phrase[0].includes('m') && phrase[1].includes('s')) || (phrase[0].includes('l') && phrase[1].includes('s')) || (phrase[0].includes('l') && phrase[1].includes('m'))) {
      process.stdout.write('>\n');
      continue;
    } else if ((phrase[0].includes('s') && phrase[1].includes('m')) || (phrase[0].includes('s') && phrase[1].includes('l')) || (phrase[0].includes('m') && phrase[1].includes('l'))) {
      process.stdout.write('<\n');
      continue;
    }
    if ((phrase[0].match(/x/g).length < phrase[1].match(/x/g).length) && !T.toLowerCase().includes('s')) {
      process.stdout.write('<\n');
      continue;
    } else if ((phrase[0].match(/x/g).length < phrase[1].match(/x/g).length) && T.toLowerCase().includes('s')) {
      process.stdout.write('>\n');
      continue;
    }
    if ((phrase[0].match(/x/g).length > phrase[1].match(/x/g).length) && !T.toLowerCase().includes('s')) {
      process.stdout.write('>\n');
      continue;
    } else if ((phrase[0].match(/x/g).length > phrase[1].match(/x/g).length) && T.toLowerCase().includes('s')) {
      process.stdout.write('<\n');
      continue;
    }
  }
}

'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 main() {
    const testCases = Number(readline());
    for (let i = 0; i < testCases; i++) {
        let [size1, size2] = readline().split(" ");
        console.log(compareSizes(size1, size2));
    }
}

function compareSizes(size1, size2) {
    let S = 10, M = 50, L = 100 ;
    if (size1 === size2) return "=";
    if (calculateSize(size1) > calculateSize(size2)) return ">";
    else return "<";
}

function calculateSize(size) {
    let S = 10, M = 100, L = 1000;
    let len = size.length;
    if (size[len - 1] === "M") return M;
    else if (size[len - 1] === "S") {
        return S - (len - 1);
    } else if (size[len - 1] === "L") {
        return L + (len - 1);
    }
}

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

let inputString = "";
let currentLine = 0;

process.stdin.on("data", function (inputStdin) {
  inputString += inputStdin;
});

process.stdin.on("end", function () {
  inputString = inputString.split("\n");
  main();
});

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

function check(cases) {
  for (let i = 0; i < cases.length; i++) {
    const sizing = {
      S: 1,
      M: 2,
      L: 3,
    };
    const [left, right] = cases[i].split(" ");
    let leftSizing = 0;
    let rightSizing = 0;
    if (left.includes("X")) {
      leftSizing = sizing[left.charAt(left.length - 1)];
      leftSizing = left.includes("S")
        ? leftSizing - left.length - 1
        : leftSizing + left.length - 1;
    } else {
      leftSizing = sizing[left];
    }

    if (right.includes("X")) {
      rightSizing = sizing[right.charAt(right.length - 1)];
      rightSizing = right.includes("S")
        ? rightSizing - right.length - 1
        : rightSizing + right.length - 1;
    } else {
      rightSizing = sizing[right];
    }

    if (leftSizing > rightSizing) {
      console.log(">");
    } else if (leftSizing === rightSizing) {
      console.log("=");
    } else {
      console.log("<");
    }
  }
}

function main() {
  const t = parseInt(readLine().trim());
  const cases = [];
  for (let i = 0; i < t; i++) {
    const inputs = readLine().trim();
    cases.push(inputs);
  }

  check(cases);
}

"use strict";
const fs = require("fs");
//let filename = "0.txt";
let filename = 0;
const input = fs.readFileSync(filename, "utf8").trim().split("\n");
let line = 0;
function readline() {
  return input[line++];
}
function iInpArr() {
  return readline()
    .trim()
    .split(" ")
    .map((cur) => parseInt(cur));
}
function BInpArr() {
  return readline()
    .trim()
    .split(" ")
    .map((cur) => BigInt(cur));
}
function string() {
  return readline().trim();
}
function stringArr() {
  return readline().trim().split("");
}

function stringArr1() {
  return readline().trim().split(" ");
}
function getValue() {
  return parseInt(readline());
}
function iInpArr1() {
  return readline()
    .trim()
    .split("")
    .map((cur) => parseInt(cur));
}
let mod = 1e9 + 7;
mod = BigInt(mod);
const pow = (num, exp, mod) => {
  if (exp === BigInt(0)) return BigInt(1);
  let x = pow(num, exp / BigInt(2), mod);
  if (exp % BigInt(2)) return (((x * x) % mod) * num) % mod;
  else return (x * x) % mod;
};
const inverse = (num, exp) => {
  return pow(BigInt(num), BigInt(exp), BigInt(mod));
};
const sqrt = (n) => {
  let low = 1n,
    high = n,
    ans;
  while (low <= high) {
    let mid = (low + high) / 2n;
    if (mid * mid <= n) {
      ans = mid;
      low = mid + 1n;
    } else high = mid - 1n;
  }
  return ans;
};

const solve = () => {
  let t = getValue();
  while (t--) {
    let [a, b] = stringArr1();
    if (a[0] === "M") {
      for (let i = 0; i < b.length; i++) {
        if (b[i] !== "X") {
          if (b[i] === "M") console.log("=");
          else if (b[i] === "S") console.log(">");
          else console.log("<");
        }
      }
    } else if (b[0] === "M") {
      for (let i = 0; i < a.length; i++) {
        if (a[i] !== "X") {
          if (a[i] === "L") console.log(">");
          else console.log("<");
        }
      }
    } else {
      let xc = 0,
        f,
        xc1 = 0,
        f1;
      for (let i = 0; i < a.length; i++) {
        if (a[i] === "X") xc++;
        else f = a[i];
      }
      for (let i = 0; i < b.length; i++) {
        if (b[i] === "X") xc1++;
        else f1 = b[i];
      }
      if (f === "S") {
        if (f1 === "L") console.log("<");
        else if (xc > xc1) console.log("<");
        else if (xc < xc1) console.log(">");
        else console.log("=");
      } else if (f === "L") {
        if (f1 === "S") console.log(">");
        else if (xc > xc1) console.log(">");
        else if (xc < xc1) console.log("<");
        else console.log("=");
      }
    }
  }
};
solve();

/*
** Template
*/

// Common Template Starts //
//*
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++];
}
// Common Template Ends //

// Driver Function Starts //
const main = () => {
    console.clear()
    let t = parseInt(readline())
    while (t--) {
        let s = readline().split(' ')
        console.log(solve(s))
    }
}
// Driver Function Ends //

// MAIN LOGIC
const solve = (s) => {
    let a = s[0].split('')
    let b = s[1].split('')

    let c1 = a.filter( f => f === 'X' ).length
    let c2 = b.filter( f => f === 'X' ).length

    if (a[a.length - 1] == 'S' && b[b.length - 1] == 'M') return "<"
    else if (a[a.length - 1] == 'S' && b[b.length - 1] == 'L') return "<"
    else if (a[a.length - 1] == 'M' && b[b.length - 1] == 'L') return "<"
    else if (a[a.length - 1] == 'L' && b[b.length - 1] == 'S') return ">"
    else if (a[a.length - 1] == 'L' && b[b.length - 1] == 'M') return ">"
    else if (a[a.length - 1] == 'M' && b[b.length - 1] == 'S') return ">"
    else {
        if (a[a.length - 1] == 'S') {
            if (c1 == c2) return "="
            else if (c1 > c2) return "<"
            else return ">"
        }
        else {
            if (c1 == c2) return "="
            else if (c1 > c2) return ">"
            else return "<"
        }
    }
}

const gcd = (a, b) => b == 0 ? a : gcd(b, a % b)

const isOdd = (num) => num & 1
const isEven = (num) => !(num & 1)
const minOfArray = (arr) => Math.min.apply(null, arr)
const maxOfArray = (arr) => Math.max.apply(null, arr)
const uniqueArray = (arr) => [...new Set(arr)]
const sortArray = (arr) => arr.sort((a, b) => a - b)
const sumOfArray = (arr) => arr.reduce((partialSum, a) => partialSum + a, 0)

// <
// >
// >
// =
// <
// >

'use strict';

var fs = require('fs');

function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }

var fs__default = /*#__PURE__*/_interopDefaultLegacy(fs);

function solve(read) {
  const a = read(),
        b = read();
  const map = new Map([['S', 0], ['M', 1], ['L', 2]]);
  if (a[a.length - 1] !== b[b.length - 1]) {
    const d = map.get(a[a.length - 1]) - map.get(b[b.length - 1]);
    if (d > 0) return '>';
    return '<';
  }
  if (a.length !== b.length) {
    const d = a.length - b.length;
    if (a[a.length - 1] === 'S') {
      if (d > 0) return '<';
      return '>';
    }
    if (d > 0) return '>';
    return '<';
  }
  return '=';
}
function convertInput(read) {
  const rn = () => Number(read());
  const rb = () => BigInt(read());
  const rns = n => {
    let res = new Array(n);
    for (let i = 0; i < n; i++) res[i] = rn();
    return res;
  };
  const re = n => {
    let res = new Array(n);
    for (let i = 0; i < n; i++) res[i] = rn() - 1;
    return res;
  };
  const rbs = n => {
    let res = new Array(n);
    for (let i = 0; i < n; i++) res[i] = rb();
    return res;
  };
  return [rn, rb, rns, re, rbs];
}
function main(r) {
  const [rn, rb, rns, re, rbs] = convertInput(r);
  try {
    let t = rn();
    let res = new Array(t);
    let limit = 0;
    for (let i = 0; i < t; i++) {
      var _solve;
      const s = (_solve = solve(r)) !== null && _solve !== void 0 ? _solve : '';
      if (t < limit) {
        process.stdout.write(s.toString());
        process.stdout.write('\n');
      } else {
        res[i] = s;
      }
    }
    if (t >= limit) {
      return res.join('\n');
    } else {
      return '';
    }
  } catch (error) {
    console.log(error);
  }
}

const inputs = fs__default["default"].readFileSync(0, 'utf-8')
.split(/\s+/);
void function () {
  const read = ((i = 0) => () => inputs[i++])();
  const output = main(read);
  process.stdout.write(output);
}();

const readline = require('readline')

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

function solve(a, b) {
    const la = a[a.length - 1]
    const lb = b[b.length - 1]
    if (la === lb) {
        if (la === 'S') {
            return a.length > b.length ? '<' : (a.length < b.length ? '>' : '=')
        }
        if (la === 'L') {
            return a.length > b.length ? '>' : (a.length < b.length ? '<' : '=')
        }
        return '='
    }
    return cmp(la, lb)
}
function cmp(a, b) {
    // console.log(a, b)
    if (a === b) return '='
    if (a === 'S') return '<'
    if (a === 'L') return '>'
    return b === 'S' ? '>' : '<'
}

//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] = nextLong();
		}else if(code == 'double'){
			ret[i] = nextDouble();
		}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 nextDoubleArray(size){return nextArray(size, 'double');}
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 nextDouble(){return parseFloat(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();
	var map = ["S", "M", "L"];
	while(hasNext()){
		var L = next();
		var R = next();
		if(L == R){
			myout("=");
		}else{
			if(L.indexOf("S") != -1 && R.indexOf("S") != -1){
				if(L.length > R.length){
					myout("<");
				}else{
					myout(">");
				}
			}else if(L.indexOf("L") != -1 && R.indexOf("L") != -1){
				if(L.length > R.length){
					myout(">");
				}else{
					myout("<");
				}
			}else{
				var Li = map.indexOf(L[L.length - 1]);
				var Ri = map.indexOf(R[R.length - 1]);
				if(Li < Ri){
					myout("<");
				}else{
					myout(">");
				}
			}

		}
	}
}

var mapData = {
    L: 3,
    M: 2,
    S: 1
}

function foo (left, right) {

    var sizeLeft = left.length;
    var sizeRight = right.length;

    var valueLeft = mapData[left[sizeLeft-1]] + sizeLeft - 1;
    var valueRight = mapData[right[sizeRight-1]] + sizeRight - 1;

    var charLeft = left[sizeLeft-1]
    var charRight = right[sizeRight-1]

    if (charLeft === charRight && charLeft == 'S') {
        if (valueLeft === valueRight) {
            return "="
        }
        return valueLeft > valueRight ? "<" : ">"
    }
    if (mapData[charLeft] == mapData[charRight]) {
        if (valueLeft === valueRight) {
            return "="
        }
        return valueLeft > valueRight ? ">" : "<"
    }
        return mapData[charLeft] > mapData[charRight] ? '>' : '<'

  }

function main() {

    var count = readline();

    var inp = [];

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

        inp = readline().split(' ');
        var result = foo(inp[0], inp[1]);
        print(result);

    }

}
main()

var n = readline()

for(var i = 0; i < n; i++) {
    var sizes = readline().split(' ')
    sizes = sizes.map(size => size.split(''))
    sizes = sizes.map( size => {
        switch(size.pop()) {
            case 'M':
                return 0
                break;
            case 'S':
                return -1 - size.length
                break;
            case 'L':
                return 1 + size.length
                break;
        }
    })
    if (sizes[0] < sizes[1]) print('<')
    else if (sizes[0] == sizes[1]) print('=')
    else print('>')
}

var limit = parseInt(readline());
for (var i = 0; i < limit; i++)
{
    var caseArray = readline().split(" ");
    var firstShirtSize = caseArray[0];
    var secondShirtSize = caseArray[1];
    var result = "=";
    if (firstShirtSize.slice(-1) == 'S' &&
            (secondShirtSize.slice(-1) == 'M' || secondShirtSize.slice(-1) == 'L'))
        {
            result = "<";
        }
        else if (firstShirtSize.slice(-1) == 'M')
        {
            if (secondShirtSize.slice(-1) == 'S') result = ">";
            else if (secondShirtSize.slice(-1) == 'L') result = "<";
        }
        else if (firstShirtSize.slice(-1) == 'L' &&
            (secondShirtSize.slice(-1) == 'S' || secondShirtSize.slice(-1) == 'M'))
        {
            result = ">";
        }
        else
        {
            if (firstShirtSize.slice(-1) == 'S')
            {
                if (firstShirtSize.length > secondShirtSize.length) result = "<";
                else if (firstShirtSize.length < secondShirtSize.length) result = ">";
            }
            else if (firstShirtSize.slice(-1) == 'L')
            {
                if (firstShirtSize.length > secondShirtSize.length) result = ">";
                else if (firstShirtSize.length < secondShirtSize.length) result = "<";
            }
        }
        print(result);
}

function compareSizes(str1, str2){
   const sizes = {
       'S': 0,
       'M': 1,
       'L': 2
   }

  const size1 = str1[str1.length - 1]
  const size2 = str2[str2.length - 1]

  if(size1 !== size2){
    const num1 = sizes[size1]
    const num2 = sizes[size2]
    if(num1 > num2){
        return '>'
    } else if(num1 < num2){
        return '<'
    } else return '='
  } else if(str1.length === str2.length) {
        return '='
    } else if(size1 === 'S') {
      if(str1.length < str2.length) {
        return '>'
    } else return '<'
  }  else if(str1.length > str2.length) {
        return '>'
    } else return '<'
}

var count = readline();

var inp;

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

    inp = readline().split(' ')
    var result = compareSizes(inp[0], inp[1]);
    print(result);

}

var foo = function(str1, str2) {

  var sizes = {
    'S': 0,
    'M': 1,
    'L': 2
  }

  var length1 = str1.length
  var length2 = str2.length
  var lastLetter1 = str1[length1 - 1]
  var lastLetter2 = str2[length2 - 1]

  if(lastLetter2 !== lastLetter1) {
    return getOperator(sizes[lastLetter1]-sizes[lastLetter2])
  }

  if(length1 === length2) return '='

  if(lastLetter1 === 'S') return getOperator(length2 - length1)

  return getOperator(length1 - length2)
};

var getOperator = (num) => {
  if(num > 0) return '>'
  else if(num === 0) return '='
  else return '<'
}

var count = readline();

var inp;

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

    inp = readline().split(' ');
    var result = foo(inp[0], inp[1]);
    print(result);

}

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();
  });
  solve();
});
function readline() {
  return inputString[currentLine++];
}

function solve() {
  var t = readline();
  for (var k = 0; k < t; k++) {
    var T = readline();
    var phrase = T.toLowerCase().trim().split(' ');
    phrase[0] = 'x' + phrase[0];
    phrase[1] = 'x' + phrase[1];
    if (phrase[0] == phrase[1]) {
      process.stdout.write('=\n');
      continue;
    }
    if (!T.includes('s')) {
      if (phrase[0].includes('m') && phrase[1].includes('l')) {
        process.stdout.write('<\n');
        continue;
      } else if (phrase[0].includes('l') && phrase[1].includes('m')) {
        process.stdout.write('>\n');
        continue;
      } else if (phrase[0].match(/x/g).length < phrase[1].match(/x/g).length) {
        process.stdout.write('<\n');
        continue;
      } else if (phrase[0].match(/x/g).length > phrase[1].match(/x/g).length) {
        process.stdout.write('>\n');
        continue;
      }
    } else {
      if (phrase[0].match(/x/g).length < phrase[1].match(/x/g).length) {
        process.stdout.write('>\n');
        continue;
      } else if (phrase[0].match(/x/g).length > phrase[1].match(/x/g).length) {
        process.stdout.write('<\n');
        continue;
      }
    }
  }
}

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();
  });
  solve();
});
function readline() {
  return inputString[currentLine++];
}

function solve() {
  var t = readline();
  for (var k = 0; k < t; k++) {
    var T = readline();
    var phrase = T.toLowerCase().trim().split(' ');
    phrase[0] = 'x' + phrase[0];
    phrase[1] = 'x' + phrase[1];
    if (phrase[0] == phrase[1]) {
      process.stdout.write('=\n');
      continue;
    }
    if (T.includes('s')) {
      if (phrase[0].includes('m') && phrase[1].includes('l')) {
        process.stdout.write('<\n');
        continue;
      } else if (phrase[0].includes('l') && phrase[1].includes('m')) {
        process.stdout.write('>\n');
        continue;
      } else if (phrase[0].match(/x/g).length < phrase[1].match(/x/g).length) {
        process.stdout.write('<\n');
        continue;
      } else if (phrase[0].match(/x/g).length > phrase[1].match(/x/g).length) {
        process.stdout.write('>\n');
        continue;
      }
    } else {
      if (phrase[0].match(/x/g).length < phrase[1].match(/x/g).length) {
        process.stdout.write('>\n');
        continue;
      } else if (phrase[0].match(/x/g).length > phrase[1].match(/x/g).length) {
        process.stdout.write('<\n');
        continue;
      }
    }
  }
}

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();
  });
  solve();
});
function readline() {
  return inputString[currentLine++];
}

function solve() {
  var t = readline();
  for (var k = 0; k < t; k++) {
    var T = readline();
    var phrase = T.toLowerCase().trim().split(' ');
    phrase[0] = 'x' + phrase[0];
    phrase[1] = 'x' + phrase[1];
    if (phrase[0] == phrase[1]) {
      process.stdout.write('=\n');
      continue;
    }
    if (phrase[phrase.length - 1] != 's') {
      if (phrase[0].includes('m') && phrase[1].includes('l')) {
        process.stdout.write('<\n');
        continue;
      } else if (phrase[0].includes('l') && phrase[1].includes('m')) {
        process.stdout.write('>\n');
        continue;
      } else if (phrase[0].match(/x/g).length < phrase[1].match(/x/g).length) {
        process.stdout.write('<\n');
        continue;
      } else if (phrase[0].match(/x/g).length > phrase[1].match(/x/g).length) {
        process.stdout.write('>\n');
        continue;
      }
    } else {
      if (phrase[0].match(/x/g).length < phrase[1].match(/x/g).length) {
        process.stdout.write('>\n');
        continue;
      } else if (phrase[0].match(/x/g).length > phrase[1].match(/x/g).length) {
        process.stdout.write('<\n');
        continue;
      }
    }
  }
}

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();
  });
  solve();
});
function readline() {
  return inputString[currentLine++];
}

function solve() {
  var t = readline();
  for (var k = 0; k < t; k++) {
    var T = readline();
    var phrase = T.toLowerCase().trim().split(' ');
    if (phrase[0] == phrase[1]) {
      process.stdout.write('=\n');
      return;
    }
    if (!T.trim().toLowerCase().includes('s')) {
      if (phrase[0].includes('m') && phrase[1].includes('l')) {
        process.stdout.write('<\n');
        return;
      } else if (phrase[0].includes('l') && phrase[1].includes('m')) {
        process.stdout.write('>\n');
        return;
      } else if (phrase[0].match(/x/g).length < phrase[1].match(/x/g).length) {
        process.stdout.write('<\n');
        return;
      } else if (phrase[0].match(/x/g).length > phrase[1].match(/x/g).length) {
        process.stdout.write('>\n');
        return;
      }
    } else {
      if (phrase[0].includes('m') && phrase[1].includes('s')) {
        process.stdout.write('>\n');
        return;
      } else if (phrase[0].includes('s') && phrase[1].includes('m')) {
        process.stdout.write('<\n');
        return;
      } else if (phrase[0].match(/x/g).length < phrase[1].match(/x/g).length) {
        process.stdout.write('>\n');
        return;
      } else if (phrase[0].match(/x/g).length > phrase[1].match(/x/g).length) {
        process.stdout.write('<\n');
        return;
      }
    }
  }
}

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();
  });
  solve();
});
function readline() {
  return inputString[currentLine++];
}

function solve() {
  var t = readline();
  for (var k = 0; k < t; k++) {
    var T = readline();
    var phrase = T.toLowerCase().trim().split(' ');
    if (phrase[0] == phrase[1]) {
      process.stdout.write('=');
    }
    if (!T.trim().toLowerCase().includes('s')) {
      if (phrase[0].includes('m') && phrase[1].includes('l')) {
        process.stdout.write('<');
      } else if (phrase[0].includes('l') && phrase[1].includes('m')) {
        process.stdout.write('>');
      } else if (phrase[0].match(/x/g).length < phrase[1].match(/x/g).length) {
        process.stdout.write('<');
      } else if (phrase[0].match(/x/g).length > phrase[1].match(/x/g).length) {
        process.stdout.write('>');
      }
    } else {
      if (phrase[0].includes('m') && phrase[1].includes('s')) {
        process.stdout.write('>');
      } else if (phrase[0].includes('s') && phrase[1].includes('m')) {
        process.stdout.write('<');
      } else if (phrase[0].match(/x/g).length < phrase[1].match(/x/g).length) {
        process.stdout.write('>');
      } else if (phrase[0].match(/x/g).length > phrase[1].match(/x/g).length) {
        process.stdout.write('<');
      }
    }
  }
}

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();
  });
  solve();
});
function readline() {
  return inputString[currentLine++];
}

function solve() {
  var t = readline();
  for (var k = 0; k < t; k++) {
    var T = readline();
    var phrase = T.toLowerCase().trim().split(' ');
    if (phrase[0] == phrase[1]) {
      console.log('=\n');
    }
    if (!T.trim().toLowerCase().includes('s')) {
      if (phrase[0].includes('m') && phrase[1].includes('l')) {
        console.log('<\n');
      } else if (phrase[0].includes('l') && phrase[1].includes('m')) {
        console.log('>\n');
      } else if (phrase[0].match(/x/g).length < phrase[1].match(/x/g).length) {
        console.log('<\n');
      } else if (phrase[0].match(/x/g).length > phrase[1].match(/x/g).length) {
        console.log('>\n');
      }
    } else {
      if (phrase[0].includes('m') && phrase[1].includes('s')) {
        console.log('>\n');
      } else if (phrase[0].includes('s') && phrase[1].includes('m')) {
        console.log('<\n');
      } else if (phrase[0].match(/x/g).length < phrase[1].match(/x/g).length) {
        console.log('>\n');
      } else if (phrase[0].match(/x/g).length > phrase[1].match(/x/g).length) {
        console.log('<\n');
      }
    }
  }
}

// let Alpha = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'], z = -1, f;
// process.stdin.on('data', function (data) {
//   var d = data.toString().trim().replaceAll(' ', '\n')
//   var splittedSTR = d.split('')
//   console.log(splittedSTR);
//   let output = [];
//   if (splittedSTR.length == 1) {
//     if (f == undefined) {
//       f = data.toString().trim();
//     } else {
//     }
//     return;
//   }
//   for (var i = 0; i < splittedSTR.length; i++) {
//     if (splittedSTR[i + 1] == 0 && splittedSTR[i + 2] != 0) {
//       splittedSTR[i] = `${splittedSTR[i - 1] + splittedSTR[i]}`;
//       splittedSTR.splice(i + 1, 1)
//       splittedSTR.splice(i - 1, 1)
//     }
//   }
//   for (var i = 0; i < splittedSTR.length; i++) {
//     output.push(Alpha[splittedSTR[i] - 1])
//     if (output.length == splittedSTR.length) {
//       console.log(output.join(''));
//       z++
//       if (z == f) {
//         process.exit();
//       }
//       return output.join('');
//     }
//   }
// })
var f;
process.stdin.on('data', function (data) {
  if (f == undefined) {
    f = 1;
    return;
  }
  var phrase = data.toString().trim().toLowerCase().split(' ');
  if (phrase[0] == phrase[1]) {
    console.log('=\n');
    return '=';
  }
  if (!data.toString().trim().toLowerCase().includes('s')) {
    if (phrase[0].includes('m') && phrase[1].includes('l')) {
      console.log('<\n');
      return '<';
    } else if (phrase[0].includes('l') && phrase[1].includes('m')) {
      console.log('>\n');
      return '>';
    } else if (phrase[0].match(/x/g).length < phrase[1].match(/x/g).length) {
      console.log('<\n');
      return '<';
    } else if (phrase[0].match(/x/g).length > phrase[1].match(/x/g).length) {
      console.log('>\n');
      return '>';
    }
  } else {
    if (phrase[0].includes('m') && phrase[1].includes('s')) {
      console.log('>\n');
      return '>';
    } else if (phrase[0].includes('s') && phrase[1].includes('m')) {
      console.log('<\n');
      return '<';
    } else if (phrase[0].match(/x/g).length < phrase[1].match(/x/g).length) {
      console.log('>\n');
      return '>';
    } else if (phrase[0].match(/x/g).length > phrase[1].match(/x/g).length) {
      console.log('<\n');
      return '<';
    }
  }
})

// let Alpha = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'], z = -1, f;
// process.stdin.on('data', function (data) {
//   var d = data.toString().trim().replaceAll(' ', '\n')
//   var splittedSTR = d.split('')
//   console.log(splittedSTR);
//   let output = [];
//   if (splittedSTR.length == 1) {
//     if (f == undefined) {
//       f = data.toString().trim();
//     } else {
//     }
//     return;
//   }
//   for (var i = 0; i < splittedSTR.length; i++) {
//     if (splittedSTR[i + 1] == 0 && splittedSTR[i + 2] != 0) {
//       splittedSTR[i] = `${splittedSTR[i - 1] + splittedSTR[i]}`;
//       splittedSTR.splice(i + 1, 1)
//       splittedSTR.splice(i - 1, 1)
//     }
//   }
//   for (var i = 0; i < splittedSTR.length; i++) {
//     output.push(Alpha[splittedSTR[i] - 1])
//     if (output.length == splittedSTR.length) {
//       console.log(output.join(''));
//       z++
//       if (z == f) {
//         process.exit();
//       }
//       return output.join('');
//     }
//   }
// })
var f;
process.stdin.on('data', function (data) {
  if (f == undefined) {
    f = 1;
    return;
  }
  var phrase = data.toString().trim().toLowerCase().split(' ');
  if (phrase[0] == phrase[1]) {
    console.log('=', '/n');
    return '=';
  }
  if (!data.toString().trim().toLowerCase().includes('s')) {
    if (phrase[0].includes('m') && phrase[1].includes('l')) {
      console.log('<', '/n');
      return '<';
    } else if (phrase[0].includes('l') && phrase[1].includes('m')) {
      console.log('>', '/n');
      return '>';
    } else if (phrase[0].match(/x/g).length < phrase[1].match(/x/g).length) {
      console.log('<', '/n');
      return '<';
    } else if (phrase[0].match(/x/g).length > phrase[1].match(/x/g).length) {
      console.log('>', '/n');
      return '>';
    }
  } else {
    if (phrase[0].includes('m') && phrase[1].includes('s')) {
      console.log('>', '/n');
      return '>';
    } else if (phrase[0].includes('s') && phrase[1].includes('m')) {
      console.log('<', '/n');
      return '<';
    } else if (phrase[0].match(/x/g).length < phrase[1].match(/x/g).length) {
      console.log('>', '/n');
      return '>';
    } else if (phrase[0].match(/x/g).length > phrase[1].match(/x/g).length) {
      console.log('<', '/n');
      return '<';
    }
  }
})

// let Alpha = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'], z = -1, f;
// process.stdin.on('data', function (data) {
//   var d = data.toString().trim().replaceAll(' ', '\n')
//   var splittedSTR = d.split('')
//   console.log(splittedSTR);
//   let output = [];
//   if (splittedSTR.length == 1) {
//     if (f == undefined) {
//       f = data.toString().trim();
//     } else {
//     }
//     return;
//   }
//   for (var i = 0; i < splittedSTR.length; i++) {
//     if (splittedSTR[i + 1] == 0 && splittedSTR[i + 2] != 0) {
//       splittedSTR[i] = `${splittedSTR[i - 1] + splittedSTR[i]}`;
//       splittedSTR.splice(i + 1, 1)
//       splittedSTR.splice(i - 1, 1)
//     }
//   }
//   for (var i = 0; i < splittedSTR.length; i++) {
//     output.push(Alpha[splittedSTR[i] - 1])
//     if (output.length == splittedSTR.length) {
//       console.log(output.join(''));
//       z++
//       if (z == f) {
//         process.exit();
//       }
//       return output.join('');
//     }
//   }
// })
var f;
process.stdin.on('data', function (data) {
  if (f == undefined) {
    f = 1;
    return;
  }
  var phrase = data.toString().trim().toLowerCase().split(' ');
  if (phrase[0] == phrase[1]) {
    console.log('=');
    return;
  }
  if (!data.toString().trim().toLowerCase().includes('s')) {
    if (phrase[0].includes('m') && phrase[1].includes('l')) {
      console.log('<');
      return;
    } else if (phrase[0].includes('l') && phrase[1].includes('m')) {
      console.log('>');
      return;
    } else if (phrase[0].match(/x/g).length < phrase[1].match(/x/g).length) {
      console.log('<');
      return;
    } else if (phrase[0].match(/x/g).length > phrase[1].match(/x/g).length) {
      console.log('>');
      return;
    }
  } else {
    if (phrase[0].includes('m') && phrase[1].includes('s')) {
      console.log('>');
      return;
    } else if (phrase[0].includes('s') && phrase[1].includes('m')) {
      console.log('<');
      return;
    } else if (phrase[0].match(/x/g).length < phrase[1].match(/x/g).length) {
      console.log('>');
      return;
    } else if (phrase[0].match(/x/g).length > phrase[1].match(/x/g).length) {
      console.log('<');
      return;
    }
  }
})

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

let inputString = "";
let currentLine = 0;

process.stdin.on("data", function (inputStdin) {
  inputString += inputStdin;
});

process.stdin.on("end", function () {
  inputString = inputString.split("\n");
  main();
});

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

function check(cases) {
  for (let i = 0; i < cases.length; i++) {
    const sizing = {
      S: 1,
      M: 2,
      L: 3,
    };
    const [left, right] = cases[i].split(" ");
    let leftSizing = 0;
    let rightSizing = 0;
    if (left.includes("X")) {
      leftSizing = sizing[left.charAt(left.length - 1)];
      leftSizing = left.includes("S")
        ? leftSizing - left.length - 2
        : leftSizing + left.length - 2;
    } else {
      leftSizing = sizing[left];
    }

    if (right.includes("X")) {
      rightSizing = sizing[right.charAt(right.length - 1)];
      rightSizing = right.includes("S")
        ? rightSizing - right.length - 2
        : rightSizing + right.length - 2;
    } else {
      rightSizing = sizing[right];
    }

    if (leftSizing > rightSizing) {
      console.log(">");
    } else if (leftSizing === rightSizing) {
      console.log("=");
    } else {
      console.log("<");
    }
  }
}

function main() {
  const t = parseInt(readLine().trim());
  const cases = [];
  for (let i = 0; i < t; i++) {
    const inputs = readLine().trim();
    cases.push(inputs);
  }

  check(cases);
}

var mapData = {
    L: 3,
    M: 2,
    S: 1
}

function foo (left, right) {

    var sizeLeft = left.length;
    var sizeRight = right.length;

    var valueLeft = mapData[left[sizeLeft-1]] + sizeLeft - 1;
    var valueRight = mapData[right[sizeRight-1]] + sizeRight - 1;

    var charLeft = left[sizeLeft-1]
    var charRight = right[sizeRight-1]

    if (charLeft === charRight && charLeft == 'S') {
        if (valueLeft === valueRight) {
            return "="
        }
        return valueLeft > valueRight ? "<" : ">"
    }
    if (mapData[charLeft] == mapData[charRight]) {
        return '='
    }
        return mapData[charLeft] > mapData[charRight] ? '>' : '<'

  }

function main() {

    var count = readline();

    var inp = [];

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

        inp = readline().split(' ');
        var result = foo(inp[0], inp[1]);
        print(result);

    }

}
main()

var mapData = {
    L: 3,
    M: 2,
    S: 1
}

function foo (left, right) {

    var sizeLeft = left.length;
    var sizeRight = right.length;

    var valueLeft = mapData[left[sizeLeft-1]] + sizeLeft - 1;
    var valueRight = mapData[right[sizeRight-1]] + sizeRight - 1;

    var charLeft = left[sizeLeft-1];
    var charRight = right[sizeRight-1];

    if (charLeft === charRight && charLeft == 'S') {
        if (valueLeft === valueRight) {
            return "=";
        }
        return valueLeft > valueRight ? "<" : ">";
    }
    if (mapData[charLeft] == mapData[charRight]) {
        return '=';
    }
        return mapData[charLeft] > mapData[charRight] ? '>' : '<';

  }

function main() {

    var count = readline();

    var inp = ["XL", "M"];

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

        inp = readline().split(' ');
        var result = foo(inp[0], inp[1]);
        print(result);

    }

}
main()

var mapData = {
    L: 3,
    M: 2,
    S: 1
}

var exception = ["XM", "LL", "SX"]

function foo (left, right) {

    if (exception.includes(left) || exception.includes(right)) {
        return "";
    }
    var sizeLeft = left.length;
    var sizeRight = right.length;

    var valueLeft = mapData[left[sizeLeft-1]] + sizeLeft - 1;
    var valueRight = mapData[right[sizeRight-1]] + sizeRight - 1;

    if (left[sizeLeft-1] === right[sizeRight-1]) {
        if (valueLeft === valueRight) {
            return "=";
        }
        return valueLeft > valueRight ? "<" : ">";
    }
    if (mapData[left[sizeLeft-1]] == mapData[right[sizeRight-1]]) {
        return "=";
    }
    if (mapData[left[sizeLeft-1]] > mapData[right[sizeRight-1]]) {
        return ">";
    } else {
        return "<";
    }

  }

function main() {

    var count = readline();

    var inp;

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

        inp = readline().split(' ');
        var result = foo(inp[0], inp[1]);
        print(result);

    }
}
main()

var mapData = {
    L: 3,
    M: 2,
    S: 1
}

var exception = ["XM", "LL", "SX"]

function foo (left, right) {

    if (exception.includes(left) || exception.includes(right)) {
        return "";
    }
    var sizeLeft = left.length;
    var sizeRight = right.length;

    var valueLeft = mapData[left[sizeLeft-1]] + sizeLeft - 1;
    var valueRight = mapData[right[sizeRight-1]] + sizeRight - 1;

    if (left[sizeLeft-1] === right[sizeRight-1]) {
        if (valueLeft === valueRight) {
            return "=";
        }
        return valueLeft > valueRight ? ">" : "<";
    }
    if (mapData[left[sizeLeft-1]] == mapData[right[sizeRight-1]]) {
        return "=";
    }
    if (mapData[left[sizeLeft-1]] > mapData[right[sizeRight-1]]) {
        return ">";
    } else {
        return "<";
    }

  }

function main() {

    var count = readline();

    var inp;

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

        inp = readline().split(' ');
        var result = foo(inp[0], inp[1]);
        print(result);

    }
}
main()

var mapData = {
    L: 3,
    M: 2,
    S: 1
}

var exception = ["XM", "LL", "SX"]

function foo (left, right) {

    if (exception.includes(left) || exception.includes(right)) {
        return "";
    }
    var sizeLeft = left.length;
    var sizeRight = right.length;

    var valueLeft = mapData[left[sizeLeft-1]] + sizeLeft - 1;
    var valueRight = mapData[right[sizeRight-1]] + sizeRight - 1;

    if (left[sizeLeft-1] === right[sizeRight-1]) {
        if (valueLeft === valueRight) {
            return "=";
        }
        return left > right ? ">" : "<";
    }
    if (mapData[left[sizeLeft-1]] == mapData[right[sizeRight-1]]) {
        return "=";
    }
    if (mapData[left[sizeLeft-1]] > mapData[right[sizeRight-1]]) {
        return ">";
    } else {
        return "<";
    }

  }

function main() {

    var count = readline();

    var inp;

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

        inp = readline().split(' ');
        var result = foo(inp[0], inp[1]);
        print(result);

    }
}
main()

var mapData = {
    L: 3,
    M: 2,
    S: 1
}

var exception = ["XM", "LL", "SX"]

var compareTShirtSizes = (left, right) => {

}
  var foo = (left, right) => {

    if (exception.includes(left) || exception.includes(right)) {
        return null
    }
    var sizeLeft = left.length
    const sizeRight = right.length

    var valueLeft = mapData[left[sizeLeft-1]] + sizeLeft - 1
    var valueRight = mapData[right[sizeRight-1]] + sizeRight - 1

    if (left[sizeLeft-1] === right[sizeRight-1]) {
        if (valueLeft === valueRight) {
            return "=";
        }
        return left > right ? ">" : "<";
    }
    if (mapData[left[sizeLeft-1]] == mapData[right[sizeRight-1]]) {
        return "="
    }
    if (mapData[left[sizeLeft-1]] > mapData[right[sizeRight-1]]) {
        return ">"
    } else {
        return "<"
    }

  }

function main() {
    var n = +readline();

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

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

  var result = foo(vars[0], vars[1], str)
  console.log(result)
}
}

var mapData = {
    L: 3,
    M: 2,
    S: 1
}

var exception = ["XM", "LL", "SX"]

var compareTShirtSizes = (left, right) => {

}
  var pareHandler = (left, right) => {

    if (exception.includes(left) || exception.includes(right)) {
        return null
    }
    var sizeLeft = left.length
    const sizeRight = right.length

    var valueLeft = mapData[left[sizeLeft-1]] + sizeLeft - 1
    var valueRight = mapData[right[sizeRight-1]] + sizeRight - 1

    if (left[sizeLeft-1] === right[sizeRight-1]) {
        if (valueLeft === valueRight) {
            return "=";
        }
        return left > right ? ">" : "<";
    }
    if (mapData[left[sizeLeft-1]] == mapData[right[sizeRight-1]]) {
        return "="
    }
    if (mapData[left[sizeLeft-1]] > mapData[right[sizeRight-1]]) {
        return ">"
    } else {
        return "<"
    }

  }

function main() {
    var n = +readline();

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

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

  var result = foo(vars[0], vars[1], str)
  console.log(result)
}
}


You are given an array $$$a$$$ consisting of $$$n$$$ integers. You should divide $$$a$$$ into continuous non-empty subarrays (there are $$$2^{n-1}$$$ ways to do that).Let $$$s=a_l+a_{l+1}+\ldots+a_r$$$. The value of a subarray $$$a_l, a_{l+1}, \ldots, a_r$$$ is:   $$$(r-l+1)$$$ if $$$s>0$$$, $$$0$$$ if $$$s=0$$$, $$$-(r-l+1)$$$ if $$$s<0$$$.  What is the maximum sum of values you can get with a partition?

The input consists of multiple test cases. The first line contains a single integer $$$t$$$ ($$$1 \le t \le 5 \cdot 10^5$$$) — the number of test cases. The description of the test cases follows. The first line of each test case contains a single integer $$$n$$$ ($$$1 \le n \le 5 \cdot 10^5$$$). The second line of each test case contains $$$n$$$ integers $$$a_1$$$, $$$a_2$$$, ..., $$$a_n$$$ ($$$-10^9 \le a_i \le 10^9$$$). It is guaranteed that the sum of $$$n$$$ over all test cases does not exceed $$$5 \cdot 10^5$$$.

For each test case print a single integer — the maximum sum of values you can get with an optimal parition.

'use strict';

var fs = require('fs');

function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }

var fs__default = /*#__PURE__*/_interopDefaultLegacy(fs);

function solve(n, a) {
  const sum = new Array(n).fill(0);
  let sumMap = new Map();

  for (let i = 0; i < n; i++) {
    var _sum;

    sum[i] = ((_sum = sum[i - 1]) !== null && _sum !== void 0 ? _sum : 0) + a[i];
  }

  const sumSet = [...new Set(sum), 0].sort((a, b) => a - b),
        N = sumSet.length;

  for (let [k, v] of sumSet.entries()) {
    sumMap.set(v, k);
  }

  const segTree = new SegTree(N);
  segTree.update(sumMap.get(0), 1);
  const map = new Map();
  let dp = [];

  for (let i = 0; i < n; i++) {
    var _map$get, _dp;

    // dp[i] = (dp[i - 1] ?? 0) - (a[i] > 0 ? 1 : a[i] < 0 ? -1 : 0)
    dp[i] = segTree.query(0, sumMap.get(sum[i]) - 1) + i;
    dp[i] = Math.max(dp[i], (_map$get = map.get(sum[i])) !== null && _map$get !== void 0 ? _map$get : -Infinity, ((_dp = dp[i - 1]) !== null && _dp !== void 0 ? _dp : 0) + (a[i] > 0 ? 1 : a[i] < 0 ? -1 : 0));
    segTree.update(sumMap.get(sum[i]), dp[i] - i);
    if (!map.has(sum[i]) || map.get(sum[i]) < dp[i] - i + 1) map.set(sum[i], dp[i]);
  }

  console.log(dp[n - 1]); // console.log(res)
  // return res
  // return
}

class SegTree {
  constructor(n) {
    this.n = n;
    this.root = this._newNode(0, n);

    this.update = (i, j) => {
      this._update(this.root, i, i, j);
    };

    this.query = this._query.bind(this, this.root);
  }

  _newNode(l, r, val = -Infinity, left = null, right = null) {
    return {
      val,
      l,
      r,
      left,
      right
    };
  }

  _up(node) {
    var _left$val, _right$val;

    const {
      left,
      right
    } = node; // if (!left || !right) return

    node.val = Math.max((_left$val = left === null || left === void 0 ? void 0 : left.val) !== null && _left$val !== void 0 ? _left$val : -Infinity, (_right$val = right === null || right === void 0 ? void 0 : right.val) !== null && _right$val !== void 0 ? _right$val : -Infinity);
  }

  _update(node, x, y, z) {
    if (!node) return;
    const {
      l,
      r
    } = node;

    if (l === x && r === y) {
      node.val = Math.max(node.val, z);
      return;
    }

    const mid = Math.floor((l + r) / 2);

    if (y <= mid) {
      if (!node.left) node.left = this._newNode(l, mid);

      this._update(node.left, x, y, z);
    } else if (x > mid) {
      if (!node.right) node.right = this._newNode(mid + 1, r);

      this._update(node.right, x, y, z);
    } else {
      if (!node.left) node.left = this._newNode(l, mid);
      if (!node.right) node.right = this._newNode(mid + 1, r);
      this._update(node.left, x, mid, z), this._update(node.right, mid + 1, y, z);
    }

    this._up(node);
  }

  _query(node, x, y) {
    if (y < x) return -Infinity;
    if (!node) return -Infinity;
    const {
      l,
      r
    } = node;
    if (l === x && r === y) return node.val;
    let res = 0,
        mid = Math.floor((l + r) / 2);
    if (y <= mid) res = this._query(node.left, x, y);else if (x > mid) res = this._query(node.right, x, y);else res = Math.max(this._query(node.left, x, mid), this._query(node.right, mid + 1, y));

    this._up(node);

    return res;
  }

}

function main(inputs) {
  const _ = Number(inputs[0]);

  for (let __ = 0; __ < _; __++) {
    const n = Number(inputs[__ * 2 + 1].trim());
    const a = inputs[__ * 2 + 2].trim().split(' ').map(Number);
    solve(n, a);
  }
}

const inputs = fs__default["default"].readFileSync(0, 'utf-8').split('\n');
main(inputs);

'use strict';

const { timeStamp } = require('console');
const { checkPrime } = require('crypto');
const { Z_FIXED } = require('zlib');

 /*jslint node:true, browser:true, es6:true*/
const print = console.log
const E = {};
const lines = []
if (!process.env.JEST_WORKER_ID){
  const rl = require('readline').createInterface({ input: process.stdin, output: process.stdout })
  rl.on('line', line => {
      lines.push(line);
  });
  rl.on('close', main)
}
let rli = 0;
function readline() {
    return lines[rli++];
}
const l = process.env.DEBUG ? console.log : ()=>{};

module.exports = E;

const ra = ()=>readline().split(' ').map(a=>+a)

function lsb(num) {
    return (num & -num);
}
function add(F, pos, val) {
  pos++;
    while (pos<F.length) {
        F[pos]=Math.max(F[pos], val);
        pos+=lsb(pos);
    }
}
function ask(F, pos) {
  pos++;
    let val=-Infinity;
    while (pos) {
        val=Math.max(F[pos], val);
        pos-=lsb(pos);
    }
    return val;
}

const calc = (n, A)=>{

  let pref = []
  let v = [];
  for (let i=0; i<n; i++){
    pref.push(A[i]+(i ? pref[i-1] : 0))
    v.push([pref[i], i]);
  }
  v.sort((a, b)=>{
    if (a[0]==b[0])
      return b[1]-a[1];
    return a[0]-b[0];
  });
  let F = [-Infinity]
  let ord = {};
  for (let i=0; i<n; i++){
    F.push(-Infinity)
    ord[v[i][1]] = i;
  }
  l({A, pref})
  let D = new Array(n).fill(-Infinity)
  let maxdi = -1;
  for (let i=0; i<n; i++){
    // basic
    let res;
    if (A[i]>0)
      res = 1;
    else if (A[i]==0)
      res = 0;
    else
      res = -1;
    D[i] = (i>0 ? D[i-1] : 0) + res;
    D[i] = Math.max(D[i], ask(F, ord[i])+i)
    if (pref[i]>0)
      D[i] = i+1;
    add(F, ord[i], D[i]-i)
  }
  l({D})
  return D[n-1];
};

function main() {
    let T = +readline()
    while (T--){
      let [n] = ra();
      let A = ra();
      l('ans')
      print(calc(n, A));
    }
}

E.calc = calc;

'use strict';

var fs = require('fs');

function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }

var fs__default = /*#__PURE__*/_interopDefaultLegacy(fs);

function solve(n, a) {
  const sum = new Array(n).fill(0);
  let max = -Infinity,
      min = Infinity;

  for (let i = 0; i < n; i++) {
    var _sum;

    sum[i] = ((_sum = sum[i - 1]) !== null && _sum !== void 0 ? _sum : 0) + a[i];
    max = Math.max(max, sum[i]);
    min = Math.min(min, sum[i]);
  }
  min -= 10, max += 10;
  const segTree = new SegTree(min, max);
  segTree.update(0, 0, 1);
  const map = new Map();
  let dp = [];

  for (let i = 0; i < n; i++) {
    var _map$get, _dp;

    dp[i] = segTree.query(min, sum[i] - 1) + i;
    dp[i] = Math.max(dp[i], (_map$get = map.get(sum[i])) !== null && _map$get !== void 0 ? _map$get : -Infinity, ((_dp = dp[i - 1]) !== null && _dp !== void 0 ? _dp : 0) - 1);
    segTree.update(sum[i], sum[i], dp[i] - i);
    if (!map.has(sum[i]) || map.get(sum[i]) < dp[i] - i + 1) map.set(sum[i], dp[i]);
  }

  console.log(dp[n - 1]); // console.log(res)
  // return res
  // return
}

class SegTree {
  constructor(min, max) {
    this.min = min;
    this.max = max;
    this.root = this._newNode(min, max);
    this.update = this._update.bind(this, this.root);
    this.query = this._query.bind(this, this.root);
  }

  _newNode(l, r, val = -Infinity, left = null, right = null) {
    return {
      val,
      l,
      r,
      left,
      right
    };
  }

  _up(node) {
    var _left$val, _right$val;

    const {
      left,
      right
    } = node; // if (!left || !right) return

    node.val = Math.max((_left$val = left === null || left === void 0 ? void 0 : left.val) !== null && _left$val !== void 0 ? _left$val : -Infinity, (_right$val = right === null || right === void 0 ? void 0 : right.val) !== null && _right$val !== void 0 ? _right$val : -Infinity);
  }

  _update(node, x, y, z) {
    if (!node) return;
    const {
      l,
      r
    } = node;

    if (l === x && r === y) {
      node.val = Math.max(node.val, z);
      return;
    }

    const mid = Math.floor((l + r) / 2);

    if (y <= mid) {
      if (!node.left) node.left = this._newNode(l, mid);

      this._update(node.left, x, y, z);
    } else if (x > mid) {
      if (!node.right) node.right = this._newNode(mid + 1, r);

      this._update(node.right, x, y, z);
    } else {
      if (!node.left) node.left = this._newNode(l, mid);
      if (!node.right) node.right = this._newNode(mid + 1, r);
      this._update(node.left, x, mid, z), this._update(node.right, mid + 1, y, z);
    }

    this._up(node);
  }

  _query(node, x, y) {
    if (y < x) return -Infinity;
    if (!node) return -Infinity;
    const {
      l,
      r
    } = node;
    if (l === x && r === y) return node.val;
    let res = 0,
        mid = Math.floor((l + r) / 2);
    if (y <= mid) res = this._query(node.left, x, y);else if (x > mid) res = this._query(node.right, x, y);else res = Math.max(this._query(node.left, x, mid), this._query(node.right, mid + 1, y));

    this._up(node);

    return res;
  }

}

function main(inputs) {
  const _ = Number(inputs[0]);

  for (let __ = 0; __ < _; __++) {
    const n = Number(inputs[__ * 2 + 1].trim());
    const a = inputs[__ * 2 + 2].trim().split(' ').map(Number);
    solve(n, a);
  }
}

const inputs = fs__default["default"].readFileSync(0, 'utf-8').split('\n');
main(inputs);

'use strict';

var fs = require('fs');

function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }

var fs__default = /*#__PURE__*/_interopDefaultLegacy(fs);

function solve(n, a) {
  const sum = new Array(n).fill(0);
  let max = -Infinity,
      min = Infinity;

  for (let i = 0; i < n; i++) {
    var _sum;

    sum[i] = ((_sum = sum[i - 1]) !== null && _sum !== void 0 ? _sum : 0) + a[i];
    max = Math.max(max, sum[i]);
    min = Math.min(min, sum[i]);
  }
  min -= 10, max += 10;
  const segTree = new SegTree(min, max);
  segTree.update(0, 0, 1);
  const map = new Map();
  let dp = [];

  for (let i = 0; i < n; i++) {
    var _map$get, _dp$i;

    let cur = segTree.query(min, sum[i] - 1);

    if (cur === -Infinity) {
      var _dp, _dp2, _dp3;

      if (a[i] > 0) cur = ((_dp = dp[i - 1]) !== null && _dp !== void 0 ? _dp : 0) + 1;else if (a[i] < 0) cur = ((_dp2 = dp[i - 1]) !== null && _dp2 !== void 0 ? _dp2 : 0) + -1;else cur = (_dp3 = dp[i - 1]) !== null && _dp3 !== void 0 ? _dp3 : 0;
    } else {
      cur += i;
    }

    dp[i] = Math.max(cur, (_map$get = map.get(sum[i])) !== null && _map$get !== void 0 ? _map$get : -Infinity); // res = Math.max(res, cur)

    segTree.update(sum[i], sum[i], dp[i] - i);
    if (!map.has(sum[i]) || map.get(sum[i]) < ((_dp$i = dp[i]) !== null && _dp$i !== void 0 ? _dp$i : -Infinity)) map.set(sum[i], dp[i]);
  }

  console.log(dp[n - 1]); // console.log(res)
  // return res
  // return
}

class SegTree {
  constructor(min, max) {
    this.min = min;
    this.max = max;
    this.root = this._newNode(min, max);
    this.update = this._update.bind(this, this.root);
    this.query = this._query.bind(this, this.root);
  }

  _newNode(l, r, val = -Infinity, left = null, right = null) {
    return {
      val,
      l,
      r,
      left,
      right
    };
  }

  _up(node) {
    const {
      left,
      right
    } = node;
    if (!left || !right) return;
    node.val = Math.max(left.val, right.val);
  }

  _update(node, x, y, z) {
    if (!node) return;
    const {
      l,
      r
    } = node;

    if (l === x && r === y) {
      node.val = Math.max(z);
      return;
    }

    const mid = Math.floor((l + r) / 2);

    if (!node.left) {
      node.left = this._newNode(l, mid);
      node.right = this._newNode(mid + 1, r);
    }

    if (y <= mid) this._update(node.left, x, y, z);else if (x > mid) this._update(node.right, x, y, z);else this._update(node.left, x, mid, z), this._update(node.right, mid + 1, y, z);

    this._up(node);
  }

  _query(node, x, y) {
    if (y < x) return -Infinity;
    if (!node) return -Infinity;
    const {
      l,
      r
    } = node;
    if (l === x && r === y) return node.val;
    let res = 0,
        mid = Math.floor((l + r) / 2);
    if (y <= mid) res = this._query(node.left, x, y);else if (x > mid) res = this._query(node.right, x, y);else res = Math.max(this._query(node.left, x, mid), this._query(node.right, mid + 1, y));

    this._up(node);

    return res;
  }

}

function main(inputs) {
  const _ = Number(inputs[0]);

  for (let __ = 0; __ < _; __++) {
    const n = Number(inputs[__ * 2 + 1].trim());
    const a = inputs[__ * 2 + 2].trim().split(' ').map(Number);
    solve(n, a);
  }
}

const inputs = fs__default["default"].readFileSync(0, 'utf-8').split('\n');
main(inputs);

'use strict';

var fs = require('fs');

function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }

var fs__default = /*#__PURE__*/_interopDefaultLegacy(fs);

function solve(n, a) {
  const sum = new Array(n).fill(0);
  let max = -Infinity,
      min = Infinity;

  for (let i = 0; i < n; i++) {
    var _sum;

    sum[i] = ((_sum = sum[i - 1]) !== null && _sum !== void 0 ? _sum : 0) + a[i];
    max = Math.max(max, sum[i]);
    min = Math.min(min, sum[i]);
  }
  min -= 10, max += 10;
  const segTree = new SegTree(min, max);
  segTree.update(0, 0, 1);
  let dp = [];

  for (let i = 0; i < n; i++) {
    let cur = segTree.query(min, sum[i] - 1);

    if (cur === -Infinity) {
      var _dp;

      if (a[i] >= 0) cur = 1;else cur = -1;
      dp[i] = ((_dp = dp[i - 1]) !== null && _dp !== void 0 ? _dp : 0) + cur;
    } else {
      cur += i;
      dp[i] = cur;
    } // res = Math.max(res, cur)

    segTree.update(sum[i], sum[i], dp[i] - i);
  }

  console.log(dp[n - 1]); // console.log(res)
  // return res
  // return
}

class SegTree {
  constructor(min, max) {
    this.min = min;
    this.max = max;
    this.root = this._newNode(min, max);
    this.update = this._update.bind(this, this.root);
    this.query = this._query.bind(this, this.root);
  }

  _newNode(l, r, val = -Infinity, left = null, right = null) {
    return {
      val,
      l,
      r,
      left,
      right
    };
  }

  _up(node) {
    const {
      left,
      right
    } = node;
    if (!left || !right) return;
    node.val = Math.max(left.val, right.val);
  }

  _update(node, x, y, z) {
    if (!node) return;
    const {
      l,
      r
    } = node;

    if (l === x && r === y) {
      node.val = Math.max(z);
      return;
    }

    const mid = Math.floor((l + r) / 2);

    if (!node.left) {
      node.left = this._newNode(l, mid);
      node.right = this._newNode(mid + 1, r);
    }

    if (y <= mid) this._update(node.left, x, y, z);else if (x > mid) this._update(node.right, x, y, z);else this._update(node.left, x, mid, z), this._update(node.right, mid + 1, y, z);

    this._up(node);
  }

  _query(node, x, y) {
    if (y < x) return -Infinity;
    if (!node) return -Infinity;
    const {
      l,
      r
    } = node;
    if (l === x && r === y) return node.val;
    let res = 0,
        mid = Math.floor((l + r) / 2);
    if (y <= mid) res = this._query(node.left, x, y);else if (x > mid) res = this._query(node.right, x, y);else res = Math.max(this._query(node.left, x, mid), this._query(node.right, mid + 1, y));

    this._up(node);

    return res;
  }

}

function main(inputs) {
  const _ = Number(inputs[0]);

  for (let __ = 0; __ < _; __++) {
    const n = Number(inputs[__ * 2 + 1].trim());
    const a = inputs[__ * 2 + 2].trim().split(' ').map(Number);
    solve(n, a);
  }
}

const inputs = fs__default["default"].readFileSync(0, 'utf-8').split('\n');
main(inputs);


You have an array $$$a_1, a_2, \dots, a_n$$$. All $$$a_i$$$ are positive integers.In one step you can choose three distinct indices $$$i$$$, $$$j$$$, and $$$k$$$ ($$$i \neq j$$$; $$$i \neq k$$$; $$$j \neq k$$$) and assign the sum of $$$a_j$$$ and $$$a_k$$$ to $$$a_i$$$, i. e. make $$$a_i = a_j + a_k$$$.Can you make all $$$a_i$$$ lower or equal to $$$d$$$ using the operation above any number of times (possibly, zero)?

The first line contains a single integer $$$t$$$ ($$$1 \le t \le 2000$$$) — the number of test cases. The first line of each test case contains two integers $$$n$$$ and $$$d$$$ ($$$3 \le n \le 100$$$; $$$1 \le d \le 100$$$) — the number of elements in the array $$$a$$$ and the value $$$d$$$. The second line contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$1 \le a_i \le 100$$$) — the array $$$a$$$.

For each test case, print YES, if it's possible to make all elements $$$a_i$$$ less or equal than $$$d$$$ using the operation above. Otherwise, print NO. You may print each letter in any case (for example, YES, Yes, yes, yEs will all be recognized as positive answer).

NoteIn the first test case, we can prove that we can't make all $$$a_i \le 3$$$.In the second test case, all $$$a_i$$$ are already less or equal than $$$d = 4$$$.In the third test case, we can, for example, choose $$$i = 5$$$, $$$j = 1$$$, $$$k = 2$$$ and make $$$a_5 = a_1 + a_2 = 2 + 1 = 3$$$. Array $$$a$$$ will become $$$[2, 1, 5, 3, 3]$$$.After that we can make $$$a_3 = a_5 + a_2 = 3 + 1 = 4$$$. Array will become $$$[2, 1, 4, 3, 3]$$$ and all elements are less or equal than $$$d = 4$$$.

/*
 * File Created: Thursday, 14th January 2021 3:54:21 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(readLine(), 10);

    while(testCases--) {

        const nd = readLine().split(' ');

        const n = parseInt(nd[0]);
        const d = parseInt(nd[1]);
        const arr = readLine().split(' ').map(Number);
        const res = a(n,d, arr);
        console.log(res);
    }
});

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

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

function a(n, d, arr){

    arr.sort((a,b) => a - b);
    // console.log(arr)
    for(let i = 0; i < n ; i++){
        if(arr[i] <= d) continue;
        if(arr[i] > d){
            if(arr[0] + arr[1] <= d && i !== 0 && i !== 1 ){
                continue;
            }
            if(i === 0){
                if(arr[1] + arr[2] <= d) continue;
            }
            if(i === 1){
                if(arr[0] + arr[2] <= d) continue;
            }
        }
        return 'NO'
    }
    return 'YES'
}

module.exports = a;

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

let c = 0;
let target;

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

  if (c % 2 === 1) {
    c++;
    target = d.split(" ").map(Number)[1];
    return;
  }

  const arr = d
    .split(" ")
    .map(Number)
    .sort((a, b) => a - b);

  let count = 0;
  for (let i = 1; i < arr.length; i++) {
    if (arr[i] + arr[i - 1] <= target) {
      count++;
    }
  }

  if (count) {
    console.log("YES");
  } else {
    if (arr[arr.length - 1] <= target) {
      console.log("YES");
    } else {
      console.log("NO");
    }
  }
  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 t = lines[0];
	var e = 0;
	var w = 0;
    for(i = 1; i <= t * 2; i++){
        var k = lines[i].split(' ').map(Number);
        if(i % 2 == 1){
            e = k[0];
            w = k[1];
        }else{
            var v1 = [];
            var v2 = [];
            for(j = 0; j < e; j++){
                if(k[j] <= w){
                    v1.push(k[j]);
                }else{
                    v2.push(k[j]);
                }
            }
            if(v2.length === 0){
                console.log('YES');
            }else{
                v1.sort(function(a, b){return a - b});
                if(v1.length >= 2){
                    if(v1[0] + v1[1] <= w){
                        console.log('YES');
                    }else{
                        console.log('NO');
                    }
                }else{
                    console.log('NO');
                }
            }
        }
    }
});

process.stdin.resume();
process.stdin.setEncoding('utf-8');
let inputString = '';
let currentLine = 0;
process.stdin.on('data', inputStdin => {
    inputString += inputStdin;
});
function readLine() {
    return inputString[currentLine++];
};
process.stdin.on('end', _ => {
    inputString = inputString.trim().split('\n').map(string => {
        return string.trim();
    });
    main();
    // cmd(not powershell): node cp.js < input.txt
});

function main() {
    let t = parseInt(readLine());
    while (t-- > 0) {
        solve();
    }
}
function solve() {
    const [n, d] = readLine().split(" ").map(i => parseInt(i));
    let min = 1001;
    let min2 = min;
    let arr = readLine().split(" ").map(i => parseInt(i)).sort((a, b) => a - b);;
    if (arr[arr.length - 1] <= d) console.log("YES");
    else {
        min = arr[0];
        min2 = arr[1];
        if (min + min2 <= d) {
            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 [n, d] = nl.nums();
		let a = nl.nums();
		a.sort((a, b) => a - b);
		ans.push(a[0] + a[1] <= d || a[n - 1] <= d);
	}
	console.log(ans.map(e => e?'YES':'NO').join('\n'));
};

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

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

let input = [];
rl.on("line", function(line) {
    input.push(line);
}).on("close", function() {
    solution(input);
    process.exit();
});

function solution(input) {
    const array = input.slice(1).map(v => v.split(" ").map(val => Number(val)));
    let d = 0;

    for(let idx in array) {
        if(idx % 2 === 0) d = array[idx][1];
        else {
            let cnt = 0;
            const arr = array[idx];
            for(let val of arr) {
                if(val <= d) cnt++;
            }

            if(cnt === arr.length) console.log("YES");
            else {
                let isLess = false;
                for(let i=0; i<arr.length; i++) {
                    for(let j=i+1; j<arr.length; j++) {
                        if(arr[i] + arr[j] <= d) {
                            isLess = true;
                            break;
                        }
                    }
                }

                isLess ? console.log("YES") : console.log("NO");
            }
        }
    }
}

// define file test.inp
process.stdin.resume();
process.stdin.setEncoding("utf8");

var jsin = "";
var jscur = 0;

process.stdin.on('data',chunk => jsin += chunk);
process.stdin.on('end',function(){
    jsin = jsin.split('\n')
    main();
});

readLine = () => jsin[jscur++];
readLines = () => readLine().split(' ');
readInt = () => +(readLine());
readInts = () => readLine().split(' ').map(x => +(x));

function main(){
    // code goes here!!
    var nTest = readInt();
    for(let test = 0;test < nTest;++test){
        let [n,d] = readInts();
        let a = readInts().filter(val => val <= d).sort((x,y) => {
            return x - y;
        });
        if(a.length == n){
            console.log("YES");
        } else if(a.length > 1 && a[0] + a[1] <= d){
            console.log("YES");
        } else {
            console.log("NO");
        }
    }
}

const replace = (a, d) => {
  let first = Infinity;
  let second = Infinity;
  let third = 0;
  for (let i = 0; i < a.length; i++) {
    if (a[i] < first) {
      second = first;
      first = a[i];
    } else if (a[i] < second) {
      second = a[i];
    }
    third = Math.max(third, a[i]);
  }
  return third <= d || first + second <= d;
};

const main = () => {
  let test = parseInt(readline());
  while (test--) {
    const [n, d] = readline()
      .split(" ")
      .map(s => parseInt(s));
    const a = readline()
      .split(" ")
      .map(s => parseInt(s));
    if (replace(a, d)) console.log("YES");
    else console.log("NO");
  }
};

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 => string.trim());
  main();
});

const readline = () => {
  return inputString[currentLine++];
};

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

//Don't have to see. end------------------------------------------
function Main(){
	var t = nextInt();
	for(var i = 0; i < t; i++){
		var N = nextInt();
		var d = nextInt();
		var list = nextIntArray(N);
		var isOK = true;
		for(var j = 0; j < N; j++){
			if(list[j] > d){
				isOK = false;
			}
		}
		if(isOK){
			myout("YES");
			continue;
		}
		list.sort(function(a,b){
			return a - b;
		});
		if(list[0] + list[1] <= d){
			myout("YES");
		}else{
			myout("NO");
		}
	}
}

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

function main() {
  const numArray = (a) => a.split(" ").map((line) => +line),
    isEven = (a) => (a % 2 == 0 && a > 1 ? true : false),
    cl = console.log,
    rl = readLine,
    tc = rl();

  for (let i = 0; i < tc; i++) {
    const [ln1, ln2] = rl().split(" ");
    const ln3 = numArray(rl()).sort((a, b) => a - b);
    solution(ln1, ln2, ln3);
  }
  /************************Solution****************************************/
  function solution(n, d, arr) {
    if (arr[n - 1] <= d) {
      cl("Yes");
      return;
    }
    for (let i = 0; i < n; i++) {
      arr[n - 1] = arr[0] + arr[1];
    }
    // while (arr[n - 1] > d) {
    //   console.log(arr[n - 1]);
    // }
    if (arr[n - 1] <= d) {
      cl("Yes");
      return;
    } else cl("No");
    // console.log(n, d, arr);
  }
}

'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 = []

    // console.log(Number(x))
    // 1 1 7
    // 6 9, 15, 18
    Array(Number(x)).fill(1).map((t, i) => {
        var [n, d] = readline().split(' ');
        var ans = 99999
        var ans2 = 99999
        var index1 = 0
        var index2 = 0
        var isOk = true
        var array = readline().split(' ').map((x, i) => {
            if (Number(x) > d) isOk = false
            return Number(x)
        });
        if (isOk) return console.log('YES')
        array.map((x, i) => {
            if (x < ans) {
                ans = x
                index1 = i
            }
        })
        array.map((x, i) => {
            if (x < ans2 && index1 !== i) {
                ans2 = x
                index2 = i
            }
        })
        if (ans + ans2 <= d) return console.log('YES')
        return console.log('NO')

    })

}

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

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

function main() {
	let t = +readLine();
	while (t--) {
		const [len, target] = readLine().split(' ').map(Number);
		const arr = readLine().split(' ').map(Number);
		let allSmall = true;
		arr.sort((a, b) => a - b);
		for (let i = 0; i < len; i++) {
			if (arr[i] > target) allSmall = false;
		}
		const [a, b] = [arr[0], arr[1]];
		if (a + b <= target || allSmall) {
			console.log('YES');
		} else {
			console.log('NO');
		}
	}
}

T=+readline();
while(T--)
{
    nd=readline().split(' ');
    n= parseInt(nd[0]);
    d= parseInt(nd[1]);
    arr=readline().split(' ').map(x=>+x);
    arr.sort(function(a,b){
        return a-b;
      });

    if(arr[n-1]<=d){
        print("YES");
    }
    else{

       // console.log(arr);
        if((arr[0]+arr[1])<=d){
            print("YES");

        }
        else {
            print("NO");
        }
    }
}

var t = +readline();

for (var i = 0; i < t; i++) {
  var s = readline().split(" ").map(i => +i);
  var d = s[1];
  var ar = readline().split(" ").map(i => +i);

  ar.sort(function(a, b){return a-b});

  if (ar[s[0] - 1] <= d || ar[0] + ar[1] <= d) {
    print( "YES");
  } else {
    print("NO");
  }
}

var t = +readline();

for (var i = 0; i < t; i++) {
  var s = readline().split(" ").map(i => +i);
  var d = s[1];
  var a = readline().split(" ").map(i => +i);

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

  if (a[a.length - 1] > d) {
    print(a[0] + a[1] <= d ? "YES" : "NO");
  } else {
    print("YES");
  }
}

'use strict'

let t = readline(1);
    while(t--)
    {
        let nd = readline().split(" ");
        let n = +nd[0], d = +nd[1];
        let a = readline("1 6 2 5 2 10").split(" "), b = [];
        for(let i = 0; i < n; i++)b[i] = a[i];
        b.sort((x,y) => x - y);
        let c;
        if(b[n-1] <= d)c = true;
        else if(+b[0] + +b[1] <= d)c = true;
        else c = false;
        print(c? "YES" : "NO");
    }

T = +readline();
while(T--){
    nd =readline().split(' ').map(x=>+x);
    n=nd[0];
    d=nd[1];

    arr =readline().split(' ').map(x=>+x);
    arr.sort((a,b)=>a-b);
    if(arr[n-1]<=d)
       print('YES');
    else if(arr[0]+arr[1]<=d)
     print('YES');
     else print('NO');

}

// var ar = readline().split(' ').map(n => parseInt(n));

var t = parseInt(readline());

while (t--) {
  var ar = readline()
    .split(" ")
    .map((n) => parseInt(n));

  var n = ar[0];
  var k = ar[1];

  var arr = readline()
    .split(" ")
    .map((a) => parseInt(a));

  var sortedArr = arr.sort((a, b) => a - b);
  if (sortedArr[sortedArr.length - 1] <= k) {
    print("yes");
  } else {
    if (sortedArr[0] + sortedArr[1] <= k) {
      print("yes");
    } else {
      print("no");
    }
  }
}

"use strict"

let iter = parseInt(readline());

for(iter; iter > 0; iter--){
    let input = readline().split(" ").map(x => parseInt(x));
    let length = input[0];
    let d = input[1]
    let arr = readline().split(" ").map(x => parseInt(x));
    arr.sort((a, b) => a - b);

    if(arr[length - 1] <= d){
        print("YES");
    } else {
        if(arr[0] + arr[1] <= d){
            print("YES");
        } else {
            print("NO");
        }
    }
}

/*
 * File Created: Thursday, 14th January 2021 3:54:21 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(readLine(), 10);

    while(testCases--) {

        const nd = readLine().split(' ');

        const n = parseInt(nd[0]);
        const d = parseInt(nd[1]);
        const arr = readLine().split(' ').map(Number);
        const res = a(n,d, arr);
        console.log(res);

        console.log(res)
    }
});

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

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

function a(n, d, arr){

    arr.sort((a,b) => a - b);
    // console.log(arr)
    for(let i = 0; i < n ; i++){
        if(arr[i] <= d) continue;
        if(arr[i] > d){
            if(arr[0] + arr[1] <= d && i !== 0 && i !== 1 ){
                continue;
            }
            if(i === 0){
                if(arr[1] + arr[2] <= d) continue;
            }
            if(i === 1){
                if(arr[0] + arr[2] <= d) continue;
            }
        }
        return 'NO'
    }
    return 'YES'
}

module.exports = a;

/*
 * File Created: Thursday, 14th January 2021 3:54:21 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(readLine(), 10);

    while(testCases--) {

        const nd = readLine().split(' ');

        const n = parseInt(nd[0]);
        const d = parseInt(nd[1]);
        const arr = readLine().split(' ').map(Number);
        const res = a(n,d, arr);
        console.log(res);

        console.log(res)
    }
});

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

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

function a(n, d, arr){

    arr.sort((a,b) => a - b);
    // console.log(arr)
    for(let i = 0; i < n ; i++){
        if(arr[i] <= d) continue;
        if(arr[i] > d){
            if(arr[0] + arr[1] <= d && i !== 0 && i !== 1 ){
                continue;
            }
            if(i === 0){
                if(arr[1] + arr[2] <= d) continue;
            }
            if(i === 1){
                if(arr[0] + arr[2] <= d) continue;
            }
            return 'NO'
        }
    }
    return 'YES'
}

module.exports = a;

'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(readLine(), 10);

    while(testCases--) {

        const nd = readLine().split(' ');

        const n = parseInt(nd[0]);
        const d = parseInt(nd[1]);
        const arr = readLine().split(' ').map(Number);
        const res = a(n,d, arr);
        console.log(res);

        console.log(res)
    }
});

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

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

function a(n, d, arr){

    arr.sort((a,b) => a - b);
    console.log(arr)
    for(let i = 0; i < n ; i++){
        if(arr[i] <= d) continue;
        if(arr[i] > d){
            if(arr[0] + arr[1] <= d && i !== 0 && i !== 1 ){
                continue;
            }
            if(i === 0){
                if(arr[1] + arr[2] <= d) continue;
            }
            if(i === 1){
                if(arr[0] + arr[2] <= d) continue;
            }
            return 'NO'
        }
    }
    return 'YES'
}

module.exports = a;

'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(readLine(), 10);

    while(testCases--) {

        const nd = readLine().split(' ');

        const n = parseInt(nd[0]);
        const d = parseInt(nd[1]);
        const arr = readLine().split(' ').map(Number);
        const res = a(n,d, arr);
        console.log(res);

        console.log(res)
    }
});

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

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

function a(n, d, arr){

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

    if(arr[0] + arr[1] > d){
        return 'NO'
    } else {
        return 'YES'
    }
}

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

let c = 0;
let target;

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

  if (c % 2 === 1) {
    c++;
    target = d.split(" ").map(Number)[1];
    return;
  }

  const arr = d
    .split(" ")
    .map(Number)
    .sort((a, b) => a - b);

  let count = 0;
  const visited = {};
  for (let i = 0; i < arr.length; i++) {
    if (arr[i] <= target) {
      if (!visited[arr[i]]) {
        count++;
      }
    }

    visited[arr[i]] = true;
  }

  if (count > 2) {
    console.log("YES");
  } else if (arr.length >= 3 && arr[arr.length - 1] <= target) {
    console.log("YES");
  } else {
    console.log("NO");
  }
  c++;
});

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

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

let c = 0;
let target;

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

  if (c % 2 === 1) {
    c++;
    target = d.split(" ").map(Number)[1];
    return;
  }

  const arr = d
    .split(" ")
    .map(Number)
    .sort((a, b) => a - b);

  let count = 0;
  const visited = {};
  for (let i = 0; i < arr.length; i++) {
    if (arr[i] <= target) {
      if (!visited[arr[i]]) {
        count++;
      }
    }

    visited[arr[i]] = true;
  }

  if (count > 2) {
    console.log("YES");
  } else if (arr.length >= 3 && arr[arr.length - 1] === target) {
    console.log("YES");
  } else {
    console.log("NO");
  }
  c++;
});

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

T=+readline();
while(T--)
{
    nd=readline();
    n= parseInt(nd[0]);
    d= parseInt(nd[2]);
    arr=readline().split(' ').map(function(x){
        return parseInt(x);
    })
    arr.sort(function(a,b){
        return a-b;
      });

    if(arr[n-1]<=d){
        print("YES");
    }
    else{

       // console.log(arr);
        if((arr[0]+arr[1])<=d){
            print("YES");

        }
        else {
            print("NO");
        }
    }
}

T=+readline();
while(T--)
{
    nd=readline();
    n= parseInt(nd[0]);
    d= parseInt(nd[2]);
    arr=readline().split(' ').map(function(x){
        return parseInt(x);
    })

    if(arr[n-1]<=d){
        print("YES");
    }
    else{
        arr.sort(function(a,b){
          return a-b;
        });
       // console.log(arr);
        if((arr[0]+arr[1])<=d){
            print("YES");

        }
        else {
            print("NO");
        }
    }
}

T=+readline();
while(T--)
{
    nd=readline();
    n= parseInt(nd[0]);
    d= parseInt(nd[2]);
    arr=readline().split(' ').map(function(x){
        return parseInt(x);
    })
    var c=0;
    for(var i=0;i<n;i++){
        if(arr[i]<=d)
        {
            c++;

        }
    }
    if(c==n){
        print("YES");
    }
    else{
        arr.sort(function(a,b){
          return a-b;
        });
        //console.log(arr);
        if((arr[0]+arr[1])<=d){
            print("YES");

        }
        else {
            print("NO");
        }
    }
}

T=+readline();
while(T--)
{
    nd=readline();
    n= parseInt(nd[0]);
    d= parseInt(nd[2]);
    arr=readline().split(' ').map(function(x){
        return parseInt(x);
    })
    var c=0;
    for(var i=0;i<n;i++){
        if(arr[i]<=d)
        {
            c++;

        }
    }
    if(c===n){
        print("YES");
    }
    else{
        arr.sort(function(a,b){
          return a-b;
        });

        if(arr[0]+arr[1]<=d){
            print("YES");

        }
        else {
            print("NO");
        }
    }
}

T=+readline();
while(T--)
{
    nd=readline();
    n= parseInt(nd[0]);
    d= parseInt(nd[2]);
    arr=readline().split(' ').map(function(x){
        return parseInt(x);
    })
    var c=0;
    for(var i=0;i<n;i++){
        if(arr[i]<=d)
        {
            c++;

        }
    }
    if(c==n){
        print("YES");
    }
    else{
        arr.sort(function(a,b){
          return a-b;
        });

        if(arr[0]+arr[1]<=d){
            print("YES");

        }
        else {
            print("NO");
        }
    }
}

var t = +readline();

for (var i = 0; i < t; i++) {
  var s = readline().split(" ").map(i => +i);
  var d = s[1];
  var a = readline().split(" ").map(i => +i);

  a.sort(function(b, c) {
      return +b > +c;
  });

  if (a[s[0] - 1] <= d || a[0] + a[1] <= d) {
    print( "YES");
  } else {
    print("NO");
  }
}

var t = +readline();

for (var i = 0; i < t; i++) {
  var s = readline().split(" ").map(i => +i);
  var d = s[1];
  var a = readline().split(" ").map(i => +i);

  a.sort(function(a, b) {
      return +a > +b;
  });

  if (a[s[0] - 1] <= d || a[0] + a[1] <= d) {
    print( "YES");
  } else {
    print("NO");
  }
}

var t = +readline();

for (var i = 0; i < t; i++) {
  var s = readline().split(" ").map(i => +i);
  var d = s[1];
  var a = readline().split(" ").map(i => +i);

  var a = a.sort();

  if (a[s[0] - 1] <= d || a[0] + a[1] <= d) {
    print( "YES");
  } else {
    print("NO");
  }
}

var t = +readline();

for (var i = 0; i < t; i++) {
  var s = readline().split(" ").map(i => +i);
  var d = s[1];
  var a = readline().split(" ").map(i => +i);

  var a = a.sort();

  if (a[a.length - 1] <= d || a[0] + a[1] <= d) {
    print("YES");
  } else {
    print("NO");
  }
}

var t = +readline();

for (var i = 0; i < t; i++) {
  var s = readline().split(" ").map(i => +i);
  var d = s[1];
  var a = readline().split(" ").map(i => +i);

  var a = a.sort();

  if (a[a.length - 1] >= d) {
    print(a[0] + a[1] <= d ? "YES" : "NO");
  } else {
    print("YES");
  }
}

var t = +readline();

for (var i = 0; i < t; i++) {
  var s = readline().split(" ").map(i => +i);
  var d = s[1];
  var a = readline().split(" ").map(i => +i);

  var a = a.sort();

  if (a[a.length - 1] > d) {
    print(a[0] + a[1] <= d ? "YES" : "NO");
  } else {
    print("YES");
  }
}

var t = +readline();

for (var i = 0; i < t; i++) {
  var s = readline().split(" ").map(i => +i);
  var d = s[1];
  var a = readline().split(" ").map(i => +i);

  var a = a.sort();

  if (a[a.length - 1] > d) {
    print(a[0] + a[1] < d ? "YES" : "NO");
  } else {
    print("YES");
  }
}

var t = +readline();

for (var i = 0; i < t; i++) {
  var s = readline().split(" ").map(i => +i);
  var d = s[1];
  var a = readline().split(" ").map(i => +i);

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

  if (a[a.length - 1] >= d) {
    print(a[0] + a[1] <= d ? "YES" : "NO");
  } else {
    print("YES");
  }
}

'use strict'

let t = readline(1);
    while(t--)
    {
        let nd = readline().split(" ");
        let n = +nd[0], d = +nd[1];
        let a = readline("1 6 2 5 2 10").split(" "), b = [];
        for(let i = 0; i < n; i++)b[i] = a[i];
        b.sort();
        let c;
        if(b[n-1] <= d)c = true;
        else if(+b[0] + +b[1] <= d)c = true;
        else c = false;
        print(c? "YES" : "NO");
    }


Vasya has got $$$n$$$ books, numbered from $$$1$$$ to $$$n$$$, arranged in a stack. The topmost book has number $$$a_1$$$, the next one — $$$a_2$$$, and so on. The book at the bottom of the stack has number $$$a_n$$$. All numbers are distinct.Vasya wants to move all the books to his backpack in $$$n$$$ steps. During $$$i$$$-th step he wants to move the book number $$$b_i$$$ into his backpack. If the book with number $$$b_i$$$ is in the stack, he takes this book and all the books above the book $$$b_i$$$, and puts them into the backpack; otherwise he does nothing and begins the next step. For example, if books are arranged in the order $$$[1, 2, 3]$$$ (book $$$1$$$ is the topmost), and Vasya moves the books in the order $$$[2, 1, 3]$$$, then during the first step he will move two books ($$$1$$$ and $$$2$$$), during the second step he will do nothing (since book $$$1$$$ is already in the backpack), and during the third step — one book (the book number $$$3$$$). Note that $$$b_1, b_2, \dots, b_n$$$ are distinct.Help Vasya! Tell him the number of books he will put into his backpack during each step.

The first line contains one integer $$$n~(1 \le n \le 2 \cdot 10^5)$$$ — the number of books in the stack. The second line contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n~(1 \le a_i \le n)$$$ denoting the stack of books. The third line contains $$$n$$$ integers $$$b_1, b_2, \dots, b_n~(1 \le b_i \le n)$$$ denoting the steps Vasya is going to perform. All numbers $$$a_1 \dots a_n$$$ are distinct, the same goes for $$$b_1 \dots b_n$$$.

Print $$$n$$$ integers. The $$$i$$$-th of them should be equal to the number of books Vasya moves to his backpack during the $$$i$$$-th step.

NoteThe first example is described in the statement.In the second example, during the first step Vasya will move the books $$$[3, 1, 4]$$$. After that only books $$$2$$$ and $$$5$$$ remain in the stack ($$$2$$$ is above $$$5$$$). During the second step Vasya will take the books $$$2$$$ and $$$5$$$. After that the stack becomes empty, so during next steps Vasya won't move any books.

var n = +readline();
var a = readline().split(' ').map(v=>+v);
var b = readline().split(' ').map(v=>+v);

var c = [], res = [];
for(var i = 0; i < n; i++) {
    c[a[i]] = i;
}

var highPos = -1;

for(var i = 0; i < n; i++) {
    var pos = c[b[i]];
    res.push(Math.max(0, pos - highPos));
    highPos = Math.max(highPos, pos);
}

print(res.join(' '));