'use strict';

function solve(n, a) {
  if (n & 1) return 'Mike';
  let min = Math.min(...a);
  for (let i = 0; i < n; i++) {
    if (a[i] === min) {
      return i & 1 ? 'Mike' : 'Joe';
    }
  }
}

async function main(read) {
  try {
    let t = Number(await read());
    let res = new Array(t);
    for (let i = 0; i < t; i++) {
      const n = Number(await read());
      const a = (await read()).split(' ').map(Number);
      res[i] = solve(n, a);
    }
    return res.join('\n');
  } catch (error) {
    console.log(error);
  }
}

let inputs,
    str = '';
function read() {
  return inputs.next().value.trim();
}
process.stdin.resume();
process.stdin.setEncoding('utf8');
process.stdin.on('data', input => str += input);
process.stdin.on('end', async () => {
  inputs = str.split('\n').values();
  const output = await main(read);
  process.stdout.write(output);
});

'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 output(x) {
    //process.stdout.write(x);   // without auto '\n' (newline)
    console.log(x);  // with auto '\n' (newline)
}

function main() {
    let N = readline();

    for (let i = 0; i < N; i++) {
        let piles = parseInt(readline(), 10);
        let sizes = readline().split(' ').map(Number);
        if (piles % 2 === 1) {
            output('Mike');
            continue;
        }

        let mike = Infinity;
        let joe = Infinity;
        for (let j = 0; j < piles; j++) {
            if (j % 2 === 0 && sizes[j] < mike) {
                mike = sizes[j];
            }
            if (j % 2 === 1 && sizes[j] < joe) {
                joe = sizes[j];
            }
        }

        if (mike === joe) {
            const firstMaxIndex = sizes.findIndex(l => l === mike);
            if (firstMaxIndex % 2 === 0) {
                output('Joe');
            } else {
                output('Mike');
            }
            continue;
        }

        output(mike > joe ? 'Mike' : 'Joe');
    }
}

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

/***
Codeforces Round #801 (Div. 2) and EPIC Institute of Technology Round
2022-06-18

B. Circle Game
***/

function main() {
  const t = parseInt(readline());
  for (let i = 0; i < t; i++) {
    const n = parseInt(readline());
    let start = readline();
    start = start.split(" ");
    start = start.map((k) => parseInt(k));

    if (n % 2 == 1) {
      // If n is odd then Mike wins because he can always take the
      // first pile so Joe loses when we loop round.
      console.log("Mike");
    } else {
      let mikeSmallest = 1e10;
      let mikeSmallestLoc;
      let joeSmallest = 1e10;
      let joeSmallestLoc;
      // If n is even, each player wants to conserve their own
      // stones, so they will always take a single stone at a time.
      // So the loser is the one with the smallest pile (first to
      // come across it if tied).
      for (let pile = 0; pile < n; pile += 2) {
        if (start[pile] < mikeSmallest) {
          mikeSmallest = start[pile];
          mikeSmallestLoc = pile;
        }
      }

      for (let pile = 1; pile < n; pile += 2) {
        if (start[pile] < joeSmallest) {
          joeSmallest = start[pile];
          joeSmallestLoc = pile;
        }
      }

      if (mikeSmallest < joeSmallest) {
        console.log("Joe");
      } else if (mikeSmallest > joeSmallest) {
        console.log("Mike");
      } else {
        console.log(mikeSmallestLoc < joeSmallestLoc ? "Joe" : "Mike");
      }
    }
  }
}

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

/***
Codeforces Round #801 (Div. 2) and EPIC Institute of Technology Round
2022-06-18

B. Circle Game
***/

function main() {
  const t = parseInt(readline());
  for (let i = 0; i < t; i++) {
    const n = parseInt(readline());
    let start = readline();
    start = start.split(" ");
    start = start.map((k) => parseInt(k));

    if (n % 2 == 1) {
      // If n is odd then Mike wins because he can always take the
      // first pile so Joe loses when we loop round.
      console.log("Mike");
    } else {
      let mikeSmallest = 1e10;
      let joeSmallest = 1e10;
      // If n is even, each player wants to conserve their own
      // stones, so they will always take a single stone at a time.
      // So the loser is the one with the smallest pile (Mike if
      // tied).
      for (let pile = 0; pile < n; pile += 2) {
        if (start[pile] < mikeSmallest) {
          mikeSmallest = start[pile];
        }
      }

      for (let pile = 1; pile < n; pile += 2) {
        if (start[pile] < joeSmallest) {
          joeSmallest = start[pile];
        }
      }

      if (mikeSmallest < joeSmallest) {
        console.log("Mike");
      } else {
        console.log("Joe");
      }
    }
  }
}

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

/***
Codeforces Round #801 (Div. 2) and EPIC Institute of Technology Round
2022-06-18

B. Circle Game
***/

function main() {
  const t = parseInt(readline());
  for (let i = 0; i < t; i++) {
    const n = parseInt(readline());
    let start = readline();
    start = start.split(" ");
    start = start.map((k) => parseInt(k));

    if (n % 2 == 1) {
      // If n is odd then Mike wins because he can always take the
      // first pile so Joe loses when we loop round.
      console.log("Mike");
    } else {
      let mikeSmallest = 1e10;
      let joeSmallest = 1e10;
      // If n is even, each player wants to conserve their own
      // stones, so they will always take a single stone at a time.
      // So the loser is the one with the smallest pile (Mike if
      // tied).
      for (let pile = 0; pile < n; pile += 2) {
        if (start[pile] < mikeSmallest) {
          mikeSmallest = start[pile];
        }
      }

      for (let pile = 1; pile < n; pile += 2) {
        if (start[pile] < joeSmallest) {
          joeSmallest = start[pile];
        }
      }

      if (mikeSmallest <= joeSmallest) {
        console.log("Joe");
      } else {
        console.log("Mike");
      }
    }
  }
}

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

/***
Codeforces Round #801 (Div. 2) and EPIC Institute of Technology Round
2022-06-18

B. Circle Game
***/

function main() {
  const t = parseInt(readline());
  for (let i = 0; i < t; i++) {
    const n = parseInt(readline());
    readline();
    // Strategy: The optimal move is always to remove all the stones
    // so the opponent can't play there next time and loses.
    console.log(n % 2 == 0 ? "Joe" : "Mike");
  }
}

'use strict';

function solve(n, a) {
  const res = a.reduce((a, b) => a ^ b, 0);
  return res > 0 ? 'Mike' : 'Joe';
}

async function main(read) {
  try {
    let t = Number(await read());
    let res = new Array(t);
    for (let i = 0; i < t; i++) {
      const n = Number(await read());
      const a = (await read()).split(' ').map(Number);
      res[i] = solve(n, a);
    }
    return res.join('\n');
  } catch (error) {
    console.log(error);
  }
}

let inputs,
    str = '';
function read() {
  return inputs.next().value.trim();
}
process.stdin.resume();
process.stdin.setEncoding('utf8');
process.stdin.on('data', input => str += input);
process.stdin.on('end', async () => {
  inputs = str.split('\n').values();
  const output = await main(read);
  process.stdout.write(output);
});

'use strict';

function solve(n, a) {
  const res = a.reduce((a, b) => a ^ b, 0);
  return res & 1 ? 'Mike' : 'Joe';
}

async function main(read) {
  try {
    let t = Number(await read());
    let res = new Array(t);
    for (let i = 0; i < t; i++) {
      const n = Number(await read());
      const a = (await read()).split(' ').map(Number);
      res[i] = solve(n, a);
    }
    return res.join('\n');
  } catch (error) {
    console.log(error);
  }
}

let inputs,
    str = '';
function read() {
  return inputs.next().value.trim();
}
process.stdin.resume();
process.stdin.setEncoding('utf8');
process.stdin.on('data', input => str += input);
process.stdin.on('end', async () => {
  inputs = str.split('\n').values();
  const output = await main(read);
  process.stdout.write(output);
});

'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 output(x) {
    //process.stdout.write(x);   // without auto '\n' (newline)
    console.log(x);  // with auto '\n' (newline)
}

function main() {
    let N = readline();

    for (let i = 0; i < N; i++) {
        let piles = parseInt(readline(), 10);
        let sizes = readline().split(' ').map(Number);
        if (piles % 2 === 1) {
            output('Mike');
            continue;
        }

        let mike = Infinity;
        let joe = Infinity;
        for (let j = 0; j < piles; j++) {
            if (j % 2 === 0 && sizes[j] < mike) {
                mike = sizes[j];
            }
            if (j % 2 === 1 && sizes[j] < joe) {
                joe = sizes[j];
            }
        }

        output(mike > joe ? 'Mike' : 'Joe');
    }
}

'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 output(x) {
    //process.stdout.write(x);   // without auto '\n' (newline)
    console.log(x);  // with auto '\n' (newline)
}

function main() {
    let N = readline();

    for (let i = 0; i < N; i++) {
        let piles = readline();
        readline(); // stones array

        output(piles % 2 === 1 ? 'Mike' : 'Joe');
    }
}


// Generated by CoffeeScript 1.7.1
(function() {
  var find, found, i, m, money, n, people, request, requests, seat, seats, tables, totalMoney, _i, _j, _k, _len, _len1, _ref;

  n = Number(readline());

  requests = [];

  for (i = _i = 1; 1 <= n ? _i <= n : _i >= n; i = 1 <= n ? ++_i : --_i) {
    _ref = readline().split(' ').map(Number), people = _ref[0], money = _ref[1];
    requests.push({
      people: people,
      money: money,
      number: i
    });
  }

  m = Number(readline());

  tables = readline().split(' ').map(function(x, i) {
    return {
      size: Number(x),
      number: i + 1,
      taken: false
    };
  });

  requests.sort(function(a, b) {
    if (a.money > b.money) {
      return -1;
    } else {
      return 1;
    }
  });

  tables.sort(function(a, b) {
    if (a.size > b.size) {
      return 1;
    } else {
      return -1;
    }
  });

  find = function(array, el, a, b) {
    var c, _ref1, _ref2;
    if (a == null) {
      a = 0;
    }
    if (b == null) {
      b = array.length - 1;
    }
    if (a === b) {
      while ((_ref1 = array[a]) != null ? _ref1.taken : void 0) {
        a++;
      }
      if (a >= array.length) {
        return null;
      }
      if (array[a].size >= el) {
        array[a].taken = true;
        return array[a];
      }
    } else {
      if (el <= array[c = Math.floor((a + b) / 2)].size) {
        return find(array, el, a, c);
      } else if (el >= array[c = Math.ceil((a + b) / 2)].size) {
        return find(array, el, c, b);
      } else {
        while ((_ref2 = array[c]) != null ? _ref2.taken : void 0) {
          c++;
        }
        if (c >= array.length) {
          return null;
        }
        array[c].taken = true;
        return array[c];
      }
    }
  };

  seats = [];

  totalMoney = 0;

  for (_j = 0, _len = requests.length; _j < _len; _j++) {
    request = requests[_j];
    found = find(tables, request.people);
    if (found != null) {
      seats.push({
        table: found.number,
        request: request.number
      });
      totalMoney += request.money;
    }
  }

  print(seats.length + ' ' + totalMoney);

  for (_k = 0, _len1 = seats.length; _k < _len1; _k++) {
    seat = seats[_k];
    print(seat.request + ' ' + seat.table);
  }

}).call(this);

