var stops = readline();
var total = 0;
var max = 0;
while(stops--){
    var pass = readline().split(' ');
    total = total - parseInt(pass[0]) + parseInt(pass[1]);
    if(total >= max){
        max = total;
    }
}

print(max);

var count = +readline();
var capacity = 0;
var inside = 0;

for (var i=0; i<count; i++) {
    var line = readline();
    line = line.split(' ');
    line = line.map(Number);
    inside -= line[0];
    inside += line[1];
    if (inside>capacity) { capacity = inside; }
}

print(capacity);

var n = parseInt(readline());
var capacity = 0;
var passengers = 0;

for(var i = 0; i < n; i++)
{
	var ab = readline().split(' ');
	passengers -= parseInt(ab[0]);
	passengers += parseInt(ab[1]);
	if(passengers > capacity) capacity = passengers;
}

print(capacity);

//numero de tramos
var dato1 =parseInt(readline());
//array que almacene pasajeros por tramos
var arra = new Array();
//contador auxiliar
var suma=0;

for(var i=0;i<dato1;i++){
    //por cada vuelta recoge los dos datos por tramo
    var datos =  readline().split(" ");
        var primero = parseInt(datos[0]);
        var segundo = parseInt(datos[1]);
        //saco número pasajero por tramos sin tener en cuenta el anterior tramo
        var res= -primero + segundo;
        //saco el número de pasajero por tramos teniendo en cuenta el anterior tramo gracias al auxiliar suma
        suma = suma +res
        arra.push(suma);

}

//ordena el array de mayor a menor
arra.sort(function(a, b){return b - a});
print(arra[0]);

n=readline();
var maxCapacity=-1;
var currCapacity=0;
while(n--){
	s=readline().split(' ').map(v=>+v);
	currCapacity=currCapacity-s[0]+s[1];
	if(currCapacity>maxCapacity){
		maxCapacity=currCapacity;
	}
}
print(maxCapacity);

var n = +readline();

var ans = 0;
var max = 0;
for(var i = 0 ; i < n ;i++){
	var arr = readline().split(' ');

	var a = +arr[0];
	var b = +arr[1];

	ans -= a;
	ans += b;

	max = Math.max(ans,max);

}

print(max);

line = readline(), ans = 0, cur = 0;
while (line = readline()) {
    line = line.split(' ').map(function(x) { return +x; });
    cur = Math.max(0, cur - line[0] +line[1]);
    ans = Math.max(ans, cur);
}
print(ans);

var n = parseInt(readline());
var passengers = [];
var a = [];
var b = [];
var max_capacity = 0;
var result = 0;

for (var i = 0; i < n; i++) {
	passengers = readline().split(' ');

	a.push(parseInt(passengers[0]));
	b.push(parseInt(passengers[1]));
}

for (var i = 0; i < n; i++) {
	result = result - a[i] + b[i];
	if (result > max_capacity) {
		max_capacity = result;
	}
}
print (max_capacity);

var n = parseInt(readline());
var passengers = [];
var max_capacity = 0;
var result = 0;

for (var i = 0; i < n; i++) {
    passengers = readline().split(' ');
    result = result - parseInt(passengers[0]) + parseInt(passengers[1]);
	max_capacity = Math.max(result, max_capacity);
}
print (max_capacity);

/* TEST CASE
input
4
0 3
2 5
4 2
4 0
output
6
 */

function main() {
	var n = parseInt(readline());
	var answer = 0;
	var splitted;
	var currentPersons = 0;

	for (var i = 0; i < n; i++) {
		splitted = readline().split(' ');
		var exits = parseInt(splitted[0]);
		var enters = parseInt(splitted[1]);
		currentPersons += enters - exits;
		answer = Math.max(answer, currentPersons);
	}

	print(answer);
}

main();

var lines = readline();
lines = parseInt(lines);
var exits= new Array();
var entries = new Array();
var sum = 0;
var persons = 0;

for (var i=0, j=0; i<lines; i++) {
	var line = readline().split(' ');
	exits.push(parseInt(line[j]));
	entries.push(parseInt(line[j+1]));
}

for (var z=0; z<entries.length; z++) {
	if (persons+entries[z]-exits[z] > sum) {
		sum = persons+parseInt(entries[z])-parseInt(exits[z]);
	}
	persons = persons+parseInt(entries[z])-parseInt(exits[z]);
}

print(sum);

//116A Трамвай
var n = +readline();
var max = 0;
var current = 0;
while (n--) {
    var io = readline().split(' ').map(e => parseInt(e));
    current += io[1] - io[0];
    max = (current > max) ? current : max;
}
print(max);

var counts = +readline(),
    max = 0, now = 0;

for (var i = 0; i < counts; i++) {
    var data = readline().split(' '),
        out = +data[0], in_p = +data[1];

        now -= out;
        now += in_p;

        if (now > max) max = now;
}

print(max);

function detectMax(out, into)
{
    return into - out;
}

{
    var num = parseInt(readline());
    var max = 0, medium = 0;
    for (var i = 1; i <= num; i++)
    {
        var input = readline();
        input = input.split(' ');
        medium += detectMax(parseInt(input[0]), parseInt(input[1]));
        if (medium > max) max = medium;
    }
    print(max);
}

var n = readline();
var io;
var current = 0;
var capacity = -1;
for(var i = 0; i < n; i++){
	io = readline().split(" ");
	current += (io[1]-io[0]);
	capacity = (current > capacity) ? current : capacity;

}
print(capacity);

readline(); for(var s, a, b, now = 0, ans = 0; s = readline(); ) {
    s = s.split( ' ' ); a = s[0] - ''; b = s[1] - '';
    now = now - a + b;
    ans = Math.max( now, ans );
}
print( ans );

var n = parseInt(readline(), 10), ab = [], minCap = 0, existPassenger = 0;

for(var i=1; i<=n-1; i++) {
    ab = readline().split(' ').map(el => parseInt(el, 10));
    existPassenger = existPassenger - ab[0] + ab[1];
    minCap = existPassenger > minCap ? existPassenger : minCap;
}

print(minCap);

var n = Number(readline());

var minTramCapcty = 0,
    temp = 0;

for (var i = 0; i < n; i++) {
    var stopStop = readline().split(' ').map(Number);
    var exit = stopStop[0];
    var enter = stopStop[1];

    temp -= exit;
    temp += enter;

    if ( temp > minTramCapcty ) {
        minTramCapcty = temp;
    }
}

print( minTramCapcty );

var n = readline()
var str = []
for (var i = 0; i < n; i++) {
    var line = readline()
    line = line.split(" ")
    str.push(line[0])
    str.push(line[1])
}
var rez = 0
var trig = true
var bol = 0
for (var i = 1; i < str.length; i++) {
        if(trig){
		rez += Number(str[i])
		trig = false
		if(rez > bol){
			bol = rez
		}
	} else {
		rez -= Number(str[i])
		trig = true
	}
}
print(bol)

var n = +readline();

var max=0;
var p=0;
while(n--){
	var l=readline().split(' ');
	p+=l[1]-l[0];
	if(p>max) max=p;
}
print(max);

var a  =  readline();
var jami = 0, max = 0;
for(i = 1; i < a; i ++ ) {
	var cin = readline().split(" ").map(function(v){return +v;});
	jami = jami + cin[1] - cin[0];
	if(jami >= max) {
		max = jami;
	}
}

print(max);

var n = +readline(), input = [], c = 0, prev = 0;

for(i = 0; i < n; i++){
	input.push(readline().split(" "));
}

for( i = 0; i < n; i++ ){
	prev = prev + +input[i][1] - +input[i][0];
	if( prev > c ){
		c = prev;
	}
}
write(c);

var stops = parseInt(readline());

var minCapacity = 0; var curntCapacity = 0;

var enterLeavLine = ''; var leavingPass = 0; var entringPass = 0;

for(var i = 1; i <= stops; i++)
{
   enterLeavLine = readline();
   leavingPass = parseInt(enterLeavLine.split(" ")[0]);
   entringPass = parseInt(enterLeavLine.split(" ")[1]);

   curntCapacity -= leavingPass;
   curntCapacity += entringPass;

   if (curntCapacity > minCapacity) minCapacity = curntCapacity;

  // print('Min : ' + minCapacity);
  // print('Crnt : ' + curntCapacity);

}

print(minCapacity);

(function() {
    var stopCount = parseInt(readline());

    var currentPassangers = 0;
    var maxPassengers = 0;
    for (var i = 0; i < stopCount; i++){

        var inOutPassangers = readline().trim().split(" ").map(Number);
        var outPass = inOutPassangers[0];
        var inPass = inOutPassangers[1];

        currentPassangers -= outPass;
        currentPassangers += inPass;

        if (currentPassangers > maxPassengers)
            maxPassengers = currentPassangers;
    }

    print(maxPassengers);

    return 0;
})();

readline();
var a = c = split(readline(), ' ')[1], b;

while (b = readline()) {
  b = split(b, ' ');
  a = a - b[0] + +b[1];
  if (a > c) c = a;
}

function split(t, r) {
  var d = t.length, e = 0, f = '', g = [];

  for (; e < d; e++) {
    if (t[e] !== r) {
      f = f + t[e];
    } else {
      g[g.length] = f;
      f = '';
    }
  }
  g[g.length] = f;
  return g;
}

print(c);

readline();
var a = c = readline().split(' ')[1], b;

while (b = readline()) {
  b = b.split(' ');
  a = a - b[0] + +b[1];
  if (a > c) c = a;
}

print(c);

var n = readline();

var max = 0;
var current = 0;
while (n > 0) {
  var m = readline().split(' ');
  current = current - Number(m[0]) + Number(m[1]);

  if (current > max)
    max = current;

  --n;
}

print(max);

var n = readline();

var capacity = 0;

var passengers=0;

for(i=0;i<n;i++){
    var line = readline().split(' ');
    passengers-=parseInt(line[0]);
    passengers+=parseInt(line[1]);

    //    print (passengers);

    if(passengers>capacity){
	capacity = passengers;
    }
}

print (capacity);

// Linear Kingdom has exactly one tram line. It has n stops, numbered from 1 to n in the order of tram's movement. At the i-th stop ai passengers exit the tram, while bi passengers enter it. The tram is empty before it arrives at the first stop. Also, when the tram arrives at the last stop, all passengers exit so that it becomes empty.

// Your task is to calculate the tram's minimum capacity such that the number of people inside the tram at any time never exceeds this capacity. Note that at each stop all exiting passengers exit before any entering passenger enters the tram.

// Input
// The first line contains a single number n (2 ≤ n ≤ 1000) — the number of the tram's stops.

// Then n lines follow, each contains two integers ai and bi (0 ≤ ai, bi ≤ 1000) — the number of passengers that exits the tram at the i-th stop, and the number of passengers that enter the tram at the i-th stop. The stops are given from the first to the last stop in the order of tram's movement.

//     The number of people who exit at a given stop does not exceed the total number of people in the tram immediately before it arrives at the stop.
//     At the last stop, all the passengers exit the tram and it becomes empty.
//     No passenger will enter the train at the last stop. That is, bn = 0.

// Output
// Print a single integer denoting the minimum possible capacity of the tram (0 is allowed).

var n = readline()
var t = []
var sum = 0
var max = 0

for (i = 0; i < n; i++) {
    t.push(readline().split(" "));
    if (i === 0){
        sum = +t[0][1];
        max = sum
    }else {
        sum += +t[i][1] - +t[i][0];
        if (sum > max) {
        max = sum
        }
    }
}

print(max)

function main() {
    var input = readline()
    var passenger = [];
    for (; input > 0; input--) {
        passenger.push(readline().split(' '))
    }
    var result = 0;
    var current = 0;
    for (var i = 0, l = passenger.length; i < l; i++) {
        current = current + (passenger[i][1] - passenger[i][0])
        result = current > result ? current : result
    }
    print(result)
}
main()

var n = readline();
var c = 0;
var t = 0;

for(var i=0; i<n; i++){
    var r = readline().split(' ');
    var out = parseInt(r[0]);
    var en = parseInt(r[1]);
    c = c - out;
    c = c + en;
    if(t < c){
        t = c;
    }
}

print(t);

var getVals =  function() {return readline().split(' '); };

var getNums = function() {
	return readline().split(' ').map(function(a) {return parseInt(a)});
};

var n = parseInt(readline());

