Little Tanya decided to present her dad a postcard on his Birthday. She has already created a message — string s of length n, consisting of uppercase and lowercase English letters. Tanya can't write yet, so she found a newspaper and decided to cut out the letters and glue them into the postcard to achieve string s. The newspaper contains string t, consisting of uppercase and lowercase English letters. We know that the length of string t greater or equal to the length of the string s.The newspaper may possibly have too few of some letters needed to make the text and too many of some other letters. That's why Tanya wants to cut some n letters out of the newspaper and make a message of length exactly n, so that it looked as much as possible like s. If the letter in some position has correct value and correct letter case (in the string s and in the string that Tanya will make), then she shouts joyfully "YAY!", and if the letter in the given position has only the correct value but it is in the wrong case, then the girl says "WHOOPS".Tanya wants to make such message that lets her shout "YAY!" as much as possible. If there are multiple ways to do this, then her second priority is to maximize the number of times she says "WHOOPS". Your task is to help Tanya make the message.

The first line contains line s (1 ≤ |s| ≤ 2·105), consisting of uppercase and lowercase English letters — the text of Tanya's message. The second line contains line t (|s| ≤ |t| ≤ 2·105), consisting of uppercase and lowercase English letters — the text written in the newspaper. Here |a| means the length of the string a.

Print two integers separated by a space:   the first number is the number of times Tanya shouts "YAY!" while making the message,  the second number is the number of times Tanya says "WHOOPS" while making the message.

var s = readline(s);
    var t = readline(t);

    var i = 0;
    var take = 0;
    var yay = 0;
    var whoops = 0;

    var count = new Array(2);

    for (i = 0; i < 2; ++i) {
        count[i] = new Array(2);

        for (j = 0; j < 2; ++j) {
            count[i][j] = new Array(26);

            for (k = 0; k < 26; ++k) {
                count[i][j][k] = 0;
            }
        }
    }

    var min = function(a, b) {
        if (a < b) {
            return a;
        }
        else return b;
    }

    var isUpperCase = function(char) {
        if ('A'.charCodeAt() <= char.charCodeAt() && char.charCodeAt() <= 'Z'.charCodeAt()) {
            return true;
        }
        else {
            return false;
        }
    }

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

        if (isUpperCase(s[i])) {
            count[0][0][s[i].charCodeAt() - 'A'.charCodeAt()]++;
        }
        else count[0][1][s[i].charCodeAt() - 'a'.charCodeAt()]++;
    }

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

        if (isUpperCase(t[i])) {
            count[1][0][t[i].charCodeAt() - 'A'.charCodeAt()]++;
        }
        else count[1][1][t[i].charCodeAt() - 'a'.charCodeAt()]++;
    }

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

        take = min(count[0][0][i], count[1][0][i]);
        count[0][0][i] -= take;
        count[1][0][i] -= take;
        yay += take;

        take = min(count[0][1][i], count[1][1][i]);
        count[0][1][i] -= take;
        count[1][1][i] -= take;
        yay += take;

        take = min(count[0][0][i] + count[0][1][i], count[1][0][i] + count[1][1][i]);
        whoops += take;
    }

    print (yay, whoops);

function InputReader(){
	this.arr = [];
	this.ind = 1;
}

InputReader.prototype.next = function(){
	if(this.ind<this.arr.length)
		return this.arr[this.ind++];
	else{
		this.arr = readline().split(" ");
		this.ind=0;
		return this.arr[this.ind++];
	}
}

function OutputWriter(){
	this.s = "";
}

OutputWriter.prototype.write = function(s1){
	this.s+=s1;
}
OutputWriter.prototype.writeln = function(s1){
	this.s+=s1;
	print(this.s);
	this.s = "";
}

OutputWriter.prototype.flush = function(){
	print(this.s);
	this.s = "";
}

function main(){
	var input = new InputReader();
	var output = new OutputWriter();

	solve(input,output);

	output.flush();
}

function solve(input, output){
	var s = input.next();
	var t = input.next();
	map = {};
	for(var i=0; i<t.length; i++){
		if(t[i] in map)
			map[t[i]]++;
		else
			map[t[i]]=1;
	}
	var yra=0,opa=0;
	var used = [];
	for(i=0; i<s.lengthe; i++) used.push(false);

	for(i=0; i<s.length; i++)
		if(map[s[i]]>=1) {
			used[i] = true;
			yra++;
			map[s[i]]--;
		}
	for(i=0; i<s.length; i++){
		if(used[i]) continue;
		if(map[s[i].toUpperCase()]>=1){
			opa++;
			map[s[i].toUpperCase()]--;
		}else if(map[s[i].toLowerCase()]>=1){
			opa++;
			map[s[i].toLowerCase()]--;
		}
	}

	output.write(yra+" "+opa);

}

main();

function isUpperCase(myString) {
  return (myString == myString.toUpperCase());
}
function count(menor, maior) {
    var yay = 0;
    var whoops = 0;
    var n_menor = menor;
    var obj_maior = {};
    for (var i = 0, len = maior.length; i < len; i++) {
  			var charz = maior[i];
        var valor = obj_maior[charz];
        obj_maior[charz] = valor ? valor + 1 : 1
    }
    for (var i = 0, len = menor.length; i < len; i++) {
    	var charac = menor[i];
        var valor = obj_maior[charac];
        if (valor > 0) {
            yay ++;
            obj_maior[charac] = valor - 1;
            n_menor = n_menor.replace(charac, '');
        }
		}
    for (var i = 0, len = n_menor.length; i < len; i++) {
    	var charac = n_menor[i];
        var upper = charac.toUpperCase()
        if (isUpperCase(charac)) {
            var lower = charac.toLowerCase();
            var valor = obj_maior[lower];
            if (valor > 0) {
                obj_maior[lower] = valor - 1;
                whoops ++;
            }
        } else if (obj_maior[upper] > 0) {
            obj_maior[upper] = obj_maior[upper] - 1;
            whoops ++;
        }
    }
    return {'y' : yay, 'w': whoops};
}

var tayne = readline();
var jornal = readline();
var result = count(tayne, jornal)
print(result['y'] + " " +result['w'])

String.prototype.forEach = Array.prototype.forEach;

function main()  {
    var tanyaStr = readline(),
        newsStr = readline(),
        remainNewsStr = newsStr.split(''),
        tanyaUpperMap = {},
        tanyaLowerMap = {},
        // YAYMap = {},
        YAY = WHOOPS = 0;

    tanyaStr.forEach(function(letter)    {
        if(letter >= 'a')   {
            if(!tanyaLowerMap[letter])  {
                tanyaLowerMap[letter] = {
                    'totalCount' : 0,
                    'YAY' : 0
                };
            }
            tanyaLowerMap[letter].totalCount++;
            tanyaLowerMap[letter].YAY++;
        } else  {
            if(!tanyaUpperMap[letter])  {
                tanyaUpperMap[letter] = {
                    'totalCount' : 0,
                    'YAY' : 0
                };
            }
            tanyaUpperMap[letter].totalCount++;
            tanyaUpperMap[letter].YAY++;
        }
    });

    newsStr.forEach(function(letter, index)    {
        if(letter >= 'a')   {
            if(tanyaLowerMap[letter])  {
                if(tanyaLowerMap[letter].YAY > 0)    {
                    tanyaLowerMap[letter].YAY--;
                    tanyaLowerMap[letter].totalCount--;
                    YAY++;
                    remainNewsStr[index] = '';
                    // if(tanyaLowerMap[letter].YAY == 0)    YAYMap[letter] = true;
                }
            }
        } else  {
            if(tanyaUpperMap[letter])  {
                if(tanyaUpperMap[letter].YAY > 0)    {
                    tanyaUpperMap[letter].YAY--;
                    tanyaUpperMap[letter].totalCount--;
                    YAY++;
                    remainNewsStr[index] = '';
                    // if(tanyaUpperMap[letter].YAY == 0)    YAYMap[letter] = true;
                }
            }
        }
    });
    // console.log(YAYMap, remainNewsStr);
    remainNewsStr.forEach(function(letter)    {
        if(letter >= 'a')   {
            var upperLetter = letter.toUpperCase();

            if(tanyaUpperMap[upperLetter]) {
                if(tanyaUpperMap[upperLetter].totalCount > 0)  {
                    tanyaUpperMap[upperLetter].totalCount--;
                    WHOOPS++;
                }
            }
        } else  {
            var lowerLetter = letter.toLowerCase();

            if(tanyaLowerMap[lowerLetter]) {
                if(tanyaLowerMap[lowerLetter].totalCount > 0)  {
                    tanyaLowerMap[lowerLetter].totalCount--;
                    WHOOPS++;
                }
            }
        }
    });

    print(YAY + ' ' + WHOOPS);
};
main();