print(function(n){
	var n = +readline();
	var ans = [];
	var a = [];
	for(var i=0; i<n; i++){
		var x = rn();
		x.push(i+1);
		a.push(x);
	}
	a.sort(function(a, b){
		if(a[1]===b[1]) return b[0]-a[0];
		return b[1]-a[1];
	});

	var k = +readline();
	var r = rn();
	r = r.map(function(v, i){
		return [v, i+1, true];
	});
	r.sort(function(a, b){ return a[0]-b[0];});
	var sum = 0;
	for(var i=0; i<n; i++){
		for(var j=0; j<k; j++){
			if(r[j][2] && r[j][0]>=a[i][0]){
				r[j][2] = false;
				ans.push(a[i][2]+' '+r[j][1]);
				sum += a[i][1];
				break;
			}
		}
	}
	if(ans.length==0) return ans.length+' '+sum;
	return ans.length+' '+sum+'\n'+ans.join('\n');
}());
function rn() { return readline().split(' ').map(Number); }

print(function(n) {
     var n=+readline();
     var ans=[];
     var a=[];
     for(var i=0; i<n; ++i) {
          var x=rn();
          x.push(i+1);
          a.push(x);
     }
     a.sort(function(a, b) {
          if(a[1]===b[1]) return b[0]-a[0];
          return b[1]-a[1];
     });
     var k= +readline();
     var r=rn();
     r=r.map(function(v, i) {
          return [v, i+1, true];
     });
     r.sort(function(a, b) {return a[0]-b[0];});
     var sum=0;
     for(var i=0; i<n; ++i) {
          for(var j=0; j<k; ++j) {
               if(r[j][2]&&r[j][0]>=a[i][0]) {
                    r[j][2]=false;
                    ans.push(a[i][2]+ ' '+r[j][1]);
                    sum+=a[i][1];
                    break;
               }
          }
     }
     if(ans.length==0) return ans.length+' '+sum;
     return ans.length+ ' ' + sum + '\n' + ans.join('\n');
}());
function rn() {
     return readline().split(' ').map(Number);
}

print(function() {
     var n=+readline();
     var ans=[];
     var a=[];
     for(var i=0; i<n; ++i) {
          var x=rn();
          x.push(i+1);
          a.push(x);
     }
     a.sort(function(a, b) {
          if(a[1]===b[1]) return b[0]-a[0];
          return b[1]-a[1];
     });
     var k= +readline();
     var r=rn();
     r=r.map(function(v, i) {
          return [v, i+1, true];
     });
     r.sort(function(a, b) {return a[0]-b[0];});
     var sum=0;
     for(var i=0; i<n; ++i) {
          for(var j=0; j<k; ++j) {
               if(r[j][2]&&r[j][0]>=a[i][0]) {
                    r[j][2]=false;
                    ans.push(a[i][2]+ ' '+r[j][1]);
                    sum+=a[i][1];
                    break;
               }
          }
     }
     if(ans.length==0) return ans.length+' '+sum;
     return ans.length+ ' ' + sum + '\n' + ans.join('\n');
}());
function rn() {
     return readline().split(' ').map(Number);
}

print(function(n) {
    var n=+readline();
    var ans=[];
    var a=[];
    for(var i=0; i<n; ++i) {
        var x=rn();
        x.push(i+1);
        a.push(x);
    }
    a.sort(function(a,b) {
        if(a[1]===b[1]) return b[0]-a[0];
        return b[1]-a[1];
    });
    var k=+readline();
    var r=rn();
    r=r.map(function(v, i) {
        return [v,i+1,true];
    });
    r.sort(function(a, b) {return a[0]-b[0];});
    var sum=0;
     for(var i=0; i<n; ++i) {
          for(var j=0; j<k; ++j) {
               if(r[j][2]&&r[j][0]>=a[i][0]) {
                    r[j][2]=false;
                    ans.push(a[i][2]+ ' '+r[j][1]);
                    sum+=a[i][1];
                    break;
               }
          }
     }
    if(ans.length==0) return ans.length+' '+sum;
    return ans.length+' '+sum+'\n' +ans.join('\n');
}());
function rn() {
    return readline().split(' ').map(Number);
}

print(function(n) {
    var n=+readline();
    var ans=[];
    var a=[];
    for(var i=0; i<n; ++i) {
        var x=rn();
        x.push(i+1);
        a.push(x);
    }
    a.sort(function(a,b) {
        if(a[1]===b[1]) return b[0]-a[0];
        return b[1]-a[1];
    });
    var k=+readline();
    var r=rn();
    r=r.map(function(v, i) {
        return [v,i+1,true];
    });
    r.sort(function(a, b) {return a[0]-b[0];});
    var sum=0;
    for(var i=0; i<n; ++i) {
        for(var j=0; j<k; ++j) {
            if(r[j][2]&&r[j][0]>=a[i][0]) {
                r[j][2]=false;
                ans.push(a[i][2]+ ' ' + r[j][1]);
                sum+=a[i][1];
                break;
            }
        }
    }
    if(ans.length==0) return ans.length+' '+sum;
    return ans.length+' '+sum+'\n' +ans.join('\n');
}());
function rn() {
    return readline().split(' ').map(Number);
}

print(function(n) {
    var n=+readline();
    var ans=[];
    var a=[];
    for(var i=0; i<n; ++i) {
        var x=rn();
        x.push(i+1);
        a.push(x);
    }
    a.sort(function(a, b) {
        if(a[1]===b[1]) return b[0]-a[0];
        return b[1]-a[1];
    });
    var k= +readline();
    var r=rn();
    r=r.map(function(v, i) {
        return [v, i+1, true];
    });
    r.sort(function(a, b) {return a[0]-b[0];});
    var sum=0;
for(var i=0; i<n; i++){
        for(var j=0; j<k; j++){
            if(r[j][2] && r[j][0]>=a[i][0]){
                r[j][2] = false;
                ans.push(a[i][2]+' '+r[j][1]);
                sum += a[i][1];
                break;
            }
        }
    }
    if(ans.length==0) return ans.length+' '+sum;
    return ans.length+ ' ' + sum + '\n' + ans.join('\n');
}());
function rn() {
    return readline().split(' ').map(Number);
}

print(function(n) {
    var n=+readline();
    var ans=[];
    var a=[];
    for(var i=0; i<n; ++i) {
        var x=rn();
        x.push(i+1);
        a.push(x);
    }
    a.sort(function(a,b) {
        if(a[1]===b[1]) return b[0]-a[0];
        return b[1]-a[1];
    });
    var k=+readline();
    var r=rn();
    r=r.map(function(v, i) {
        return [v,i+1,true];
    });
    r.sort(function(a, b) {return a[0]-b[0];});
     var sum=0;
     for(var i=0; i<n; ++i) {
          for(var j=0; j<k; ++j) {
               if(r[j][2]&&r[j][0]>=a[i][0]) {
                    r[j][2]=false;
                    ans.push(a[i][2]+ ' '+r[j][1]);
                    sum+=a[i][1];
                    break;
               }
          }
     }
     if(ans.length==0) return ans.length+' '+sum;
     return ans.length+ ' ' + sum + '\n' + ans.join('\n');
}());
function rn() {
     return readline().split(' ').map(Number);
}

print(function(n) {
    var n=+readline();
    var ans=[];
    var a=[];
    for(var i=0; i<n; ++i) {
        var x=rn();
        x.push(i+1);
        a.push(x);
    }
    a.sort(function(a, b) {
        if(a[1]===b[1]) return b[0]-a[0];
        return b[1]-a[1];
    });
    var k = +readline();
    var r = rn();
    r = r.map(function(v, i){
        return [v, i+1, true];
    });
    r.sort(function(a, b){ return a[0]-b[0];});
    var sum = 0;
    for(var i=0; i<n; i++){
        for(var j=0; j<k; j++){
            if(r[j][2] && r[j][0]>=a[i][0]){
                r[j][2] = false;
                ans.push(a[i][2]+' '+r[j][1]);
                sum += a[i][1];
                break;
            }
        }
    }
    if(ans.length==0) return ans.length+' '+sum;
    return ans.length+' '+sum+'\n'+ans.join('\n');
}());
function rn() { return readline().split(' ').map(Number); }

print(function(n){
	var n = +readline();
	var ans = [];
	var a = [];
	for(var i=0; i<n; i++){
		var x = rn();
		x.push(i+1);
		a.push(x);
	}
	a.sort(function(a, b){return a[1]<b[1];});

	var k = +readline();
	var r = rn();
	r = r.map(function(v, i){
		return [v, i+1, true];
	});
	r.sort(function(a, b){ return a[0]>b[0];});
	var sum = 0;
	for(var i=0; i<n; i++){
		for(var j=0; j<k; j++){
			if(r[j][2] && r[j][0]>=a[i][0]){
				r[j][2] = false;
				ans.push(a[i][2]+' '+r[j][1]);
				sum += a[i][1];
				break;
			}
		}
	}
	if(ans.length==0) return ans.length+' '+sum;
	return ans.length+' '+sum+'\n'+ans.join('\n');
}());
function rn() { return readline().split(' ').map(Number); }

print(function(n){
	var n = +readline();
	var ans = [];
	var a = [];
	for(var i=0; i<n; i++){
		var x = rn();
		x.push(i+1);
		a.push(x);
	}
	a.sort(function(a, b){return a[1]<b[1];});

	var k = +readline();
	var r = rn();
	r = r.map(function(v, i){
		return [v, i+1, true];
	});
	r.sort(function(a, b){ return a[0]>b[0];});
	var sum = 0;
	for(var i=0; i<n; i++){
		for(var j=0; j<k; j++){
			if(r[j][2] && r[j][0]>=a[i][0]){
				r[j][2] = false;
				ans.push(a[i][2]+' '+r[j][1]);
				sum += a[i][1];
				break;
			}
		}
	}
	return ans.length+' '+sum+'\n'+ans.join('\n');
}());
function rn() { return readline().split(' ').map(Number); }