var max = 0;
var curr = 0;

for (var i = 0; i < n; i++) {
	var arr = getNums();
	curr = curr - arr[0] + arr[1];
	max = Math.max(max, curr);
}

print(max);

var input = parseInt(readline());
	var salida = 0;
	var input2;
	var pasajeros = 0;

	for (var i = 0; i < input; i++) {
		input2 = readline().split(' ');
		var bajan = parseInt(input2[0]);
		var suben = parseInt(input2[1]);
		pasajeros += suben - bajan;
		salida = Math.max(salida, pasajeros);
	}

	print(salida);

var n = parseInt(readline());
var min_capacity = 0;
var capacity = 0;
for(var i = 0; i < n; i++){
    var array = readline().split(' ').map(Number);
    capacity = capacity - array[0] + array[1];
    if (min_capacity < capacity) {
        min_capacity = capacity;
    }
}
print(min_capacity);

var print = this.print || require('lol-io').print
var write = this.write || require('lol-io').write
var readline = this.readline || require('lol-io').readline

var s=parseInt(readline().split(' ')[0]);
var arr=[];
for(var i=0;i<s;i++){
arr[i]=readline().split(' ').map(i=>parseInt(i));
}

var sum=0;
var max=0;
for(var i=0;i<arr.length;i++){
    var remove=arr[i][0];
    var adding=arr[i][1];
    sum=Math.abs(sum-remove);
    sum+=adding;
    if(max<sum){
        max=sum;
    }
}
//console.log(max)
print(max)

 function main(){
    var ans=0;
    var cur=0;
    var n=parseInt(readline());

    for(var i=0;i<n;i++){
        var line=readline().split(' ');
        var a=parseInt(line[0]);
        var b=parseInt(line[1]);
        cur+=(b-a);
        if(cur>ans){
            ans=cur;
        }

    }

    print(ans);
}
main();

var numberStopTram = +readline();
var maxVolumeTram = 0;
var currentVolumeTram = 0;
for (numberStopTram; numberStopTram>0; numberStopTram--) {
    var currentStopInfo = readline().split(" ");
    var passengersOut = +currentStopInfo[0];
    var passengersIn = +currentStopInfo[1];
    currentVolumeTram = currentVolumeTram - passengersOut + passengersIn;
    if (currentVolumeTram > maxVolumeTram) maxVolumeTram = currentVolumeTram;
}
print(maxVolumeTram);

n = readline();

var pas = 0;
var max = 0;

for (var i = 0; i < n; i++) {
	ab = readline().split(' ').map(Number);
	var a = ab[0], b = ab[1];

	pas = pas - a + b;

	if (pas > max) {
		max = pas;
	};
};

print(max);

var n = readline();
var ac = 0;
var res = 0;
for(var i = 0; i < n; ++i){
    var c = readline().split(' ');
    ac += (+c[1] - +c[0]);
    if(ac > res) res = ac;
}
print(res);

var n=parseInt(readline());
var p = 0;
var max = 0;
while(n--){
    var l=readline().split(' ');
    p+=l[1]-l[0];
    if(p>max) max=p;
}
print(max);

var N = readline() - 0;

var m = 0;
var max = 0;
for (var i = 0; i < N; i++) {
    var input = readNums();
    m += input[1] - input[0];
    if (m > max)
        max = m;
}
print(max);

function readNums() {
    return readline().split(' ').map(v => v - 0);
}

n = parseInt(readline());
cap = 0;
maxc = 0;
for (var i = 0; i < n; i++){
	A = readline().split(" ");
	cap -= parseInt(A[0]);
	cap += parseInt(A[1]);
	if (cap > maxc) maxc = cap;
}
write(maxc);

var ints = function() {
	return readline().split(' ').map(function(word) {
		return parseInt(word)
	})
}

var n = parseInt(readline()),
	m = 0,
	c = 0,
	p = []

while (n > 0) {
	p = ints()
	c = c - p[0] + p[1]
	if (c > m)
		m = c
	n --
}

print(m)

var stops = readline();
var passengers = 0;
var max = [];

for (var i = 0; i < +stops; i++) {
	var str = readline().match(/\d{1,4}/g);
	var into = +str[1];
	var out = +str[0];

	passengers += (into - out);
	max.push(Math.abs(passengers));
}

print(Math.max(...max))

var stops = readline();
stops = parseInt(stops);
var max = 0;
var current = 0;
while(stops > 0){
    var input = readline().split(" ").map(x=>parseInt(x));
    var out = input[0];
    var inp = input[1];
    current = (current+inp)-out;
    if(current > max)max = current;
    stops--;
}

print(max);

;(function () {
	var n = readline();
	var v = 0;
	var r = 0;
	for(var i = 0; i < n; i++) {
		var t = readline().split(' ');
		r += t[1] - t[0];
		v = Math.max(v, r);
	}

	print(v);
}).call(this);

var arrTram = [];
var n = +readline();
var m = 0;
var arrCheck = [];
for(var i = 0; i < n; i++){
    arrTram[i] = readline().split(' ');
}
for(var i = 0; i < n; i++){
    arrTram[i][0] = +arrTram[i][0];
    arrTram[i][1] = +arrTram[i][1];
	m = m - arrTram[i][0] + arrTram[i][1];
	arrCheck[i] = m;
//	print(+arrTram[i][1]);
}
arrCheck.sort(function(a, b){
    if(a > b)return -1;
    if(a < b)return 1;
});
print(arrCheck[0]);

var n = parseInt(readline());
      var arr = [],
        min = 0,
        remaining = 0,
        exit = 0,
        newmin,
        newPassenger;
      for (var i = 0; i < n; i++) {
        var line = readline()
          .split(" ")
          .map((el) => parseInt(el));
        arr.push(line);
      }
      for (var j = 0; j < arr.length - 1; j++) {
        if (min == 0) {
          exit = arr[1][0];
          newPassenger = arr[0][1];
        }
        if (newmin == undefined) {
          remaining = arr[j][1] - arr[j + 1][0];
        } else {
          remaining = newmin - arr[j + 1][0];
        }
        newmin = remaining + arr[j + 1][1];
        if (newmin > min) {
          min = newmin;
        }
      }
      if (min == 0) {
        print(exit);
      } else if (min < exit) {
        print(newPassenger);
      } else {
        print(min);
      }

var stops=parseInt(readline()),
    minCapac=0
    temp = 0;
while(stops--){
    var outAndIn = readline().split(" "),
    out = parseInt(outAndIn[0]),
    In = parseInt(outAndIn[1]);
    if((temp -out+In)>=minCapac){
        minCapac=temp-out+In;

    }
            temp += In - out;
}
print(minCapac);

var numberOfStop = +readline(),
    minCapac = 0,
    curCapac = 0;
while(numberOfStop--){
    var line = readline().split(" ");
    curCapac += (+line[1])-(+line[0]);
    if(curCapac > minCapac){ minCapac = curCapac }
}
print(minCapac);

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

let inputString = '';
let currentLine = 0;

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

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

    main();
});

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

function main() {
    let t = readLine()
    t = parseInt(t)
    let str = '', max = 0, res = 0
    for (let i = 0; i < t; i++) {
        str = readLine().split(" ")
        str[0] = parseInt(str[0])
        str[1] = parseInt(str[1])
        if (i === 0) {
            max = str[1]
        } else {
            max -= str[0]
            max += str[1]
        }

        if (res < max) res = max
    }
    console.log(res)
}

let inputString = "";
let currentLine = 0;
process.stdin.on("data", (data) => {
  inputString += data;
});
process.stdin.on("end", function () {
  inputString = inputString
    .trim()
    .split("\n")
    .map((str) => str.trim());
  main();
});
function readLine() {
  return inputString[currentLine++];
}
function main() {
  let len = +readLine();
  let count = 0;
  let max = 0;
  while (len--) {
    const [exit, enter] = readLine()
      .split(" ")
      .map((n) => parseInt(n));
    count -= exit;
    count += enter;
    max = Math.max(max, count);
  }
  console.log(max);
}

var line_number = 0;
const cs = require("readline").createInterface({
  input: process.stdin,
  output: process.stdout,
});

var lines = [];
cs.on("line", (input) => {
  if (input == "") {
    cs.close();
  }
  lines.push(input.split(" "))
  line_number += 1;
}).on("close", () => {
  main();
  process.exit();
});

function isOp(str) {
  return str.length === 1 && str.match(/[<=>]/);
}
function isChr(str) {
  return str.length === 1 && str.match(/[a-z]/i);
}
function isInt(str) {
  return str.length === 1 && str.match(/[0-9*]/);
}

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

function exit(status = 0) {
  process.exit(status);
}

function predict(test) {
  let op = "";
  let ops = [];
  let opVariables = [];
  let limits = [];
  for (let t of test) {
    // console.log(t);
    for (let i = 0; i < t.length; i++) {
      if (isOp(t[i])) {
        op = t[i];
        if (isOp(t[i + 1])) {
          op += t[i + 1];
          i += 1;
        }
        ops.push(op);
        op = "";
      } else if (isChr(t[i])) {
        // console.log(t[i])
        op = t[i];
        for (var j = i + 1; j < t.length; j++) {
          if (isChr(t[j]) || isInt(t[j])) {
            op += t[j];
            i = j;
          } else break;
        }
        opVariables.push(op);
        op = "";
      } else {
        if (i == 0 || (i > 0 && isOp(t[i - 1]))) {
          op = t[i];
          let j = i + 1;
          for (; j < t.length; j++) {
            if (isInt(t[j])) {
              op += t[j];
              i = j;
            } else break;
          }
          limits.push(op);
          op = "";
        }
      }
    }
  }

  let min = limits[0];
  let max = limits[1];

  let pvs = ops.map((o, i) => [o, opVariables[i]]);

  for (let pv of pvs) {
    if (pv[1] == undefined) {
      pv[1] = max;
    }
    // print(`${min} ${pv[0]} ${pv[1]} ?`)
    if (eval(`${min}${pv[0]}${pv[1]}`)) {
      // print(` ${min} ${pv[0]} ${pv[1]} true`)
      min = pv[1];
    } else {
      print("input error");
      exit();
    }
  }
}

var n;
function main() {
  n = parseInt(lines[0][0],10)
  let d = 0,r=0
  for(let i = 1; i <= lines.slice(1,).length; i++) {
    stops = lines[i].map(x => parseInt(x,10))
      if(d > r )
        r = d
      d = d - stops[0] + stops[1];
    }
    print(r)
}

// author: Oscar Ramos

/// Source Code
// const input = require('competitive-programming-js').inputReader
// const { forn } = require('../utils/utils')
//
// const n = input.readNumber()
//
// let capacity = 0
// let minCapacity = 0
// forn(n, () => {
//   const [a, b] = input.readNumberArray()
//   capacity = capacity - a + b
//   minCapacity = Math.max(minCapacity, capacity)
// })
//
// console.log(minCapacity)
//