//var input = "abacaba\nAbaCaBA";
//var index = 0;
//
//function readline(){
//    var data = input.split('\n');
//    if(index < data.length)
//        return data[index++];
//}
//
//function print(output){
//    console.log(output);
//}

function main(){
    var a = readline();
    var b = readline();
    var arrL = new Array(26), arrU = new Array(26);
    var arr = [];
    for(var i = 0; i < a.length; i++){
        arr[i] = a.charAt(i);
    }
    for(var i = 0; i < 26; i++){
        arrL[i] = 0;
        arrU[i] = 0;
    }
    var ans1 = 0, ans2 = 0;
    for(var i = 0; i < b.length; i++){
        if(b.charCodeAt(i) >= 'A'.charCodeAt(0) && b.charCodeAt(i) <= 'Z'.charCodeAt(0))
            arrU[b.charCodeAt(i) - 'A'.charCodeAt(0)]++;
        else
            arrL[b.charCodeAt(i) - 'a'.charCodeAt(0)]++;
    }
    for(var i = 0; i < a.length; i++){
        if(a.charCodeAt(i) >= 'A'.charCodeAt(0) && a.charCodeAt(i) <= 'Z'.charCodeAt(0)){
            if(arrU[a.charCodeAt(i) - 'A'.charCodeAt(0)] > 0){
                ans1++;
                arrU[a.charCodeAt(i) - 'A'.charCodeAt(0)]--;
                arr[i] = undefined;
            }
        }else if(arrL[a.charCodeAt(i) - 'a'.charCodeAt(0)] > 0){
            ans1++;
            arrL[a.charCodeAt(i) - 'a'.charCodeAt(0)]--;
            arr[i] = undefined;
        }
    }

    for(var i = 0; i < a.length; i++){
        if(arr[i] != undefined){
            if(a.charCodeAt(i) >= 'A'.charCodeAt(0) && a.charCodeAt(i) <= 'Z'.charCodeAt(0)){
                if(arrL[a.charCodeAt(i) - 'A'.charCodeAt(0)] > 0){
                    ans2++;
                    arrL[a.charCodeAt(i) - 'A'.charCodeAt(0)]--;
                }
            }else if(arrU[a.charCodeAt(i) - 'a'.charCodeAt(0)] > 0){
                ans2++;
                arrU[a.charCodeAt(i) - 'a'.charCodeAt(0)]--;
            }
        }
    }
    print(ans1 + " " + ans2);
}
main();

var s = readline(s);
    var t = readline(t);

    var i = 0;
    var take = 0;
    var yay = 0;
    var whoops = 0;

    var count = new Array(2);

    for (i = 0; i < 2; ++i) {
        count[i] = new Array(2);

        for (j = 0; j < 2; ++j) {
            count[i][j] = new Array(26);

            for (k = 0; k < 26; ++k) {
                count[i][j][k] = 0;
            }
        }
    }

    var min = function(a, b) {
        if (a < b) {
            return a;
        }
        else return b;
    }

    var isUpperCase = function(char) {
        if ('A'.charCodeAt() <= char && char <= 'Z'.charCodeAt()) {
            return true;
        }
    }

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

        if (isUpperCase(s[i])) {
            count[0][0][s[i].charCodeAt() - 'A'.charCodeAt()]++;
        }
        else count[0][1][s[i].charCodeAt() - 'a'.charCodeAt()]++;
    }

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

        if (isUpperCase(t[i])) {
            count[1][0][t[i].charCodeAt() - 'A'.charCodeAt()]++;
        }
        else count[1][1][t[i].charCodeAt() - 'a'.charCodeAt()]++;
    }

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

        take = min(count[0][0][i], count[1][0][i]);
        count[0][0][i] -= take;
        count[1][0][i] -= take;
        yay += take;

        take = min(count[0][1][i], count[1][1][i]);
        count[0][1][i] -= take;
        count[1][1][i] -= take;
        yay += take;

        take = min(count[0][0][i] + count[0][1][i], count[1][0][i] + count[1][1][i]);
        whoops += take;
    }

    print (yay, whoops);

    var s = readline(s);
    var t = readline(t);

    var i = 0;
    var take = 0;
    var yay = 0;
    var whoops = 0;

    var count = new Array(2);

    for (i = 0; i < 2; ++i) {
        count[i] = new Array(2);

        for (j = 0; j < 2; ++j) {
            count[i][j] = new Array(26);

            for (k = 0; k < 26; ++k) {
                count[i][j][k] = 0;
            }
        }
    }

    var min = function(a, b) {
        if (a < b) {
            return a;
        }
        else return b;
    }

    var isUpperCase = function(char) {
        if ('A'.charCodeAt() <= char && char <= 'Z'.charCodeAt()) {
            return true;
        }
        else {
            return false;
        }
    }

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

        if (isUpperCase(s[i])) {
            count[0][0][s[i].charCodeAt() - 'A'.charCodeAt()]++;
        }
        else count[0][1][s[i].charCodeAt() - 'a'.charCodeAt()]++;
    }

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

        if (isUpperCase(t[i])) {
            count[1][0][t[i].charCodeAt() - 'A'.charCodeAt()]++;
        }
        else count[1][1][t[i].charCodeAt() - 'a'.charCodeAt()]++;
    }

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

        print (count[0][0][i], count[0][1][i], count[1][0][i], count[1][1][i]);

        take = min(count[0][0][i], count[1][0][i]);
        count[0][0][i] -= take;
        count[1][0][i] -= take;
        yay += take;

        take = min(count[0][1][i], count[1][1][i]);
        count[0][1][i] -= take;
        count[1][1][i] -= take;
        yay += take;

        take = min(count[0][0][i] + count[0][1][i], count[1][0][i] + count[1][1][i]);
        whoops += take;
    }

    print (yay, whoops);

var s = readline(s);
    var t = readline(t);

    var i = 0;
    var take = 0;
    var yay = 0;
    var whoops = 0;

    var count = new Array(2);

    for (i = 0; i < 2; ++i) {
        count[i] = new Array(2);

        for (j = 0; j < 2; ++j) {
            count[i][j] = new Array(26);

            for (k = 0; k < 26; ++k) {
                count[i][j][k] = 0;
            }
        }
    }

    var min = function(a, b) {
        if (a < b) {
            return a;
        }
        else return b;
    }

    var isUpperCase = function(char) {
        if ('A'.charCodeAt() <= char && char <= 'Z'.charCodeAt()) {
            return true;
        }
        else {
            return false;
        }
    }

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

        if (isUpperCase(s[i])) {
            count[0][0][s[i].charCodeAt() - 'A'.charCodeAt()]++;
        }
        else count[0][1][s[i].charCodeAt() - 'a'.charCodeAt()]++;
    }

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

        if (isUpperCase(t[i])) {
            count[1][0][t[i].charCodeAt() - 'A'.charCodeAt()]++;
        }
        else count[1][1][t[i].charCodeAt() - 'a'.charCodeAt()]++;
    }

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

        take = min(count[0][0][i], count[1][0][i]);
        count[0][0][i] -= take;
        count[1][0][i] -= take;
        yay += take;

        take = min(count[0][1][i], count[1][1][i]);
        count[0][1][i] -= take;
        count[1][1][i] -= take;
        yay += take;

        take = min(count[0][0][i] + count[0][1][i], count[1][0][i] + count[1][1][i]);
        whoops += take;
    }

    print (yay, whoops);

var s = readline(s);
    var t = readline(t);

    var i = 0;
    var take = 0;
    var yay = 0;
    var whoops = 0;

    var count = new Array(2);

    for (i = 0; i < 2; ++i) {
        count[i] = new Array(2);

        for (j = 0; j < 2; ++j) {
            count[i][j] = new Array(26);

            for (k = 0; k < 2; ++k) {
                count[i][j][k] = 0;
            }
        }
    }

    var min = function(a, b) {
        if (a < b) {
            return a;
        }
        else return b;
    }

    var isUpperCase = function(char) {
        if ('A'.charCodeAt() <= char && char <= 'Z'.charCodeAt()) {
            return true;
        }
    }

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

        if (isUpperCase(s[i])) {
            count[0][0][s[i].charCodeAt() - 'A'.charCodeAt()]++;
        }
        else count[0][1][s[i].charCodeAt() - 'a'.charCodeAt()]++;
    }

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

        if (isUpperCase(t[i])) {
            count[1][0][t[i].charCodeAt() - 'A'.charCodeAt()]++;
        }
        else count[1][1][t[i].charCodeAt() - 'a'.charCodeAt()]++;
    }

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

        take = min(count[0][0][i], count[1][0][i]);
        count[0][0][i] -= take;
        count[1][0][i] -= take;
        yay += take;

        take = min(count[0][1][i], count[1][1][i]);
        count[0][1][i] -= take;
        count[1][1][i] -= take;
        yay += take;

        take = min(count[0][0][i] + count[0][1][i], count[1][0][i] + count[1][1][i]);
        whoops += take;
    }

    print (yay, whoops);