print(function(n){
	var n = +readline();
	var ans = [];
	var a = [];
	for(var i=0; i<n; i++){
		var x = rn();
		x.push(i+1);
		a.push(x);
	}
	a.sort(function(a, b){return a[0]<b[0];});

	var k = +readline();
	var r = rn();
	r = r.map(function(v, i){
		return [v, i+1, true];
	});
	r.sort(function(a, b){ return a[0]>b[0];});
	var sum = 0;
	for(var i=0; i<n; i++){
		for(var j=0; j<k; j++){
			if(r[j][2] && r[j][0]>=a[i][0]){
				r[j][2] = false;
				ans.push(a[i][2]+' '+r[j][1]);
				sum += a[i][1];
				break;
			}
		}
	}
	if(ans.length==0) return ans.length+' '+sum;
	return ans.length+' '+sum+'\n'+ans.join('\n');
}());
function rn() { return readline().split(' ').map(Number); }

print(function(n) {
    var n=+readline();
    var ans=[];
    var a=[];
    for(var i=0; i<n; ++i) {
        var x=rn();
        x.push(i+1);
        a.push(x);
    }
    a.sort(function(a,b) {
        if(a[1]===b[1]) return b[0]-a[0];
        return b[1]-a[1];
    });
    var k=+readline();
    var r=rn();
    r=r.map(function(v, i) {
        return [v,i+1,true];
    });
    r.sort(function(a, b) {return a[0]-b[0];});
    var sum=0;
    for(var i=0; i<n; ++i) {
        for(var j=0; j<k; ++j) {
            if(r[j][2]&&r[j][0]>=a[i][0]) {
                r[j][2]=false;
                ans.push(a[j][2]+ ' ' + r[j][1]);
                sum+=a[i][1];
                break;
            }
        }
    }
    if(ans.length==0) return ans.length+' '+sum;
    return ans.length+' '+sum+'\n' +ans.join('\n');
}());
function rn() {
    return readline().split(' ').map(Number);
}

print(function(n) {
    var n=+readline();
    var ans=[];
    var a=[];
    for(var i=0; i<n; ++i) {
        var x=rn();
        x.push(i+1);
        a.push(x);
    }
    a.sort(function(a, b) {
        if(a[1]===b[1]) return b[0]-a[0];
        return b[1]-a[1];
    });
    var k= +readline();
    var r=rn();
    r=r.map(function(v, i) {
        return [v, i+1, true];
    });
    r.sort(function(a, b) {return a[0]-b[0];});
    var sum=0;
    for(var i=0; i<n; ++i) {
        for(var j=0; j<k; ++j) {
            if(r[j][2]&&r[j][0]>=a[i][0]) {
                r[j][2]=true;
                ans.push(a[i][2]+ ' '+r[j][1]);
                sum+=a[i][1];
                break;
            }
        }
    }
    if(ans.length==0) return ans.length+' '+sum;
    return ans.length+ ' ' + sum + '\n' + ans.join('\n');
}());
function rn() {
    return readline().split(' ').map(Number);
}

// Generated by CoffeeScript 1.7.1
(function() {
  var find, found, i, m, money, n, people, request, requests, seat, seats, tables, test_array, totalMoney, _i, _j, _k, _len, _len1, _ref;

  n = Number(readline());

  requests = [];

  for (i = _i = 1; 1 <= n ? _i <= n : _i >= n; i = 1 <= n ? ++_i : --_i) {
    _ref = readline().split(' ').map(Number), people = _ref[0], money = _ref[1];
    requests.push({
      people: people,
      money: money,
      number: i
    });
  }

  m = Number(readline());

  tables = readline().split(' ').map(function(x, i) {
    return {
      size: Number(x),
      number: i + 1,
      taken: false
    };
  });

  requests.sort(function(a, b) {
    if (a.money > b.money) {
      return -1;
    } else {
      return 1;
    }
  });

  tables.sort(function(a, b) {
    if (a.size > b.size) {
      return 1;
    } else {
      return -1;
    }
  });

  find = function(array, el, a, b) {
    var c, _ref1, _ref2;
    if (a == null) {
      a = 0;
    }
    if (b == null) {
      b = array.length - 1;
    }
    if (a === b) {
      while ((_ref1 = array[a]) != null ? _ref1.taken : void 0) {
        a--;
      }
      if (a < 0) {
        return null;
      }
      array[a].taken = true;
      if (array[a].size > el) {
        return array[0];
      }
    } else {
      if (el < array[c = Math.floor((a + b) / 2)].size) {
        return find(array, el, a, c);
      } else if (el > array[c = Math.ceil((a + b) / 2)].size) {
        return find(array, el, c, b);
      } else {
        while ((_ref2 = array[c]) != null ? _ref2.taken : void 0) {
          c--;
        }
        if (c < 0) {
          return null;
        }
        array[c].taken = true;
        return array[c];
      }
    }
  };

  test_array = (function() {
    var _j, _results;
    _results = [];
    for (i = _j = 1; _j <= 100; i = _j += 5) {
      _results.push({
        size: i,
        number: i
      });
    }
    return _results;
  })();

  seats = [];

  totalMoney = 0;

  for (_j = 0, _len = requests.length; _j < _len; _j++) {
    request = requests[_j];
    found = find(tables, request.people);
    if (found != null) {
      seats.push({
        table: found.number,
        request: request.number
      });
      totalMoney += request.money;
    }
  }

  print(seats.length + ' ' + totalMoney);

  for (_k = 0, _len1 = seats.length; _k < _len1; _k++) {
    seat = seats[_k];
    print(seat.request + ' ' + seat.table);
  }

}).call(this);

// Generated by CoffeeScript 1.7.1
(function() {
  var find, found, i, m, money, n, people, request, requests, seat, seats, tables, test_array, totalMoney, _i, _j, _k, _len, _len1, _ref;

  n = Number(readline());

  requests = [];

  for (i = _i = 1; 1 <= n ? _i <= n : _i >= n; i = 1 <= n ? ++_i : --_i) {
    _ref = readline().split(' ').map(Number), people = _ref[0], money = _ref[1];
    requests.push({
      people: people,
      money: money,
      number: i
    });
  }

  m = Number(readline());

  tables = readline().split(' ').map(function(x, i) {
    return {
      size: Number(x),
      number: i + 1,
      taken: false
    };
  });

  requests.sort(function(a, b) {
    if (a.money > b.money) {
      return -1;
    } else {
      return 1;
    }
  });

  tables.sort(function(a, b) {
    if (a.size > b.size) {
      return 1;
    } else {
      return -1;
    }
  });

  find = function(array, el, a, b) {
    var c, _ref1, _ref2;
    if (a == null) {
      a = 0;
    }
    if (b == null) {
      b = array.length - 1;
    }
    if (a === b) {
      while ((_ref1 = array[a]) != null ? _ref1.taken : void 0) {
        a--;
      }
      if (a < 0) {
        return null;
      }
      array[a].taken = true;
      if (array[a].size >= el) {
        return array[0];
      }
    } else {
      if (el < array[c = Math.floor((a + b) / 2)].size) {
        return find(array, el, a, c);
      } else if (el > array[c = Math.ceil((a + b) / 2)].size) {
        return find(array, el, c, b);
      } else {
        while ((_ref2 = array[c]) != null ? _ref2.taken : void 0) {
          c--;
        }
        if (c < 0) {
          return null;
        }
        array[c].taken = true;
        return array[c];
      }
    }
  };

  test_array = (function() {
    var _j, _results;
    _results = [];
    for (i = _j = 1; _j <= 100; i = _j += 5) {
      _results.push({
        size: i,
        number: i
      });
    }
    return _results;
  })();

  seats = [];

  totalMoney = 0;

  for (_j = 0, _len = requests.length; _j < _len; _j++) {
    request = requests[_j];
    found = find(tables, request.people);
    if (found != null) {
      seats.push({
        table: found.number,
        request: request.number
      });
      totalMoney += request.money;
    }
  }

  print(seats.length + ' ' + totalMoney);

  for (_k = 0, _len1 = seats.length; _k < _len1; _k++) {
    seat = seats[_k];
    print(seat.request + ' ' + seat.table);
  }

}).call(this);

// Generated by CoffeeScript 1.7.1
(function() {
  var find, found, i, m, money, n, people, request, requests, seat, seats, tables, totalMoney, _i, _j, _k, _len, _len1, _ref;

  n = Number(readline());

  requests = [];

  for (i = _i = 1; 1 <= n ? _i <= n : _i >= n; i = 1 <= n ? ++_i : --_i) {
    _ref = readline().split(' ').map(Number), people = _ref[0], money = _ref[1];
    requests.push({
      people: people,
      money: money,
      number: i
    });
  }

  m = Number(readline());

  tables = readline().split(' ').map(function(x, i) {
    return {
      size: Number(x),
      number: i + 1,
      taken: false
    };
  });

  requests.sort(function(a, b) {
    if (a.money > b.money) {
      return -1;
    } else {
      return 1;
    }
  });

  tables.sort(function(a, b) {
    if (a.size > b.size) {
      return 1;
    } else {
      return -1;
    }
  });

  find = function(array, el, a, b) {
    var c, _ref1, _ref2;
    if (a == null) {
      a = 0;
    }
    if (b == null) {
      b = array.length - 1;
    }
    if (a === b) {
      while ((_ref1 = array[a]) != null ? _ref1.taken : void 0) {
        a++;
      }
      if (a >= array.length) {
        return null;
      }
      if (array[a].size >= el) {
        array[a].taken = true;
        return array[a];
      }
    } else {
      if (el >= array[c = Math.ceil((a + b) / 2)].size) {
        return find(array, el, c, b);
      } else if (el <= array[c = Math.floor((a + b) / 2)].size) {
        return find(array, el, a, c);
      } else {
        while ((_ref2 = array[c]) != null ? _ref2.taken : void 0) {
          c++;
        }
        if (c >= array.length) {
          return null;
        }
        array[c].taken = true;
        return array[c];
      }
    }
  };

  seats = [];

  totalMoney = 0;

  for (_j = 0, _len = requests.length; _j < _len; _j++) {
    request = requests[_j];
    found = find(tables, request.people);
    if (found != null) {
      seats.push({
        table: found.number,
        request: request.number
      });
      totalMoney += request.money;
    }
  }

  print(seats.length + ' ' + totalMoney);

  for (_k = 0, _len1 = seats.length; _k < _len1; _k++) {
    seat = seats[_k];
    print(seat.request + ' ' + seat.table);
  }

}).call(this);