!function(n){var t={};function r(e){if(t[e])return t[e].exports;var o=t[e]={i:e,l:!1,exports:{}};return n[e].call(o.exports,o,o.exports,r),o.l=!0,o.exports}r.m=n,r.c=t,r.d=function(n,t,e){r.o(n,t)||Object.defineProperty(n,t,{enumerable:!0,get:e})},r.r=function(n){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(n,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(n,"__esModule",{value:!0})},r.t=function(n,t){if(1&t&&(n=r(n)),8&t)return n;if(4&t&&"object"==typeof n&&n&&n.__esModule)return n;var e=Object.create(null);if(r.r(e),Object.defineProperty(e,"default",{enumerable:!0,value:n}),2&t&&"string"!=typeof n)for(var o in n)r.d(e,o,function(t){return n[t]}.bind(null,o));return e},r.n=function(n){var t=n&&n.__esModule?function(){return n.default}:function(){return n};return r.d(t,"a",t),t},r.o=function(n,t){return Object.prototype.hasOwnProperty.call(n,t)},r.p="",r(r.s=1)}([function(n,t){n.exports=function(n){return null!=n&&"object"==typeof n&&!0===n["@@functional/placeholder"]}},function(n,t,r){n.exports=r(2)},function(n,t,r){let e,o=0,u={readNumber:function(){return Number(e[o++])},readNumberArray:function(){return e[o++].split(" ").map(n=>Number(n))}};var c="";process.stdin.resume(),process.stdin.setEncoding("utf8"),process.stdin.on("data",(function(n){c+=n})).on("end",(function(){e=c.trim().split("\n").map(n=>n.trim());const{forn:n}=r(3),t=u.readNumber();let o=0,i=0;n(t,()=>{const[n,t]=u.readNumberArray();o=o-n+t,i=Math.max(i,o)}),console.log(i)}))},function(n,t,r){const e=r(4);n.exports={forn:(n,t)=>e(0,n).forEach(t)}},function(n,t,r){var e=r(5),o=r(7),u=e((function(n,t){if(!o(n)||!o(t))throw new TypeError("Both arguments to range must be numbers");for(var r=[],e=n;e<t;)r.push(e),e+=1;return r}));n.exports=u},function(n,t,r){var e=r(6),o=r(0);n.exports=function(n){return function t(r,u){switch(arguments.length){case 0:return t;case 1:return o(r)?t:e((function(t){return n(r,t)}));default:return o(r)&&o(u)?t:o(r)?e((function(t){return n(t,u)})):o(u)?e((function(t){return n(r,t)})):n(r,u)}}}},function(n,t,r){var e=r(0);n.exports=function(n){return function t(r){return 0===arguments.length||e(r)?t:n.apply(this,arguments)}}},function(n,t){n.exports=function(n){return"[object Number]"===Object.prototype.toString.call(n)}}]);

/// package.json
// {
//   "name": "competitive",
//   "version": "1.0.0",
//   "description": "",
//   "main": "src/index.js",
//   "scripts": {
//     "convert": "cp-convert -s src/index.js -d output/converted.js",
//     "bundle": "webpack --config ./webpack.config.js",
//     "test": "npm run convert && jest ./",
//     "production": "npm run convert && npm run bundle && node src/getOutput.js",
//     "start": "node src/index.js"
//   },
//   "author": "Oscar Ramos",
//   "dependencies": {
//     "child-process-promise": "^2.2.1",
//     "competitive-programming-js": "^1.0.10",
//     "mathball": "^0.4.0",
//     "ramda": "^0.27.1"
//   },
//   "devDependencies": {
//     "@types/jest": "^26.0.10",
//     "concat-stream": "^2.0.0",
//     "cross-spawn": "^7.0.3",
//     "jest": "^26.4.2",
//     "jest-expect-message": "^1.0.2",
//     "mock-stdin": "^1.0.0",
//     "terser-webpack-plugin": "^4.1.0",
//     "webpack": "^4.44.1",
//     "webpack-cli": "^3.3.12"
//   },
//   "jest": {
//     "setupFilesAfterEnv": ["jest-expect-message"]
//   }
// }
//

let inputString = '';
let currentLine = 0;

const runMain = () => {
  inputString = inputString.trim().split('\n').map(string => string.trim());
  main();
  process.exit();
}
const readLine = () => inputString[currentLine++];

process.stdin.on('data', inputStdin => inputString += inputStdin);
process.stdin.on('end', runMain);
process.on('SIGINT', runMain);

function main() {
  const n = Number(readLine());
  let max = 0;
  let count = 0;
  for (let i = 0; i < n; i++) {
    const [a, b] = readLine().split(' ').map(num => Number(num));
    count -= a;
    count += b;
    max = Math.max(max, count);
  }
  console.log(max);
}

//Tram

const {EOL} = require('os');

let inp = '';

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

process.stdin.on('end', () => {
    let lines = inp.split(EOL);

    let max = 0, curr = 0;
    for(let i = 1; i <= +lines[0]; i++)  {
    	let s = lines[i].split(' ').map(c => +c);
    	curr -= s[0];
    	curr += s[1];
    	if(curr > max)  {
    		max = curr;
    	}
    }

    process.stdout.write(max + '');

    return;
});

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

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

function isPrime(x) {
	let s = Math.sqrt(x);
	let i = 2;
	while (i <= s) {
		if (x % i === 0) {
			return false;
		}
		i++;
	}
	return true;
}

function main() {
	let n = readLine() >> 0;
	let cap = 0,
		curr = 0,
		exit = [],
		enter = [];
	while (n--) {
		let [a, b] = readLine()
			.split(' ')
			.map(x => x >> 0);
		exit.push(a);
		enter.push(b);
	}

	exit.forEach((p, i) => {
		curr -= p;
		curr += enter[i];
		cap = Math.max(cap, curr);
	});
	console.log(cap);
}

'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 readAsInt(){
  return parseInt(readline());
}

function readAsIntList(){
  return readline().split(' ').filter(i => i).map(i => parseInt(i));
}

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

function main() {
  let n = readAsInt();
  let m = 0;
  let c = 0;
  for(let i = 1; i <= n; i++) {
    let [a, b] = readAsIntList();
    c = c - a + b;
    if (c > m) m = c;
  }
  console.log(m);
}

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

let currentLine = 0;
let inputString = "";

process.stdin.on("data", (raw_data) => {
  inputString += raw_data;
});

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

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

/******** Main function*************/

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

  var arr = [];
  for (var i = 0; i < n; i++) {
    var inp = readLine().split(" ").map(Number);
    arr.push(inp);
  }

  var enter = 0;
  var exit = 0;
  var result = [];
  for (var k = 0; k < n; k++) {
    for (var j = 1; j < 2; j += 2) {
      enter += arr[k][j];
    }
    for (var m = 0; m < 2; m += 2) {
      exit += arr[k][m];
    }
    result.push(enter - exit);
  }
  var minimumPossibleCapacity = Math.max(...result);
  console.log(minimumPossibleCapacity);
}

let fs = require("fs");

let txt = fs.readFileSync(0, "utf-8").split("\r\n").filter(data => {
    return data.length > 0
});
// txt.shift();
for (let index = 0; index < txt.length; index++) {
    if(!isNaN(txt[index]*1)){
        let tab=[]
        for (let i = index+1; i < index+txt[index]*1+1; i++) {
            tab.push(txt[i].split(" ").filter(data=>{return data.length>0}).map(data=>{return data*1}));
        }
        doit(tab);
    }
}

function doit(tab) {
    let arr=[]
    let pnt=0;
    tab.forEach(data => {
        pnt-=data[0];
        arr.push(pnt);
        pnt+=data[1]
        arr.push(pnt)
    });
    console.log(Math.max(...arr));
}

// Sample code to perform I/O:

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

process.stdin.on("data", function (input) {
    stdin_input += input;                               // Reading input from STDIN
});

process.stdin.on("end", function () {
    main(stdin_input);
});

function main(input) {
    let output = nameLookUp(input);
    process.stdout.write(output);       // Writing output to STDOUT
}

// Warning: Printing unwanted or ill-formatted data to output will cause the test cases to fail

// Write your code here
function nameLookUp(str) {
    let tramLines = str.trim().split('\n');
    let capacity = [0];
    for (let i = 1; i <= +tramLines[0]; i++) {

        let stops = tramLines[i].trim().split(' ').map((num) => Number(num));
        let currentStopCapacity = capacity[capacity.length - 1] - stops[0];
        capacity.push(stops[1] + currentStopCapacity);
    }

    return Math.max(...capacity).toString();
}

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

const input = [];
readLine.on('line', line => input.push(line));
const tram = () => {
    const n = +input.shift();
    let q = 0;
    let max = 0;
    for (let i = 0; i < n; i++) {
        let row = input[i].split(' ').map(x => +x);
        q -= row[0];
        q+=row[1];
        if (q > max) {
            max = q;
        }
    }
    console.log(max);

};

readLine.on('close', tram);

'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.replace(/\s*$/, '')
        .split('\n')
        .map(str => str.replace(/\s*$/, ''));

    main();
});

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

function main() {
    let n = parseInt(readLine(), 10);
    let ans = 0;
    let passInside = 0;
    for (let i = 0; i < n; i++) {
        let arr = readLine()
            .split(' ')
            .map(value => parseInt(value));

        passInside = passInside - arr[0] + arr[1];
        if (passInside > ans) {
            ans = passInside;
        }
    }
    console.log(ans);
}

var stops=+readline(),
    minCapac=0;
while(stops--){
    var outAndIn = readline().split(" "),
    out = parseInt(outAndIn[0]),
    In = parseInt(outAndIn[1]);
    if((minCapac -out+In)>minCapac)
        minCapac= minCapac+ (In-out);
}
print(minCapac);

var stops=+readline(),
    minCapac=0;
while(stops--){
    var outAndIn = readline().split(" ");
    if((minCapac -(+outAndIn[0])+(+outAndIn[1]))>minCapac)
        minCapac= minCapac+ ((+outAndIn[1])-(+outAndIn[0]));
}
print(minCapac);

  var numberOfStops = readline()
  var currentNumberOfPassengers = 0
  var result = 0

  for (var i = 0; i < numberOfStops; i++) {
    const stopData = readline().split(' ').map(function (number) { return parseInt(number, 10) })
    currentNumberOfPassengers = currentNumberOfPassengers - stopData[0] + stopData[1]
    if (currentNumberOfPassengers > result) (result = currentNumberOfPassengers)
  }

  print(result)

var tram = 0, ans = 0, n = readline(), arr = [];
n = Number(n);
var i;
for(i=0;i<n;i++)
{
	arr = readline().split(" ");
	tram -= +arr[0];
	tram += +arr[1];
	// ans = Math.max(ans, tram);
}
print(tram);
// console.log(tram);

var linenum = parseInt(readline());
var i, views, confirmed = 0;
for(i=0;i<linenum;i++){
    views = readline().split(' ').map(function(view){
        return parseInt(view);
    });
    if(views[0] + views[1] + views[2] >= 2){
        confirmed ++;
    }
}
print(confirmed);

var n = readline();
var c = 0;
var temp = 0;
var a = 0;
for (var i=0; i<n; i++){
	var str = readline().split("");
	var inn = str[1];
	var out = str[0];

	 c=c-out+inn;
	 if (temp>c)
		a = temp;
	 temp = c;
}
print(a); //console.log

var n = readline();
var c = 0;
var temp = 0;
var a = 0;
for (var i=0; i<n; i++){
	var str = readline().split("");
	var inn = str[1];
	var out = str[0];

	 c=-out+inn;
	 if (temp>c)
		a = temp;
	 temp = c;
}
print(a); //console.log

var n = readline();
var c = 0;
var temp = 0;
var a = 0;
for (var i=0; i<n; i++){
	var str = readline().split("");
	var inn = str[1];
	var out = str[0];

	 c=c-out+inn;
	 if (temp>c)
		a = temp;
		temp=0;
		c=0;
	 temp = c;
}
print(Math.abs(a)); //conso

var n = readline();
var c = 0;
var temp = 0;
var a = 0;
for (var i=0; i<n; i++){
	var str = readline().split("");
	var inn = str[1];
	var out = str[0];

	 c=c-out+inn;
	 if (temp>c)
		a = temp;
	 temp = c;
}
print(Math.abs(a)); //console.log

var n = readline();
var c = 0;
var temp = 0;
var a = 0;
for (var i=0; i<n; i++){
	var str = readline().split("");
	var inn = str[1];
	var out = str[0]

	 c=-(+out)+inn;
	 if (temp>c)
		a = temp;
	 temp = c;
}
print(a); //console.log

var n = readline();
var c = 0;
var temp = 0;
var a = 0;
for (var i=0; i<n; i++){
	var str = readline().split("");
	var inn = str[1];
	var out = str[0];

	 c=c-out+inn;
	 if (temp>c)
	 {
		a = temp;

	 }
	 temp = c;
	 if(n==i){
	temp = 0;
     c = 0;
	 }
}
print(Math.abs(a)); //console.log

var n = readline();
var c = 0;
var temp = 0;
var a = 0;
for (var i=0; i<n; i++){
	var str = readline().split("");
	var inn = str[1];
	var out = str[0];

	 c=c-out+inn;
	 if (temp>c)
	 {
		a = temp;
		temp=0;
		c=0;
		}
	 temp = c;
}
print(Math.abs(a)); //console.log

var n = readline();
var c = 3;
var temp = 0;
var a = 0;
for (var i=0; i<n; i++){
	var str = readline().split("");
	var inn = str[1];
	var out = str[0];

	 c=c-out+inn;
	 if (temp>c)
		a = temp;
	 temp = c;
}