var s = readline(s);
    var t = readline(t);

    var i = 0;
    var take = 0;
    var yay = 0;
    var whoops = 0;

    var count = new Array(2);

    for (i = 0; i < 2; ++i) {
        count[i] = new Array(2);

        for (j = 0; j < 2; ++j) {
            count[i][j] = new Array(26);

            for (k = 0; k < 26; ++k) {
                count[i][j][k] = 0;
            }
        }
    }

    var min = function(a, b) {
        if (a < b) {
            return a;
        }
        else return b;
    }

    var isUpperCase = function(char) {
        if ('A'.charCodeAt() <= char.charCodeAt() && char.charCodeAt() <= 'Z'.charCodeAt()) {
            return true;
        }
        else {
            return false;
        }
    }

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

        if (isUpperCase(s[i])) {
            count[0][0][s[i].charCodeAt() - 'A'.charCodeAt()]++;
        }
        else count[0][1][s[i].charCodeAt() - 'a'.charCodeAt()]++;
    }

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

        if (isUpperCase(t[i])) {
            count[1][0][t[i].charCodeAt() - 'A'.charCodeAt()]++;
        }
        else count[1][1][t[i].charCodeAt() - 'a'.charCodeAt()]++;
    }

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

        print (count[0][0][i], count[0][1][i], count[1][0][i], count[1][1][i]);

        take = min(count[0][0][i], count[1][0][i]);
        count[0][0][i] -= take;
        count[1][0][i] -= take;
        yay += take;

        take = min(count[0][1][i], count[1][1][i]);
        count[0][1][i] -= take;
        count[1][1][i] -= take;
        yay += take;

        take = min(count[0][0][i] + count[0][1][i], count[1][0][i] + count[1][1][i]);
        whoops += take;
    }

    print (yay, whoops);

function isUpperCase(myString) {
  return (myString == myString.toUpperCase());
}
function count(menor, maior) {
    var yay = 0;
    var whoops = 0;
    var n_menor = menor;
    var obj_maior = {};
    for (var i = 0, len = maior.length; i < len; i++) {
  			var charz = maior[i];
        var valor = obj_maior[charz];
        obj_maior[charz] = valor ? valor + 1 : 1
    }
    for (var i = 0, len = menor.length; i < len; i++) {
    		var charac = menor[i];
        var valor = obj_maior[charac];
        if (valor > 0) {
            yay ++;
            obj_maior[charac] = valor - 1;
            n_menor = n_menor.replace(charac, '');
        }
		}
    for (var i = 0, len = menor.length; i < len; i++) {
    		var charac = menor[i];
        var upper = charac.toUpperCase()
        if (isUpperCase(charac)) {
            var lower = charac.toLowerCase();
            var valor = obj_maior[lower];
            if (valor > 0) {
                obj_maior[lower] = valor - 1;
                whoops ++;
            }
        } else if (obj_maior[upper] > 0) {
            obj_maior[upper] = obj_maior[upper] - 1;
            whoops ++;
        }
    }
    return {'y' : yay, 'w': whoops};
}

var tayne = readline();
var jornal = readline();
var result = count(tayne, jornal)
print(result['y'] + " " +result['w'])

/*
ncMeXssLHS
uwyeMcaFatpInZVdEYpwJQSnVxLK
*/
String.prototype.forEach = Array.prototype.forEach;

function main()  {
    var tanyaStr = readline(),
        newsStr = readline(),
        tanyaUpperMap = {},
        tanyaLowerMap = {},
        YAYMap = {},
        YAY = WHOOPS = 0;

    tanyaStr.forEach(function(letter)    {
        if(letter >= 'a')   {
            if(!tanyaLowerMap[letter])  {
                tanyaLowerMap[letter] = {
                    'totalCount' : 0,
                    'YAY' : 0
                };
            }
            tanyaLowerMap[letter].totalCount++;
            tanyaLowerMap[letter].YAY++;
        } else  {
            if(!tanyaUpperMap[letter])  {
                tanyaUpperMap[letter] = {
                    'totalCount' : 0,
                    'YAY' : 0
                };
            }
            tanyaUpperMap[letter].totalCount++;
            tanyaUpperMap[letter].YAY++;
        }
    });

    newsStr.forEach(function(letter)    {
        if(letter >= 'a')   {
            if(tanyaLowerMap[letter])  {
                if(tanyaLowerMap[letter].YAY > 0)    {
                    tanyaLowerMap[letter].YAY--;
                    tanyaLowerMap[letter].totalCount--;
                    YAY++;
                    if(tanyaLowerMap[letter].YAY == 0)    YAYMap[letter] = true;
                }
            }
        } else  {
            if(tanyaUpperMap[letter])  {
                if(tanyaUpperMap[letter].YAY > 0)    {
                    tanyaUpperMap[letter].YAY--;
                    tanyaUpperMap[letter].totalCount--;
                    YAY++;
                    if(tanyaUpperMap[letter].YAY == 0)    YAYMap[letter] = true;
                }
            }
        }
    });

    newsStr.forEach(function(letter)    {
        if(YAYMap[letter])    return true;
        if(letter >= 'a')   {
            var upperLetter = letter.toUpperCase();

            if(tanyaUpperMap[upperLetter]) {
                if(tanyaUpperMap[upperLetter].totalCount > 0)  {
                    tanyaUpperMap[upperLetter].totalCount--;
                    WHOOPS++;
                }
            }
        } else  {
            var lowerLetter = letter.toLowerCase();

            if(tanyaLowerMap[lowerLetter]) {
                if(tanyaLowerMap[lowerLetter].totalCount > 0)  {
                    tanyaLowerMap[lowerLetter].totalCount--;
                    WHOOPS++;
                }
            }
        }
    });

    print(YAY + ' ' + WHOOPS);
};

main();

String.prototype.forEach = Array.prototype.forEach;

function main()    {
    var tanyaMsg = readline(),
        newsMsg = readline(),
        tanyaLetterMap = {},
        tanyaLetterList = [],
        newsLetterMap = {},
        result = [ 0, 0 ];

    tanyaMsg.forEach(function(tanyaLetter)    {
        if(!tanyaLetterMap[tanyaLetter])    {
            tanyaLetterList.push(tanyaLetter);
            tanyaLetterMap[tanyaLetter] = 0;
        }
        tanyaLetterMap[tanyaLetter]++;
    });
    newsMsg.forEach(function(newsLetter)    {
        if(!newsLetterMap[newsLetter])    newsLetterMap[newsLetter] = 0;
        newsLetterMap[newsLetter]++;
    });

    tanyaLetterList.forEach(function(tanyaLetter)    {
        var tanyaLetterCount = tanyaLetterMap[tanyaLetter],
            newsLetterCount = newsLetterMap[tanyaLetter];

        !newsLetterCount ? newsLetterCount = 0 : false;

        if(tanyaLetterCount <= newsLetterCount)    {
            result[0] += tanyaLetterCount;
        } else    {
            result[0] += newsLetterCount;
            result[1] += (tanyaLetterCount - newsLetterCount);
        }
    });

    print(result.join(' '));
};

main();

function main()    {
    var tanyaMsg = readline(),
        newsMsg = readline(),
        tanyaLetterMap = {},
        newsLetterMap = {},
        result = [ 0, 0 ];

    newsMsg.split('').forEach(function(newsLetter, index)    {
        var tanyaLetter = tanyaMsg[index];

        if(tanyaLetter)    {
            if(!tanyaLetterMap[tanyaLetter])    tanyaLetterMap[tanyaLetter] = 0;
            tanyaLetterMap[tanyaLetter]++;
        }
        if(!newsLetterMap[newsLetter])    newsLetterMap[newsLetter] = 0;
        newsLetterMap[newsLetter]++;
    });

    Object.keys(tanyaLetterMap).forEach(function(tanyaLetter)    {
        var tanyaLetterCount = tanyaLetterMap[tanyaLetter],
            newsLetterCount = newsLetterMap[tanyaLetter];

        !newsLetterCount ? newsLetterCount = 0 : false;

        if(tanyaLetterCount <= newsLetterCount)    {
            result[0] += tanyaLetterCount;
        } else    {
            result[0] += newsLetterCount;
            result[1] += (tanyaLetterCount - newsLetterCount);
        }
    });

    print(result.join(' '));
};

main();

String.prototype.forEach = Array.prototype.forEach;