// Generated by CoffeeScript 1.7.1
(function() {
  var find, found, i, m, money, n, people, request, requests, seat, seats, tables, totalMoney, _i, _j, _k, _len, _len1, _ref;

  n = Number(readline());

  requests = [];

  for (i = _i = 1; 1 <= n ? _i <= n : _i >= n; i = 1 <= n ? ++_i : --_i) {
    _ref = readline().split(' ').map(Number), people = _ref[0], money = _ref[1];
    requests.push({
      people: people,
      money: money,
      number: i
    });
  }

  m = Number(readline());

  tables = readline().split(' ').map(function(x, i) {
    return {
      size: Number(x),
      number: i + 1,
      taken: false
    };
  });

  requests.sort(function(a, b) {
    if (a.money > b.money) {
      return -1;
    } else {
      return 1;
    }
  });

  tables.sort(function(a, b) {
    if (a.size > b.size) {
      return 1;
    } else {
      return -1;
    }
  });

  find = function(array, el, a, b) {
    var c, _ref1, _ref2;
    if (a == null) {
      a = 0;
    }
    if (b == null) {
      b = array.length - 1;
    }
    if (a === b) {
      while ((_ref1 = array[a]) != null ? _ref1.taken : void 0) {
        a--;
      }
      if (a < 0) {
        return null;
      }
      if (array[a].size >= el) {
        array[a].taken = true;
        return array[0];
      }
    } else {
      if (el <= array[c = Math.floor((a + b) / 2)].size) {
        return find(array, el, a, c);
      } else if (el >= array[c = Math.ceil((a + b) / 2)].size) {
        return find(array, el, c, b);
      } else {
        while ((_ref2 = array[c]) != null ? _ref2.taken : void 0) {
          c--;
        }
        if (c < 0) {
          return null;
        }
        array[c].taken = true;
        return array[c];
      }
    }
  };

  seats = [];

  totalMoney = 0;

  for (_j = 0, _len = requests.length; _j < _len; _j++) {
    request = requests[_j];
    found = find(tables, request.people);
    if (found != null) {
      seats.push({
        table: found.number,
        request: request.number
      });
      totalMoney += request.money;
    }
  }

  print(seats.length + ' ' + totalMoney);

  for (_k = 0, _len1 = seats.length; _k < _len1; _k++) {
    seat = seats[_k];
    print(seat.request + ' ' + seat.table);
  }

}).call(this);


function ProblemSolver() {

    this.getLexicographicallySmallest = function( prev , x , y ) {
        var l1 , l2 , l3 , res , i;
        res = "Invalid";
        l1 = prev.length;
        l2 = x.length;
        l3 = y.length;
        for( i = 0 ; i < Math.min( l2 , l3 ) ; i++ ) {
            if( x.charCodeAt( i ) == y.charCodeAt( i ) ) {
                continue;
            }
            else {
                if( x.charCodeAt( i ) < y.charCodeAt( i ) ) {
                    res = x;
                }
                else {
                    res = y;
                }
                break;
            }
        }
        if( res == "Invalid" ) {
            if( l2 < l3 ) {
                res = x ;
            }
            else {
                res = y ;
            }
        }

        if( l1 > 0 && prev.localeCompare( res ) >= 0 ) {
            if( res == x ) {
                if( prev.localeCompare( y ) < 0 ) {
                    res = y ;
                }
                else {
                    res = "Invalid";
                }
            }
            else {
                if( prev.localeCompare( x ) < 0 ) {
                    res = x ;
                }
                else {
                    res = "Invalid";
                }
            }
        }
        return res;
    };

    this.solveCase = function() {
        var res , i , j , a , b , c , prev , x , y;
        res = "YES";
        for( i = 0 ; i < this.n ; i++ ) {
            a = this.arr[ i ];
            this.brr[ a ] = i;
        }
        prev = "";
        for( i = 0 ; i < this.n ; i++ ) {
            a = this.arr[ i ];
            x = this.srr[ a - 1 ];
            y = this.trr[ a - 1 ];
            //print( "..." + this.srr[ a - 1 ] + "...." + this.trr[ a - 1 ] ) ;
            prev = this.getLexicographicallySmallest( prev , x , y );
            if( prev == "Invalid" ) {
                res = "NO";
                break;
            }
        }
        print( res );
    };

    this.getInput = function( irObj ) {
        var hasMoreInput , i;
        hasMoreInput = true;
        try {
            this.n = irObj.nextInt();
            for( i = 0 ; i < this.n ; i++ ) {
                this.srr[ i ] = irObj.nextString();
                this.trr[ i ] = irObj.nextString();
            }
            for( i = 0 ; i < this.n ; i++ ) {
                this.arr[ i ] = irObj.nextInt();
            }
        }
        catch( ex ) {
            hasMoreInput = false;
        }
        return hasMoreInput;
    };

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

    this.clearPerCase = function() {
        this.cn = 0;
        this.cc++;
        //this.clearArraysPerCase() ;
    };

    this.HAS_TEST_CASES = false;
    this.INPUT_FILE_NAME = "test.in";
    this.OUTPUT_FILE_NAME = "out.txt";
    this.DO_OUTPUT_TO_FILE = false;

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

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

    this.memsetArray1D = function( arrParam , val ) {
        var i;
        if( arrParam == null ) {
            throw new Error( "No array supplied in the parameter!" );
        }
        if( val == null ) {
            throw new Error( "No value for memset has been supplied in the parameter!" );
        }
        arrParam = new Array();
        for( i = 0 ; i < this.lim1 ; i++ ) {
            arrParam.push( val );
        }
        return arrParam;
    };

    this.getStringLength = function( stringData ) {
        var len , lengthType;
        len = stringData.length;
        lengthType = typeof len;
        if( lengthType == "function" ) {
            len = stringData.length();
        }
        else {
            len = stringData.length;
        }
        return len;
    };

    this.init();
}

function InputReader() {
    this.allLines = new Array();
    this.currrentLineNumber = 0;
    this.currrentCharacterIndex = 0;

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

    this.readAllLinesFromRhinoStdin = function() {
        importPackage( java.io );
        importPackage( java.lang );
        var singleLine , reader;
        reader = new BufferedReader( new InputStreamReader( System[ "in" ] ) );
        this.allLines = [];
        while( true ) {
            singleLine = reader.readLine();
            if( singleLine != null ) {
                this.allLines.push( singleLine );
            }
            else {
                break;
            }
        }
    };

    this.readAllLinesFromNodeStdin = function() {
        var fsObj , size , rawData;
        process.stdin.setEncoding( 'ascii' );
        fsObj = require( 'fs' );
        size = fsObj.fstatSync( process.stdin.fd ).size;
        rawData = fsObj.readSync( process.stdin.fd , size )[ 0 ];
        this.parseRawData( rawData );
    };

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

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

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

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

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

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

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

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

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

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

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

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

    this.runCode = function() {
        var testCases , i , hasMoreTestCases , isLocalMachine , localContext;
        isLocalMachine = false;
        try {
            if( __dirname != null && __dirname.charAt( 1 ) == ':' ) {
                //only on windows
                isLocalMachine = true;
            }
        }
        catch( ex ) {
            isLocalMachine = false;
        }
        if( isLocalMachine == true ) {
            //local machine runs on node and relies on file i/o
            print = console.log;
            if( this.psObj.DO_OUTPUT_TO_FILE == true ) {
                localContext = this.fohObj;
                print = function() {
                    localContext.addNewLine.apply( localContext , arguments );
                }
            }
            this.irObj.readAllLinesFromFile( this.psObj.INPUT_FILE_NAME );
        }
        else {
            //server machine
            try {
                var rlObj = readline;
                //server runs on javasctipt v8 distribution and has readline method on global context
                this.irObj.readAllLines();
            }
            catch( ex ) {
                try {
                    var pObj = process;
                    //server runs on node
                    print = console.log;
                    this.irObj.readAllLinesFromNodeStdin();
                }
                catch( ex ) {
                    try {
                        var ipObj = importPackage;
                        //server runs on rhino
                        this.irObj.readAllLinesFromRhinoStdin();
                    }
                    catch( ex ) {
                        throw new Error( "Unknown javasctipt distribution!" );
                    }
                }
            }
        }
        if( this.psObj.HAS_TEST_CASES == true ) {
            testCases = this.irObj.nextInt();
            for( i = 0 ; i < testCases ; i++ ) {
                this.psObj.clearPerCase();
                this.psObj.getInput( this.irObj );
                this.psObj.solveCase();
            }
        }
        else {
            while( true ) {
                this.psObj.clearPerCase();
                hasMoreTestCases = this.psObj.getInput( this.irObj );
                if( hasMoreTestCases == false ) {
                    break;
                }
                this.psObj.solveCase();
            }
        }
        if( this.psObj.DO_OUTPUT_TO_FILE == true ) {
            //only works for local machine(tested)
            this.fohObj.flushOutOutputToFile( this.psObj.OUTPUT_FILE_NAME );
        }
    };

    this.runCode();
}

new CodeExecutioner();

var n =readline();
var str = [];
for (i=1;i<=n;i++) str.push(readline());
var p = readline().split(" ");
var pos;
var str1 = [];
var shag=0;
var result = true;
for (i = 0;i<p.length;i++){
	pos = p[i]-1;
	var str3 = str[pos];
	var str2 = str3.split(" ");
	str1[i+shag] = str2[0];
	str1[i+shag+1] = str2[1];
	shag=shag+1;
}
var sravn = [str1[0],str1[1],0];
var sra = 2;
for (i = 2;i<=str1.length-2;i=i+2){
	if (sra == 2){
	if ((sravn[0]<str1[i]||sravn[1]<str1[i])&&(sravn[0]<str1[i+1]||sravn[1]<str1[i+1])){
		sravn[0]=str1[i];
		sravn[1]=str1[i+1];
		sra = 2;}
	else if(sravn[0]<str1[i]||sravn[1]<str1[i]) {sravn[3]=str1[i]; sra=1;}
			else if (sravn[0]<str1[i+1]||sravn[1]<str1[i+1]) {sravn[3]=str1[i+1];sra = 1;}
				else {result = false;break}
	}
	else if (sravn[3]<str[i]&&sravn[3]<str[i+1]) {
			sravn[0]=str1[i];
			sravn[1]=str1[i+1];
			sra = 2;}
		else if(sravn[3]<str1[i]) {sravn[3]=str1[i]; sra=1;}
				else if (sravn[3]<str1[i+1]) {sravn[3]=str1[i+1]; sra=1;}
				else {result = false;break};
}
if(result) print("YES");
else print("NO");

(function(){print(function(){var e=+readline(),t=[];while(e--){t.push(readline().split(" "));}e=t.length;var n=[];readline().split(" ").forEach(function(e){return n.push(t[+e-1])});var r=n[0][0]<n[0][1]?n[0][0]:n[0][1];for(var i=1;i<e;i++){var s=[];n[i].forEach(function(e){if(e>=r)s.push(e)});switch(s.length){case 2:r=s.sort()[0];break;case 1:r=s[0];break;case 0:return"NO"}}return"YES"}())}).call(this)