line = readline(), ans = 0, cur = 0;
while (line = readline()) {
    line = line.split(' ').map(function(x) { return +x; });
    cur = Math.max(0, ans - line[0] +line[1]);
    ans = Math.max(ans, cur);
}
print(ans);

var paradas = parseInt(readline());
var cantidadMax = 0;
var difSubBaj = new Array();
var final = new Array();
var sum = new Array();

function numeroPlazas (sitios) {
   for (i=0; i<sitios; i++) {
        var valores = readline().split(" ");
        difSubBaj.push(parseInt(valores[1])-parseInt(valores[0]));
    }

    for (i=0; i<difSubBaj.length; i++) {
        sum.push(parseInt(difSubBaj[i])+parseInt(difSubBaj[i+1]));
    }

    for (i=0; i<sum.length; i++) {
        final.push(parseInt(sum[i])+parseInt(sum[i+1]));
    }

    for (i=0; i<final.length; i++) {
        if (cantidadMax < parseInt(final[i])) {
            cantidadMax = parseInt(final[i])
        }
    }

    return cantidadMax;
}

print(numeroPlazas(paradas));

var paradas = parseInt(readline());
var cantidadMax = 0;
var difSubBaj = new Array();
var final = new Array();
var sum = new Array();

function numeroPlazas (sitios) {
   for (i=0; i<sitios; i++) {
        var valores = readline().split(" ");
        difSubBaj.push(parseInt(valores[1])-parseInt(valores[0]));
    }

    for (i=0; i<difSubBaj.length; i++) {
        sum.push(parseInt(difSubBaj[i])+parseInt(difSubBaj[i+1]));
    }

    for (i=0; i<sum.length; i++) {
        final.push(parseInt(sum[i])+parseInt(sum[i+1]));
    }

    for (i=0; i<final.length; i++) {
        if (cantidadMax < parseInt(sum[i])) {
            cantidadMax = parseInt(sum[i])
        }
    }

    return cantidadMax;
}

print(numeroPlazas(paradas));

var paradas = parseInt(readline());
var cantidadMax = 0;
var difSubBaj = new Array();

function numeroPlazas (sitios) {
   for (i=0; i<sitios; i++) {
        var valores = readline();
        difSubBaj.push(parseInt(valores[1])-parseInt(valores[0]));
    }

    for (i=0; i<paradas; i++) {
        if (cantidadMax < parseInt(difSubBaj[i])+parseInt(difSubBaj[i+1])) {
            cantidadMax = parseInt(difSubBaj[i])+parseInt(difSubBaj[i+1]);
        }
    }
    return cantidadMax;
}

print(numeroPlazas(paradas));

var lines = readline();
lines = parseInt(lines);
function calcular(valor) {
    var exits= new Array();
    var entries = new Array();
    var sum = 0;
    var persons = 0;

    for (var i=0, j=0; i<lines; i++) {
        var line = readline().split(' ');
        exits.push(parseInt(line[j]));
        entries.push(parseInt(line[j+1]));
    }

    for (var z=0; z<entries.length; z++) {
        if (persons+entries[z]-exits[z] > sum) {
            sum = persons+parseInt(entries[z])-parseInt(exits[z]);
        }
        persons = persons+parseInt(entries[z])-parseInt(exits[z]);
    }
}

print(calcular(lines));

var paradas = parseInt(readline());
var cantidadMax = 0;
var difSubBaj = new Array();

function numeroPlazas (sitios) {
   for (i=0; i<sitios; i++) {
        var valores = readline();
        difSubBaj.push(parseInt(valores[1])-parseInt(valores[0]));
       print (parseInt(valores[1])+", "+parseInt(valores[0]));
    }

    for (i=0; i<paradas; i++) {
        if (cantidadMax < parseInt(difSubBaj[i])+parseInt(difSubBaj[i+1])) {
            cantidadMax = parseInt(difSubBaj[i])+parseInt(difSubBaj[i+1]);
        }
    }
    return cantidadMax;
}

print(numeroPlazas(paradas));

var paradas = parseInt(readline());
var cantidadMax = 0;
var difSubBaj = new Array();
var sum = new Array();

function numeroPlazas (sitios) {
   for (i=0; i<sitios; i++) {
        var valores = readline().split(" ");
        difSubBaj.push(parseInt(valores[1])-parseInt(valores[0]));
    }

    for (i=0; i<difSubBaj.length; i++) {
        sum.push(parseInt(difSubBaj[i])+parseInt(difSubBaj[i+1]));
    }

    for (i=0; i<sum.length; i++) {
        if (cantidadMax < parseInt(sum[i])) {
            cantidadMax = parseInt(sum[i])
        }
    }

    return cantidadMax;
}

print(numeroPlazas(paradas));

var paradas = parseInt(readline());
var cantidadMax = 0;
var difSubBaj = new Array();

function numeroPlazas (sitios) {
   for (i=0; i<sitios; i++) {
        var valores = readline();
        difSubBaj[i] = parseInt(valores[1])-parseInt(valores[0]);
    }

    for (i=0; i<paradas; i++) {
        if (cantidadMax < parseInt(difSubBaj[i])+parseInt(difSubBaj[i+1])) {
            cantidadMax = parseInt(difSubBaj[i])+parseInt(difSubBaj[i+1]);
        }
    }
    return cantidadMax;
}

print(numeroPlazas(paradas));

var lineas = readline();
lineas = parseInt(lineas);

function calculo(valor) {
    var salidas= new Array();
    var entradas = new Array();
    var sum = 0;
    var personas = 0;

    for (var i=0, j=0; i<lineas; i++) {
        var linea = readline().split(' ');
        salidas.push(parseInt(linea[j]));
        entradas.push(parseInt(linea[j+1]));
    }

    for (var z=0; z<entradas.length; z++) {
        if (personas+entradas[z]-salidas[z] > sum) {
            sum = personas+parseInt(entradas[z])-parseInt(salidas[z]);
        }
        personas = personas+parseInt(entradas[z])-parseInt(salidas[z]);
    }

}
print(calculo(lineas));

var paradas = parseInt(readline());
var cantidadMax = 0;
var difSubBaj = new Array();

function numeroPlazas (sitios) {
   for (i=0; i<sitios; i++) {
        var valores = readline();
        difSubBaj.push(parseInt(valores[1])-parseInt(valores[0]));
        print (parseInt(valores[1])+ ", " + parseInt(valores[0]))
    }

    for (i=0; i<paradas; i++) {
        if (cantidadMax < parseInt(difSubBaj[i])+parseInt(difSubBaj[i+1])) {
            cantidadMax = parseInt(difSubBaj[i])+parseInt(difSubBaj[i+1]);
        }
    }
    return cantidadMax;
}

print(numeroPlazas(paradas));

var valor = readline();
valor = parseInt(valor);

function calculo(lineas) {
    var salidas= new Array();
    var entradas = new Array();
    var sum = 0;
    var personas = 0;

    for (var i=0, j=0; i<lineas; i++) {
        var linea = readline().split(' ');
        salidas.push(parseInt(linea[j]));
        entradas.push(parseInt(linea[j+1]));
    }

    for (var z=0; z<entradas.length; z++) {
        if (personas+entradas[z]-salidas[z] > sum) {
            sum = personas+parseInt(entradas[z])-parseInt(salidas[z]);
        }
        personas = personas+parseInt(entradas[z])-parseInt(salidas[z]);
    }

}
print(calculo(valor));

var paradas = parseInt(readline());
var cantidadMax = 0;
var difSubBaj = new Array();

function numeroPlazas (sitios) {
   for (i=0; i<sitios; i++) {
        var valores = readline().split(" ");
        difSubBaj.push(parseInt(valores[1])-parseInt(valores[0]));
    }

    for (i=0; i<paradas; i++) {
        if (cantidadMax < parseInt(difSubBaj[i])+parseInt(difSubBaj[i+1])) {
            cantidadMax = parseInt(difSubBaj[i])+parseInt(difSubBaj[i+1]);
        }
    }
    return cantidadMax;
}

print(numeroPlazas(paradas));

var valor = readline();
valor = parseInt(valor);
function calcular(lines) {
    var exits= new Array();
    var entries = new Array();
    var sum = 0;
    var persons = 0;

    for (var i=0, j=0; i<lines; i++) {
        var line = readline().split(' ');
        exits.push(parseInt(line[j]));
        entries.push(parseInt(line[j+1]));
    }

    for (var z=0; z<entries.length; z++) {
        if (persons+entries[z]-exits[z] > sum) {
            sum = persons+parseInt(entries[z])-parseInt(exits[z]);
        }
        persons = persons+parseInt(entries[z])-parseInt(exits[z]);
    }
}

print(calcular(valor));

var numberOfStops = readline();
var minCapacity = 0;

for(var i = 0; i < numberOfStops; i++){
    var line = readline().split(' ');
    var exitNumber = line[0];
    var entryNumber = line[1];

    minCapacity -= parseInt(exitNumber);
    minCapacity += parseInt(entryNumber);
}

print(minCapacity);

var numberOfStops = readline();
var minCapacity = 0;

for(var i = 0; i < numberOfStops; i++){
    var line = readline().split(' ');
    var exitNumber = line[0];
    var entryNumber = line[1];

    minCapacity -= exitNumber;
    minCapacity += entryNumber;
}

print(minCapacity);

function detectMax(out, into)
{
    return into - out;
}

{
    var num = parseInt(readline());
    var max = 0, medium = 0;
    for (var i = 1; i <= num; i++)
    {
        var input = readline();
        input = input.split(' ');
        medium += detectMax(parseInt(input[0]), parseInt(input[2]));
        if (medium > max) max = medium;
    }
    print(max);
}

function detectMax(out, into)
{
    if (into - out > 0)
        return into - out;
    else return 0;
}

{
    var number = parseInt(readline());
    var max = 0;
    for (var i = 1; i <= number; i++)
    {
        var input = readline();
        max += detectMax(parseInt(input[0]), parseInt(input[3]));
    }
    print(max);
}

function detectMax(out, into)
{
    if (into - out > 0)
        return into - out;
    else return 0;
}

{
    var number = parseInt(readline());
    var max = 0;
    for (var i = 1; i <= number; i++)
    {
        var input = readline();
        max += detectMax(parseInt(input[0]), parseInt(input[3]));
    }
}

function detectMax(out, into)
{
    return into - out;
}

{
    var num = parseInt(readline());
    var max = 0, medium = 0;
    for (var i = 1; i <= num; i++)
    {
        var input = readline();
        input = input.split(' ');
        medium += detectMax(input[0], input[2]);
        if (medium > max) max = medium;
    }
    print(max);
}

function detectMax(out, into)
{
    return into - out;
}

{
    var num = parseInt(readline());
    var max = 0, medium = 0;
    for (var i = 1; i <= num; i++)
    {
        var input = readline();
        medium += detectMax(input[0], input[2]);
        if (medium > max) max = medium;
    }
    print(max);
}

function detectMax(out, into)
{
    if (into - out > 0)
        return into - out;
    else return 0;
}

{
    var num = parseInt(readline());
    var max = 0;
    for (var i = 1; i <= num; i++)
    {
        var input = readline();
        max += detectMax(input[0], input[2]);
    }
    print(max);
}

readline(); for(var s, a, b, now, ans = 0; s = readline(); ) {
    s = s.split( ' ' ); a = s[0] - ''; b = s[1] - '';
    now = now - a + b;
    ans = Math.max( now, ans );
}
print( ans );

var stops = readline();
var total = 0;
var max = 0;
while(stops--){
    var pass = readline().split(' ');
    total = total - pass[0] + pass[1];
    print(pass[0]);
    print(pass[1]);
    print(total);
}

var stops = readline();
var total = 0;
var max = 0;
while(stops--){
    var pass = readline().split(' ');
    total = total - pass[0] + pass[1];
    if(total >= max){
        max = total;
    }
}

print(max);

var n = parseInt(readline(), 10), ab = [], minCap = 0;

for(var i=1; i<=n-1; i++) {
    ab = readline().split(' ').map(el => parseInt(el, 10));
    if((minCap - ab[0] + ab[1]) > minCap) minCap = minCap - ab[0] + ab[1];
}

print(minCap);