function main()  {
    var tanyaStr = readline(),
        newsStr = readline(),
        tanyaUpperMap = {},
        tanyaLowerMap = {},
        YAY = WHOOPS = 0;

    tanyaStr.forEach(function(letter)    {
        if(letter >= 'a')   {
            if(!tanyaLowerMap[letter])  {
                tanyaLowerMap[letter] = {
                    'totalCount' : 0,
                    'YAY' : 0
                };
            }
            tanyaLowerMap[letter].totalCount++;
            tanyaLowerMap[letter].YAY++;
        } else  {
            if(!tanyaUpperMap[letter])  {
                tanyaUpperMap[letter] = {
                    'totalCount' : 0,
                    'YAY' : 0
                };
            }
            tanyaUpperMap[letter].totalCount++;
            tanyaUpperMap[letter].YAY++;
        }
    });

    newsStr.forEach(function(letter)    {
        if(letter >= 'a')   {
            if(tanyaLowerMap[letter])  {
                if(tanyaLowerMap[letter].YAY > 0)    {
                    tanyaLowerMap[letter].YAY--;
                    tanyaLowerMap[letter].totalCount--;
                    YAY++;
                }
            }
        } else  {
            if(tanyaUpperMap[letter])  {
                if(tanyaUpperMap[letter].YAY > 0)    {
                    tanyaUpperMap[letter].YAY--;
                    tanyaUpperMap[letter].totalCount--;
                    YAY++;
                }
            }
        }
    });

    newsStr.forEach(function(letter)    {
        if(letter >= 'a')   {
            var upperLetter = letter.toUpperCase();

            if(tanyaUpperMap[upperLetter]) {
                if(tanyaUpperMap[upperLetter].totalCount > 0)  {
                    tanyaUpperMap[upperLetter].totalCount--;
                    WHOOPS++;
                }
            }
        } else  {
            var lowerLetter = letter.toLowerCase();

            if(tanyaLowerMap[lowerLetter]) {
                if(tanyaLowerMap[lowerLetter].totalCount > 0)  {
                    tanyaLowerMap[lowerLetter].totalCount--;
                    WHOOPS++;
                }
            }
        }
    });

    print(YAY + ' ' + WHOOPS);
};
main();

String.prototype.forEach = Array.prototype.forEach;

function main()    {
    var tanyaMsg = readline(),
        newsMsg = readline(),
        tanyaLetterList = [],
        hasLetterCount = hasNotLetterCount = 0;

    tanyaMsg.forEach(function(ch)    {
        if(!tanyaLetterList[ch.charCodeAt()])    tanyaLetterList[ch.charCodeAt()] = 0;
        tanyaLetterList[ch.charCodeAt()]++;
    });

    hasNotLetterCount = tanyaMsg.length;

    newsMsg.forEach(function(ch)    {
        if(tanyaLetterList[ch.charCodeAt()] > 0)    {
            tanyaLetterList[ch.charCodeAt()]--;
            hasLetterCount++;
        }
    });

    hasNotLetterCount -= hasLetterCount;

    print(hasLetterCount + ' ' + hasNotLetterCount);
};

main();

String.prototype.forEach = Array.prototype.forEach;

function main()    {
    var tanyaMsg = readline(),
        newsMsg = readline(),
        tanyaLowerList = [],
        tanyaUpperList = [],
        hasLetterCount = hasNotLetterCount = 0;

    tanyaMsg.forEach(function(ch)    {
        var chVal = ch.charCodeAt();

        if(chVal >= 65 && chVal <= 90)    {
            if(!tanyaUpperList[chVal - 65])    tanyaUpperList[chVal - 65] = 0;
            tanyaUpperList[chVal - 65]++;
        } else    {
            if(!tanyaLowerList[chVal - 97])    tanyaLowerList[chVal - 97] = 0;
            tanyaLowerList[chVal - 97]++;
        }
    });

    hasNotLetterCount = tanyaMsg.length;

    newsMsg.forEach(function(ch)    {
        var chVal = ch.charCodeAt();

        if(chVal >= 65 && chVal <= 90)    {
            if(tanyaUpperList[chVal - 65] > 0)    {
                tanyaUpperList[chVal - 65]--;
                hasLetterCount++;
            }
        } else    {
            if(tanyaLowerList[chVal - 97] > 0)    {
                tanyaLowerList[chVal - 97]--;
                hasLetterCount++;
            }
        }
    });

    hasNotLetterCount -= hasLetterCount;

    print(hasLetterCount + ' ' + hasNotLetterCount);
};

main();

String.prototype.forEach = Array.prototype.forEach;

function main()    {
    var tanyaMsg = readline(),
        newsMsg = readline(),
        tanyaLetterMap = {},
        tanyaLetterList = [],
        newsLetterMap = {},
        tanyaLetterLength = 0,
        result1 = result2 = 0;

    tanyaMsg.forEach(function(tanyaLetter)    {
        if(!tanyaLetterMap[tanyaLetter])    {
            tanyaLetterList.push(tanyaLetter);
            tanyaLetterMap[tanyaLetter] = 0;
        }
        tanyaLetterMap[tanyaLetter]++;
    });
    tanyaLetterLength = tanyaMsg.length;
    result2 = tanyaLetterLength;

    newsMsg.forEach(function(newsLetter)    {
        if(tanyaLetterMap[newsLetter] > 0)    {
            tanyaLetterMap[newsLetter]--;
            result1++;
        }
    });

    result2 -= result1;

    print(result1 + ' ' + result2);
};

main();

String.prototype.forEach = Array.prototype.forEach;

function main()  {
    var tanyaStr = readline(),
        newsStr = readline(),
        tanyaUpperMap = {},
        tanyaLowerMap = {},
        YAY = WHOOPS = 0;

    tanyaStr.forEach(function(letter)    {
        if(letter >= 'a')   {
            if(!tanyaLowerMap[letter])  {
                tanyaLowerMap[letter] = {
                    'totalCount' : 0,
                    'YAY' : 0
                };
            }
            tanyaLowerMap[letter].totalCount++;
            tanyaLowerMap[letter].YAY++;
        } else  {
            if(!tanyaUpperMap[letter])  {
                tanyaUpperMap[letter] = {
                    'totalCount' : 0,
                    'YAY' : 0
                };
            }
            tanyaUpperMap[letter].totalCount++;
            tanyaUpperMap[letter].YAY++;
        }
    });

    newsStr.forEach(function(letter)    {
        if(letter >= 'a')   {
            if(tanyaLowerMap[letter])  {
                if(tanyaLowerMap[letter].YAY > 0)    {
                    tanyaLowerMap[letter].YAY--;
                    tanyaLowerMap[letter].totalCount--;
                    YAY++;
                }
            }
        } else  {
            if(tanyaUpperMap[letter])  {
                if(tanyaUpperMap[letter].YAY > 0)    {
                    tanyaUpperMap[letter].YAY--;
                    tanyaUpperMap[letter].totalCount--;
                    YAY++;
                }
            }
        }
    });

    newsStr.forEach(function(letter)    {
        if(letter >= 'a')   {
            var upperLetter = letter.toUpperCase();

            if(tanyaUpperMap[upperLetter] && tanyaLowerMap[letter]) {
                if(tanyaUpperMap[upperLetter].totalCount > 0 && tanyaLowerMap[letter].YAY == 0)  {
                    tanyaUpperMap[upperLetter].totalCount--;
                    WHOOPS++;
                }
            }
        } else  {
            var lowerLetter = letter.toLowerCase();

            if(tanyaLowerMap[lowerLetter] && tanyaUpperMap[letter]) {
                if(tanyaLowerMap[lowerLetter].totalCount > 0 && tanyaUpperMap[letter].YAY == 0)  {
                    tanyaLowerMap[lowerLetter].totalCount--;
                    WHOOPS++;
                }
            }
        }
    });

    print(YAY + ' ' + WHOOPS);
};
main();

//var input = "abacaba\nAbaCaBA";
//var index = 0;
//
//function readline(){
//    var data = input.split('\n');
//    if(index < data.length)
//        return data[index++];
//}
//
//function print(output){
//    console.log(output);
//}

