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

var lines = [];
var reader = require('readline').createInterface({
  input: process.stdin,
  output: process.stdout
});
reader.on('line', (line) => {
  lines.push(line);
});
reader.on('close', () => {
const [f, l] = lines[0].split(" ").map(Number);
//console.log(n);
function kazu(s, t) {
  return Math.abs(s-t);
}
for(let i = 1; i<= f; i++) {
  const [a, b] = lines[i].split(" ").map(Number);
  console.log(kazu(a, b));
}

});