var n = readline()
var str = []
for (var i = 0; i < n; i++) {
    var line = readline()
    str += line.replace(/\s/g, '')
}
str = str.split("")
var rez = 0
var trig = true
var bol = 0
for (var i = 1; i < str.length - 1; i++) {
	if(trig){
		rez += Number(str[i])
		trig = false
		if(rez > bol){
			bol = rez
		}
	} else {
		rez -= Number(str[i])
		trig = true
	}
}
print(bol)

readline();
var a = readline()[2], b, c = 0;

while (b = readline()) {
  a = a - b[0] + +b[2];
  if (a > c) c = a;
}

print(c);

readline();
var a = readline().split(' ')[1], b, c = 0;

while (b = readline()) {
  b = b.split(' ');
  a = a - b[0] + +b[1];
  if (a > c) c = a;
}

print(c);

// Linear Kingdom has exactly one tram line. It has n stops, numbered from 1 to n in the order of tram's movement. At the i-th stop ai passengers exit the tram, while bi passengers enter it. The tram is empty before it arrives at the first stop. Also, when the tram arrives at the last stop, all passengers exit so that it becomes empty.

// Your task is to calculate the tram's minimum capacity such that the number of people inside the tram at any time never exceeds this capacity. Note that at each stop all exiting passengers exit before any entering passenger enters the tram.

// Input
// The first line contains a single number n (2 ≤ n ≤ 1000) — the number of the tram's stops.

// Then n lines follow, each contains two integers ai and bi (0 ≤ ai, bi ≤ 1000) — the number of passengers that exits the tram at the i-th stop, and the number of passengers that enter the tram at the i-th stop. The stops are given from the first to the last stop in the order of tram's movement.

//     The number of people who exit at a given stop does not exceed the total number of people in the tram immediately before it arrives at the stop.
//     At the last stop, all the passengers exit the tram and it becomes empty.
//     No passenger will enter the train at the last stop. That is, bn = 0.

// Output
// Print a single integer denoting the minimum possible capacity of the tram (0 is allowed).

var n = readline()
var t = []
var max = 0

for (i = 0; i < n; i++) {
    t.push(readline().split(" "));
    if (i > 0 && (+t[i-1][1] - +t[i][0] + +t[i][1]) > max) {
        max = +t[i-1][1] - +t[i][0] + +t[i][1]
    }
}

print(max)

// Linear Kingdom has exactly one tram line. It has n stops, numbered from 1 to n in the order of tram's movement. At the i-th stop ai passengers exit the tram, while bi passengers enter it. The tram is empty before it arrives at the first stop. Also, when the tram arrives at the last stop, all passengers exit so that it becomes empty.

// Your task is to calculate the tram's minimum capacity such that the number of people inside the tram at any time never exceeds this capacity. Note that at each stop all exiting passengers exit before any entering passenger enters the tram.

// Input
// The first line contains a single number n (2 ≤ n ≤ 1000) — the number of the tram's stops.

// Then n lines follow, each contains two integers ai and bi (0 ≤ ai, bi ≤ 1000) — the number of passengers that exits the tram at the i-th stop, and the number of passengers that enter the tram at the i-th stop. The stops are given from the first to the last stop in the order of tram's movement.

//     The number of people who exit at a given stop does not exceed the total number of people in the tram immediately before it arrives at the stop.
//     At the last stop, all the passengers exit the tram and it becomes empty.
//     No passenger will enter the train at the last stop. That is, bn = 0.

// Output
// Print a single integer denoting the minimum possible capacity of the tram (0 is allowed).

var n = readline()
var t = []
var sum = 0
var max = 0

for (i = 0; i < n; i++) {
    t.push(readline().split(" "));
    if (i === 0){
        sum = +t[0][1]
    }else {
        sum += +t[i][1] - +t[i][0]
        if (sum > max) {
        max = sum
        }
    }
}

print(max)

var tram = 0, ans = 0, n = readline(), arr = [];
n = Number(n);
var i;
for(i=0;i<n;i++)
{
	arr = readline().split(" ");
	tram -= arr[0];
	tram += arr[1];
	ans = Math.max(ans, tram);
}
print(ans);

var data = parseInt(readline()), stop = [], answer = 0, max = 0;

for (var i = 0; i < data; i++) {
    stop[i] = readline().split(" ");
}

for (var i = 0; i < data; i++) {
    answer = answer - parseInt(stop[i][0] + stop[i][1]);

    if (answer > max) {
        max = answer;
    }
}

write(max);

var data = parseInt(readline()), stop = [], answer = 0, max = 0;

for (var i = 0; i < data; i++) {
	stop = readline().split(" ");
}

for (var i = 0; i < data; i++) {
	answer = answer - parseInt(data[0] + data[1]);

	if (answer > max) {
		max = answer;
	}
}

write(max);

var input = readline().split('\n');
var n = parseInt(input[0]);

var cap = [],
	exit = [],
	enter = [],
    cur = 0;

var maxCap = 0;
for (var i=0; i<n; i++) {
	exit[i] = input[2*i + 1];
	enter[i] = input[2*i + 2];
    cur = cur + (enter[i] - exit[i]);

	maxCap = (maxCap >= cur) ? maxCap : cur;
}

print(maxCap);

var input = readline();
var n = parseInt(input[0]);

var exit = 0,
	enter = 0,
    cur = 0;

var maxCap = 0;
for (var i=1; i<n; i++) {
	temp = readline().split(' ');
	exit = temp[0];
	enter = temp[1];
    cur = cur + (enter - exit);

	maxCap = (maxCap >= cur) ? maxCap : cur;
}

print(maxCap);

var input = readline().split(' ');
var n = parseInt(input[0]);

var cap = [],
	exit = [],
	enter = [],
    cur = 0;

var maxCap = 0;
for (var i=0; i<n; i++) {
	exit[i] = input[2*i + 1];
	enter[i] = input[2*i + 2];
    cur = cur + (enter[i] - exit[i]);

	maxCap = (maxCap >= cur) ? maxCap : cur;
}

print("%d", parseInt(maxCap));

var input = readline();
var n = parseInt(input[0]);

var exit = 0;
	enter = 0;
    cur = 0;

var maxCap = 0;
for (var i=1; i<n; i++) {
	temp = readline().split(' ');
	exit = temp[0];
	enter = temp[1];
    cur = cur + (enter - exit);

	maxCap = (maxCap >= cur) ? maxCap : cur;
}

print(maxCap);

var input = readline();
var n = parseInt(input[0]);

var cap = [],
	exit = [],
	enter = [],
    cur = 0;

var maxCap = 0;
for (var i=0; i<n; i++) {
	temp = readline().split(' ');
	exit[i] = temp[2*i + 1];
	enter[i] = temp[2*i + 2];
    cur = cur + (enter[i] - exit[i]);

	maxCap = (maxCap >= cur) ? maxCap : cur;
}

print(maxCap);

var input = readline().split(' ');
var n = parseInt(input[0]);

var cap = [],
	exit = [],
	enter = [],
    cur = 0;

var maxCap = 0;
for (var i=0; i<n; i++) {
	exit[i] = input[2*i + 1];
	enter[i] = input[2*i + 2];
    cur = cur + (enter[i] - exit[i]);

	maxCap = (maxCap >= cur) ? maxCap : cur;
}

print("%d", maxCap);

var input = readline();
var n = parseInt(input[0]);

var exit = 0;
	enter = 0;
    cur = 0;

var maxCap = 0;
for (var i=0; i<n; i++) {
	temp = readline().split(' ');
	exit = temp[0];
	enter = temp[1];
    cur = cur + (enter - exit);

	maxCap = (maxCap >= cur) ? maxCap : cur;
}

print(maxCap);

var input = readline();
var n = parseInt(input[0]);

var cap = [],
	exit = [],
	enter = [],
    cur = 0;

var maxCap = 0;
for (var i=1; i<n; i++) {
	temp = readline().split(' ');
	exit[i] = temp[0];
	enter[i] = temp[1];
    cur = cur + (enter[i] - exit[i]);

	maxCap = (maxCap >= cur) ? maxCap : cur;
}

print(maxCap);

var input = readline().split(' ');
var n = parseInt(input[0]);

var cap = [],
	exit = [],
	enter = [],
    cur = 0;

var maxCap = 0;
for (var i=0; i<n; i++) {
	exit[i] = input[2*i + 1];
	enter[i] = input[2*i + 2];
    cur = cur + (enter[i] - exit[i]);

	maxCap = (maxCap >= cur) ? maxCap : cur;
}

print(maxCap);

var inputStopsStr = readline();
var intialPass;
var leftPass;
var inputStop = parseInt(inputStopsStr);
for (var i = 0; i < inputStop; i++) {
	var input = readline().split(" ");
	var firstParams = parseInt(input[0]);
	var secondParams = parseInt(input[1]);
	if (i === 0) {
		intialPass = firstParams;
		leftPass = intialPass + secondParams;
	}
	else {
		leftPass = leftPass - firstParams;
		leftPass = leftPass + secondParams;
	}
	if (i == (inputStop - 1)) {
		print (leftPass);
	}
}

var inputStopsStr = readline();
var intialPass;
var leftPass;
var inputStop = parseInt(inputStopsStr);
for (var i = 0; i < inputStop; i++) {
	var input = readline().split(" ");
	var firstParams = parseInt(input[0]);
	var secondParams = parseInt(input[1]);
	if (i === 0) {
		intialPass = firstParams;
		leftPass = intialPass + secondParams;
	}
	else {
		leftPass -= firstParams;
		leftPass += secondParams;
	}
}
print (leftPass);

var inputStopsStr = readline();
var intialPass;
var leftPass;
var inputStop = parseInt(inputStopsStr);
for (var i = 0; i < inputStop; i++) {
	var input = readline().split(" ");
	var firstParams = parseInt(input[0]);
	var secondParams = parseInt(input[1]);
	if (i === 0) {
		intialPass = firstParams;
		leftPass = intialPass + secondParams;
	}
	else {
		leftPass -= firstParams;
		leftPass += secondParams;
	}
	if (i == (inputStop - 1)) {
		print (leftPass);
	}
}

var inputStopsStr = readline();
var intialPass;
var leftPass;
var inputStop = parseInt(inputStopsStr);
for (var i = 0; i < inputStop; i++) {
	var input = readline().split(" ");
	var firstParams = parseInt(input[0]);
	var secondParams = parseInt(input[1]);
	if (i == 0) {
		intialPass = firstParams;
		leftPass = intialPass + secondParams;
	}
	else {
		leftPass = leftPass - firstParams;
		leftPass = leftPass + secondParams;
	}
	if (i == (inputStop - 1)) {
		print (leftPass);
	}
}

var n=parseInt(readline());
var p = 0;
var max = 0;
while(n--){
    var l=parseInt(readline());
    p+=l[1]-l[0];
    if(p>max) max=p;
}
print(max);

var stops = readline();
var passengers = 0;
var max = [];

for (var i = 0; i < +stops; i++) {
	var str = readline().match(/\d/g);
	var into = +str[1];
	var out = +str[0];

	passengers += (into - out);
	max.push(Math.abs(passengers));
}

print(Math.max(...max))

var stops = readline();
var passengers = 0;
var max = [];

for (var i = 0; i < +stops; i++) {
	var str = readline().match(/\d{1,3}/g);
	var into = +str[1];
	var out = +str[0];

	passengers += (into - out);
	max.push(Math.abs(passengers));
}

print(Math.max(...max))

var stops = readline();
var max = 0;
var current = 0;
while(stops > 0){
    var input = readline();
    var out = input[0];
    var inp = input[1];
    current = (current+inp)-out;
    if(current > max)max = current;
    stops--;
}

print(max);

var stops = readline();
var max = 0;
var current = 0;
while(stops > 0){
    var input = readline();
    var out = input[0];
    var inp = input[1];
    current = inp-out;
    if(current > max)max = current;
    stops--;
}