function main(){
    var a = readline();
    var b = readline();
    var arrL = new Array(26), arrU = new Array(26);
    for(var i = 0; i < 26; i++){
        arrL[i] = 0;
        arrU[i] = 0;
    }
    var ans1 = 0, ans2 = 0;
    for(var i = 0; i < b.length; i++){
        if(b.charCodeAt(i) >= 'A'.charCodeAt(0) && b.charCodeAt(i) <= 'Z'.charCodeAt(0))
            arrU[b.charCodeAt(i) - 'A'.charCodeAt(0)]++;
        else
            arrL[b.charCodeAt(i) - 'a'.charCodeAt(0)]++;
    }
    for(var i = 0; i < a.length; i++){
        if(a.charCodeAt(i) >= 'A'.charCodeAt(0) && a.charCodeAt(i) <= 'Z'.charCodeAt(0)){
            if(arrU[a.charCodeAt(i) - 'A'.charCodeAt(0)] > 0){
                ans1++;
                arrU[a.charCodeAt(i) - 'A'.charCodeAt(0)]--;
            }else if(arrL[a.charCodeAt(i) - 'A'.charCodeAt(0)] > 0){
                ans2++;
                arrL[a.charCodeAt(i) - 'A'.charCodeAt(0)]--;
            }
        }
    }
    for(var i = 0; i < a.length; i++){
        if(a.charCodeAt(i) >= 'a'.charCodeAt(0) && a.charCodeAt(i) <= 'z'.charCodeAt(0)){
            if(arrL[a.charCodeAt(i) - 'a'.charCodeAt(0)] > 0){
                ans1++;
                arrL[a.charCodeAt(i) - 'a'.charCodeAt(0)]--;
            }else if(arrU[a.charCodeAt(i) - 'a'.charCodeAt(0)] > 0){
                ans2++;
                arrU[a.charCodeAt(i) - 'a'.charCodeAt(0)]--;
            }
        }
    }
    print(ans1 + " " + ans2);
}
main();

//var input = "abacaba\nAbaCaBA";
//var index = 0;
//
//function readline(){
//    var data = input.split('\n');
//    if(index < data.length)
//        return data[index++];
//}
//
//function print(output){
//    console.log(output);
//}

function main(){
    var a = readline();
    var b = readline();
    var arrL = new Array(26), arrU = new Array(26);
    for(var i = 0; i < 26; i++){
        arrL[i] = 0;
        arrU[i] = 0;
    }
    var ans1 = 0, ans2 = 0;
    for(var i = 0; i < b.length; i++){
        if(b.charCodeAt(i) >= 'A'.charCodeAt(0) && b.charCodeAt(i) <= 'Z'.charCodeAt(0))
            arrU[b.charCodeAt(i) - 'A'.charCodeAt(0)]++;
        else
            arrL[b.charCodeAt(i) - 'a'.charCodeAt(0)]++;
    }
    for(var i = 0; i < a.length; i++){
        if(a.charCodeAt(i) >= 'A'.charCodeAt(0) && a.charCodeAt(i) <= 'Z'.charCodeAt(0)){
            if(arrU[a.charCodeAt(i) - 'A'.charCodeAt(0)] > 0){
                ans1++;
                arrU[a.charCodeAt(i) - 'A'.charCodeAt(0)]--;
            }else if(arrL[a.charCodeAt(i) - 'A'.charCodeAt(0)] > 0){
                ans2++;
                arrL[a.charCodeAt(i) - 'A'.charCodeAt(0)]--;
            }
        }else{
            if(arrL[a.charCodeAt(i) - 'a'.charCodeAt(0)] > 0){
                ans1++;
                arrL[a.charCodeAt(i) - 'a'.charCodeAt(0)]--;
            }else if(arrU[a.charCodeAt(i) - 'a'.charCodeAt(0)] > 0){
                ans2++;
                arrU[a.charCodeAt(i) - 'a'.charCodeAt(0)]--;
            }
        }
    }
    print(ans1 + " " + ans2);
}
main();

//var input = "abacaba\nAbaCaBA";
//var index = 0;
//
//function readline(){
//    var data = input.split('\n');
//    if(index < data.length)
//        return data[index++];
//}
//
//function print(output){
//    console.log(output);
//}

function main(){
    var a = readline();
    var b = readline();
    var arrL = new Array(26), arrU = new Array(26);
    for(var i = 0; i < 26; i++){
        arrL[i] = 0;
        arrU[i] = 0;
    }
    var ans1 = 0, ans2 = 0;
    for(var i = 0; i < b.length; i++){
        if(b.charCodeAt(i) >= 'A'.charCodeAt(0) && b.charCodeAt(i) <= 'Z'.charCodeAt(0))
            arrU[b.charCodeAt(i) - 'A'.charCodeAt(0)]++;
        else
            arrL[b.charCodeAt(i) - 'a'.charCodeAt(0)]++;
    }
    for(var i = 0; i < a.length; i++){
        if(a.charCodeAt(i) >= 'A'.charCodeAt(0) && a.charCodeAt(i) <= 'Z'.charCodeAt(0)){
            if(arrU[a.charCodeAt(i) - 'A'.charCodeAt(0)] > 0){
                ans1++;
                arrU[a.charCodeAt(i) - 'A'.charCodeAt(0)]--;
            }
        }else if(arrL[a.charCodeAt(i) - 'a'.charCodeAt(0)] > 0){
            ans1++;
            arrL[a.charCodeAt(i) - 'a'.charCodeAt(0)]--;
        }
    }

    for(var i = 0; i < a.length; i++){
        if(a.charCodeAt(i) >= 'A'.charCodeAt(0) && a.charCodeAt(i) <= 'Z'.charCodeAt(0)){
            if(arrL[a.charCodeAt(i) - 'A'.charCodeAt(0)] > 0){
                ans2++;
                arrL[a.charCodeAt(i) - 'A'.charCodeAt(0)]--;
            }else if(arrU[a.charCodeAt(i) - 'a'.charCodeAt(0)] > 0){
                ans2++;
                arrU[a.charCodeAt(i) - 'a'.charCodeAt(0)]--;
            }
        }
    }
    print(ans1 + " " + ans2);
}
main();

//var input = "abacaba\nAbaCaBA";
//var index = 0;
//
//function readline(){
//    var data = input.split('\n');
//    if(index < data.length)
//        return data[index++];
//}
//
//function print(output){
//    console.log(output);
//}

function main(){
    var a = readline();
    var b = readline();
    var arrL = new Array(26), arrU = new Array(26);
    for(var i = 0; i < 26; i++){
        arrL[i] = 0;
        arrU[i] = 0;
    }
    var ans1 = 0, ans2 = 0;
    for(var i = 0; i < b.length; i++){
        if(b.charCodeAt(i) >= 'A'.charCodeAt(0) && b.charCodeAt(i) <= 'Z'.charCodeAt(0))
            arrU[b.charCodeAt(i) - 'A'.charCodeAt(0)]++;
        else
            arrL[b.charCodeAt(i) - 'a'.charCodeAt(0)]++;
    }
    for(var i = 0; i < a.length; i++){
        if(a.charCodeAt(i) >= 'A'.charCodeAt(0) && a.charCodeAt(i) <= 'Z'.charCodeAt(0)){
            if(arrU[a.charCodeAt(i) - 'A'.charCodeAt(0)] > 0){
                ans1++;
                arrU[a.charCodeAt(i) - 'A'.charCodeAt(0)]--;
            }
        }else if(arrL[a.charCodeAt(i) - 'a'.charCodeAt(0)] > 0){
            ans1++;
            arrL[a.charCodeAt(i) - 'a'.charCodeAt(0)]--;
        }
    }

    for(var i = 0; i < a.length; i++){
        if(a.charCodeAt(i) >= 'A'.charCodeAt(0) && a.charCodeAt(i) <= 'Z'.charCodeAt(0)){
            if(arrL[a.charCodeAt(i) - 'A'.charCodeAt(0)] > 0){
                ans2++;
                arrL[a.charCodeAt(i) - 'A'.charCodeAt(0)]--;
            }
        }else if(arrU[a.charCodeAt(i) - 'a'.charCodeAt(0)] > 0){
            ans2++;
            arrU[a.charCodeAt(i) - 'a'.charCodeAt(0)]--;
        }
    }
    print(ans1 + " " + ans2);
}
main();


Stepan has the newest electronic device with a display. Different digits can be shown on it. Each digit is shown on a seven-section indicator like it is shown on the picture below.  So, for example, to show the digit 3 on the display, 5 sections must be highlighted; and for the digit 6, 6 sections must be highlighted. The battery of the newest device allows to highlight at most n sections on the display. Stepan wants to know the maximum possible integer number which can be shown on the display of his newest device. Your task is to determine this number. Note that this number must not contain leading zeros. Assume that the size of the display is enough to show any integer.

The first line contains the integer n (2 ≤ n ≤ 100 000) — the maximum number of sections which can be highlighted on the display.

Print the maximum integer which can be shown on the display of Stepan's newest device.

var str=readline();
var n=parseInt(str);
var can=false;
if(n%2!=0) can=true, n--;
n=n/2;
for(var i=0; i<n; i++){
    if(i==0&&can==true) write("7");
    else write("1");
}