var n = parseInt(readline());
var a = new Array();
for(var i=0;i<n;i++)
{
    var aa = readline().split(' ');
	a[i]=new Array();
	if(aa[0]>aa[1])
	{
	    a[i][0]=aa[1];
		a[i][1]=aa[0];
	}
	else
	{
	    a[i][0]=aa[0];
		a[i][1]=aa[1];
	}
}
var result ='YES';
var str = '';
var b = readline().split(' ');
for(var i=0;i<b.length;i++)
{
    var pos = parseInt(b[i])-1;
	if(a[pos][0]>str)
	{
	    str = a[pos][0];
	}
	else if(a[pos][1]>str)
	{
	    str = a[pos][1];
	}
	else
	{
	    result = 'NO';
		break;
	}
}
print(result);

(function() {
    print(function() {
        var e = +readline(),
            t = [];
        while (e--) {
            t.push(readline().split(" "));
        }
        e = t.length;
        var n = [];
        readline().split(" ").forEach(function(e) {
            return n.push(t[+e - 1])
        });
        var r = n[0][0] < n[0][1] ? n[0][0] : n[0][1];
        for (var i = 1; i < e; i++) {
            var s = [];
            n[i].forEach(function(e) {
                if (e >= r) s.push(e)
            });
            switch (s.length) {
                case 2:
                    r = s.sort()[0];
                    break;
                case 1:
                    r = s[0];
                    break;
                case 0:
                    return "NO"
            }
        }
        return "YES"
    }())
}).call(this)

;(function () {

	print(function () {

		var n = +readline(), people = [];

		while (n--) {
			people.push(readline().split(' ').map(function (e) {
				return e.toLowerCase();
			} ));
		} n = people.length;

		people = readline().split(' ').map(function (e) {
			return people[+e - 1];
		});

		for (var i = 1; i < n; i++) {
			if (
				people[i - 1][0] > people[i][0] &&
				people[i - 1][0] > people[i][1] &&
				people[i - 1][1] > people[i][0] &&
				people[i - 1][1] > people[i][1]
			) return 'NO';
		}

		return 'YES';

	}());

}.call(this));

var n =readline();
var str = [];
for (i=1;i<=n;i++) str.push(readline().split(" "));
var p = readline().split(" ");
var pos;
var pos2;
var str1 = [];
var shag=0;
var result;
for (i = 0;i<p.length;i++){
	str1[i+shag] = str[i];
	str1[i+shag+1] = str[i+1];
	shag=shag+1;
}
for (i = 0;i<str1.length-2;i=i+2){
	if (str1[i]<str1[i+2]||str1[i]<str1[i+3]||str1[i+1]<str1[i+2]||str1[i+1]<str1[i+3])
		result = true;
	else {print("NO");result = false;break};
}
if(result) print("YES");

var n =readline();
var str = [];
for (i=1;i<=n;i++) str.push(readline().split(" "));
var p = readline().split(" ");
var pos;
var pos2;
var str1 = [];
var shag=0;
var result;
for (i = 0;i<p.length;i++){
	pos = p[i];
	str1[i+shag] = str[pos];
	str1[i+shag+1] = str[pos+1];
	shag=shag+1;
}
for (i = 0;i<str1.length-2;i=i+2){
	if (str1[i]<str1[i+2]||str1[i]<str1[i+3]||str1[i+1]<str1[i+2]||str1[i+1]<str1[i+3])
		result = true;
	else {print("NO");result = false;break};
}
if(result) print("YES");

var n =readline();
var str = [];
for (i=1;i<=n;i++) str.push(readline().split(" "));
var p = readline().split(" ");
var pos;
var pos2;
var str1 = [];
var shag=0;
var result;
for (i = 0;i<p.length;i++){
	pos = p[i]*2-2;
	str1[i+shag] = str[pos];
	str1[i+shag+1] = str[pos+1];
	shag=shag+1;
}
for (i = 0;i<str1.length-2;i=i+2){
	if (str1[i]<str1[i+2]||str1[i]<str1[i+3]||str1[i+1]<str1[i+2]||str1[i+1]<str1[i+3])
		result = true;
	else {print(str1);result = false;break};
}
if(result) print("YES");

var n =readline();
var str = [];
for (i=1;i<=n;i++) str.push(readline());
var p = readline().split(" ");
print (str);

var n =readline();
var str = [];
for (i=1;i<=n;i++) str.push(readline().split(" "));
var p = readline().split(" ");
var pos;
var pos2;
var str1 = [];
var shag=0;
var result;
for (i = 0;i<p.length;i++){
	pos = p[i]*2-2;
	str1[i+shag] = str[pos];
	str1[i+shag+1] = str[pos+1];
	shag=shag+1;
}
for (i = 0;i<str1.length-2;i=i+2){
	if (str1[i]<str1[i+2]||str1[i]<str1[i+3]||str1[i+1]<str1[i+2]||str1[i+1]<str1[i+3])
		result = true;
	else {print("NO");result = false;break};
}
if(result) print("YES");

var n =readline();
var str = [];
for (i=1;i<=n;i++) str.push(readline().split(" "));
var p = readline().split(" ");
var pos;
var pos2;
var str1 = [];
var shag=0;
var result;
for (i = 0;i<p.length;i++){
	pos = p[i]*2-2;
	str1[i+shag] = str[pos];
	str1[i+shag+1] = str[pos+1];
	shag=shag+1;
}
for (i = 0;i<str1.length-2;i=i+2){
	if (str1[i]<str1[i+2]||str1[i]<str1[i+3]||str1[i+1]<str1[i+2]||str1[i+1]<str1[i+3])
		result = true;
	else {print(p);result = false;break};
}
if(result) print("YES");

var n =readline();
var str = [];
for (i=1;i<=n;i++) str.push(readline());
var p = readline().split(" ");
var pos;
var str1 = [];
var shag=0;
var result = true;
for (i = 0;i<p.length;i++){
	pos = p[i]-1;
	var str3 = str[pos];
	var str2 = str3.split(" ");
	str1[i+shag] = str2[0];
	str1[i+shag+1] = str2[1];
	shag=shag+1;
}
for (i = 0;i<str1.length-2;i=i+2){
	if (str1[i]<str1[i+2]||str1[i]<str1[i+3]||str1[i+1]<str1[i+2]||str1[i+1]<str1[i+3])
		result = true;
	else {print("NO");result = false;break};
}
if(result) print("YES");

var n =readline();
var str = [];
for (i=1;i<=n;i++) str.push(readline());
var p = readline().split(" ");
print (str.lenght);

var n =readline();
var str = [];
for (i=1;i<=n;i++) str.push(readline().split(" "));
var p = readline().split(" ");
print (str.length);

var n =readline();
var str = [];
for (i=1;i<=n;i++) str.push(readline());
var p = readline().split(" ");
var pos;
var str1 = [];
var shag=0;
var result;
for (i = 0;i<p.length;i++){
	pos = p[i]-1;
	var str3 = str[pos];
	var str2 = str3.split(" ");
	str1[i+shag] = str2[0];
	str1[i+shag+1] = str2[1];
	shag=shag+1;
}
for (i = 0;i<str1.length-2;i=i+2){
	if (str1[i]<str1[i+2]||str1[i]<str1[i+3]||str1[i+1]<str1[i+2]||str1[i+1]<str1[i+3])
		result = true;
	else {print("NO");result = false;break};
}
if(result) print("YES");

var n =readline();
var str = [];
for (i=1;i<=n;i++) str.push(readline().split(" "));
var p = readline().split(" ");
print (str[2])

var n =readline();
var str = [];
for (i=1;i<=n;i++) str.push(readline());
var p = readline().split(" ");
var pos;
var str1 = [];
var shag=0;
var result = true;
for (i = 0;i<p.length;i++){
	pos = p[i]-1;
	var str3 = str[pos];
	var str2 = str3.split(" ");
	str1[i+shag] = str2[0];
	str1[i+shag+1] = str2[1];
	shag=shag+1;
}
var sravn = [str1[0],str1[1],0];
var sra = 2;
for (i = 2;i<=str1.length-2;i=i+2){
	if (sra = 2){
	if ((sravn[0]<str1[i]||sravn[1]<str1[i])&&(sravn[0]<str1[i+1]||sravn[1]<str1[i+1])){
		sravn[0]=str1[i];
		sravn[1]=str1[i+1];
		sra = 2;}
	else if(sravn[0]<str1[i]||sravn[1]<str1[i]) {sravn[3]=str1[i]; sra=1;}
			else if (sravn[0]<str1[i+1]||sravn[1]<str1[i+1]) {sravn[3]=str1[i+1];sra = 1;}
				else {result = false;break}
	}
	else if (sravn[3]<str[i]&&sravn[3]<str[i+1]) {
			sravn[0]=str1[i];
			sravn[1]=str1[i+1];
			sra = 2;}
		else if(sravn[3]<str1[i]) {sravn[3]=str1[i]; sra=1;}
				else if (sravn[3]<str1[i+1]) {sravn[3]=str1[i+1]; sra=1;}
				else {result = false;break};
}
if(result) print("YES");
else print("NO");

var n =readline();
var str = [];
for (i=1;i<=n;i++) str.push(readline());
var p = readline().split(" ");
var pos;
var str1 = [];
var shag=0;
var result = true;
for (i = 0;i<p.length;i++){
	pos = p[i]-1;
	var str3 = str[pos];
	var str2 = str3.split(" ");
	str1[i+shag] = str2[0];
	str1[i+shag+1] = str2[1];
	shag=shag+1;
}
var sravn = [str1[0],str1[1],0];
var sra = 2;
for (i = 2;i<str1.length-2;i=i+2){
	if (sra = 2){
	if ((sravn[0]<str1[i]||sravn[1]<str1[i])&&(sravn[0]<str1[i+1]||sravn[1]<str1[i+1])){
		sravn[0]=str1[i];
		sravn[1]=str1[i+1];
		sra = 2;}
	else if(sravn[0]<str1[i]||sravn[1]<str1[i]) {sravn[3]=str1[i]; sra=1;}
			else if (sravn[0]<str1[i+1]||sravn[1]<str1[i+1]) {sravn[3]=str1[i+1];sra = 1;}
				else {result = false;break}
	}
	else if (sravn[3]<str[i]&&sravn[3]<str[i+1]) {
			sravn[0]=str1[i];
			sravn[1]=str1[i+1];
			sra = 2;}
		else if(sravn[3]<str1[i]) {sravn[3]=str1[i]; sra=1;}
				else if (sravn[3]<str1[i+1]) {sravn[3]=str1[i+1]; sra=1;}
				else {result = false;break};
}
if(result) print("YES");
else print("NO");

var n =readline();
var str = [];
for (i=1;i<=n;i++) str.push(readline().split(" "));
var p = readline().split(" ");
var pos;
var pos2;
var str1 = [];
var shag=0;
var result;
for (i = 0;i<p.length;i++){
	pos = p[i]*2-2;
	str1[i+shag] = str[pos];
	str1[i+shag+1] = str[pos+1];
	shag=shag+1;
}
for (i = 0;i<str1.length-2;i=i+2){
	if (str1[i]<str1[i+2]||str1[i]<str1[i+3]||str1[i+1]<str1[i+2]||str1[i+1]<str1[i+3])
		result = true;
	else {print(p.length);result = false;break};
}
if(result) print("YES");