print(max);

      var n = parseInt(readline());
      var arr = [],
        min = 0,
        remaining = 0,
        exit = 0,
        newmin;
      for (var i = 0; i < n; i++) {
        var line = readline()
          .split(" ")
          .map((el) => parseInt(el));
        arr.push(line);
      }
      for (var j = 0; j < arr.length - 1; j++) {
        if (arr[1][0] == 1) {
          exit = 1;
        }
        if (newmin == undefined) {
          remaining = arr[j][1] - arr[j + 1][0];
        } else {
          remaining = newmin - arr[j + 1][0];
        }
        newmin = remaining + arr[j + 1][1];
        if (newmin > min) {
          min = newmin;
        }
      }
      if (min == 0 && exit == 1) {
        print(1);
      } else {
        print(min);
      }

      var n = parseInt(readline());
      var arr = [],
        min = 0,
        remaining = 0,
        exit = 0,
        newmin;
      for (var i = 0; i < n; i++) {
        var line = readline()
          .split(" ")
          .map((el) => parseInt(el));
        arr.push(line);
      }
      for (var j = 0; j < arr.length - 1; j++) {
        exit = arr[j][0];
        if (newmin == undefined) {
          remaining = arr[j][1] - arr[j + 1][0];
        } else {
            remaining = newmin - arr[j+1][0];
        }
        newmin = remaining + arr[j + 1][1];
        if (newmin > min) {
          min = newmin;
        }
      }
      print(min);

      var n = parseInt(readline());
      var arr = [],
        min = 0,
        remaining = 0,
        exit = 0,
        newmin;
      for (var i = 0; i < n; i++) {
        var line = readline()
          .split(" ")
          .map((el) => parseInt(el));
        arr.push(line);
      }
      for (var j = 0; j < arr.length - 1; j++) {
        if (min == 0) {
          exit = arr[1][0];
        }
        if (newmin == undefined) {
          remaining = arr[j][1] - arr[j + 1][0];
        } else {
          remaining = newmin - arr[j + 1][0];
        }
        newmin = remaining + arr[j + 1][1];
        if (newmin > min) {
          min = newmin;
        }
      }
      if (min == 0) {
        print(exit);
      } else {
        print(min);
      }

      var n = parseInt(readline());
      var arr = [],
        min = 0,
        remaining = 0,
        exit = 0,
        newmin;
      for (var i = 0; i < n; i++) {
        var line = readline()
          .split(" ")
          .map((el) => parseInt(el));
        arr.push(line);
      }
      for (var j = 0; j < arr.length - 1; j++) {
        if (min == 0) {
          exit = arr[1][0];
        }
        if (newmin == undefined) {
          remaining = arr[j][1] - arr[j + 1][0];
        } else {
          remaining = newmin - arr[j + 1][0];
        }
        newmin = remaining + arr[j + 1][1];
        if (newmin > min) {
          min = newmin;
        }
      }
      if (min == 0) {
        print(exit);
      } else if (min < exit) {
        print(exit);
      } else {
        print(min);
      }

      var n = parseInt(readline());
      var arr = [],
        min = 0,
        remaining = 0,
        exit = 0,
        newmin;
      for (var i = 0; i < n; i++) {
        var line = readline()
          .split(" ")
          .map((el) => parseInt(el));
        arr.push(line);
      }
      for (var j = 0; j < arr.length - 1; j++) {
        if (min == 0) {
          exit = arr[j +1][0];
        }
        if (newmin == undefined) {
          remaining = arr[j][1] - arr[j + 1][0];
        } else {
          remaining = newmin - arr[j + 1][0];
        }
        newmin = remaining + arr[j + 1][1];
        if (newmin > min) {
          min = newmin;
        }
      }
      if (min == 0) {
        print(exit);
      } else {
        print(min);
      }

var stops=parseInt(readline()),
    minCapac=0;
while(stops--){
    var outAndIn = readline().split(" "),
    out = parseInt(outAndIn[0]),
    In = parseInt(outAndIn[1]);
    if((minCapac -out+In)>minCapac)
        minCapac= minCapac+ (In-out);
}
print(minCapac);

var stops=parseInt(readline()),
    minCapac=0;

print(6);
while(stops--){
    var outAndIn = readline().split(" "),
    out = parseInt(outAndIn[0]),
    In = parseInt(outAndIn[1]);
    if((minCapac -out+In)>minCapac)
        minCapac=minCapac-out+In;
    print(minCapac);
}

var stops=parseInt(readline()),
    minCapac=0;
while(stops--){
    var outAndIn = readline().split(" "),
    out = parseInt(outAndIn[0]),
    In = parseInt(outAndIn[1]);
    if((minCapac -out+In)>minCapac)
        minCapac=minCapac-out+In;

}
print(minCapac);

var numberOfStop = +readline(),
    minCapac = 0,
    curCapac = 0;
while(numberOfStop--){
    var line = readline().split(" ");
    curCapac = (+line[1])-(+line[0]);
    if(curCapac > minCapac){ minCapac = curCapac }
}
print(minCapac);

var stops=+readline(),
    minCapac=0;
while(stops--){
    var outAndIn = readline().split(" ");
    if(minCapac -(+outAndIn[0])+(+outAndIn[1])>minCapac)
        minCapac+= ((+outAndIn[1])-(+outAndIn[0]));
}
print(minCapac);

var stops=parseInt(readline()),
    minCapac=0;
while(stops--){
    var outAndIn = readline().split(" "),
    out = parseInt(outAndIn[0]),
    In = parseInt(outAndIn[1]);
    if((minCapac -out+In)>minCapac)
        minCapac=minCapac-out+In;
    print(minCapac);
}
print(6);

var stops=+readline(),
    minCapac=0;
while(stops--){
    var outAndIn = readline().split(" "),
    out = +outAndIn[0],
    In = +outAndIn[1];
    if((minCapac -out+In)>minCapac)
        minCapac= minCapac+ (In-out);
}
print(minCapac);

var stops=parseInt(readline()),
    minCapac=0;
while(stops--){
    var outAndIn = readline().split(" "),
    out = parseInt(outAndIn[0]),
    In = parseInt(outAndIn[1]);
    if((minCapac -out+In)>minCapac)
        minCapac= minCapac+ (In-out);
    print(minCapac);
}

var stops=parseInt(readline()),
    minCapac=0
    temp = 0;
while(stops--){
    var outAndIn = readline().split(" "),
    out = parseInt(outAndIn[0]),
    In = parseInt(outAndIn[1]);
    if((temp -out+In)>=minCapac){
        minCapac=temp-out+In;
        temp += In - out;
    }
}
print(minCapac);

var line_number = 0;
const cs = require("readline").createInterface({
  input: process.stdin,
  output: process.stdout,
});

var lines = [];
cs.on("line", (input) => {
  if (input == "") {
    cs.close();
  }
  lines.push(input.split(" "))
  line_number += 1;
}).on("close", () => {
  main();
  process.exit();
});

function isOp(str) {
  return str.length === 1 && str.match(/[<=>]/);
}
function isChr(str) {
  return str.length === 1 && str.match(/[a-z]/i);
}
function isInt(str) {
  return str.length === 1 && str.match(/[0-9*]/);
}

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

function exit(status = 0) {
  process.exit(status);
}

function predict(test) {
  let op = "";
  let ops = [];
  let opVariables = [];
  let limits = [];
  for (let t of test) {
    // console.log(t);
    for (let i = 0; i < t.length; i++) {
      if (isOp(t[i])) {
        op = t[i];
        if (isOp(t[i + 1])) {
          op += t[i + 1];
          i += 1;
        }
        ops.push(op);
        op = "";
      } else if (isChr(t[i])) {
        // console.log(t[i])
        op = t[i];
        for (var j = i + 1; j < t.length; j++) {
          if (isChr(t[j]) || isInt(t[j])) {
            op += t[j];
            i = j;
          } else break;
        }
        opVariables.push(op);
        op = "";
      } else {
        if (i == 0 || (i > 0 && isOp(t[i - 1]))) {
          op = t[i];
          let j = i + 1;
          for (; j < t.length; j++) {
            if (isInt(t[j])) {
              op += t[j];
              i = j;
            } else break;
          }
          limits.push(op);
          op = "";
        }
      }
    }
  }

  let min = limits[0];
  let max = limits[1];

  let pvs = ops.map((o, i) => [o, opVariables[i]]);

  for (let pv of pvs) {
    if (pv[1] == undefined) {
      pv[1] = max;
    }
    // print(`${min} ${pv[0]} ${pv[1]} ?`)
    if (eval(`${min}${pv[0]}${pv[1]}`)) {
      // print(` ${min} ${pv[0]} ${pv[1]} true`)
      min = pv[1];
    } else {
      print("input error");
      exit();
    }
  }
}

var n;
function main() {
  n = parseInt(lines[0][0],10)
  let d = 0
  for(let i = 1; i <= lines.slice(1,).length; i++) {
    stops = lines[i].map(x => parseInt(x,10))
    if(d < d-stops[0]+stops[1] )
      d = d - stops[0] + stops[1]
    }
    print(d)
}

var line_number = 0;
const cs = require("readline").createInterface({
  input: process.stdin,
  output: process.stdout,
});

var lines = [];
cs.on("line", (input) => {
  if (input == "") {
    cs.close();
  }
  lines.push(input.split(" "))
  line_number += 1;
}).on("close", () => {
  main();
  process.exit();
});

function isOp(str) {
  return str.length === 1 && str.match(/[<=>]/);
}
function isChr(str) {
  return str.length === 1 && str.match(/[a-z]/i);
}
function isInt(str) {
  return str.length === 1 && str.match(/[0-9*]/);
}

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

function exit(status = 0) {
  process.exit(status);
}

function predict(test) {
  let op = "";
  let ops = [];
  let opVariables = [];
  let limits = [];
  for (let t of test) {
    // console.log(t);
    for (let i = 0; i < t.length; i++) {
      if (isOp(t[i])) {
        op = t[i];
        if (isOp(t[i + 1])) {
          op += t[i + 1];
          i += 1;
        }
        ops.push(op);
        op = "";
      } else if (isChr(t[i])) {
        // console.log(t[i])
        op = t[i];
        for (var j = i + 1; j < t.length; j++) {
          if (isChr(t[j]) || isInt(t[j])) {
            op += t[j];
            i = j;
          } else break;
        }
        opVariables.push(op);
        op = "";
      } else {
        if (i == 0 || (i > 0 && isOp(t[i - 1]))) {
          op = t[i];
          let j = i + 1;
          for (; j < t.length; j++) {
            if (isInt(t[j])) {
              op += t[j];
              i = j;
            } else break;
          }
          limits.push(op);
          op = "";
        }
      }
    }
  }

  let min = limits[0];
  let max = limits[1];

  let pvs = ops.map((o, i) => [o, opVariables[i]]);

  for (let pv of pvs) {
    if (pv[1] == undefined) {
      pv[1] = max;
    }
    // print(`${min} ${pv[0]} ${pv[1]} ?`)
    if (eval(`${min}${pv[0]}${pv[1]}`)) {
      // print(` ${min} ${pv[0]} ${pv[1]} true`)
      min = pv[1];
    } else {
      print("input error");
      exit();
    }
  }
}

var n;
function main() {
  n = parseInt(lines[0][0],10)
  let d = 0
  for(let i = 1; i < lines.slice(1,).length; i++) {
    // if (i == 0)
    stops = lines[i].map(x => parseInt(x,10))
    if(d < d-stops[0]+stops[1] )
      d = d - stops[0] + stops[1]
    }
    print(d)
}

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

let ans = 0;
let count = 0;

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

    [exit, enter] = d.split(' ').map(Number);
    ans = Math.max(ans + enter - exit, ans);

    count++;
});

rl.on('close', () => {
    console.log(ans);
});

'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() {
		var arr = [...inputString];

		arr.shift();

		console.log(arr.reduce((prev, cur) => {
		  var [a, b] = cur.split(' ').map(el => parseInt(el, 10));
		  return prev - a + b > prev ? prev - a + b : prev;
		}, 0));
}

// Sample code to perform I/O:

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

process.stdin.on("data", function (input) {
    stdin_input += input;                               // Reading input from STDIN
});

process.stdin.on("end", function () {
    main(stdin_input);
});

function main(input) {
    let output = nameLookUp(input);
    process.stdout.write(output);       // Writing output to STDOUT
}

// Warning: Printing unwanted or ill-formatted data to output will cause the test cases to fail

// Write your code here
function nameLookUp(str) {
    let tramLines = str.trim().split('\n');
    let capacity = [0];
    for (let i = 1; i <= +tramLines[0]; i++) {

        if (i === 1) {
            let stops = tramLines[i].trim().split(' ').map((num) => Number(num));
            capacity.push(stops[1]);
        }
        else {
            let stopsBack = tramLines[i - 1].trim().split(' ').map((num) => Number(num));
            let stops = tramLines[i].trim().split(' ').map((num) => Number(num));
            let currentStopCapacity = stopsBack[1] - stops[0];
            capacity.push(stops[1] + currentStopCapacity);
        }

    }
    return Math.max(...capacity).toString();
}