n = parseInt(readline());
if (n % 2 == 1) {
    write(7);
    n -= 3;
}
while (n > 0) {
    write(1);
    n-=2;
}

  var n = parseInt(readline());

  var res = '';

  while(n > 0) {
    if(n === 3) {
      res = '7' + res;
      n -= 3;
    } else {
      n -= 2;
      res = '1' + res;
    }
  }

  if(res === '') {
    res = '0';
  }

  print(res);

n = +readline()
if (n % 2 == 0) {
    ans = ""
    while (n >= 2) {
        ans += "1"
        n -= 2
    }
    print(ans)
} else {
    ans = "7"
    n -= 3
    while (n >= 2) {
        ans += "1"
        n -= 2
    }
    print(ans)
}

var n = readline();
var ans="";
for(var i=n; i>0;){
    if(i==3) {ans='7'+ans; i-=3; }
    else { ans='1'+ans; i-=2; }
}
print(ans);

n = readline();

comp = n % 2;
if(comp == 0)
{
   var res = "";
   for(var i = 1; i <= n / 2; i++)
      res += "1";
   print(res);
}
else
{
   var res = "7";
   for(var i = 1; i <= (n - 3) / 2; i++)
      res += "1";
   print(res);
}

var num = readline()
var res = ""

if (num%2 == 1){
    res += "7"
    num -= 3
}

while (num > 0){
    res += "1"
    num -= 2
}

print(res)

function sa(n){
var arr = [];
        if(n%2!=0){
			arr.push(7);
			n-=3;

        }
for(var i=0;i<n/2;i++){
				arr.push(1);
            }

return arr.join("")

    }

    var f = Number(readline());

    print(sa(f));

var x = +readline()
var answer = [];

if (x % 2 === 1) {
    answer.push('7');
    x -= 3;
}

while (x) {
    answer.push('1');
    x -= 2;
}

print(answer.join(''));

var n = readline();
if(n%2==1){
    n=n-3;
    var answer = '7';
    n=n/2;
    for(var i=0; i<n; i++){
        answer= answer + '1';
    }
}
else{
    n=n/2-1;
    var answer = '1';
    for(var i=0; i<n; i++){
        answer = answer + '1';
    }
}
print(answer);

var n = +readline();
var arr = [];
if (n % 2 === 0) {
  while(n >= 2) {
    n-= 2;
    arr.push(1);
  }
} else {
  n-= 3;
  arr.push(7);
  while(n >= 2) {
    n-= 2;
    arr.push(1);
  }
}
for(var i = 0; i < arr.length; i++) {
  write(arr[i]);
}

function main() {
    var N = readline();
    var ans = "";
    var n = parseInt(N);
    if(n % 2 && n > 2){
        //print("7");
        ans += "7";
        n = n - 3;
    }
    for(var i = 0; i < n/2; ++i){
        //print("1");
        ans += "1";
    }
    print(ans);
}

main();

var n=+readline()
var maxLen = 0
var s = 0
var digit = 0
var arr = [6, 2, 5, 5, 4, 5, 6, 3, 7, 6]
for (var i = 1; i <= 9; ++i)
		{
			var sum = arr[i];
			if (sum <= n)
			{
				var len = 1 + ((n - sum) / 2 | 0);
				if (len >= maxLen)
				{
					s = len - 1;
					maxLen = len;
					digit = i;
				}
			}
		}
var str = digit
for (var i = 0; i < s; ++i)
	str = str + "1"
print(str)

const readline = require('readline');
//const lineReader = require('fs');
//const scanner = lineReader.createReadStream('main.in');
const rl = readline.createInterface({
    input: process.stdin,
    output: process.stdout
});

let mp = {}

function reverse(str){
    return str.split("").reverse().join("");
}

rl.on('line', (input) => {
    let n = parseInt(input);
    mp[3] = "7";
    mp[2] = "1";
    let an = "";
    while(n){
        if (n >= 2 && n != 3){
            an += mp[2];
            n -= 2;
        } else {
            an += mp[3];
            n -= 3;
        }
    }
    an = reverse(an);
    console.log(an);
    rl.close();
});

var n = readline();
var k = parseInt(n);
var j = "";
if (k%2 == 1) {
	j += "7"
	k-=3;
}
while(k) {
	j += "1"
	k-=2;
}
print(j);

var x=readline()
var y=Math.floor(x/2)
var s='';
if (x % 2 > 0) {
    y--;
}
while(y > 0) {
    s=s+'1'
    y--;
}
if (x % 2 > 0) {
    s = '7' + s
}
print(s)

var str=readline();
var n=parseInt(str);
var can=false;
if(n%2!=0) can=true;
n=n/2;
for(var i=0; i<n; i++){
    if(i==0&&can==true) write("7");
    else write("1");
}

var n = readline();
var ans="";
for(var i=n; i>0;){
    if(i==3) {ans+='7'; i-=3; }
    else { ans+='1'; i-=2; }
}
print(ans);

var n = +readline();
var arr = [];
while(n >= 6) {
  n-= 6;
  arr.push(9);
}
while(n >= 3) {
  n-= 3;
  arr.push(7);
}
while(n >= 2) {
  n-= 2;
  arr.push(1);
}
for(var i = 0; i < arr.length; i++) {
  write(arr[i]);
}

var n = +readline();

ans = ''

x = Math.floor(n / 3)

while (x--)
   ans += '7'

if (n % 3 == 2)
   ans += '1'

print(ans)

var n = readline();
var k = parseInt(n);
var j = "";
while(k>2) {
	j += "1"
	k-=2;
}
if (k) {
	j += "7"
}
print(j);

var n = readline();
var k = parseInt(n);
var j = "";
while(k>3) {
	j += "1"
	k-=2;
}
if (k) {
	j += "7"
}
print(j);


Polycarp has a strict daily schedule. He has n alarms set for each day, and the i-th alarm rings each day at the same time during exactly one minute.Determine the longest time segment when Polycarp can sleep, i. e. no alarm rings in that period. It is possible that Polycarp begins to sleep in one day, and wakes up in another.

The first line contains a single integer n (1 ≤ n ≤ 100) — the number of alarms. Each of the next n lines contains a description of one alarm. Each description has a format "hh:mm", where hh is the hour when the alarm rings, and mm is the minute of that hour when the alarm rings. The number of hours is between 0 and 23, and the number of minutes is between 0 and 59. All alarm times are distinct. The order of the alarms is arbitrary. Each alarm starts ringing in the beginning of the corresponding minute and rings for exactly one minute (i. e. stops ringing in the beginning of the next minute). Polycarp can start sleeping instantly when no alarm is ringing, and he wakes up at the moment when some alarm starts ringing.

Print a line in format "hh:mm", denoting the maximum time Polycarp can sleep continuously. hh denotes the number of hours, and mm denotes the number of minutes. The number of minutes should be between 0 and 59. Look through examples to understand the format better.

NoteIn the first example there is only one alarm which rings during one minute of a day, and then rings again on the next day, 23 hours and 59 minutes later. Polycarp can sleep all this time.

var n=parseInt(readline());
var i,j,cur,Max,t;
var arr=[];
for(i = 0; i < n; i++){
    t = readline().split(':').map(el => parseInt(el));
    arr.push(t[0]*60+t[1]);
}
arr.sort((a, b) => a-b)
cur = arr[arr.length - 1] - 24 * 60 + 1;
Max = 0;
for(i = 0; i < n; i++){
    Max = Math.max(arr[i] - cur, Max);
    cur = arr[i] + 1;
}
print((Math.floor(Max/60) < 10 ? '0' : '') + Math.floor(Max/60) +':'+(Max%60 < 10 ? '0':'') + Max%60);

var n = parseInt(readline());
var arr = [];
for(var i = 0; i < n; i++){
    var t = readline().split(':').map(el => parseInt(el));
    arr.push(t[0]*60+t[1]);
}
arr.sort((a, b) => a-b)
var cur = arr[arr.length - 1] - 24 * 60 + 1;
var Max = 0;
for(var i = 0; i < n; i++){
    Max = Math.max(arr[i] - cur, Max);
    cur = arr[i] + 1;
}
print((Math.floor(Max/60) < 10 ? '0' : '') + Math.floor(Max/60) +':'+(Max%60 < 10 ? '0':'') + Max%60);

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

var nn = readline().split(" ").map(v => +v.trim());
var n = nn[0];
//print(n);
var a = [];

for (var i = 0; i < n; i++) {
    var tmp = readline().split(":").map(v => +v.trim());
    var cur = 60 * tmp[0] + tmp[1];
    //print(cur);
    a.push(cur);
}