var n =readline();
var str = [];
for (i=1;i<=n;i++) str.push(readline().split(" "));
var p = readline().split(" ");
var pos;
var pos2;
var str1 = [];
var shag=0;
var result;
for (i = 0;i<p.length;i++){
    pos = p[i]*2-2;
    str1[i+shag] = str[pos];
    str1[i+shag+1] = str[pos+1];
    shag=shag+1;
}
for (i = 0;i<str1.length-2;i=i+2){
    if (str1[i]<str1[i+2]||str1[i]<str1[i+3]||str1[i+1]<str1[i+2]||str1[i+1]<str1[i+3])
        result = true;
    else {print(str.length);result = false;break};
}
if(result) print("YES");

var n =readline();
var str = [];
for (i=1;i<=n;i++) str.push(readline().split("/\s/"));
var p = readline().split(" ");
print (str.length);

var n =readline();
var str = [];
for (i=1;i<=n;i++) str.push(readline().split(" "));
var p = readline().split(" ");
var pos;
var pos2;
var str1 = [];
var shag=0;
var result;
for (i = 0;i<p.length;i++){
    pos = p[i]*2-2;
    str1[i+shag] = str[pos];
    str1[i+shag+1] = str[pos+1];
    shag=shag+1;
}
for (i = 0;i<str1.length-2;i=i+2){
    if (str1[i]<str1[i+2]||str1[i]<str1[i+3]||str1[i+1]<str1[i+2]||str1[i+1]<str1[i+3])
        result = true;
    else {print("No");result = false;break};
}
if(result) print("Yes");

var n =readline();
var str = [];
for (i=1;i<=n;i++) str.push(readline().split(" "));
var p = readline().split(" ");
var pos;
var pos2;
var str1 = [];
var shag=0;
var result;
for (i = 0;i<p.length;i++){
	pos = p[i]*2-2;
	str1[i+shag] = str[pos];
	str1[i+shag+1] = str[pos+1];
	shag=shag+1;
}
for (i = 0;i<str1.length-2;i=i+2){
	if (str1[i]<str1[i+2]||str1[i]<str1[i+3]||str1[i+1]<str1[i+2]||str1[i+1]<str1[i+3])
		result = true;
	else {print(str1.length);result = false;break};
}
if(result) print("YES");

var n =readline();
var str = [];
for (i=1;i<=n;i++) str.push(readline().split(" "));
var p = readline().split(" ");
print (str);

var n =readline();
var str = [];
for (i=1;i<=n;i++) str.push(readline().split("\s"));
var p = readline().split(" ");
print (str.length);

var n =readline();
var str = [];
for (i=1;i<=n;i++) str.push(readline().split(" "));
var p = readline().split(" ");
var pos;
var pos2;
var str1 = [];
var shag=0;
var result;
for (i = 0;i<p.length;i++){
    pos = p[i]*2-2;
    str1[i+shag] = str[pos];
    str1[i+shag+1] = str[pos+1];
    shag=shag+1;
}
for (i = 0;i<str1.length-2;i=i+2){
    if (str1[i]<str1[i+2]||str1[i]<str1[i+3]||str1[i+1]<str1[i+2]||str1[i+1]<str1[i+3])
        result = true;
    else {print(str);result = false;break};
}
if(result) print("YES");

var n =readline();
var str = [];
for (i=1;i<=n;i++) str.push(readline());
var p = readline().split(" ");
var x = str.lenght;
print (x);

var n =readline();
var str = [];
for (i=1;i<=n;i++) str.push(readline());
var p = readline().split(" ");
var pos;
var str1 = [];
var shag=0;
var result = true;
for (i = 0;i<p.length;i++){
	pos = p[i]-1;
	var str3 = str[pos];
	var str2 = str3.split(" ");
	str1[i+shag] = str2[0];
	str1[i+shag+1] = str2[1];
	shag=shag+1;
}
var sravn = [str1[0],str1[1],0];
var sra = 2;
for (i = 2;i<str1.length-2;i=i+2){
	if (sra = 2){
	if ((sravn[0]<str[i]||sravn[1]<str[i])&&(sravn[0]<str[i+1]||sravn[1]<str[i+1])){
		sravn[0]=str[i];
		sravn[1]=str[i+1];
		sra = 2;}
	else if(sravn[0]<str[i]||sravn[1]<str[i]) {sravn[3]=str[i]; sra=1;}
			else if (sravn[0]<str[i+1]||sravn[1]<str[i+1]) {sravn[3]=str[i+1];sra = 1;}
				else {result = false;break}
	}
	else if (sravn[3]<str[i]&&sravn[3]<str[i+1]) {
			sravn[0]=str[i];
			sravn[1]=str[i+1];
			sra = 2;}
		else if(sravn[3]<str[i]) {sravn[3]=str[i]; sra=1;}
				else if (sravn[3]<str[i+1]) {sravn[3]=str[i+1]; sra=1;}
				else {result = false;break};

			}
if(result) print("YES");
else print("NO");


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

const readline = () => inputString[currentLine++]
// Common Template Ends //

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

// MAIN LOGIC
const solve = (n) => {
    if( n == 6 ) return 0

    while( n%3 != 0 ){
        n--
    }

    n = n/3

    return n - 2
}

let buf='';

process.stdin.on('readable',function(){
    let chunk=process.stdin.read();
    if(chunk) buf+=chunk.toString();
})

process.stdin.on('end',function(){
    const {EOL}=require('os');
    let line=buf.split(EOL);
    let t=parseInt(line[0]);
    for(let i=1;i<=t;i++)
    {
        let n=parseInt(line[i]);
        n-=6;
        console.log(Math.floor(n/3));
    }
})

let stop = '';
process.stdin.on('data', c => stop += c);
process.stdin.on('end', () => {
    const {EOL} = require('os');
    const lines = stop.split(EOL);
    var t = lines[0];
    for(i = 1; i <= t; i++){
        var k = lines[i];
        console.log(Math.floor(k / 3) - 2);
    }
});

"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());
}
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 solve = () => {
  let t = getValue();
  while (t--) {
    let n = getValue();
    console.log(Math.floor((n-3)/3)-1);
  }
};
solve();

var readline = require('readline');
var inputString = [], currentLine = 0;
process.stdin.resume();
process.stdin.setEncoding('utf-8');
var rl = readline.createInterface(process.stdin);
rl.on('line', line => { inputString.push(line) });
process.stdin.on('end', () => {  main()  });

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

function main() {
    const t = +readLine();
    for(let i = 0; i < t; i++){
        const n = +readLine();
        // const arr = readLine().split(' ').map(p => +p);
        let result = myFunc(n);
        console.log(result);
    }
}

function myFunc(n){

    n = n-3;

    return parseInt(n/3)-1;

}

'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 [rn, rb, rns, re, rbs] = convertInput(read);
  const n = rn();
  const a = Math.ceil((n - 2) / 3);
  return a - 2;
}
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 = 100;
    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);
}();

'use strict';

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

let processIn = '';
let processCurr = 0;

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

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

    JS();
});

function readLine() {
    return processIn[processCurr++];
}
function mergeSort(a) {
    let r = a.length;
    let l = 0;
    let m = Math.round((r - l) / 2);
    if (r === 1) {
        return;   // returns recursively
    }
    let L = [];   // left half of current a
    let R = [];   // right half of current a
    for (let i = l; i < m; i++) {
        L.push(a[i]);
    }
    for (let j = m; j < r; j++) {
        R.push(a[j]);
    }
    mergeSort(L);
    mergeSort(R);
    let i = 0, j = 0, k = 0;
    // Merging part
    while (i < L.length && j < R.length) {
        if (L[i] < R[j]) {
            a[k] = L[i];
            i++;
        } else {
            a[k] = R[j];
            j++;
        }
        k++;
    }
    while (i < L.length) {
        a[k] = L[i];
        i++;
        k++;
    }
    while (j < R.length) {
        a[k] = R[j];
        j++;
        k++;
    }
}

function JS() {
    /*

    */
    let tt = parseInt(readLine());
    // let tt = 1;
    for(let t=0;t<tt;++t){
        let n = parseInt(readLine());
        // let a = readLine().trim().split(' ').map(string => { return parseInt(string.trim()); });
        console.log(Math.floor(n/3) - 2);
    }
}

var n = +readline();
for (var i = 0; i < n; i++) {
  var val = +readline();
  print(Math.floor((val - 6) / 3));
}


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 r = nl.num();
		let x = 1;
		if (r <= 1399){
			x = 4;
		} else if (r <= 1599){
			x = 3;
		} else if (r <= 1899){
			x = 2;
		}
		ans.push(`Division ${x}`);
	}
	console.log(ans.join('\n'));
};

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

var len = parseInt(readline());
var i=0;
var rating;
for(i=0; i < len; i++){
 rating = parseInt(readline());
if (rating >= 1900){
	print("Division 1")
}
else if (rating <= 1899 && rating >= 1600){
	print("Division 2")
}

else if (rating <= 1599 && rating >= 1400){
	print("Division 3")
}
else if(rating <= 1399){
	print("Division 4")
}
}

const linesCount = readline();

for(x = 0; x < +linesCount; x++) {
    var curLine = parseInt(readline());
    // print(curLine, typeof curLine);
    if (curLine >= 1900) {
        print('Division 1');
    } else if (curLine >= 1600) {
        print('Division 2');
    } else if (curLine >= 1400) {
        print('Division 3');
    } else {
        print('Division 4');
    }
}

var x = readline();
x = Number(x);

while (x--) {
	var a = readline(); a = Number(a);
	if (1900<=a) print('Division 1');
	if (1600<=a&&a<=1899) print('Division 2');
	if (1400<=a&&a<=1599) print('Division 3');
	if (a<=1399) print('Division 4');
}

var testCase = +readline()
for (var i = 0; i < testCase; i++) {
  var sequence = +readline()
  if (sequence >= 1900) {
    print("Division 1")
  } else if (sequence >= 1600 && sequence <= 1899) {
    print("Division 2")
  } else if (sequence >= 1400 && sequence <= 1599) {
    print("Division 3")
  } else {
    print("Division 4")
  }
}

var num=parseInt(readline());
var arr=[];
for(var i=0;i<num;i++){
    arr.push(parseInt(readline()));
}
for(var i=0;i<num;i++){
    if(arr[i]<=1399){
        print("Division 4");
    }
    else if(arr[i]<=1599){
        print("Division 3");
    }
    else if(arr[i]<=1899){
        print("Division 2");
    }
    else{
        print("Division 1");
    }
}