let inputString = "";
let currentLine = 0;
process.stdin.on("data", (data) => {
  inputString += data;
});
process.stdin.on("end", function () {
  inputString = inputString
    .trim()
    .split("\n")
    .map((str) => str.trim());
  main();
});
function readLine() {
  return inputString[currentLine++];
}
function main() {
  var T = +readLine();
  var ans = 0,
    namche = 0,
    loopNumber = 1;
  while (T--) {
    var [a, b] = readLine().split(" ").map(Number);
    namche = a - b;
    if (namche < 0) {
      ans += namche;
    }
  }
  console.log(Math.abs(ans));
}

let inputString = "";
let currentLine = 0;
process.stdin.on("data", (data) => {
  inputString += data;
});
process.stdin.on("end", function () {
  inputString = inputString
    .trim()
    .split("\n")
    .map((str) => str.trim());
  main();
});
function readLine() {
  return inputString[currentLine++];
}
function main() {
  var T = +readLine();
  var max = 0,
    current = 0;
  while (T--) {
    var [a, b] = readLine().split(" ").map(Number);
    current -= a;
    current += b;
    if (current > max) {
      max = current;
    }
  }
  // console.log(max);
}

let inputString = "";
let currentLine = 0;
process.stdin.on("data", (data) => {
  inputString += data;
});
process.stdin.on("end", function () {
  inputString = inputString
    .trim()
    .split("\n")
    .map((str) => str.trim());
  main();
});
function readLine() {
  return inputString[currentLine++];
}
function main() {
  var T = +readLine();
  var total = 0,
    down = 0;
  while (T--) {
    var [a, b] = readLine().split(" ").map(Number);
    down = b - a;
    total += a;
  }
  console.log(total - Math.abs(down));
}

var lines = readline();
lines = parseInt(lines);
var exits= new Array();
var entries = new Array();
var sum = 0;
var persons = 0;

for (var i=0, j=0; i<lines; i++) {
	var line = readline().split(' ');
	exits.push(parseInt(line[j]));
	entries.push(parseInt(line[j+1]));
}

for (var z=0; z<entries.length; z++) {
	if (persons+entries[z]-exits[i] > sum) {
		sum = persons+entries[z]-exits[i];
	}
	persons = persons+entries[z]-exits[i]
}

print(sum);

var lines = readline();
lines = parseInt(lines);
var exits= new Array();
var entries = new Array();
var sum = 0;

for (var i=0, j=0; i<lines; i++) {
	var line = readline().split(' ');
	exits.push(parseInt(line[j]));
	entries.push(parseInt(line[j+1]));
}

for (var z=0; z<entries.length; z++) {
	if (exits[z]+entries[z]-exits[z+1] > sum) {
		sum = exits[z]+entries[z]-exits[z+1];
	}
}

print(sum);

var lines = readline();
lines = parseInt(lines);
var exit = new Array();
var entry = new Array();
var sum = 0;

for (var i=0, j=0; i<lines; i++) {
	var line = readline().split(' ');
	exit.push(parseInt(line[j]));
	entry.push(parseInt(line[j+1]));
}

for (var z=0; z<entry.length; z++) {
	if (exit[z]+entry[z]-exit[z+1] > sum) {
		sum = exit[z]+entry[z]-exit[z+1];
	}
}

print(sum);

var lines = readline();
lines = parseInt(lines);
var exit = new Array();
var entry = new Array();
var sum = 0;

for (var i=0, j=0; i<lines; i++) {
	var line = parseInt(readline().split(' '));
	exit.push(line[j]);
	entry.push(line[j+1]);
}

for (var z=0; z<entry.length; z++) {
	if (exit[z]+entry[z]-exit[z+1] > sum) {
		sum = exit[z]+entry[z]-exit[z+1];
	}
}

print(sum);

var lines = parseInt(readline());
var exit = new Array();
var entry = new Array();
var sum = 0;

for (var i=0, j=0; i<lines; i++) {
	var line = readline().split(' ');
	exit.push(line[j]);
	entry.push(line[j+1]);
}

for (var z=0; z<entry.length; z++) {
	if (exit[z]+entry[z]-exit[z+1] > sum) {
		sum = exit[z]+entry[z]-exit[z+1];
	}
}

print(sum);

var print = this.print || require('lol-io').print
var write = this.write || require('lol-io').write
var readline = this.readline || require('lol-io').readline

var s=parseInt(readline().split(' ')[0]);
var arr=[];
for(var i=0;i<s;i++){
arr[i]=readline().split(' ').map(i=>parseInt(i));
}

var sum=0;
var max=0;
for(var i=0;i<arr.length;i++){
    var remove=arr[i][0];
    var adding=arr[i][1];
    sum=Math.abs(sum-remove);
    sum+=adding;
    if(max<sum){
        max=sum;
    }
}

print(sum)


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 n = rn();
		const a = rna();

		const dp = []; dp[-1] = 0;
		const sum = [];
		for (let i = 0; i < n; i++) {
			if (sum[a[i]] == undefined) sum[a[i]] = 0;

			dp[i] = dp[i-1] + sum[a[i]];
			sum[a[i]] += i + 1;
		}

		let ans = 0n;
		for (let i = 0; i < n; i++) ans += BigInt(dp[i]);
		console.log(ans.toString());
	}
}

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

const getLine = (function () {
    const getLineGen = (async function* () {
        for await (const line of rl) {
            yield line;
        }
    })();
    return async () => {
        let next;
        do {
            next = (await getLineGen.next());
        } while (!next.done && next.value === '');
        return next.value;
    };
})();

let solve = async () => {
    const nsc = parseInt(await getLine());
    for(let sc = 0; sc < nsc; sc++) {
        const n = parseInt(await getLine());
        const ar = (await getLine()).split(' ').map(num => parseInt(num));
        const calc = {};
        for(let i = 0; i < ar.length; i++) {
           if (!calc[ar[i]]) {
              calc[ar[i]] = [];
           }
           const m = calc[ar[i]];
           m.push({index: BigInt(i), sum: BigInt(n - i)});
           if (m.length > 1) {
              m[m.length - 1].sum += m[m.length - 2].sum;
           }
        }

        let res = BigInt(0);
        for(let val in calc) {
            let m = calc[val];
           for(let i = 0; i < m.length - 1; i++) {
              res += (m[i].index + BigInt(1)) * (m[m.length - 1].sum - m[i].sum);
           }
        }

        console.log(res.toString());
    }
}

solve();

///////////////////////////////// pre-define ////////////////////////////////////////////////////////////////////////////////
const pr = console.log;
const mi = Math.min;
const mx = Math.max;
const abs = Math.abs;
const fl = Math.floor;
const ce = Math.ceil;
const sq = Math.sqrt;
const lge = Math.log;
const lg10 = Math.log10;
const gcd = (a, b) => b == 0 ? a : gcd(b, a % b);
const lcm = (a, b) => (a / gcd(a, b)) * b;
const amax = (a) => mx.apply(Math, a);
const amin = (a) => mi.apply(Math, a);
const sm = (a) => a.reduce(((x, y) => x + y), 0);
const aeq = (a, b) => JSON.stringify(a) == JSON.stringify(b);
const swap = (a, i, j) => [a[i], a[j]] = [a[j], a[i]];
const stin = (a) => a.sort((x, y) => x - y);
const stde = (a) => a.sort((x, y) => y - x);
const counter = (a_or_s) => { let map = new Map(); for (const i of a_or_s) map.set(i, map.get(i) + 1 || 1); return map; };
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/**
 * 05/20/21 afternoon
 */

const solve = (n, a) => {
    let res = 0n;
    let m = new Map();
    for (let i = 0; i < n; i++) {
        res += BigInt(m.get(a[i]) || 0) * BigInt((n - i));
        let plus = BigInt(i + 1);
        m.set(a[i], BigInt(m.get(a[i]) || 0) + plus);
    }
    pr(res.toString());
};

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

main()

///////////////////////////////// pre-define ////////////////////////////////////////////////////////////////////////////////
const pr = console.log;
const mi = Math.min;
const mx = Math.max;
const abs = Math.abs;
const fl = Math.floor;
const ce = Math.ceil;
const sq = Math.sqrt;
const lge = Math.log;
const lg10 = Math.log10;
const gcd = (a, b) => b == 0 ? a : gcd(b, a % b);
const lcm = (a, b) => (a / gcd(a, b)) * b;
const amax = (a) => mx.apply(Math, a);
const amin = (a) => mi.apply(Math, a);
const sm = (a) => a.reduce(((x, y) => x + y), 0);
const aeq = (a, b) => JSON.stringify(a) == JSON.stringify(b);
const swap = (a, i, j) => [a[i], a[j]] = [a[j], a[i]];
const stin = (a) => a.sort((x, y) => x - y);
const stde = (a) => a.sort((x, y) => y - x);
const counter = (a_or_s) => { let map = new Map(); for (const i of a_or_s) map.set(i, map.get(i) + 1 || 1); return map; };
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/**
 * 05/20/21 afternoon
 */
const solve = (n, a) => {
    // pr(n, a)
    let res = 0n;
    let m = new Map();
    for (let i = 0n; i < n; i++) {
        res += (m.get(a[i]) || 0n) * (n - i);
        // pr(m, res);
        let plus = i + 1n;
        m.set(a[i], (m.get(a[i]) || 0n) + plus);
        // pr(m);
    }
    pr(res.toString());
};

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

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 n = rn();
		const a = rna();

		let ans = 0n;
		const sum = [];
		for (let i = 0; i < n; i++) {
			if (sum[a[i]] == undefined) sum[a[i]] = 0;

			ans += BigInt(sum[a[i]] * (n - i));
			sum[a[i]] = sum[a[i]] + i + 1;
		}
		console.log(ans.toString());
	}
}

var readline = require('readline');

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

function solve(n, arr) {
    let total = 0n
    const map = {} // x -> sum
    arr.forEach((x, i) => {
        let sum = map[x] || 0n
        total = add(total, mul(sum, BigInt(n - i)))
        // console.log(x, sum, sum * (n - i))
        sum += BigInt(i + 1)
        map[x] = sum
    })
    return total.toString()
}
function add(a, b) {
    return a + b
}
function mul(a, b) {
    return a * b
}

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

const getLine = (function () {
    const getLineGen = (async function* () {
        for await (const line of rl) {
            yield line;
        }
    })();
    return async () => {
        let next;
        do {
            next = (await getLineGen.next());
        } while (!next.done && next.value === '');
        return next.value;
    };
})();

let solve = async () => {
    const nsc = parseInt(await getLine());
    for(let sc = 0; sc < nsc; sc++) {
        const n = parseInt(await getLine());
        const ar = (await getLine()).split(' ').map(num => parseInt(num));
        const calc = {};
        for(let i = 0; i < ar.length; i++) {
           if (!calc[ar[i]]) {
              calc[ar[i]] = [];
           }
           const m = calc[ar[i]];
           m.push({index: i, sum: n - i});
           if (m.length > 1) {
              m[m.length - 1].sum += m[m.length - 2].sum;
           }
        }

        let res = 0;
        for(let val in calc) {
            let m = calc[val];
           for(let i = 0; i < m.length - 1; i++) {
              res += (m[i].index + 1) * (m[m.length - 1].sum - m[i].sum);
           }
        }

        console.log(res);
    }
}

solve();

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

const getLine = (function () {
    const getLineGen = (async function* () {
        for await (const line of rl) {
            yield line;
        }
    })();
    return async () => {
        let next;
        do {
            next = (await getLineGen.next());
        } while (!next.done && next.value === '');
        return next.value;
    };
})();

let solve = async () => {
    const nsc = parseInt(await getLine());
    for(let sc = 0; sc < nsc; sc++) {
        const n = parseInt(await getLine());
        const ar = (await getLine()).split(' ').map(num => parseInt(num));
        const calc = {};
        for(let i = 0; i < ar.length; i++) {
           if (!calc[ar[i]]) {
              calc[ar[i]] = [];
           }
           const m = calc[ar[i]];
           m.push({index: i, sum: n - i});
           if (m.length > 1) {
              m[m.length - 1].sum += m[m.length - 2].sum;
           }
        }

        let res = 0;
        for(let val in calc) {
           for(let i = 0; i < calc[val].length - 2; i++) {
              res += (calc[val][i].index + 1) * calc[val][i+1].sum;
           }
        }

        console.log(res);
    }
}