a = a.sort(sortFunction)
a.push(a[0] + 24 * 60);
//print(a);
var mx = 0;
for (var i = 0; i < n; i++) {
    var cur = a[i + 1] - a[i] - 1;
    if (mx < cur) {
        mx = cur;
    }
}
//print(mx);
var h = Math.floor( mx / 60 );
var m = mx - h * 60;
if (h < 10 && m < 10) {
    print("0" + h + ":" + "0" + m);
}
else if (h < 10) {
    print("0" + h + ":" + m);
}
else if (m < 10) {
    print(h + ":" + "0" + m);
}
else {
    print(h + ":" + m);
}

var n;
var arr = new Array();
n = readline();
for (var i = 0; i < n; ++i) {
    var s = readline();
    var t = parseInt(parseInt(s[0]) * 600 + parseInt(s[1]) * 60 + parseInt(s[3]) * 10 + parseInt(s[4]));
    arr[i] = t;
}
arr.sort(function(a, b){return parseInt(a) - parseInt(b)});
arr[n] = parseInt(parseInt(arr[0]) + parseInt(1440));
var ans = 0;
for (var i = 0; i < n; ++i) {
    ans = Math.max(ans, parseInt(arr[i + 1]) - parseInt(arr[i]) - 1);
}
var q = "" + parseInt(parseInt(ans) / parseInt(600)) + "" + parseInt(parseInt(ans) / parseInt(60)) % 10 + ":" + parseInt(ans / 10) % 6 + parseInt(ans % 10);
print(q);

var n = parseInt(readline());
var a = [];
for(var i=0;i<n;++i){
    var time = readline().split(':').map(function(x){return parseInt(x);});
    a.push(time[0]*60 + time[1]);
}
a.sort(function (a, b) {return a-b;});
var ans = a[0]+24*60 - a[a.length-1] - 1;
for(var i=1;i<n+2;++i){
    if(a[i]-a[i-1]-1 > ans){
        ans = a[i]-a[i-1]-1;
    }
}
var h = parseInt(ans/60);
if(h<10)
    h = '0' + h;
var m = ans%60;
if(m<10)
    m = '0'+m;
print(h+':'+m);

var n = readline();
var tmp = [];
var time = new Array();
var s;

for (var i = 0; i < 1440; ++i) {
    time[i] = false;
}

for (var i = 0; i < n; ++i) {
    s = readline();
    if (s != undefined) {
        tmp = s.split(":");
    }
    time[parseInt(tmp[0] * 60) + parseInt(tmp[1])] = true;
}

var cur = 0, max = 0, first = -1, last = 0;

for (var i = 0; i < 1440; ++i) {
    if (!time[i]) {
        cur++;
    }
    if (time[i]) {
        if (max < cur) {
            max = cur;
        }
        last = i;
        if (first == -1) {
            first = i;
        }
        cur = 0;
    }
}

if (max < first + 1439 - last) {
    max = first + 1439 - last;
}

print(("0" + Math.floor(max / 60)).slice(-2) + ":" + ("0" + max % 60).slice(-2));

function compareNumeric(a, b) {
  return a - b;
}

var n = readline();

var mas = [];
for(i = 0; i < n; i++){
    var login = readline();
    var k = login[0] * 10 + login[1] * 1;
    k = k * 60;
    k = k * 1 + login[3] * 10 + login[4] * 1;
    mas.push(k);
}
mas.sort(compareNumeric);
var ans = 0;
for(i = 0; i < n-1; i++){
    ans = Math.max(mas[i+1] - mas[i] - 1, ans);
}
ans = Math.max(ans, (23*60+59 - mas[n-1]) + mas[0] * 1);
var k1 = (Math.floor(ans / 60));
var k2 = ans - k1 * 60;
if(k1 < 10) k1 = '0' + k1;
if(k2 < 10) k2 = '0'+ k2;
print(k1 + ":" + k2);

function compare(a, b) {
  return a - b;
}

Number.prototype.pad = function(size) {
    var s = String(this);
    while (s.length < (size || 2)) {s = "0" + s;}
    return s;
}

var a = [];
var num = 1440;
var n = readline();
var x = 0, y = 0, i = 0;
for(i = 0; i < n; i++){
    var line = readline().replace(":", " ").split(" ");
    x = parseInt(line[0]); y = parseInt(line[1]);
    a.push(x * 60 + y);
}
a.sort(compare);
var res = 0;
for(i = 1; i < n; i++){
    if(a[i] - a[i - 1] - 1 > res){
        res = a[i] - a[i - 1] - 1;
    }
}
if(num - a[n-1] + a[0] - 1 > res){
    res = num - a[n-1] + a[0] - 1;
}

print(parseInt(res / 60).pad(2).toString()+ ":" + (res % 60).pad(2).toString());

var n=+readline()
var st=[]
while(n-->0){
   hm=readline().split(':')
   st.push(hm[0]*60+ +hm[1])
}
st.sort((a,b)=>a-b)

var ans=0
for(var i=1;i<st.length;++i){
   ans=Math.max(ans,st[i]-st[i-1])
}
ans=Math.max(ans,st[0]+24*60-st[st.length-1])-1

var h=Math.floor(ans/60)+'',m=(ans%60)+'';
while(h.length<2)h='0'+h;
while(m.length<2)m='0'+m;
print(h+':'+m)

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

var n = +readline()
var a = []
for (var i = 0; i < n; i++)
{
	var s = readline();
	var x = (+s[4]) + (+s[3]) * 10 + (+s[1]) * 60 + (+s[0]) * 600;
	a.push(x);
}
a.sort(function(x, y){if (x < y) return -1; else if (x == y) return 0; else return 1;});
for (var i = 0; i < n; i++)
	a.push(a[i] + 24 * 60);
var ans = 0;
for (var i = 1; i < n * 2; i++)
{
	if (ans < (a[i] - a[i - 1] - 1))
		ans = (a[i] - a[i - 1] - 1);
}
var str = ""
str += div(ans, 600);
ans %= 600;
str += div(ans, 60);
ans %= 60;
str += ":";
str += div(ans, 10);
ans %= 10;
str += ans;
print(str);

var n=parseInt(readline());
var arr=[];
for (var i=0;i<2880;++i) arr[i]=0;
for (var i=0;i<n;++i) {
    var arr1=readline().split(":");
    var h=parseInt(arr1[0]);
    var m=parseInt(arr1[1])+h*60;
    arr[m]=1;
    arr[m+1440]=1;
}
var pros=0;
var masleep=0;
for (var i=0;i<2880;++i) if (arr[i]===1) {
    if (i-pros-1>masleep) masleep=i-pros-1;
    pros=i;
}
var str='';
if ((masleep-masleep%60)/60<10) str='0';
var str1='';
if (masleep%60<10) str1='0';
print(str+(masleep-masleep%60)/60+':'+str1+masleep%60);

var n = ~~readline();
var x = Array.apply(null, Array(1440)).map(Number.prototype.valueOf,0);

for(var i = 0; i < n; ++i) {
    var t = readline().split(":");
    x[(~~t[0]) * 60 + (~~t[1])] = 1;
}

var ans = 0, cnt = 0;
for(var i = 0; i < 1440 * 2; ++i) {
    if(x[i % 1440] === 0) {
        ++cnt;
    } else {
        if(cnt > ans) ans = cnt;
        cnt = 0;
    }
}

var h = parseInt(ans / 60);
var m = ans % 60;

if(h < 10) h = '0' + h;
if(m < 10) m = '0' + m;
print(h + ":" + m);

var n = parseInt(readline());
var arr = [];
for(var i = 0; i < n; i++){
    var t = readline().split(':').map(el => parseInt(el));
    arr.push(t[0]*60+t[1]);
}
arr.sort((a, b) => a-b)
var cur = arr[arr.length - 1] - 24 * 60 + 1;
var Max = 0;
for(var i = 0; i < n; i++){
    Max = Math.max(arr[i] - cur, Max);
    cur = arr[i] + 1;
}
print(Math.floor(Max/60)+':'+Max%60);

var n = readline();
var tmp = [];
var time = new Array();
var s;

for (var i = 0; i < 1440; ++i) {
    time[i] = false;
}

for (var i = 0; i < n; ++i) {
    s = readline();
    if (s != undefined) {
        tmp = s.split(":");
    }
    time[parseInt(tmp[0] * 60) + parseInt(tmp[1])] = true;
}

var cur = 0, max = 0, first = -1, last = 0;

for (var i = 0; i < 1440; ++i) {
    if (!time[i]) {
        cur++;
    }
    if (time[i]) {
        if (max < cur) {
            max = cur;
        }
        last = i;
        if (first == -1) {
            first = i;
        }
        cur = 0;
    }
}

if (max < first + 1440 - last) {
    max = first + 1440 - last;
}

print(("0" + Math.floor(max / 60)).slice(-2) + ":" + ("0" + max % 60).slice(-2));

function compareNumeric(a, b) {
  return a - b;
}