var a = readline();
var arr = [];
var s = 0;
for(var i = 0; i < a; i++){
    arr[i] = readline();
    if(arr[i]<=1399){
        print("Division 4");
    }else if(arr[i]>=1400 && 1599>=arr[i]){
        print("Division 3")
    }else if(arr[i]>=1600 && 1899>=arr[i]){
        print("Division 2")
    }else{
        print("Division 1")
    }
}

var t = readline();
for(var i =0 ; i < t ; i++){
    var rating = Number(readline());
    if (rating >= 1900) {
        print('Division 1');
    } else if (rating >= 1600) {
        print('Division 2');
    } else if (rating >= 1400) {
        print('Division 3');
    } else {
        print('Division 4');
    }
}

var t = readline();
for(var  i = 0 ; i < t ; i++){
    var rating  = readline();
        if(rating <= 1399 ){
            print("Division 4");
        }
        else if(rating >= 1400 && rating <= 1599){
            print("Division 3");
        }
        else if(rating >= 1600 && rating <= 1899  ){
            print("Division 2");
        }
                else if(rating >= 1900 ){
            print("Division 1");
        }
}

T = readline()
while (T--) {
   x = readline()
   ans = 0
   if(x <= 1399)
      ans = 'Division 4'
   else  if(x >= 1400 && x <= 1599)
      ans = 'Division 3'
   else  if(x >= 1600 && x <= 1899)
      ans = 'Division 2'
   else  if(x >= 1900)
      ans = 'Division 1'

   print(ans)
}

n=Number(readline())
for (i=0;i<n;++i) {
  x = Number(readline())
  if (x<=1399)
    print('Division 4');
  else if (x<=1599)
    print('Division 3');
  else if (x<=1899)
    print('Division 2');
  else
    print('Division 1')

}

var n = parseInt(readline());
for(var i = 0; i < n; i++)
{
    var points = parseInt(readline());
    if(points <= 1399) print('Division 4')
    if(points >= 1400 && points <= 1599) print('Division 3')
    if(points >= 1600 && points <= 1899) print('Division 2')
    if(points >= 1900) print('Division 1')
}

var t = readline();
while ( t -- ) {
    var n = readline();
    if ( n >= 1900 ){
        print("Division 1")
    }
    else if ( n >= 1600 ) {
        print("Division 2") ;
    }
    else if ( n >= 1400 ) {
        print("Division 3") ;
    }
    else {
        print("Division 4") ;
    }
}

var t = +readline()

for(var i = 0; i< t; i ++) {
    var a = +readline()
    print(whichDivision(a))
}

function whichDivision(n){
   if (n >= 1900){
      return 'Division 1'
   }
   else if (1600 <= n && n <= 1899){
      return 'Division 2'
   }
   else if (1400 <= n && n <= 1599){
      return 'Division 3'
   }
   else {
      return 'Division 4'
   }
}

let i = '';
process.stdin.on('data', c => i += c);
process.stdin.on('end', () => {
    const {EOL} = require('os');
    const lines = i.split(EOL);
    var n = lines[0]
    for(j = 1; j <= n ; j++){
        var rating = lines[j]
        if(1900 <= rating){
            console.log('Division 1')
        }else if(1600 <= rating && rating <= 1899){
            console.log('Division 2')
        }else if(1400 <= rating && rating <= 1599){
            console.log('Division 3')
        }else {
            console.log('Division 4')
        }
    }
});

let stdin = process.stdin;
stdin.setEncoding('utf8');
stdin.on('data', function (data) {
    let input = data.split('\n');
    let count = parseInt(input[0]);

    for (let i = 0; i < count; i++) {
        const number = input[i + 1];

        if (number >= 1900) {
            console.log('Division ', 1);
        }

        if (number >= 1600 && number <= 1899) {
            console.log('Division ', 2);
        }

        if (number >= 1400 && number <= 1599) {
            console.log('Division ', 3);
        }

        if (number <= 1399) {
            console.log('Division ', 4);
        }
    }
});

let stdin = process.stdin;
stdin.setEncoding('utf8');
stdin.on('data', function (data) {
    let input = data.split('\n');
    let count = parseInt(input[0]);

    for (let i = 0; i < count; i++) {
        const number = input[i + 1];

        if (number >= 1900) {
            console.log('Division 1');
        }

        if (number >= 1600 && number <= 1899) {
            console.log('Division 2');
        }

        if (number >= 1400 && number <= 1599) {
            console.log('Division 3');
        }

        if (number <= 1399) {
            console.log('Division 4');
        }
    }
});

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

let c = 0;

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

  const rating = Number(d);
  if (rating <= 1399) {
    console.log("Division 4");
  } else if (rating >= 1400 && rating <= 1599) {
    console.log("Division 3");
  } else if (rating >= 1600 && rating <= 1899) {
    console.log("Division 2");
  } else {
    console.log("Division 1");
  }

  c++;
});

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

/**
 * Author : Fazlul Hoque
 * Node.js version : 12.16.3
 * command : node fileName.js <input.txt >output.txt
 */
"use strict";
process.stdin.resume();
process.stdin.setEncoding("utf-8");
let inputString = ""; //An array of  raw inputs (includes 'n,\r , not usable. need to process before use)
let currentLine = 0; //input sequence controller variable.

process.stdin.on("data", (inputStdin) => {
    inputString += inputStdin;
});
process.stdin.on("end", () => {
    inputString = inputString.split("\n");
    main(); // after input
});

/********** Utility Functions Start **********/
/**
 *  read row Input
 * @returns string
 */
function _readRawLine() {
    return inputString[currentLine++];
}
function readLine(){
    // return _readRawLine().replace(/\s+$/g, '');
    return _readRawLine().replace('\r', '');
}

function print(x) {
    console.log(x);
}

function readSingleInt() {
    const p = readLine();
    return parseInt(p);
}

function readIntArray() {
    return readLine().split(" ").map((v) => parseInt(v));
}

function readArray() {
    return readLine().split(" ");
}

function int(n) {
    return parseInt(n);
}
/********** Utility Functions End **********/
/**
 * Don't Touch this fucntion at all , unless you know what are you doing!
 */
function main() {
    solve();
}

// ********** actual Code Starts from here **********

function getDivision(rating = Number)
{
    let rs = 4;
    if (rating >= 1900)
    {
        rs = 1;
    }
    else if (rating >= 1600 && rating < 1900)
    {
        rs = 2;
    }
    else if (rating >= 1400 && rating < 1600)
    {
        rs = 3;
    }

    return `Division ${rs}`;
}

function solve()
{
    let n = readSingleInt();
    while (n--)
    {
        let p = readSingleInt();
        console.log(getDivision(p))
    }
}

'use strict';

var readline = require('readline');

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

var readline__default = /*#__PURE__*/_interopDefaultLegacy(readline);

function solve(n) {
  if (n < 1400) {
    console.log('Division 4');
  } else if (n < 1600) {
    console.log('Division 3');
  } else if (n < 1900) {
    console.log('Division 2');
  } else {
    console.log('Division 1');
  }
}

async function main(read) {
  const t = Number(await read());
  for (let i = 0; i < t; i++) {
    const n = Number(await read());
    solve(n);
  }
}

const rl = readline__default["default"].createInterface({
  input: process.stdin,
  output: process.stdout
});
void async function () {
  const inputs = [];
  let i = 0;
  for await (const line of rl) {
    inputs.push(line.trim());
  }
  function read() {
    return inputs[i++];
  }
  await main(read);
}();

'use strict';
 /*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)

const calc = (n, m, A)=>{
  if (n<=1399)
    return 4;
  if (n<=1599)
    return 3;
  if (n<=1899)
    return 2;
    return 1
};

function main() {
    let T = +readline()
    while (T--){
      let [n, m] = ra();
      L('Ans:')
      print('Division '+calc(n, m));
    }
}

E.calc = calc;

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

let input = [];
let ans = [];
readline.on('line', line => {
    input.push(line);
}).on('close', () => {
    let cases = input.slice(1).map(Number);
    for (let i = 0; i < cases.length; i++) {
        ans.push(`Division ${cases[i] <= 1399 ? 4 : cases[i] <= 1599 ? 3 : cases[i] <= 1899 ? 2 : 1}`);
    }
    console.log(ans.join('\n'));
});

'use strict';

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

let inputString = '';
let currentLine = 0;

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

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

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

function output(x) {
    if (typeof x !== 'string') {
        x = x.toString();
    }
    //process.stdout.write(x);   // without auto '\n' (newline)
    console.log(x);  // with auto '\n' (newline)
}

function main() {
    let N = readline();

    for (let test = 0; test < N; test++) {
        let n = parseInt(readline(), 10);

        let o = d => output(`Division ${d}`);

        if (n <= 1399) {
            o(4);
        } else if (n <= 1599) {
            o(3);
        } else if (n <= 1899) {
            o(2);
        } else {
            o(1);
        }
    }
}

'use strict';

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

let inputString = '';
let currentLine = 0;

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

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

    main();
});

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

function main() {
  let i = readline()
  while (i--) {
    const n = readline() | 0
    if (n >= 1900) {
      console.log('Division 1')
    } else if (n >= 1600) {
      console.log('Division 2')
    } else if (n >= 1400) {
      console.log('Division 3')
    } else {
      console.log('Division 4')
    }
  }
}

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) {
        console.log(solve());
    }
}
function solve() {
    const num = parseInt(readLine());
    if (num <= 1399) return "Division 4";
    if (num <= 1599) return "Division 3";
    if (num <= 1899) return "Division 2";
    if (num >= 1900) return "Division 1";
}

'use strict';

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

let inputString = '';
let currentLine = 0;

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

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

    main();
});

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

function main() {
    const T = readline();
    for (let i = 0; i < T; i++) {
        const n = readline()
        solve(n)
    }
}
function solve(n) {
    let res = 4
    if (n >= 1900) {
        res = 1
    } else if (n >= 1600) {
        res = 2
    } else if (n >= 1400) {
        res = 3
    }

    console.log('Division ' + res)
}

/*
 * File Created: Thursday, 11th February 2021 1:42:08 pm
 * Author: Lukas Rimkus
 */
'use-strict'

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

let data = '';
let currentLine = 0;

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

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

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

    while(testCases--) {

        const s = parseInt(data.shift());

        console.log(a784(s));
    }
});

function get_ints() {
    return data[currentLine++].split(' ').map(Number);
}

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

function a(n,arr){
    let k = 0;
    let j = 0;
    for(let i = 0 ; i < n; i++){
        if(arr[i] < 0){
            arr[j++] *= -1;
            arr[i] *= -1;
        }
    }
    if(isSorted(arr)) {
        return 'YES';
    } else {
        return 'NO'
    }
}