solve();

///////////////////////////////// pre-define ////////////////////////////////////////////////////////////////////////////////
const pr = console.log;
const mi = Math.min;
const mx = Math.max;
const abs = Math.abs;
const fl = Math.floor;
const ce = Math.ceil;
const sq = Math.sqrt;
const lge = Math.log;
const lg10 = Math.log10;
const gcd = (a, b) => b == 0 ? a : gcd(b, a % b);
const lcm = (a, b) => (a / gcd(a, b)) * b;
const amax = (a) => mx.apply(Math, a);
const amin = (a) => mi.apply(Math, a);
const sm = (a) => a.reduce(((x, y) => x + y), 0);
const aeq = (a, b) => JSON.stringify(a) == JSON.stringify(b);
const swap = (a, i, j) => [a[i], a[j]] = [a[j], a[i]];
const stin = (a) => a.sort((x, y) => x - y);
const stde = (a) => a.sort((x, y) => y - x);
const counter = (a_or_s) => { let map = new Map(); for (const i of a_or_s) map.set(i, map.get(i) + 1 || 1); return map; };
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/**
 * 05/20/21 afternoon
 */
const solve = (n, a) => {
    // pr(n, a)
    let res = 0;
    let m = new Map();
    for (let i = 0; i < n; i++) {
        res += (m.get(a[i]) || 0) * (n - i);
        // pr(m);
        let plus = i + 1;
        m.set(a[i], m.get(a[i]) + plus || plus);
        // pr(m);
    }
    pr(res);
};

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

main()

var readline = require('readline');

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

function solve(n, arr) {
    let total = 0
    const map = {} // x -> sum
    arr.forEach((x, i) => {
        let sum = map[x] || 0
        total = add(total, mul(sum, n - i))
        // console.log(x, sum, sum * (n - i))
        sum += i + 1
        map[x] = sum
    })
    return total
}
function add(a, b) {
    return a + b
}
function mul(a, b) {
    return a * b
}


input = readline().split(" ").map(Number);
var n = input[0];
var t = input[1];
var s1 = readline();
var s2 = readline();

var diff1 = 0;
var a = new Array(n);
var answer = "";
var d = [];
var j = 0;
for (var i = 0; i < n; i++)
{
	if (s1[i] != s2[i]) {
		diff1 += 1;
		d[j++] = i;
	}
}

if (diff1 <= (t+t)) {
	for (var i = 0; i < n; i++)
		a[i] = s1.charCodeAt(i);

	var samePreffix = diff1 - t;

	if (samePreffix > 0) {
		var restPreffix = samePreffix;
		for (var i = 0; i < diff1; i++) {
			// part 1
			if (i < samePreffix) {
				a[d[i]] = s2.charCodeAt(d[i]);
			}
			// part 2
			if (samePreffix <= i && i < diff1-samePreffix) {
				a[d[i]] = s1.charCodeAt(d[i]) + 1;
				if (a[d[i]] > "z".charCodeAt(0))
					a[d[i]] -= 26;

				if (a[d[i]] == s2.charCodeAt(d[i]))
					a[d[i]] += 1;
			}
			// part 3
		}
	} else {
		for (var i = 0; i < n; i++) {
			if (s1[i] == s2[i]) {
				if (samePreffix < 0) {
					a[i] += 1;
					samePreffix += 1;
				}
			} else {
				a[i] += 1;
				if (a[i] > "z".charCodeAt(0))
					a[i] -= 26;
				if (a[i] == s2.charCodeAt(i))
					a[i] += 1;
			}
		}
	}

	for (var i = 0; i < n; i++) {
		if (a[i] > "z".charCodeAt(0))
			a[i] -= 26;
		answer += String.fromCharCode(a[i]);
	}
} else {
	answer = "-1";
}

write(answer);

let i = ''
process.stdin.on('data', c => i += c)
process.stdin.on('end', () => {
    const {EOL} = require('os')
    const lines = i.split(EOL) /*your input text, split by lines*/
    // console.log(lines);

    let [n, t] = lines[0].split(' ');
    let s1 = lines[1];
    let s2 = lines[2];
    let ans = [];
    let sameCount = 0;
    let remain1, remain2;
    let diff = t;
    let bb = true;
    t = n - t; // t defind as the count need to be the same
    for (let i = 0; i < n; i++) {
        if (s1[i] === s2[i] && n - sameCount > diff) {
            ans[i] = s1[i];
            sameCount++;
        }
    }

    if (t * 2 - sameCount > n) {
        console.log(-1);
        bb = false;
    } else {
        remain1 = remain2 = t - sameCount;
        for (i = 0; i < n; i++) {
            if (ans[i]) { continue }
            if (remain1 > 0) {
                ans[i] = s1[i];
                remain1--;
            } else if (remain2 > 0) {
                ans[i] = s2[i];
                remain2--;
            } else {
                ans[i] = ['a', 'b', 'c'].find(char => (char !== s1[i] && char !== s2[i]))
            }
        }
    }
    if (bb) {
        console.log(ans.join(''));
    }
})

let i = ''
process.stdin.on('data', c => i += c)
process.stdin.on('end', () => {
    const {EOL} = require('os')
    const lines = i.split(EOL) /*your input text, split by lines*/
    // console.log(lines);

    let [n, t] = lines[0].split(' ');
    let s1 = lines[1];
    let s2 = lines[2];
    let ans = [];
    let sameCount = 0;
    let remain1, remain2;
    let diff = t;
    t = n - t; // t defind as the count need to be the same
    for (let i = 0; i < n; i++) {
        if (s1[i] === s2[i] && n - sameCount > diff) {
            ans[i] = s1[i];
            sameCount++;
        }
    }

    if (t * 2 - sameCount > n) {
        console.log(-1);
    } else {
        remain1 = remain2 = t - sameCount;
        for (i = 0; i < n; i++) {
            if (ans[i]) { continue }
            if (remain1 > 0) {
                ans[i] = s1[i];
                remain1--;
            } else if (remain2 > 0) {
                ans[i] = s2[i];
                remain2--;
            } else {
                ans[i] = ['a', 'b', 'c'].find(char => (char !== s1[i] && char !== s2[i]))
            }
        }
    }
    console.log(ans.join(''));
})

let i = ''
process.stdin.on('data', c => i += c)
process.stdin.on('end', () => {
    const {EOL} = require('os')
    const lines = i.split(EOL) /*your input text, split by lines*/
    // console.log(lines);

    let [n, t] = lines[0].split(' ');
    let s1 = lines[1];
    let s2 = lines[2];
    let ans = [];
    let sameCount = 0;
    let remain1, remain2;

    t = n - t; // t defind as the count need to be the same
    for (let i = 0; i < n; i++) {
        if (s1[i] === s2[i]) {
            ans[i] = s1[i];
            sameCount++;
        }
    }

    if (t * 2 - sameCount > n) {
        console.log(-1);
    } else {
        remain1 = remain2 = t - sameCount;
        for (i = 0; i < n; i++) {
            if (ans[i]) { continue }
            if (remain1 > 0) {
                ans[i] = s1[i];
                remain1--;
            } else if (remain2 > 0) {
                ans[i] = s2[i];
                remain2--;
            } else {
                ans[i] = ['a', 'b', 'c'].find(char => (char !== s1[i] && char !== s2[i]))
            }
        }
    }
    console.log(ans.join(''));
})

let i = ''
process.stdin.on('data', c => i += c)
process.stdin.on('end', () => {
    const {EOL} = require('os')
    const lines = i.split(EOL) /*your input text, split by lines*/
    // console.log(lines);

    let [n, t] = lines[0].split(' ');
    let s1 = lines[1];
    let s2 = lines[2];
    let ans = [];
    let sameCount = 0;
    let remain1, remain2;

    t = n - t; // t defind as the count need to be the same
    for (let i = 0; i < n; i++) {
        if (s1[i] === s2[i] && sameCount < n - t) {
            ans[i] = s1[i];
            sameCount++;
        }
    }

    if (t * 2 - sameCount > n) {
        console.log(-1);
    } else {
        remain1 = remain2 = t - sameCount;
        for (i = 0; i < n; i++) {
            if (ans[i]) { continue }
            if (remain1 > 0) {
                ans[i] = s1[i];
                remain1--;
            } else if (remain2 > 0) {
                ans[i] = s2[i];
                remain2--;
            } else {
                ans[i] = ['a', 'b', 'c'].find(char => (char !== s1[i] && char !== s2[i]))
            }
        }
    }
    console.log(ans.join(''));
})

let i = ''
process.stdin.on('data', c => i += c)
process.stdin.on('end', () => {
    const {EOL} = require('os')
    const lines = i.split(EOL) /*your input text, split by lines*/
    console.log(lines);
})

let i = ''
process.stdin.on('data', c => i += c)
process.stdin.on('end', () => {
    const {EOL} = require('os')
    const lines = i.split(EOL) /*your input text, split by lines*/
    // console.log(lines);

    let [n, t] = lines[0].split(' ');
    let s1 = lines[1];
    let s2 = lines[2];
    let ans = [];
    let sameCount = 0;
    let remain1, remain2;

    t = n - t; // t defind as the count need to be the same
    for (let i = 0; i < n; i++) {
        if (s1[i] === s2[i]) {
            ans[i] = s1[i];
            sameCount++;
        }
    }

    if (t * 2 - sameCount > n) {
        console.log(-1);
    } else {
        remain1 = remain2 = t - sameCount;
        for (i = 0; i < n; i++) {
            if (ans[i]) { continue }
            if (remain1 > 0) {
                ans[i] = s1[i];
                remain1--;
            } else if (remain2 > 0) {
                ans[i] = s2[i];
                remain2--;
            } else {
                ans[i] = ['a', 'b', 'c'].find(char => (char !== s1[i] && char !== s2[i]))
            }
        }
    }
    ans = ans.join();
    console.log(ans);
})

let i = ''
process.stdin.on('data', c => i += c)
process.stdin.on('end', () => {
    const {EOL} = require('os')
    const lines = i.split(EOL) /*your input text, split by lines*/
    // console.log(lines);

    let [n, t] = lines[0].split(' ');
    let s1 = lines[1];
    let s2 = lines[2];
    let ans = [];
    let sameCount = 0;
    let remain1, remain2;

    t = n - t; // t defind as the count need to be the same
    for (let i = 0; i < n; i++) {
        if (s1[i] === s2[i]) {
            ans[i] = s1[i];
            sameCount++;
        }
    }

    if (t * 2 - sameCount > n) {
        console.log(-1);
    } else {
        remain1 = remain2 = t - sameCount;
        for (i = 0; i < n; i++) {
            if (ans[i]) { continue }
            if (remain1 > 0) {
                ans[i] = s1[i];
                remain1--;
            } else if (remain2 > 0) {
                ans[i] = s2[i];
                remain2--;
            } else {
                ans[i] = ['a', 'b', 'c'].find(char => (char !== s1[i] && char !== s2[i]))
            }
        }
    }
    console.log(ans.join());
})

let i = ''
process.stdin.on('data', c => i += c)
process.stdin.on('end', () => {
    const {EOL} = require('os')
    const lines = i.split(EOL) /*your input text, split by lines*/
    // console.log(lines);

    let [n, t] = lines[0].split(' ');
    let s1 = lines[1];
    let s2 = lines[2];
    let ans = [];
    let sameCount = 0;
    let remain1, remain2;

    t = n - t; // t defind as the count need to be the same
    for (let i = 0; i < n; i++) {
        if (s1[i] === s2[i] && n - sameCount > t) {
            ans[i] = s1[i];
            sameCount++;
        }
    }

    if (t * 2 - sameCount > n) {
        console.log(-1);
    } else {
        remain1 = remain2 = t - sameCount;
        for (i = 0; i < n; i++) {
            if (ans[i]) { continue }
            if (remain1 > 0) {
                ans[i] = s1[i];
                remain1--;
            } else if (remain2 > 0) {
                ans[i] = s2[i];
                remain2--;
            } else {
                ans[i] = ['a', 'b', 'c'].find(char => (char !== s1[i] && char !== s2[i]))
            }
        }
    }
    console.log(ans.join(''));
})