var n = readline();

var mas = [];
for(i = 0; i < n; i++){
    var login = readline();
    var k = login[0] * 10 + login[1] * 1;
    k = k * 60;
    k = k * 1 + login[3] * 10 + login[4] * 1;
    mas.push(k);
}
mas.sort(compareNumeric);
var ans = 0;
for(i = 0; i < n-1; i++){
    ans = Math.max(mas[i+1] - mas[i] - 1, ans);
}
ans = Math.max(ans, (23*60+59 - mas[n-1]) + mas[0] * 1);
print((Math.floor(ans / 60)) + ":" + (ans - Math.floor(ans / 60) * 60));

function sortNumber(a,b) {
    return a - b;
}
var n;
n = readline();
var x = [n+1];
var m = 5465464;
for (i = 0; i < n; i++) {
	var s = readline();
	x[i] = parseInt(s[4]-'0')+parseInt(s[3]-'0')*10+parseInt(s[1]-'0')*60+parseInt(s[0]-'0')*600;
	if ( m > x[i] ) m = x[i];
}
x[n] = m + 1440;
x = x.sort(sortNumber);

var l = 0;
for (i = 1; i <= n; i++) {
    if (l < x[i] - x[i-1] - 1 ) {
        l = x[i] - x[i-1] - 1;
    }
}
print(parseInt(l/(60)) + ":" + parseInt(l%60) );

var n=parseInt(readline());
var arr=[];
for (var i=0;i<2880;++i) arr[i]=0;
for (var i=0;i<n;++i) {
    var arr1=readline().split(":");
    var h=parseInt(arr1[0]);
    var m=parseInt(arr1[1])+h*60;
    arr[m]=1;
    arr[m+1440]=1;
}
var pros=0;
var masleep=0;
for (var i=0;i<2880;++i) if (arr[i]===1) {
    if (i-pros-1>masleep) masleep=i-pros-1;
    pros=i;
}
var str='';
if ((masleep-masleep%60)/60<10) str='0';
print(str+(masleep-masleep%60)/60+':'+masleep%60);


Blake is a CEO of a large company called "Blake Technologies". He loves his company very much and he thinks that his company should be the best. That is why every candidate needs to pass through the interview that consists of the following problem.We define function f(x, l, r) as a bitwise OR of integers xl, xl + 1, ..., xr, where xi is the i-th element of the array x. You are given two arrays a and b of length n. You need to determine the maximum value of sum f(a, l, r) + f(b, l, r) among all possible 1 ≤ l ≤ r ≤ n.

The first line of the input contains a single integer n (1 ≤ n ≤ 1000) — the length of the arrays. The second line contains n integers ai (0 ≤ ai ≤ 109). The third line contains n integers bi (0 ≤ bi ≤ 109).

Print a single integer — the maximum value of sum f(a, l, r) + f(b, l, r) among all possible 1 ≤ l ≤ r ≤ n.

NoteBitwise OR of two non-negative integers a and b is the number c = a OR b, such that each of its digits in binary notation is 1 if and only if at least one of a or b have 1 in the corresponding position in binary notation.In the first sample, one of the optimal answers is l = 2 and r = 4, because f(a, 2, 4) + f(b, 2, 4) = (2 OR 4 OR 3) + (3 OR 3 OR 12) = 7 + 15 = 22. Other ways to get maximum value is to choose l = 1 and r = 4, l = 1 and r = 5, l = 2 and r = 4, l = 2 and r = 5, l = 3 and r = 4, or l = 3 and r = 5.In the second sample, the maximum value is obtained for l = 1 and r = 9.

try {require('codef');} catch (e){global = this};
function readLineAsArray(separator){return readline().split(typeof separator == "undefined" ? ' ' : separator)}
function readLineAsIntegerArray(separator){return readLineAsArray(separator).map(function(v){return +v})}
Array.prototype.list = function() {var length = arguments.length; for(var i=0; i < length; i++){global[arguments[i]] = this[i]}};
String.prototype.repeat = function(n){return new Array(n + 1).join(this);}

var n = readLineAsIntegerArray()[0];
var a = readLineAsIntegerArray();
var b = readLineAsIntegerArray();
var aa = a[0], bb = b[0];
for(var i = 1; i < a.length; i++) {
    aa = aa | a[i];
    bb = bb | b[i];
}

write(aa + bb);

var n = Number(readline());
var a = readline().split(" ", n).map(Number);
var b = readline().split(" ", n).map(Number);

var x = 0, y = 0;
for (var i = 0; i < n; ++i) {
	x |= a[i];
	y |= b[i];
}
print(x + y);

var n = Number(readline());
var a = readline().split("", n).map(Number);
var b = readline().split("", n).map(Number);

var x = 0, y = 0;
for (var i = 0; i < n; ++i) {
	x |= a[i];
	y |= b[i];
}
print(x + y);


Amr has got a large array of size n. Amr doesn't like large arrays so he intends to make it smaller.Amr doesn't care about anything in the array except the beauty of it. The beauty of the array is defined to be the maximum number of times that some number occurs in this array. He wants to choose the smallest subsegment of this array such that the beauty of it will be the same as the original array.Help Amr by choosing the smallest subsegment possible.

The first line contains one number n (1 ≤ n ≤ 105), the size of the array. The second line contains n integers ai (1 ≤ ai ≤ 106), representing elements of the array.

Output two integers l, r (1 ≤ l ≤ r ≤ n), the beginning and the end of the subsegment chosen respectively. If there are several possible answers you may output any of them.

NoteA subsegment B of an array A from l to r is an array of size r - l + 1 where Bi = Al + i - 1 for all 1 ≤ i ≤ r - l + 1

        Node = function (count, position) {
            this.count = 0;
            this.minPosition = 100001;
            this.maxPosition = -100001;

            this.setPosition = function (position) {
                this.count++;
                this.minPosition = Math.min(this.minPosition, position);
                this.maxPosition = Math.max(this.maxPosition, position);
            }

            this.getLength = function () {
                return this.maxPosition - this.minPosition;
            }

            this.toString = function () {
                return '(' + this.count + ': ' + this.minPosition + ' - ' + this.maxPosition + ')';
            };

            this.setPosition(position);
        };

        n = +readline();
        numbers = readline().split(' ');
        nodes = {};
        for (i = 0; i < n; i++) {
            var node = nodes[numbers[i]];
            if (!node) {
                node = nodes[numbers[i]] = new Node(+numbers[i], i);
            }
            else {
                node.setPosition(i);
            }
        }

        var maxValueNode = null;

        for (key in nodes) {
            var node = nodes[key];
            if (maxValueNode === null || maxValueNode.count < node.count ||
                (maxValueNode.count == node.count && maxValueNode.getLength() > node.getLength())) {
                maxValueNode = node;
            }
        }

        print((maxValueNode.minPosition + 1) + ' ' + (maxValueNode.maxPosition + 1));

MAX = 1000001;
counts = [];
firsts = [];
lasts = [];
for (i = 0; i < MAX; i++) {
    counts[i] = 0;
    firsts[i] = -1;
    lasts[i] = MAX;
}
n = +readline();
array = readline().split(' ');
for (i = 0; i < n; i++) {
    ele = array[i] = +array[i];
    counts[ele]++;
    if (firsts[ele] < 0) firsts[ele] = i + 1;
    lasts[ele] = i + 1;
}

max = -1;
left = -1;
right = MAX;
for (i = 0; i < MAX; i++) {
    if (max < counts[i]) {
        max = counts[i];
        left = firsts[i];
        right = lasts[i];
    } else if (max == counts[i] && right - left > lasts[i] - firsts[i]) {
        left = firsts[i];
        right = lasts[i];
    }
}

print(left + ' ' + right);

Node = function(position, value) {
    this.position = position;
    this.value = value;
    this.toString = function() {
        return '(' + this.position + ', ' + this.value + ')';
    };
};

n = +readline();
numbers = readline().split(' ');
nodes = [];
for (i = 0; i < n; i++) {
    nodes[i] = new Node(i, +numbers[i]);
}
nodes.sort(function(n1, n2) {
    if (n1.value != n2.value) return n1.value - n2.value;
    return n1.position - n2.position;
});

max = 1;
mright = mleft = nodes[0].position;
count = 1;
left = right = nodes[0].position;
for (i = 1; i < n; i++) {
    if (nodes[i].value != nodes[i - 1].value) {
        left = right = nodes[i].position;
        count = 1;
    } else {
        right = nodes[i].position;
        count++;
    }
    if (max < count) {
        max = count;
        mleft = left;
        mright = right;
    } else if (max == count && mright - mleft > right - left) {
        mleft = left;
        mright = right;
    }

}

print((mleft + 1) + ' ' + (mright + 1));