function isSorted(arr){
    for(let i = 0 ; i < arr.length - 1; i++){
        if(arr[i] > arr[i+1]) return false;
    }
    return true;
}

function b(s) {
    let arr = [];
    for(let i = 97; i <= 122; i++ ){
        for(let j = 97; j <= 122; j++){
            if(i != j) arr.push(String.fromCharCode(i,j));
        }
    }
    let count = 1;
    let index = 0;
    while(true){
        if(s != arr[index]) {
            count++;
            index++;
        } else{
            return count;
        }
    }
}

function a784(s){
    if(s >= 1900) {
        return 'Division 1';
    } else if(s >= 1600){
        return 'Division 2';
    } else if(s >= 1400){
        return 'Division 3';
    } else {
        return 'Division 4';
    }
}
module.exports = a784;

let q = '';
process.stdin.on('data', c => q += c);
process.stdin.on('end', () => {
    const {EOL} = require('os');
    const lines = q.split(EOL);
    var n = lines[0];
    var e = 0;
    for(i = 1; i <= n; i++){
        var k = lines[i];
        if(1900 <= k){
            console.log('Division 1');
        }else if(1600 <= k && k <= 1899){
            console.log('Division 2');
        }else if(1400 <= k && k <= 1599){
            console.log('Division 3');
        }else if(k <= 1399){
            console.log('Division 4');
        }
    }
});

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

let lines = [];

async function main() {
  for await (let line of rl) {
	  lines.push(line);
  }

	let inputs = +lines.splice(0, 1); // dirty javascript typecasting to number

  for (let line of lines) {
    switch (true) {
      case +line <= 1399:
        console.log("Division 4");
        break;
      case +line <= 1599:
        console.log("Division 3");
        break;
      case +line <= 1899:
        console.log("Division 2");
        break;
      default:
        console.log("Division 1");
        break;
    }
  }
}

main();

var stdin_input = "";
var stdin_input_itr;
process.stdin.resume();
process.stdin.setEncoding("ascii");
process.stdin.on("data", function (input) { stdin_input += input; });
process.stdin.on("end", function () { stdin_input_itr = stdin_input.split('\n').values(); main(); });

const rl = () => stdin_input_itr.next().value.trim();
const rn = () => Number(rl());
const ra = () => rl().split(' ');
const rna = () => ra().map(x => Number(x));

var deb; const log = msg => (typeof deb != "undefined") && console.log("DEBUG", msg);

function main () {
	let T = rn();
	while (T--) {
		const rating = rn();
		let ans;
		if (rating >= 1900) ans = 1;
		else if (rating >= 1600) ans = 2;
		else if (rating >= 1400) ans = 3;
		else ans = 4;

		console.log('Division', ans);
	}
}

const getDivison = (n) => {
    if (n >= 1900) {
        return 1
    }
    if (n >= 1600) {
        return 2
    }
    if (n>= 1400) {
        return 3
    }
    return 4;
}

const processData = (lines) => {
    let n = +lines[0];
    for (let i=1; i<=n; i++) {
        let num = +lines[i]
        console.log(`Division ${getDivison(num)}`)
    }

}

let i = []
process.stdin.on('data', c => i.push(c))
process.stdin.on('end', () => {
    const {EOL} = require('os')
    const lines = i.join('').split(EOL) /*your input text, split by lines*/
    processData(lines)
})

//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();
	while(hasNext()){
		var rating = nextInt();
		var S = "Division ";
		if(rating <= 1399){
			S += 4;
		}else if(1400 <= rating && rating <= 1599){
			S += 3;
		}else if(1600 <= rating && rating <= 1899){
			S += 2;
		}else{
			S += 1;
		}
		myout(S);
	}
}

const lines = [];
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 ra = ()=>readline().split(' ').map(a=>+a);

function div(val, by){
    return (val - val % by) / by;
}

const calc = (a)=>{
    if (a >= 1900) return 1;
    if (a >= 1600) return 2;
    if (a >= 1400) return 3;
    return 4;
};

function main() {
    let T = +readline();
    for (let t = 1; t <= T; t++){
        let a = +readline();

        console.log(`Division ${calc(a)}`);
    }
}

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 n = +lines[l++]
        output[i] = solve(n)
    }
    console.log(output.join('\n'))
// })()
})

function solve(n) {
    if (n >= 1900) {
        return 'Division 1'
    } else if (n >= 1600) {
        return 'Division 2'
    } else if (n >= 1400) {
        return 'Division 3'
    } else {
        return 'Division 4'
    }
}

var len = parseInt(readline());
var i=0;
var rating;
for(i=0; i < len; i++){
 rating = parseInt(readline());
if (rating >= 1900){
	print("Divison 1")
}
else if (rating <= 1899 && rating >= 1600){
	print("Divison 2")
}

else if (rating <= 1599 && rating >= 1400){
	print("Divison 3")
}
else if(rating <= 1399){
	print("Divison 4")
}
}

var len = parseInt(readline());
var i=0;
var rating;
for(i=0; i < len; i++){
 rating = parseInt(readline());
if (rating >= 1900){
	print("Divison 1")
}
else if (rating <= 1899 || rating >= 1600){
	print("Divison 2")
}

else if (rating <= 1599 || rating >= 1400){
	print("Divison 3")
}
else if(rating <= 1399){
	print("Divison 4")
}
}

var len = parseInt(readline());
var i=0;
var rating;
for(i=0; i < len; i++){
 rating = parseInt(readline());
if (rating >= 1900){
	print("Divison 1")
}
else if (rating <= 1899 && rating >= 1600){
	print("Divison 2")
}

else if (rating <= 1599 && rating >= 1400){
	print("Divison 3")
}
else{
	print("Divison 4")
}
}

var len = parseInt(readline());
var i=0;
var rating;
for(i=0; i < len; i++){
 rating = parseInt(readline());
if (rating <= 1900){
	print("Divison 1")
}
else if (rating <= 1899 && rating >= 1600){
	print("Divison 2")
}

else if (rating <= 1599 && rating >= 1400){
	print("Divison 3")
}
else{
	print("Divison 4")
}
}

const linesCount = readline();

for(x = 0; x < +linesCount; x++) {
    var curLine = parseInt(readline());
    print(curLine, typeof curLine);
    if (curLine >= 1900) {
        print('Division 1');
    } else if (curLine >= 1600) {
        print('Division 2');
    } else if (curLine >= 1400) {
        print('Division 3');
    } else {
        print('Division 4');
    }
}

var testCase = +readline()
for (var i = 0; i < testCase; i++) {
  var sequence = +readline()
  if (sequence > 1900) {
    print("Division 1")
  } else if (sequence >= 1600 && sequence <= 1899) {
    print("Division 2")
  } else if (sequence >= 1400 && sequence <= 1599) {
    print("Division 3")
  } else {
    print("Division 4")
  }
}

var num=parseInt(readline());
var arr=[];
for(var i=0;i<num;i++){
    arr.push(parseInt(readline()));
}
for(var i=0;i<num;i++){
    switch(arr[i]){
        case arr[i]<=1399:
            print("Division 4");
            break;
        case arr[i]<=1599:
            print("Division 3");
            break;
        case arr[i]<=1899:
            print("Division 2");
            break;
        default:
            print("Division 1");
    }
}

let i = '';
process.stdin.on('data', c => i += c);
process.stdin.on('end', () => {
    const {EOL} = require('os');
    const lines = i.split(EOL);
    var n = lines[0]
    for(j = 1; j <= n; j++){
        var rating = lines[j]
        if(1900 < rating){
            console.log('Division 1')
        }else if(1600 < rating && rating < 1899){
            console.log('Division 2')
        }else if(1400 < rating && rating < 1599){
            console.log('Division 3')
        }else if(rating < 1399){
            console.log('Division 4')
        }
    }
});

let i = '';
process.stdin.on('data', c => i += c);
process.stdin.on('end', () => {
    const {EOL} = require('os');
    const lines = i.split(EOL);
    var n = lines[0]
    for(j = 1; j <= n; j++){
        var rating = lines[j]
        if(1900 < rating){
            console.log('Division 1')
        }else if(1600 < rating && rating < 1899){
            console.log('Division 2')
        }else if(1400 < rating < 1599){
            console.log('Division 3')
        }else if(rating < 1399){
            console.log('Division 4')
        }
    }
});

let i = '';
process.stdin.on('data', c => i += c);
process.stdin.on('end', () => {
    const {EOL} = require('os');
    const lines = i.split(EOL);
    var n = lines[0]
    for(j = 1; j <= n; j++){
        var rating = lines[j]
        if(1900 < rating){
            console.log('Division 1')
        }else if(1600 < rating && rating < 1899){
            console.log('Division 2')
        }else if(1400 < rating < 1599){
            console.log('Division 3')
        }else if(1399 > rating){
            console.log('Division 4')
        }
    }
});

let i = '';
process.stdin.on('data', c => i += c);
process.stdin.on('end', () => {
    const {EOL} = require('os');
    const lines = i.split(EOL);
    var n = lines[0]
    for(j = 1; j <= n; j++){
        var rating = lines[j]
        if(1900 < rating){
            console.log('Division 1')
        }else if(1600 < rating && rating < 1899){
            console.log('Division 1')
        }else if(1400 < rating < 1599){
            console.log('Division 1')
        }else if(1399 > rating){
            console.log('Division 1')
        }
    }
});

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

let c = 0;

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

  const rating = Number(d);
  if (rating <= 1399) {
    console.log("Division 4");
  } else if (rating >= 1400 && rating <= 1599) {
    console.log("Divison 3");
  } else if (rating >= 1600 && rating <= 1899) {
    console.log("Division 2");
  } else {
    console.log("Division 1");
  }

  c++;
});

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

'use strict';

var readline = require('readline');

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

var readline__default = /*#__PURE__*/_interopDefaultLegacy(readline);

function solve(n) {
  if (n < 1400) {
    console.log('Division4');
  } else if (n < 1600) {
    console.log('Division3');
  } else if (n < 1900) {
    console.log('Division2');
  } else {
    console.log('Division1');
  }
}

async function main(read) {
  const t = Number(await read());
  for (let i = 0; i < t; i++) {
    const n = Number(await read());
    solve(n);
  }
}

const rl = readline__default["default"].createInterface({
  input: process.stdin,
  output: process.stdout
});
void async function () {
  const inputs = [];
  let i = 0;
  for await (const line of rl) {
    inputs.push(line.trim());
  }
  function read() {
    return inputs[i++];
  }
  await main(read);
}();

'use strict';
 /*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)

const calc = (n, m, A)=>{
  if (n<=1399)
    return 4;
  if (n<=1599)
    return 3;
  if (n<=1899)
    return 2;
    return 1
};

function main() {
    let T = +readline()
    while (T--){
      let [n, m] = ra();
      L('Ans:')
      print(calc(n, m));
    }
}

E.calc = calc;