You have a positive integer m and a non-negative integer s. Your task is to find the smallest and the largest of the numbers that have length m and sum of digits s. The required numbers should be non-negative integers written in the decimal base without leading zeroes.

The single line of the input contains a pair of integers m, s (1 ≤ m ≤ 100, 0 ≤ s ≤ 900) — the length and the sum of the digits of the required numbers.

In the output print the pair of the required non-negative integer numbers — first the minimum possible number, then — the maximum possible number. If no numbers satisfying conditions required exist, print the pair of numbers "-1 -1" (without the quotes).

var inp = readline().split(" ").map(function(x){return parseInt(x);});
var m = inp[0];
var s = inp[1];
var sMin = s;
var sMax = s;

var numberMin = "";
var numberMax = "";
var sum = 0;
var min = -1;
var max = -1;

if (s == 0){
	if (m == 1){
		print("0 0");
	}else{
		print("-1 -1");
	}
} else {
	if (s > m * 9){
		print("-1 -1");
	} else
	{
		var k = 1;

		for(var i=m; i > 0; i--){
			function getMin(){
				if (i==m){
					return Math.min(Math.max(1, sMin - (i-1) * 9), 9);
				} else
				{
					return Math.min(Math.max(0, sMin - (i-1) * 9), 9);
				}
			}

			function getMax(){
				return Math.min(Math.max(sMax - (i-1) * 9, 9), sMax);
			}

			min = getMin();
			numberMin += min;
			sMin -= min;

			max = getMax();
			numberMax += max;
			sMax -= max;
		}

		print(numberMin + " " + numberMax);
	}
}

var inp = readline().split(" ").map(function(x){return parseInt(x);});
	var m = inp[0];
	var s = inp[1];
	var maximum='',minimum='';
	if(s === 0)
	{
		if(m === 1){
			maximum = '0';
			minimum = '0';
		}
		else
		{
			maximum = '-1';
			minimum = '-1';
		}
	}else if(s > m*9){
		maximum = '-1';
		minimum = '-1';
	}
	else if(m === 1){
		maximum = s.toString();
		minimum = s.toString();
	}
	else{
		/*最大值*/
		if(s < 9){
			maximum = s.toString();
			for(var i = 2; i <= m; i++)
			{
				maximum += '0';
			}
		}
		else if(s >= 9){
			var ans = s;
			maximum = '9';
			ans = ans-9;
			while(ans > 0){
				if(ans >= 9){
					maximum = maximum+'9';
					ans -= 9;
				}
				else {
					maximum += ans.toString();
					ans -= ans;
				}
			}
			var len='';
			for(var j = 1; j <= m-maximum.length; j++)
			{
				len = len+ '0';
			}
			maximum = maximum+len;
		}
		/*最小值*/
		s = s-1;
		if(s < 9){
			var s1 = s;
			minimum = (s1).toString();
			var len1='';
			for(var k = 1; k <= m-2; k ++)
			{
				len1 = len1+'0';
			}
			minimum = '1'+len1+minimum;
		}
		else {
			var ans1 = s;
			var flag = 0;
			var temp=0;
			minimum = '9';
			ans1 = ans1 - 9;
			while(ans1 > 0){
				if(minimum.length === m-1)
				{
					temp = ans1;
					ans1 = 0;
					flag = 1;
					break;
				}
				else{
					if(ans1 >= 9){
						minimum = '9'+minimum;
						ans1 -= 9;
						}
					else{
						minimum = ans1.toString()+minimum;
						ans1 -= ans1;
					}
				}
			}
			if(flag === 1)
			{
				minimum = (temp+1).toString()+minimum;
			}
			else{
				var temp1 = '';
				for(var l = 1; l < m-minimum.length; l ++)
				{
					temp1 = temp1+'0';
				}
				minimum = '1'+temp1+minimum;
			}
		}
	}
	print(minimum+" "+maximum);

var solution = function() {

	//Считываем данные
	var input = readline().split(' ');
	var count = input[0];
	var sum = input[1];

	//Проверяем, что можно
	if (9*count < sum || sum == 0 && count > 1) {
		print(-1, -1);
		return;
	}

	//максимальное число
	var mx = "";
	var sumLeft = sum;
	var countLeft = count;
	while (countLeft) {
		mx += Math.min(9, sumLeft);
		sumLeft -= Math.min(9, sumLeft);
		countLeft--;
	}

	//минимальное число
	var mn = "";
	var countLeft = count;
	var sumLeft = sum;
	while (countLeft) {
		var cur = Math.max(sumLeft - (countLeft-1)*9, 0);

		if (!cur && countLeft == count && sumLeft > 0) {
			cur = 1;
		}

		mn += cur;
		sumLeft -= cur;

		countLeft--;
	}

	//вывод
	print(mn, mx);

}

solution();

function solve()
{
var st=[],ss=[];
var line = readline().split(" ");
var m = parseInt(line[0]);
var s = parseInt(line[1]);

if(m===1&&s===0)
{
    print(0,0);
    return;
}
if(m>1&&s===0)
{
    print(-1,-1);
    return;
}
for(var i=0;i<m;i++)
{
    if(s>=9)
    {
        st.push(9);
        ss.push(9);
        s-=9;

    }
    else{
        st.push(s);
        ss.push(s);
        s=0;
    }
}
if(st.length!==m||s>0)
{
print(-1,-1);
return;
}

ss.reverse();
for (var k = 0; k < ss.length; k++)
    {
        if (ss[k] !== 0)
        {
            ss[k]=ss[k]-1;
            ss[0]=ss[0]+1;
            break;
        }
    }

print(ss.join(""));
print(st.join(""));

    return;
}
solve();

'use strict'

const fn = (M, S) => {
    if (S === 0) return M === 1 ? '0 0' : '-1 -1'
    if (S > 9 * M) return '-1 -1'
    const s = (S - 1) % 9 + 1;
    let r = Array((S - s) / 9 + 1).join('9');
    if (M - 1 === r.length) return `${s}${r} ${r}${s}`;
    const zzz = Array(M - 1 - r.length).join('0');
    return `1${zzz}${s-1}${r} ${r}${s}${zzz}0`;
}
const x = readline().split(' ');
print(fn(parseInt(x[0]), parseInt(x[1])));

'use strict'

const fn = (M, S) => {
    if (S === 0) return M === 1 ? '0 0' : '-1 -1'
    if (S > 9 * M) return '-1 -1'
    const s = (S - 1) % 9 + 1;
    const len9 = (S - s) / 9;
    const r = '9'.repeat(len9);
    if (M - 1 === len9) return `${s}${r} ${r}${s}`;
    const z = '0'.repeat(M - 2 - len9);
    return `1${z}${s-1}${r} ${r}${s}${z}0`;
}
const x = readline().split(' ');
write(fn(parseInt(x[0]), parseInt(x[1])));

var x = readline(),a=x.substring(0,x.indexOf(' ')), n = Number.parseInt(a),
            m =Number.parseInt(x.substring(x.indexOf(' ')+1,x.length)),h=m
            ,min = "", max = ""
            var ok = true,ok2=true
            if (n > 1 && m === 0) {
                print("-1 -1")
            } else if (m > n * 9) {
                print("-1 -1")
            } else {
                for (var i = 0; i < n; ++i) {
                    if (h - 9 > 0) {
                        min += "9"
                        max += "9"
                        h -= 9
                    } else {
                        if (ok) {
                            max += h
                            ok = false
                        }
                        else
                            max += "0"
                        if (ok2){
                            if (i===n-1)min=h+min
                            else min=(h-1)+min
                            ok2=false
                        }else{
                             if(i===n-1)min="1"+min
                             else min="0"+min
                        }
                    }
                }
            }
            print(min + " " + max)

var inp = readline().split(' ');
var m = parseInt(inp[0]);
var s = parseInt(inp[1]);

var largestArr = [], smallestArr = [1];
for (var i = 0; i < m; i ++) {
	largestArr.push(0);
	if (i !== 0) smallestArr.push(0);
}
if (s === 0) smallestArr[0] = 0;

var largestOn = 0, smallestOn = m - 1;
for (var i = 0; i < s; i ++) {
	if (largestOn < m) {
		largestArr[largestOn] ++;
		if (largestArr[largestOn] === 9) largestOn ++;
	} else largestArr = [-1];

	if (smallestOn >= 0) {
		if (i >= 1) {
			smallestArr[smallestOn] ++;
			if (smallestArr[smallestOn] === 9) smallestOn --;
		}
	} else smallestArr = largestArr[0] !== -1 ? largestArr : [-1];
}

print(s === 0 && m !== 1 ? '-1 -1' : smallestArr.join('') + ' ' + largestArr.join(''));

var enter = readline().split(' ');
var n = enter[0];
var s = enter[1];
if(s <= n * 9 && s != 0 || s == 0 && n == 1) {
	var get_max = function(n,s) {
  var max = '';
  	while(n--) {
  		if( s >= 9) {
    max += 9;
    s -= 9;
    } else {
    max += s;
		s = 0;
    }
  }
  return max;
  };
  	var get_min = function(n,s) {
  	var first = true;
  	var min = '';
  		while(n--) {
  		var mn = first && n ? 1 : 0;
		var cur = Math.max(mn, s-9*n);
		s -= cur;
		min += cur;
		first = false;
  }
  return min;
  };
  print(get_min(n, s), get_max(n, s));
} else {
	print(-1, -1);
}

'use strict';

String.prototype.getNumArray = function () {
  return String(this).split(' ').map(function (value) {
    return parseInt(value);
  });
}

let input = readline().getNumArray();
let length = input[0];
let sum = input[1];
let arrayMax = [], max = -1;
let arrayMin = [], min = -1;

for (let i = 0; i<length; i++) {
  arrayMax.push(0);
  arrayMin.push(0);
}

// МАКСИМУМ
arrayMax[length - 1] = sum;
let ost = 0;
for(let i = length -1; i>=0; i--) {
  arrayMax[i] += ost;
  ost = 0;

  if (arrayMax[i] > 9) {
    ost = arrayMax[i] - 9;
    arrayMax[i] = 9;
  }
}

if (ost === 0 && (sum !== 0 || length === 1)) {
  max = arrayMax.reverse().join('');
}

ost = 0;

// МИНИМУМ

if(length > 1) {
  arrayMin[length - 1] = sum - 1;
  arrayMin[0] = 1;
} else {
  arrayMin[length - 1] = sum;
}

for(let i = length -1; i>=0; i--) {
  arrayMin[i] += ost;
  ost = 0;

  if (arrayMin[i] > 9) {
    ost = arrayMin[i] - 9;
    arrayMin[i] = 9;
  }
}

if (ost === 0 && (sum !== 0 || length === 1)) {
  min = arrayMin.join('');
}

write(min + ' ' + max);

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

const input = [];
readLine.on('line', line => input.push(line));

readLine.on('close', () => {
  let [m, s] = input[0].split(' ').map(x => parseInt(x));
  if (s === 0 || m*9 < s) {
    if (m === 1 && s === 0)
      console.log(`0 0`);
    else
      console.log(`-1 -1`);
  } else {
    let bigAnswer = [];
    let smallAnswer = [1];
    let smallSumm = s - 1;

    if (s <= 9 && m === 1) {
      console.log(`${s} ${s}`); return;
    }

    if (s <= 9) {
      bigAnswer.push(s);
      bigAnswer = bigAnswer.concat(Array(m-1).fill(0));
    } else {
      while (s !== 0) {
        if (s - 9 < 0) {
          bigAnswer.push(s); break;
        }

        bigAnswer.push(9);
        s -= 9;
      }
      bigAnswer = bigAnswer.concat(Array(m - bigAnswer.length).fill(0));
    }

    let smallTmpNums = [];
    while (smallSumm !== 0) {
      if (smallSumm - 9 < 0) {
        smallTmpNums.push(smallSumm); break;
      }

      smallTmpNums.push(9);
      smallSumm -= 9;
    }

    if (smallTmpNums.length + 1 < m) {
      smallAnswer = smallAnswer.concat(Array( m - (smallTmpNums.length + 1) ).fill(0)).concat(smallTmpNums.reverse());
    } else {
      smallAnswer = smallAnswer.concat(smallTmpNums.reverse());
    }
    if (smallAnswer.length > bigAnswer.length) {
      smallAnswer = [...bigAnswer].reverse();
    }

    console.log(`${smallAnswer.join('')} ${bigAnswer.join('')}`)
  }
});

// Lang: Node.js
'use strict';
let x = '', y = 0;
let print = x => console.log(x);

process.stdin.on('data', inputStdin => x += inputStdin);
process.stdin.on('end', () => { x = x.split('\n'); main(); });
let readline = () => x[y++];

// ************************ Code Start ***************************

function main() {

  var ar = readline().split(" ");
  var n = ar[0], m = ar[1];

  if (9 * n < m || (m == 0 && n > 1)) print(-1 + " " + -1);
  else {
    var mx = "", mm = m, nn = n;
    while (nn) {
      mx += Math.min(9, mm);
      mm -= Math.min(9, mm);
      nn--;
    }
    var mn = "", nn = n, mm = m;
    while (nn) {
      var res = Math.max(mm - (nn - 1) * 9, 0);
      if (!res && nn == n && mm > 0) res = 1;
      mn += res;
      mm -= res;
      nn--;
    }
    print(mn + " " + mx);
  }
}

function foo(m, s) {
  if (m === 1 && s === 0) {
    return { min: 0, max: 0 }
  }

  if (m*9 < s || s === 0) {
    return { min: '-1', max: '-1' }
  }

  var maxArr = [];

  var i=0;
  while (i != m) {
    if (s/9 >= 1) {
      maxArr[i] = 9;
      s -= 9;
    } else {
      maxArr[i] = s;
      s -= s;
    }

    i++;
  }

  var max = '';
  for (var j=0; j<maxArr.length; j++) {
    max += maxArr[j];
  }

  var minArray = maxArr.reverse();

  if (minArray[0] === 0) {
    minArray[0] = 1;

    for (var l=1; l < m; l++) {
      if (minArray[l] > 0) {
        minArray[l]--;
        break;
      }
    }
  }

  var min = '';
  for (var k=0; k<minArray.length; k++) {
    min += minArray[k];
  }

  return { min: min, max: max };
}

var args = readline().split(" ").map(function(x) { return parseInt(x); });

var res = foo(args[0], args[1]);

write(res.min + ' ' + res.max);

var line = readline().split(' ');
var m = parseInt(line[0]);
var s = parseInt(line[1]);

if (s == 0) {
	if (m == 1)
		print('0 0');
	else
		print('-1 -1');
}
else {
	var minNum = parseInt(s/9) + (s % 9 ? 1 : 0);
	if (minNum > m) {
		print('-1 -1');
	}
	else {
		//there is a solution
		var ansBig = [];
		var ss = s;
		for (var i = 0; i < m; i++) {
			if (s > 9) {
				ansBig[i] = 9;
				s -= 9;
			}
			else {
				ansBig[i] = s;
				s = 0;
			}
		}
		s = ss;
		var ansSmall = [];
		for (var i = 0; i < m; i++) {
			if (s > 9) {
				ansSmall[i] = 9;
				s -= 9;
			} else if (s > 0) {
				if (i + 1 < m) {
					ansSmall[i] = s - 1;
					s = 1;
				} else {
					ansSmall[i] = s;
					s = 0;
				}
			}
		}
		ansBig = ansBig.join('');
		ansSmall = ansSmall.reverse().join('');
		print(ansSmall + ' ' + ansBig);
	}
}

var input = readline().split(' ').map(value => +value);
var m = input[0];
var s = input[1];

if (s === 0) {
    write(m === 1 ? '0 0' : '-1 -1');
    quit();
}

if (m * 9 === s) {
    var result = (new Array(m).fill(9)).join('');
    write([result, result].join(' '));
    quit();
}

var getMin = function () {
    var result = [1].concat(new Array(m - 1).fill(0));
    var cs = 1;

    for (var i = result.length - 1; i >= 0; --i) {
        while (result[i] < 9) {
            if (cs === s) {
                return result.join('');
            }

            ++result[i];
            ++cs;
        }
    }

    return '-1';
};

var getMax = function () {
    var result = [1].concat(new Array(m - 1).fill(0));
    var cs = 1;

    for (var i = 0; i <= result.length; ++i) {
        while (result[i] < 9) {
            if (cs === s) {
                return result.join('');
            }

            ++result[i];
            ++cs;
        }
    }

    return '-1';
};

write([getMin(), getMax()].join(' '));

var input = readline().split(' ').map(value => +value);
var m = input[0];
var s = input[1];

var printResult = function (arrayMin, arrayMax) {
    write([arrayMin.join(''), (arrayMax || arrayMin).join('')].join(' '));
    quit();
};

if (s === 0) {
    printResult(m === 1 ? [0] : [-1]);
}

if (m * 9 === s) {
    printResult(new Array(m).fill(9));
}

var getMin = function () {
    var result = [1].concat(new Array(m - 1).fill(0));
    var cs = 1;

    for (var i = result.length - 1; i >= 0; --i) {
        while (result[i] < 9) {
            if (cs++ === s) {
                return result;
            }

            ++result[i];
        }
    }

    return [-1];
};

var getMax = function () {
    var result = new Array(m).fill(0);
    var cs = 0;

    for (var i = 0; i <= result.length; ++i) {
        while (result[i] < 9) {
            if (cs++ === s) {
                return result;
            }

            ++result[i];
        }
    }

    return [-1];
};

printResult(getMin(), getMax());

var input = readline().split(' ').map(Number), m = input[0], s = input[1];
if (s > 9 * m) write('-1 -1');
else if (m > 1 && s === 0) write('-1 -1');
else {
    var bigS = s;
    var smallS = s;
    var big = '';
    var small = '';
    while (m > 0) {

        if (bigS >= 9) { big = big + '9'; bigS -= 9; }
        else { big = big + bigS.toString(); bigS = 0; }

        var cur = Math.min('9', smallS - 1);
        if (m == 1) cur++;
        small = cur.toString() + small;
        smallS -= cur;
        m--;

    }
    write (small + ' ' + big);
}

if (!readline) {
    var _i = 0;

    var readline = function() {
        _i ++;

        switch (_i) {
            case 1: return '3 0';
        }
    }

    var write = console.log;
}

var x = readline().split(' ');

var m = +x[0];
var s = +x[1];

var f = [];

for (var i = 0; i <= s; i ++) {
    f[i] = [];
    for (var j = 0; j <= m; j ++) {
        f[i][j] = false;
    }
}

for (var j = 0; j <= m; j ++) {
    f[0][j] = true;

}

for (var i = 1; i <= s; i ++) {
    for (var j = 1; j <= m; j ++) {
        for (var k = 0; k <= 9; k ++) {
            f[i][j] = f[i][j] || (i-k >= 0 ? f[i-k][j-1] : false);
        }
    }
}

if (f[s][m] && !(m > 1 && s == 0)) {
    var i = s;
    var j = m;
    var nmax = '';
    var nmin = '';

    while (j > 0) {
        for (var k = 9; k >= 1; k --) {
            if (i-k >= 0 && f[i-k][j-1]) {
                nmax += k;
                i -= k;
                break;
            }
        }
        j --;
    }

    while (nmax.length < m) {
        nmax += '0';
    }

    i = s;
    j = m;

    while (j > 0) {
        for (var k = (j == m ? 1 : 0); k <= 9; k ++) {
            if (i-k >= 0 && f[i-k][j-1]) {
                nmin += k;
                i -= k;
                break;
            }
        }
        j --;
    }

    while (nmin.length < m) {
        nmin += '0';
    }

    write(nmin + ' ' + nmax);
} else {
    write('-1 -1');
}

var inp = readline().split(" ").map(function(x){return parseInt(x);});
var m = inp[0];
var s = inp[1];
var sMin = s;
var sMax = s;

var numberMin = "";
var numberMax = "";
var sum = 0;
var min = -1;
var max = -1;

if (s == 0){
	if (m == 0){
		print(0);
		print(0);
	}else{
		print(-1);
		print(-1);
	}
} else {
	if (s > m * 9){
		print(-1);
		print(-1);
	} else
	{
		var k = 1;

		for(var i=m; i > 0; i--){
			function getMin(){
				if (i==m){
					return Math.min(Math.max(1, sMin - (i-1) * 9), 9);
				} else
				{
					return Math.min(Math.max(0, sMin - (i-1) * 9), 9);
				}
			}

			function getMax(){
				return Math.min(Math.max(sMax - (i-1) * 9, 9), sMax);
			}

			min = getMin();
			numberMin += min;
			sMin -= min;

			max = getMax();
			numberMax += max;
			sMax -= max;
		}

		print(numberMin);
		print(numberMax);
	}
}

var inp = readline().split(" ").map(function(x){return parseInt(x);});
var m = inp[0];
var s = inp[1];
var sMin = s;
var sMax = s;

var numberMin = "";
var numberMax = "";
var sum = 0;
var min = -1;
var max = -1;

if (s == 0){
	if (m == 0){
		print("0 0");
	}else{
		print("-1 -1");
	}
} else {
	if (s > m * 9){
		print("-1 -1");
	} else
	{
		var k = 1;

		for(var i=m; i > 0; i--){
			function getMin(){
				if (i==m){
					return Math.min(Math.max(1, sMin - (i-1) * 9), 9);
				} else
				{
					return Math.min(Math.max(0, sMin - (i-1) * 9), 9);
				}
			}

			function getMax(){
				return Math.min(Math.max(sMax - (i-1) * 9, 9), sMax);
			}

			min = getMin();
			numberMin += min;
			sMin -= min;

			max = getMax();
			numberMax += max;
			sMax -= max;
		}

		print(numberMin + " " + numberMax);
	}
}

function calculate(m,s){
	var maximum='',minimum='';
	if(s === 0)
	{
		if(m === 1){
			maximum = '0';
			minimum = '0';
		}
		else
		{
			maximum = '-1';
			minimum = '-1';
		}
	}else if(s > m*9){
		maximum = '-1';
		minimum = '-1';
	}
	else if(m === 1){
		maximum = s.toString();
		minimum = '0';
	}
	else{
		/*最大值*/
		if(s < 9){
			maximum = s.toString();
			for(var i = 2; i <= m; i++)
			{
				maximum += '0';
			}
		}
		else if(s >= 9){
			var ans = s;
			maximum = '9';
			ans = ans-9;
			while(ans > 0){
				if(ans >= 9){
					maximum = maximum+'9';
					ans -= 9;
				}
				else {
					maximum += ans.toString();
					ans -= ans;
				}
			}
			var len='';
			for(var j = 1; j <= m-maximum.length; j++)
			{
				len = len+ '0';
			}
			maximum = maximum+len;
		}
		/*最小值*/
		s = s-1;
		if(s < 9){
			var s1 = s;
			minimum = (s1).toString();
			var len1='';
			for(var k = 1; k <= m-2; k ++)
			{
				len1 = len1+'0';
			}
			minimum = '1'+len1+minimum;
		}
		else {
			var ans1 = s;
			var flag = 0;
			var temp=0;
			minimum = '9';
			ans1 = ans1 - 9;
			while(ans1 > 0){
				if(minimum.length === m-1)
				{
					temp = ans1;
					ans1 = 0;
					flag = 1;
					break;
				}
				else{
					if(ans1 >= 9){
					minimum = '9'+minimum;
					ans1 -= 9;
					}
					else{
						minimum = ans1.toString()+minimum;
						ans1 -= ans1;
					}
				}
			}
			if(flag === 1)
			{
				minimum = (temp+1).toString()+minimum;
			}
			else{
				var temp1 = '';
				for(var l = 2; l <= m-2; l ++)
				{
					temp1 = temp1+'0';
				}
				minimum = '1'+temp1+minimum;
			}
		}
	}
	return minimum+" "+maximum;
}
function main(){
	var m = Number(readline().split(" ")[0]);
	var s = Number(readline().split(" ")[1]);
	print(calculate(m,s));
	/*
	var m = Number(str.split(" ")[0]);
	var s = Number(str.split(" ")[1]);
	return calculate(m,s);*/
}

var inp = readline().split(" ").map(function(x){return parseInt(x);});
	var m = inp[0];
	var s = inp[1];
	var maximum='',minimum='';
	if(s === 0)
	{
		if(m === 1){
			maximum = '0';
			minimum = '0';
		}
		else
		{
			maximum = '-1';
			minimum = '-1';
		}
	}else if(s > m*9){
		maximum = '-1';
		minimum = '-1';
	}
	else if(m === 1){
		maximum = s.toString();
		minimum = '0';
	}
	else{
		/*最大值*/
		if(s < 9){
			maximum = s.toString();
			for(var i = 2; i <= m; i++)
			{
				maximum += '0';
			}
		}
		else if(s >= 9){
			var ans = s;
			maximum = '9';
			ans = ans-9;
			while(ans > 0){
				if(ans >= 9){
					maximum = maximum+'9';
					ans -= 9;
				}
				else {
					maximum += ans.toString();
					ans -= ans;
				}
			}
			var len='';
			for(var j = 1; j <= m-maximum.length; j++)
			{
				len = len+ '0';
			}
			maximum = maximum+len;
		}
		/*最小值*/
		s = s-1;
		if(s < 9){
			var s1 = s;
			minimum = (s1).toString();
			var len1='';
			for(var k = 1; k <= m-2; k ++)
			{
				len1 = len1+'0';
			}
			minimum = '1'+len1+minimum;
		}
		else {
			var ans1 = s;
			var flag = 0;
			var temp=0;
			minimum = '9';
			ans1 = ans1 - 9;
			while(ans1 > 0){
				if(minimum.length === m-1)
				{
					temp = ans1;
					ans1 = 0;
					flag = 1;
					break;
				}
				else{
					if(ans1 >= 9){
					minimum = '9'+minimum;
					ans1 -= 9;
					}
					else{
						minimum = ans1.toString()+minimum;
						ans1 -= ans1;
					}
				}
			}
			if(flag === 1)
			{
				minimum = (temp+1).toString()+minimum;
			}
			else{
				var temp1 = '';
				for(var l = 2; l <= m-2; l ++)
				{
					temp1 = temp1+'0';
				}
				minimum = '1'+temp1+minimum;
			}
		}
	}
	print(minimum+" "+maximum);

function calculate(m, s){
	var maximum, minimum;
	if(m === 1)
	{
		maximum = m.toString();
		minimum = '0';
	}
	else if(s <= m*9 && s >= (m-1)*9){
		maximum = '9';
		for(var i = 1; i <= m-2; i++)
		{
			maximum += '9';
		}
		maximum += (s - (m-1)*9).toString();
		var str = maximum.split("");
		var sign = str[str.length-1];
		if(sign === '0'){
			var str1 = str.reverse();
			var temp = str1[0];
			str1[0] = str1[1];
			str1[1] = temp;
			minimum = str1.join("");
		}
		else{
			minimum = str.reverse().join("");
		}
	}
	else
	{
		maximum = '-1';
		minimum = '-1';
	}
	return minimum+maximum;

}
function main(){
	var m = Number(readline().split(" ")[0]);
	var s = Number(readline().split(" ")[1]);
	print(calculate(m,s));
}

function calculate(m, s){
	var maximum, minimum;
	if(m === 1)
	{
		maximum = m.toString();
		minimum = '0';
	}
	else if(s <= m*9 && s >= (m-1)*9){
		maximum = '9';
		for(var i = 1; i <= m-2; i++)
		{
			maximum += '9';
		}
		maximum += (s - (m-1)*9).toString();
		var str = maximum.split("");
		var sign = str[str.length-1];
		if(sign === '0'){
			var str1 = str.reverse();
			var temp = str1[0];
			str1[0] = str1[1];
			str1[1] = temp;
			minimum = str1.join("");
		}
		else{
			minimum = str.reverse().join("");
		}
	}
	else
	{
		maximum = '-1';
		minimum = '-1';
	}
	return  minimum+' '+maximum;

}
function main(){
	var m = Number(readline().split(" ")[0]);
	var s = Number(readline().split(" ")[1]);
	print(calculate(m,s));
}

var inp = readline().split(" ").map(function(x){return parseInt(x);});
	var m = inp[0];
	var s = inp[1];
	var maximum='',minimum='';
	if(s === 0)
	{
		if(m === 1){
			maximum = '0';
			minimum = '0';
		}
		else
		{
			maximum = '-1';
			minimum = '-1';
		}
	}else if(s > m*9){
		maximum = '-1';
		minimum = '-1';
	}
	else if(m === 1){
		maximum = s.toString();
		minimum = '0';
	}
	else{
		/*最大值*/
		if(s < 9){
			maximum = s.toString();
			for(var i = 2; i <= m; i++)
			{
				maximum += '0';
			}
		}
		else if(s >= 9){
			var ans = s;
			maximum = '9';
			ans = ans-9;
			while(ans > 0){
				if(ans >= 9){
					maximum = maximum+'9';
					ans -= 9;
				}
				else {
					maximum += ans.toString();
					ans -= ans;
				}
			}
			var len='';
			for(var j = 1; j <= m-maximum.length; j++)
			{
				len = len+ '0';
			}
			maximum = maximum+len;
		}
		/*最小值*/
		s = s-1;
		if(s < 9){
			var s1 = s;
			minimum = (s1).toString();
			var len1='';
			for(var k = 1; k <= m-2; k ++)
			{
				len1 = len1+'0';
			}
			minimum = '1'+len1+minimum;
		}
		else {
			var ans1 = s;
			var flag = 0;
			var temp=0;
			minimum = '9';
			ans1 = ans1 - 9;
			while(ans1 > 0){
				if(minimum.length === m-1)
				{
					temp = ans1;
					ans1 = 0;
					flag = 1;
					break;
				}
				else{
					if(ans1 >= 9){
					minimum = '9'+minimum;
					ans1 -= 9;
					}
					else{
						minimum = ans1.toString()+minimum;
						ans1 -= ans1;
					}
				}
			}
			if(flag === 1)
			{
				minimum = (temp+1).toString()+minimum;
			}
			else{
				var temp1 = '';
				for(var l = 1; l < m-1; l ++)
				{
					temp1 = temp1+'0';
				}
				minimum = '1'+temp1+minimum;
			}
		}
	}
	print(minimum+" "+maximum);

function calculate(m, s){
	var maximum='', minimum='';
	if(m === 1)
	{
		maximum = m.toString();
		minimum = '0';
	}
	else if(s <= m*9 && s >= (m-1)*9)
	{
		maximum = '9';
		for(var i = 1; i <= m-2; i++)
		{
			maximum += '9';
		}
		maximum += (s - (m-1)*9).toString();
		var str = maximum.split("");
		var sign = str[str.length-1];
		if(sign === '0'){
			var str1 = str.reverse();
			var temp = str1[0];
			str1[0] = str1[1];
			str1[1] = temp;
			minimum = str1.join("");
		}
		else{
			minimum = str.reverse().join("");
		}
	}
	else
	{
		maximum = '-1';
		minimum = '-1';
	}
	return  minimum+' '+maximum;
}
function main(str){
	var m = Number(readline().split(" ")[0]);
	var s = Number(readline().split(" ")[1]);
	print(calculate(m,s));
}

function calculate(m, s){
	var maximum, minimum;
	if(m === 1)
	{
		maximum = m.toString();
		minimum = '0';
	}
	else if(s <= m*9 && s >= (m-1)*9){
		maximum = '9';
		for(var i = 1; i <= m-2; i++)
		{
			maximum += '9';
		}
		maximum += (s - (m-1)*9).toString();
		var str = maximum.split("");
		var sign = str[str.length-1];
		if(sign === '0'){
			var str1 = str.reverse();
			var temp = str1[0];
			str1[0] = str1[1];
			str1[1] = temp;
			minimum = str1.join("");
		}
		else{
			minimum = str.reverse().join("");
		}
	}
	else
	{
		maximum = '-1';
		minimum = '-1';
	}
	return minimum+" "+maximum;

}
function main(){
	var m = Number(readline().split(" ")[0]);
	var s = Number(readline().split(" ")[1]);
	print(calculate(m,s));
}

function calculate(m, s){
	var maximum, minimum;
	if(m === 1)
	{
		maximum = m.toString();
		minimum = '0';
	}
	else if(s <= m*9 && s >= (m-1)*9){
		maximum = '9';
		for(var i = 1; i <= m-2; i++)
		{
			maximum += '9';
		}
		maximum += (s - (m-1)*9).toString();
		var str = maximum.split("");
		var sign = str[str.length-1];
		if(sign === '0'){
			var str1 = str.reverse();
			var temp = str1[0];
			str1[0] = str1[1];
			str1[1] = temp;
			minimum = str1.join("");
		}
		else{
			minimum = str.reverse().join("");
		}
	}
	else
	{
		maximum = '-1';
		minimum = '-1';
	}
	var a=[];
	a[0] = Number(minimum);
	a[1] = Number(maximum);
	return  a;

}
function main(){
	var m = Number(readline().split(" ")[0]);
	var s = Number(readline().split(" ")[1]);
	print(calculate(m,s));
}

var inp = readline().split(" ").map(function(x){return parseInt(x);});
	var m = inp[0];
	var s = inp[1];
	var maximum='',minimum='';
	if(s === 0)
	{
		if(m === 1){
			maximum = '0';
			minimum = '0';
		}
		else
		{
			maximum = '-1';
			minimum = '-1';
		}
	}else if(s > m*9){
		maximum = '-1';
		minimum = '-1';
	}
	else if(m === 1){
		maximum = s.toString();
		minimum = '0';
	}
	else{
		/*最大值*/
		if(s < 9){
			maximum = s.toString();
			for(var i = 2; i <= m; i++)
			{
				maximum += '0';
			}
		}
		else if(s >= 9){
			var ans = s;
			maximum = '9';
			ans = ans-9;
			while(ans > 0){
				if(ans >= 9){
					maximum = maximum+'9';
					ans -= 9;
				}
				else {
					maximum += ans.toString();
					ans -= ans;
				}
			}
			var len='';
			for(var j = 1; j <= m-maximum.length; j++)
			{
				len = len+ '0';
			}
			maximum = maximum+len;
		}
		/*最小值*/
		s = s-1;
		if(s < 9){
			var s1 = s;
			minimum = (s1).toString();
			var len1='';
			for(var k = 1; k <= m-2; k ++)
			{
				len1 = len1+'0';
			}
			minimum = '1'+len1+minimum;
		}
		else {
			var ans1 = s;
			var flag = 0;
			var temp=0;
			minimum = '9';
			ans1 = ans1 - 9;
			while(ans1 > 0){
				if(minimum.length === m-1)
				{
					temp = ans1;
					ans1 = 0;
					flag = 1;
					break;
				}
				else{
					if(ans1 >= 9){
						minimum = '9'+minimum;
						ans1 -= 9;
						}
					else{
						minimum = ans1.toString()+minimum;
						ans1 -= ans1;
					}
				}
			}
			if(flag === 1)
			{
				minimum = (temp+1).toString()+minimum;
			}
			else{
				var temp1 = '';
				for(var l = 1; l < m-minimum.length; l ++)
				{
					temp1 = temp1+'0';
				}
				minimum = '1'+temp1+minimum;
			}
		}
	}
	print(minimum+" "+maximum);

var solution = function() {

	//Считываем данные
	var input = readline().split(' ');
	var count = input[0];
	var sum = input[1];

	//Проверяем, что можно
	if (9*count < sum || sum === 0 && count > 1) {
		print(-1, -1);
		return;
	}

	//максимальное число
	var mx = "";
	var sumLeft = sum;
	var countLeft = count;
	while (countLeft) {
		mx += Math.min(9, sumLeft);
		sumLeft -= Math.min(9, sumLeft);
		countLeft--;
	}

	//минимальное число
	var mn = "";
	var countLeft = count;
	var sumLeft = sum;
	while (countLeft) {
		var cur = Math.max(sumLeft - (countLeft-1)*9, 0);

		if (!cur && countLeft == count) {
			cur = 1;
		}

		mn += cur;
		sumLeft -= cur;

		countLeft--;
	}

	//вывод
	print(mn, mx);

}

solution();

var solution = function() {

	//Считываем данные
	var input = readline().split(' ');
	var count = input[0];
	var sum = input[1];

	//Проверяем, что можно
	if (9*count < sum || sum == 0 && count > 1) {
		print(-1, -1);
		return;
	}

	//максимальное число
	var mx = "";
	var sumLeft = sum;
	var countLeft = count;
	while (countLeft) {
		mx += Math.min(9, sumLeft);
		sumLeft -= Math.min(9, sumLeft);
		countLeft--;
	}

	//минимальное число
	var mn = "";
	var countLeft = count;
	var sumLeft = sum;
	while (countLeft) {
		var cur = Math.max(sumLeft - (countLeft-1)*9, 0);

		if (!cur && countLeft == count && sumLeft) {
			cur = 1;
		}

		mn += cur;
		sumLeft -= cur;

		countLeft--;
	}

	//вывод
	print(mn, mx);

}

solution();

var solution = function() {

	//Считываем данные
	var input = readline().split(' ');
	var count = input[0];
	var sum = input[1];

	//Проверяем, что можно
	if (9*count < sum || sum === 0 && count > 1) {
		print(-1, -1);
		return;
	}

	//максимальное число
	var mx = "";
	var sumLeft = sum;
	var countLeft = count;
	while (countLeft) {
		mx += Math.min(9, sumLeft);
		sumLeft -= Math.min(9, sumLeft);
		countLeft--;
	}

	//минимальное число
	var mn = "";
	var countLeft = count;
	var sumLeft = sum;
	while (countLeft) {
		var cur = Math.max(sumLeft - (countLeft-1)*9, 0);

		if (!cur && countLeft == count) {
			cur = 1;
		}

		mn += cur;
		sumLeft -= cur;

		countLeft--;
	}

	//вывод
	print(mx, mn);

}

solution();

var solution = function() {

	//Считываем данные
	var input = readline().split(' ');
	var count = input[0];
	var sum = input[1];

	//Проверяем, что можно
	if (9*count < sum || sum == 0 && count > 1) {
		print(-1, -1);
		return;
	}

	//максимальное число
	var mx = "";
	var sumLeft = sum;
	var countLeft = count;
	while (countLeft) {
		mx += Math.min(9, sumLeft);
		sumLeft -= Math.min(9, sumLeft);
		countLeft--;
	}

	//минимальное число
	var mn = "";
	var countLeft = count;
	var sumLeft = sum;
	while (countLeft) {
		var cur = Math.max(sumLeft - (countLeft-1)*9, 0);

		if (!cur && countLeft == count) {
			cur = 1;
		}

		mn += cur;
		sumLeft -= cur;

		countLeft--;
	}

	//вывод
	print(mx, mn);

}

solution();

var solution = function() {

	//Считываем данные
	var input = readline().split(' ');
	var count = input[0];
	var sum = input[1];

	//Проверяем, что можно
	if (9*count < sum || sum == 0 && count > 1) {
		print(-1, -1);
		return;
	}

	//максимальное число
	var mx = "";
	var sumLeft = sum;
	var countLeft = count;
	while (countLeft) {
		mx += Math.min(9, sumLeft);
		sumLeft -= Math.min(9, sumLeft);
		countLeft--;
	}

	//минимальное число
	var mn = "";
	var countLeft = count;
	var sumLeft = sum;
	while (countLeft) {
		var cur = Math.max(sumLeft - (countLeft-1)*9, 0);

		if (!cur && countLeft == count) {
			cur = 1;
		}

		mn += cur;
		sumLeft -= cur;

		countLeft--;
	}

	//вывод
	print(mn, mx);

}

solution();

function solve()
{
var st=[],ss=[];
var line = readline().split(" ");
var m = parseInt(line[0]);
var s = parseInt(line[1]);

if(m===1&&s===2)
{
    print(0,0);
    return;
}
if(m>1&&s===0)
{
    print(-1,-1);
    return;
}
for(var i=0;i<m;i++)
{
    if(s>=9)
    {
        st.push(9);
        ss.push(9);
        s=s-9;

    }
    else{
        st.push(s);
        ss.push(s);
        s=0;
    }
}

ss.reverse();
for (var k = 0; k < ss.length; k++)
    {
        if (ss[k] !== 0)
        {
            ss[k]=ss[k]-1;
            ss[0]=ss[0]+1;
            break;
        }
    }

print(ss.join(""));
print(st.join(""));

    return;
}
solve();

function solve()
{
var st=[],ss=[];
var line = readline().split(" ");
var m = parseInt(line[0]);
var s = parseInt(line[1]);

if(m===1&&s===2)
{
    print(0,0);
    return;
}
if(m>1&&s===0)
{
    print(-1,-1);
    return;
}
for(var i=0;i<m;i++)
{
    if(s>=9)
    {
        st.push(9);
        ss.push(9);
        s=s-9;
        print(s);
    }
    else{
        st.push(s);
        ss.push(s);
        s=0;
    }
}

ss.reverse();
for (var k = 0; k < ss.length; k++)
    {
        if (ss[k] !== 0)
        {
            ss[k]--;
            ss[0]++;
            break;
        }
    }

print(ss.join(""));
print(st.join(""));

    return;
}
solve();

'use strict'

const q = [];
const r = [];
const input = readline().split(' ').map(Number);
let x = { m: input[0], s: input[1], h: '' };
for(let i = 1; i < Math.min(10, x.s + 1); i++) q.push({ m: x.m - 1, s: x.s - i, h: `${i}` });
while(q.length) {
    x = q.pop();
    if (x.m === 0 && x.s === 0) r.push(x.h);
    if (x.m === 0 || x.s === 0) continue;
	for(let i = 0; i < Math.min(10, x.s + 1); i++)
        q.push({ m: x.m - 1, s: x.s - i, h: `${x.h}${i}` });
}
if (!r.length) print('-1 -1');
print(Math.min(...r) + ' ' + Math.max(...r))

'use strict'

const fn = (S, M) => {
    if (S === 0) return M === 1 ? '0 0' : '-1 -1'
    if (S > 9 * M) return '-1 -1'
    const s = (S - 1) % 9 + 1;
    let r = Array((S - s) / 9 + 1).join('9');
    if (M - 1 === r.length) return `${s}${r} ${r}${s}`;
    const zzz = Array(M - 1 - r.length).join('0');
    return `1${zzz}${s-1}${r} ${r}${s}${zzz}0`;
}
const x = readline().split(' ');
print(fn(parseInt(x[0]), parseInt(x[1])));

'use strict'

const x = readline().split(' ').map(Number);
const m = x[0];
const S = x[1];

if (S === 0 || S > 9 * m) {
    print('-1 -1');
} else {
    const s = (S - 1) % 9 + 1;
    let r = Array((S - s) / 9 + 1).join('9');
    if (r.length === m - 1) print(`${s}${r} ${r}${s}`);
    else {
        const zzz = Array(m - r.length - 1).join('0');
        print(`1${zzz}${s-1}${r} ${r}${s}${zzz}0`);
    }
}

'use strict'

const q = [];
const r = [];
let x = { m: parseInt(readline()), s: parseInt(readline()), h: '' };
for(let i = 1; i < Math.min(10, x.s + 1); i++) q.push({ m: x.m - 1, s: x.s - i, h: `${i}` });
while(q.length) {
    x = q.pop();
    if (x.m === 0 && x.s === 0) r.push(x.h);
    if (x.m === 0 || x.s === 0) continue;
	for(let i = 0; i < Math.min(10, x.s + 1); i++)
        q.push({ m: x.m - 1, s: x.s - i, h: `${x.h}${i}` });
}
if (!r.length) print('-1 -1');
print(Math.min(...r) + ' ' + Math.max(...r))

'use strict'

const q = [];
const r = [];
const input = readline().split(' ').map(Number);
let x = { m: input[0], s: input[1], h: '' };
for(let i = 1; i < Math.min(10, x.s + 1); i++) q.push({ m: x.m - 1, s: x.s - i, h: `${i}` });
while(q.length) {
    x = q.pop();
    if (x.m === 0 && x.s === 0) r.push(x.h);
    if (x.m === 0 || x.s === 0) continue;
	for(let i = 0; i < Math.min(10, x.s + 1); i++)
        q.push({ m: x.m - 1, s: x.s - i, h: `${x.h}${i}` });
}
if (!r.length) print('-1 -1');
else print(Math.min(...r) + ' ' + Math.max(...r))

'use strict'

const fn = (m, s) => {
    const q = [ { m, s, h: '' } ];
    const r = []
    while(q.length) {
        const x = q.pop();
        if (x.m === 0 && x.s === 0) r.push(x.h);
        if (x.m === 0 || x.s === 0) continue;
		for(let i = 1; i < Math.min(10, x.s + 1); i++)
            q.push({ m: x.m - 1, s: x.s - i, h: `${x.h}${i}` });
    }
    if (!r.length) print('-1 -1');
    print(Math.min(...r) + ' ' + Math.max(...r))
}

var n = readline(), m = readline(), h = m
            var min = "", max = ""
            var ok = true,ok2=true
            if (n > 1 && m === 0) {
                print.log("-1 -1")
            } else if (m > n * 9) {
                print.log("-1 -1")
            } else {
                for (var i = 0; i < n; ++i) {
                    if (h - 9 > 0) {
                        min += "9"
                        max += "9"
                        h -= 9
                    } else {
                        if (ok) {
                            max += h
                            ok = false
                        }
                        else
                            max += "0"
                        if (ok2){
                            if (i===n-1)min=h+min
                            else min=(h-1)+min
                            ok2=false
                        }else{
                             if(i===n-1)min="1"+min
                             else min="0"+min
                        }
                    }
                }
            }
            print(min + " " + max)

var inp = readline().split(' ');
var m = parseInt(inp[0]);
var s = parseInt(inp[1]);

var largestArr = [], smallestArr = [];
for (var i = 0; i < m; i ++) {
	largestArr.push(0);
	smallestArr.push(1);
}

var largestOn = 0, smallestOn = m - 1;
for (var i = 0; i < s; i ++) {
	if (largestOn < m) {
		largestArr[largestOn] ++;
		if (largestArr[largestOn] === 9) largestOn ++;
	} else largestArr = [-1];

	if (smallestOn >= 0 && m <= s) {
		if (i >= m) {
			smallestArr[smallestOn] ++;
			if (smallestArr[smallestOn] === 9) smallestOn --;
		}
	} else smallestArr = largestArr[0] !== -1 ? largestArr : [-1];
}

print(s === 0 ? '-1 -1' : smallestArr.join('') + ' ' + largestArr.join(''));

var inp = readline().split(' ');
var m = parseInt(inp[0]);
var s = parseInt(inp[1]);

var largestArr = [], smallestArr = [1];
for (var i = 0; i < m; i ++) {
	largestArr.push(0);
	if (i !== 0) smallestArr.push(0);
}

var largestOn = 0, smallestOn = m - 1;
for (var i = 0; i < s; i ++) {
	if (largestOn < m) {
		largestArr[largestOn] ++;
		if (largestArr[largestOn] === 9) largestOn ++;
	} else largestArr = [-1];

	if (smallestOn >= 0) {
		if (i >= 1) {
			smallestArr[smallestOn] ++;
			if (smallestArr[smallestOn] === 9) smallestOn --;
		}
	} else smallestArr = largestArr[0] !== -1 ? largestArr : [-1];
}

print(s === 0 ? '-1 -1' : smallestArr.join('') + ' ' + largestArr.join(''));

var inp = readline().split(' ');
var m = parseInt(inp[0]);
var s = parseInt(inp[1]);

var largestArr = [], smallestArr = [];
for (var i = 0; i < m; i ++) {
	largestArr.push(0);
	smallestArr.push(1);
}

var largestOn = 0, smallestOn = m - 1;
for (var i = 0; i < s; i ++) {
	if (largestOn < m) {
		largestArr[largestOn] ++;
		if (largestArr[largestOn] === 9) largestOn ++;
	} else largestArr = [-1];

	if (smallestOn >= 0 && m <= s) {
		if (i >= m) {
			smallestArr[smallestOn] ++;
			if (smallestArr[smallestOn] === 9) smallestOn --;
		}
	} else smallestArr = [-1];
}

print(s === 0 ? '-1 -1' : smallestArr.join('') + ' ' + largestArr.join(''));

var inp = readline().split(' ');
var m = parseInt(inp[0]);
var s = parseInt(inp[1]);

var largestArr = [], smallestArr = [];
for (var i = 0; i < m; i ++) {
	largestArr.push(0);
	smallestArr.push(1);
}

var largestOn = 0, smallestOn = m - 1;
for (var i = 0; i < s; i ++) {
	if (largestOn < m) {
		largestArr[largestOn] ++;
		if (largestArr[largestOn] === 9) largestOn ++;
	} else largestArr = [-1];

	if (smallestOn >= 0 && m <= s) {
		if (i >= m) {
			smallestArr[smallestOn] ++;
			if (smallestArr[smallestOn] === 9) smallestOn --;
		}
	} else smallestArr = [-1];
}

print(s === 0 ? '-1 -1' : largestArr.join('') + ' ' + smallestArr.join(''));

var enter = readline().split(' ');
var n = enter[0];
var s = enter[1];
if(s <= n * 9 && s != 0 || s == 0 && n == 1) {
	var get_max = function(n,s) {
  var max = '';
  	while(n--) {
  		if( s >= 9) {
    max += 9;
    s -= 9;
    } else {
    max += s;
		s = 0;
    }
  }
  return max;
  };
  	var get_min = function(n,s) {
  	var first = true;
  	var min = '';
  		while(n--) {
  		var mn = first && n ? 1 : 0;
		var cur = Math.max(mn, s-9*n);
		s -= cur;
		min += cur;
		first = false;
  }
  return min;
  };
  print(get_min(n, s), get_max(n, s));
} else {
	print(1, -1);
}

var enter = readline().split(' ');
var n = enter[0];
var s = enter[1];
if(s <= n * 9 && s != 0 || s == 0 && n == 1) {
	var get_max = function(n,s) {
  var max = '';
  	while(n--) {
  		if( s >= 9) {
    max += 9;
    s -= 9;
    } else {
    max += s;
		s = 0;
    }
  }
  return max;
  };
  	var get_min = function(n,s) {
  	var first = true;
  	var min = '';
  		while(n--) {
  		var mn = first && n ? 1 : 0;
		var cur = Math.min(mn, s-9*n);
		s -= cur;
		min += cur;
		first = false;
  }
  return min;
  };
  print(get_min(n, s), get_max(n, s));
} else {
	print(1, -1);
}

'use strict';

String.prototype.getNumArray = function () {
  return String(this).split(' ').map(function (value) {
    return parseInt(value);
  });
}

let input = readline().getNumArray();
let length = input[0];
let sum = input[1];
let arrayMax = [], max = -1;
let arrayMin = [], min = -1;

for (let i = 0; i<length; i++) {
  arrayMax.push(0);
  arrayMin.push(0);
}

// МАКСИМУМ
arrayMax[length - 1] = sum;
let ost = 0;
for(let i = length -1; i>=0; i--) {
  arrayMax[i] += ost;
  ost = 0;

  if (arrayMax[i] > 9) {
    ost = arrayMax[i] - 9;
    arrayMax[i] = 9;
  }
}

if (ost === 0 && sum !== 0) {
  max = parseInt(arrayMax.reverse().join(''));
}

ost = 0;

// МИНИМУМ
arrayMin[length - 1] = sum - 1;
arrayMin[0] = 1;

for(let i = length -1; i>=0; i--) {
  arrayMin[i] += ost;
  ost = 0;

  if (arrayMin[i] > 9) {
    ost = arrayMin[i] - 9;
    arrayMin[i] = 9;
  }
}

if (ost === 0 && sum !== 0) {
  min = parseInt(arrayMin.join(''));
}

write(min + ' ' + max);

'use strict';

String.prototype.getNumArray = function () {
  return String(this).split(' ').map(function (value) {
    return parseInt(value);
  });
}

let input = readline().getNumArray();
let length = input[0];
let sum = input[1];
let arrayMax = [], max = -1;
let arrayMin = [], min = -1;

for (let i = 0; i<length; i++) {
  arrayMax.push(0);
  arrayMin.push(0);
}

// МАКСИМУМ
arrayMax[length - 1] = sum;
let ost = 0;
for(let i = length -1; i>=0; i--) {
  arrayMax[i] += ost;
  ost = 0;

  if (arrayMax[i] > 9) {
    ost = arrayMax[i] - 9;
    arrayMax[i] = 9;
  }
}

if (ost === 0 && sum !== 0) {
  max = arrayMax.reverse().join('');
}

ost = 0;

// МИНИМУМ

if(length > 1) {
  arrayMin[length - 1] = sum - 1;
  arrayMin[0] = 1;
} else {
  arrayMin[length - 1] = sum;
}

for(let i = length -1; i>=0; i--) {
  arrayMin[i] += ost;
  ost = 0;

  if (arrayMin[i] > 9) {
    ost = arrayMin[i] - 9;
    arrayMin[i] = 9;
  }
}

if (ost === 0 && sum !== 0) {
  min = arrayMin.join('');
}

write(min + ' ' + max);

'use strict';

String.prototype.getNumArray = function () {
  return String(this).split(' ').map(function (value) {
    return parseInt(value);
  });
}

let input = readline().getNumArray();
let length = input[0];
let sum = input[1];
let arrayMax = [], max = -1;
let arrayMin = [], min = -1;

for (let i = 0; i<length; i++) {
  arrayMax.push(0);
  arrayMin.push(0);
}

// МАКСИМУМ
arrayMax[length - 1] = sum;
let ost = 0;
for(let i = length -1; i>=0; i--) {
  arrayMax[i] += ost;
  ost = 0;

  if (arrayMax[i] > 9) {
    ost = arrayMax[i] - 9;
    arrayMax[i] = 9;
  }
}

if (ost === 0 && sum !== 0) {
  max = arrayMax.reverse().join('');
}

ost = 0;

// МИНИМУМ
arrayMin[length - 1] = sum - 1;
arrayMin[0] = 1;

for(let i = length -1; i>=0; i--) {
  arrayMin[i] += ost;
  ost = 0;

  if (arrayMin[i] > 9) {
    ost = arrayMin[i] - 9;
    arrayMin[i] = 9;
  }
}

if (ost === 0 && sum !== 0) {
  min = arrayMin.join('');
}

write(min + ' ' + max);

function foo(m, ss) {
  if (m*9 < ss || ss === 0) {
    return { min: '-1', max: '-1' }
  }

  var maxArr = [];

  var s = ss;
  var i=0;
  while (i != m) {
    if (s/9 >= 1) {
      maxArr[i] = 9;
      s -= 9;
    } else {
      maxArr[i] = s;
      s -= s;
    }

    i++;
  }

  var max = '';
  for (var j=0; j<maxArr.length; j++) {
    max += maxArr[j];
  }

  var minArray = maxArr.reverse();

  if (ss === maxArr[0]) {
    minArray[m-1]--;
    minArray[0] = 1;
  }

  var min = '';
  for (var k=0; k<minArray.length; k++) {
    min += minArray[k];
  }

  return { min: min, max: max };
}

var args = readline().split(" ").map(function(x) { return parseInt(x); });

var res = foo(args[0], args[1]);

write(res.min + ' ' + res.max);

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

const input = [];
readLine.on('line', line => input.push(line));

readLine.on('close', () => {
  let [m, s] = input[0].split(' ').map(x => parseInt(x));
  if (s === 0 || m*9 < s) {
    if (m === 1 && s === 0)
      console.log(`0 0`);
    else
      console.log(`-1 -1`);
  } else {
    let bigAnswer = [];
    let smallAnswer = [1];
    let smallSumm = s - 1;

    if (s <= 9 && m === 1) {
      console.log(`${s} ${s}`); return;
    }

    if (s <= 9) {
      bigAnswer.push(s);
      bigAnswer = bigAnswer.concat(Array(m-1).fill(0));
    } else {
      while (s !== 0) {
        if (s - 9 < 0) {
          bigAnswer.push(s); break;
        }

        bigAnswer.push(9);
        s -= 9;
      }
      bigAnswer = bigAnswer.concat(Array(m - bigAnswer.length).fill(0));
    }

    let smallTmpNums = [];
    while (smallSumm !== 0) {
      if (smallSumm - 9 < 0) {
        smallTmpNums.push(smallSumm); break;
      }

      smallTmpNums.push(9);
      smallSumm -= 9;
    }

    if (smallTmpNums.length + 1 < m) {
      smallAnswer = smallAnswer.concat(Array( m - (smallTmpNums.length + 1) ).fill(0)).concat(smallTmpNums.reverse());
    } else {
      smallAnswer = smallAnswer.concat(smallTmpNums.reverse());
    }

    console.log(`${smallAnswer.join('')} ${bigAnswer.join('')}`)
  }
});

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

const input = [];
readLine.on('line', line => input.push(line));

readLine.on('close', () => {
  let [m, s] = input[0].split(' ').map(x => parseInt(x));
  if (s === 0 || m*9 < s) {
    console.log(`-1 -1`);
  } else {
    let answer = [];
    if (s <= 9) {
      answer.push(s);
      answer = answer.concat(Array(m-1).fill(0));

      console.log(`${answer.join('')} ${answer.join('')}`);
      return;
    }

    let len = 0;
    while (s !== 0) {
      len += 1;
      if (s - 9 < 0) {
        answer.push(s); break;
      }

      answer.push(9);
      s -= 9;
    }

    answer = answer.concat(Array(m - len).fill(0));
    let reverse = [...answer].reverse();

    if (reverse[0] === 0)
      for (let i = 0; i < reverse.length; i += 1) {
        if (reverse[i] !== 0) {
          reverse[0] = reverse[i];
          reverse[i] = 0; break;
        }
      }

    console.log(`${reverse.join('')} ${answer.join('')}`);
  }
});

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

const input = [];
readLine.on('line', line => input.push(line));

readLine.on('close', () => {
  let [m, s] = input[0].split(' ').map(x => parseInt(x));
  if (s === 0 || m*9 < s) {
    console.log(`-1 -1`);
  } else {
    let answer = [];
    if (s <= 9) {
      answer.push(s);
      answer = answer.concat(Array(m-1).fill(0));

      console.log(`${answer.join('')} ${answer.join('')}`);
      return;
    }

    let len = 0;
    while (s !== 0) {
      len += 1;
      if (s - 9 < 0) {
        answer.push(s); break;
      }

      answer.push(9);
      s -= 9;
    }

    answer = answer.concat(Array(m - len).fill(0));
    console.log(`${[...answer].reverse().join('')} ${answer.join('')}`);
  }
});

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

const input = [];
readLine.on('line', line => input.push(line));

readLine.on('close', () => {
  let [m, s] = input[0].split(' ').map(x => parseInt(x));
  if (s === 0 || m*9 < s) {
    if (m === 1 && s === 0)
      console.log(`0 0`);
    else
      console.log(`-1 -1`);
  } else {
    let answer = [];
    if (s <= 9) {
      answer.push(s);
      answer = answer.concat(Array(m-1).fill(0));

      console.log(`${answer.join('')} ${answer.join('')}`);
      return;
    }

    let len = 0;
    while (s !== 0) {
      len += 1;
      if (s - 9 < 0) {
        answer.push(s); break;
      }

      answer.push(9);
      s -= 9;
    }

    answer = answer.concat(Array(m - len).fill(0));
    let reverse = [...answer].reverse();

    if (reverse[0] === 0)
      for (let i = 0; i < reverse.length; i += 1) {
        if (reverse[i] !== 0) {
          reverse[0] = reverse[i];
          reverse[i] = 0; break;
        }
      }

    console.log(`${reverse.join('')} ${answer.join('')}`);
  }
});

function foo(m, s) {
  if (m*9 < s || s === 0) {
    return { min: '-1', max: '-1' };
  }

  var maxArr = [];

  var i=0;
  while (i != m) {
    if (s/9 >= 1) {
      maxArr[i] = 9;
      s -= 9;
    } else {
      maxArr[i] = s;
      s -= s;
    }

    i++;
  }

  var max = '';
  for (var j=0; j<maxArr.length; j++) {
    max += maxArr[j];
  }

  var minArray = maxArr.reverse();

  if (s === maxArr[0]) {
    minArray[m-1]--;
    minArray[0] = 1;
  }

  var min = '';
  for (var k=0; k<minArray.length; k++) {
    min += minArray[k];
  }

  return { min: min, max: max };
}

var args = readline().split(" ").map(function(x) { return parseInt(x); });

var res = foo(args[0], args[1]);

write(res.min + ' ' + res.max);

function foo(m, s) {
  if (m*9 < s || s === 0) {
    return { min: '-1', max: '-1' }
  }

  var maxArr = [];

  var i=0;
  while (i != m) {
    if (s/9 >= 1) {
      maxArr[i] = 9;
      s -= 9;
    } else {
      maxArr[i] = s;
      s -= s;
    }

    i++;
  }

  var max = '';
  for (var j=0; j<maxArr.length; j++) {
    max += maxArr[j];
  }

  var minArray = maxArr.reverse();

  if (minArray[0] === 0) {
    minArray[0] = 1;

    for (var l=1; l < m; l++) {
      if (minArray[l] > 0) {
        minArray[l]--;
        break
      }
    }
  }

  var min = '';
  for (var k=0; k<minArray.length; k++) {
    min += minArray[k];
  }

  return { min: min, max: max };
}

var args = readline().split(" ").map(function(x) { return parseInt(x); });

var res = foo(args[0], args[1]);

write(res.min + ' ' + res.max);

var line = readline().split(' ');
var m = parseInt(line[0]);
var s = parseInt(line[1]);

if (s == 0) {
	if (m == 1)
		print('0 0');
	else
		print('-1 -1');
}
else {
	var minNum = parseInt(16/9) + (16 % 9 ? 1 : 0);
	if (minNum > m) {
		print('-1 -1');
	}
	else {
		//there is a solution
		var ansBig = [];
		var ss = s;
		for (var i = 0; i < m; i++) {
			if (s > 9) {
				ansBig[i] = 9;
				s -= 9;
			}
			else {
				ansBig[i] = s;
				s = 0;
			}
		}
		s = ss;
		var ansSmall = [];
		for (var i = 0; i < m; i++) {
			if (s > 9) {
				ansSmall[i] = 9;
				s -= 9;
			} else if (s > 0) {
				if (i + 1 < m) {
					ansSmall[i] = s - 1;
					s = 1;
				} else {
					ansSmall[i] = s;
					s = 0;
				}
			}
		}
		ansBig = ansBig.join('');
		ansSmall = ansSmall.reverse().join('');
		print(ansSmall + ' ' + ansBig);
	}
}

var input = readline().split(' ').map(value => +value);
var m = input[0];
var s = input[1];

var printResults = function (arrayMin, arrayMax) {
    write([arrayMin.join(''), (arrayMax || arrayMin).join('')].join(' '));
    quit();
};

if (s === 0) {
    write(m === 1 ? '0 0' : '-1 -1');
    quit();
}

if (m * 9 === s) {
    printResults(new Array(m).fill(9));
}

var result = [1].concat(new Array(m - 1).fill(0));

if (s === 1) {
    printResults(result);
}

var cs = 1;

for (var i = result.length - 1; i >= 0; --i) {
    while (true) {
        if (cs === s) {
            printResults(
                result.join('').split(''),
                result.splice(0, i).reverse().concat(result).reverse()
            );
        }

        if (result[i] === 9) {
            break;
        }

        ++result[i];
        ++cs;
    }
}

write('-1 -1');

var input = readline().split(' ').map(value => +value);
var m = input[0];
var s = input[1];

var printResults = function (arrayMin, arrayMax) {
    write([arrayMin.join(''), (arrayMax || arrayMin).join('')].join(' '));
    quit();
};

if (s === 0) {
    write(m === 1 ? '0 0' : '-1 -1');
    quit();
}

if (m * 9 === s) {
    printResults(new Array(m).fill(9));
}

var result = [1].concat(new Array(m - 1).fill(0));

if (s === 1) {
    printResults(result);
}

var cs = 1;

for (var i = result.length - 1; i >= 0; --i) {
    while (true) {
        if (cs++ === s) {
            printResults(
                result.join('').split(''),
                result.splice(0, i).reverse().concat(result).reverse()
            );
        }

        if (result[i]++ === 9) {
            break;
        }
    }
}

write('-1 -1');

var input = readline().split(' ').map(value => +value);
var m = input[0];
var s = input[1];

if (s === 0) {
    write(m === 1 ? '0 0' : '-1 -1');
    quit();
}

var result = [1].concat(new Array(m - 1).fill(0));

if (s === 1) {
    result = result.join('');
    write([result, result].join(' '));
    quit();
}

var cs = 1;

for (var i = result.length - 1; i >= 0; --i) {
    do {
        if (cs++ === s) {
            write([result.join(''), result.splice(0, i).reverse().concat(result).reverse().join('')].join(' '));
            quit();
        }
    } while (++result[i] < 9)
}

write('-1 -1');

var input = readline().split(' ').map(value => +value);
var m = input[0];
var s = input[1];

if (s === 0) {
    write(m === 1 ? '0 0' : '-1 -1');
    quit();
}

var result = [1].concat(new Array(m - 1).fill(0));

if (s === 1) {
    result = result.join('');
    write([result, result].join(' '));
    quit();
}

var cs = 1;

for (var i = result.length - 1; i >= 0; --i) {
    while (result[i] < 9) {
        ++result[i];

        if (++cs === s) {
            write([result.join(''), result.splice(0, i).reverse().concat(result).reverse().join('')].join(' '));
            quit();
        }
    }
}

write('-1 -1');

var input = readline().split(' ').map(value => +value);
var m = input[0];
var s = input[1];

var printResults = function (arrayMin, arrayMax) {
    write([arrayMin.join(''), (arrayMax || arrayMin).join('')].join(' '));
    quit();
};

if (s === 0) {
    write(m === 1 ? '0 0' : '-1 -1');
    quit();
}

if (m * 9 === s) {
    printResults(new Array(m).fill(9));
}

var result = [1].concat(new Array(m - 1).fill(0));

if (s === 1) {
    printResults(result);
}

var cs = 1;

for (var i = result.length - 1; i >= 0; --i) {
    while (result[i] < 9) {
        if (cs === s) {
            printResults(
                result.join('').split(''),
                result.splice(0, i).reverse().concat(result).reverse()
            );
        }

        ++result[i];
        ++cs;
    }
}

write('-1 -1');

var input = readline().split(' ').map(value => +value);
var m = input[0];
var s = input[1];

if (s === 0) {
    write(m === 1 ? '0 0' : '-1 -1');
    quit();
}

var result = [1].concat(new Array(m - 1).fill(0));
var cs = 1;

for (var i = result.length - 1; i >= 0; --i) {
    while (result[i] < 9) {
        ++result[i];

        if (++cs === s) {
            write([result.join(''),result.splice(0, i).reverse().concat(result).reverse().join('')].join(' '));
            quit();
        }
    }
}

write('-1 -1');

var input = readline().split(' ').map(Number), m = input[0], s = input[1];

if ((s < m - 1)|| (s > 9 * m)) write('-1 -1')
else {
    var bigS = s;
    var smallS = s;
    var big = '';
    var small = '';
    while (m > 0) {

        if (bigS >= 9) { big = big + '9'; bigS -= 9; }
        else { big = big + bigS.toString(); bigS = 0; }

        var cur = Math.min('9', smallS - 1);
        if (m == 1) cur++;
        small = cur.toString() + small;
        smallS -= cur;
        m--;

    }
    write (small + ' ' + big);
}

var input = readline().split(' ').map(Number), m = input[0], s = input[1];

if ((s < 1)|| (s > 9 * m)) write('-1 -1')
else {
    var bigS = s;
    var smallS = s;
    var big = '';
    var small = '';
    while (m > 0) {

        if (bigS >= 9) { big = big + '9'; bigS -= 9; }
        else { big = big + bigS.toString(); bigS = 0; }

        var cur = Math.min('9', smallS - 1);
        if (m == 1) cur++;
        small = cur.toString() + small;
        smallS -= cur;
        m--;

    }
    write (small + ' ' + big);
}

var input = readline().split(' ').map(Number), m = input[0], s = input[1];

if ((s < m - 1)|| (s > 9 * m)) write('-1 -1')
else {
    var bigS = s;
    var smallS = s;
    var big = '';
    var small = '';
    while (m > 0) {

        if (bigS >= 9) { big = big + '9'; bigS -= 9; }
        else { big = big + bigS.toString(); bigS = 0; }

        var cur = Math.min('9', smallS - (m - 1));
        small = cur.toString() + small;
        smallS -= cur;
        m--;

    }
}
write (small + ' ' + big);

var input = readline().split(' ').map(Number), m = input[0], s = input[1];

if ((s < m - 1)|| (s > 9 * m)) write('-1 -1')
else {
    var bigS = s;
    var smallS = s;
    var big = '';
    var small = '';
    while (m > 0) {

        if (bigS >= 9) { big = big + '9'; bigS -= 9; }
        else { big = big + bigS.toString(); bigS = 0; }

        var cur = Math.min('9', smallS - (m - 1));
        small = cur.toString() + small;
        smallS -= cur;
        m--;

    }
}
write (big + ' ' + small);

var input = readline().split(' ').map(Number), m = input[0], s = input[1];

if ((s < m - 1)|| (s > 9 * m)) write('-1 -1')
else {
    var bigS = s;
    var smallS = s;
    var big = '';
    var small = '';
    while (m > 0) {

        if (bigS >= 9) { big = big + '9'; bigS -= 9; }
        else { big = big + bigS.toString(); bigS = 0; }

        var cur = Math.min('9', smallS - (m - 1));
        small = cur.toString() + small;
        smallS -= cur;
        m--;

        write (big + ' ' + small + '\n');

    }
}

var input = readline().split(' ').map(Number), m = input[0], s = input[1];

if ((s < m - 1)|| (s > 9 * m)) write('-1 -1')
else {
    var bigS = s;
    var smallS = s;
    var big = '';
    var small = '';
    while (m > 0) {

        if (bigS >= 9) { big = big + '9'; bigS -= 9; }
        else { big = big + bigS.toString(); bigS = 0; }

        var cur = Math.min('9', smallS - (m - 1));
        small = cur.toString() + small;
        smallS -= cur;
        m--;

    }
    write (small + ' ' + big);
}


Alice and Bob begin their day with a quick game. They first choose a starting number X0 ≥ 3 and try to reach one million by the process described below. Alice goes first and then they take alternating turns. In the i-th turn, the player whose turn it is selects a prime number smaller than the current number, and announces the smallest multiple of this prime number that is not smaller than the current number.Formally, he or she selects a prime p < Xi - 1 and then finds the minimum Xi ≥ Xi - 1 such that p divides Xi. Note that if the selected prime p already divides Xi - 1, then the number does not change.Eve has witnessed the state of the game after two turns. Given X2, help her determine what is the smallest possible starting number X0. Note that the players don't necessarily play optimally. You should consider all possible game evolutions.

The input contains a single integer X2 (4 ≤ X2 ≤ 106). It is guaranteed that the integer X2 is composite, that is, is not prime.

Output a single integer — the minimum possible X0.

NoteIn the first test, the smallest possible starting number is X0 = 6. One possible course of the game is as follows:   Alice picks prime 5 and announces X1 = 10  Bob picks prime 7 and announces X2 = 14. In the second case, let X0 = 15.   Alice picks prime 2 and announces X1 = 16  Bob picks prime 5 and announces X2 = 20.

var primes = [];

function decompose(n) {
  var res = [];
  var p = 2;
  while (true) {
    if (n >= p * p) {
      if (n % p === 0) {
        res.push(p);
        n /= p;
      } else {
        p++;
      }
    } else {
      res.push(n);
      break;
    }
  }
  return res;
}

function resolve(n) {
  var d1 = decompose(n);
  var px1 = (n / d1[d1.length - 1] - 1) * d1[d1.length - 1] + 1;
  var min = Infinity;
  var d2;
  var px2;
  for (var i = px1; i < n; i++) {
    d2 = decompose(i);
    px2 = (i / d2[d2.length - 1] - 1) * d2[d2.length - 1] + 1;
    if (px2 < min && px2 >= 3) {
      min = px2;
    }
  }
  if (min === Infinity) {
    return px1;
  }
  return min;
}

const k = parseInt(readline(), 10);

const result = resolve(k);

print(result + '\n');


There is a beautiful garden of stones in Innopolis.Its most beautiful place is the $$$n$$$ piles with stones numbered from $$$1$$$ to $$$n$$$.EJOI participants have visited this place twice. When they first visited it, the number of stones in piles was $$$x_1, x_2, \ldots, x_n$$$, correspondingly. One of the participants wrote down this sequence in a notebook. They visited it again the following day, and the number of stones in piles was equal to $$$y_1, y_2, \ldots, y_n$$$. One of the participants also wrote it down in a notebook.It is well known that every member of the EJOI jury during the night either sits in the room $$$108$$$ or comes to the place with stones. Each jury member who comes there either takes one stone for himself or moves one stone from one pile to another. We can assume that there is an unlimited number of jury members. No one except the jury goes to the place with stones at night.Participants want to know whether their notes can be correct or they are sure to have made a mistake.

The first line of the input file contains a single integer $$$n$$$, the number of piles with stones in the garden ($$$1 \leq n \leq 50$$$). The second line contains $$$n$$$ integers separated by spaces $$$x_1, x_2, \ldots, x_n$$$, the number of stones in piles recorded in the notebook when the participants came to the place with stones for the first time ($$$0 \leq x_i \leq 1000$$$). The third line contains $$$n$$$ integers separated by spaces $$$y_1, y_2, \ldots, y_n$$$, the number of stones in piles recorded in the notebook when the participants came to the place with stones for the second time ($$$0 \leq y_i \leq 1000$$$).

If the records can be consistent output "Yes", otherwise output "No" (quotes for clarity).

NoteIn the first example, the following could have happened during the night: one of the jury members moved one stone from the second pile to the first pile, and the other jury member moved one stone from the fourth pile to the third pile.In the second example, the jury took stones from the second and fourth piles.It can be proved that it is impossible for the jury members to move and took stones to convert the first array into the second array.

var n = readline();
var firstNote = readline().split(' ');
var secondNote = readline().split(' ');
var first = 0;
var second = 0;
for(var i = 0; i < n; i++){
    first += parseInt(firstNote[i]);
    second += parseInt(secondNote[i]);
}
if(second > first){
    print('NO');
}else{
    print('YES');
}

var n= readline('n');
var x = readline().split(" ").map(function(x) { return parseInt(x); });;
var y = readline().split(" ").map(function(x) { return parseInt(x); });;
var sumX = x.reduce((total, x)=>{
    return total + x;
});
var sumY = y.reduce((total, x)=>{
    return total+ x;
}, 0);
if(sumX >= sumY && n>=1 && n <= 50 && n == x.length && n == y.length){
    print('Yes');
}else{
    print('No');
}

n = readline();
var sum1 = parseInt(readline().split(' ').reduce((a, b) => parseInt(a) + parseInt(b)));
var sum2 = parseInt(readline().split(' ').reduce((a, b) => parseInt(a) + parseInt(b)));
if(sum2 > sum1){print("NO")}
else{print("YES")}

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

//Don't have to see. end------------------------------------------
function Main(){
	var N = nextInt();
	var alist = nextIntArray();
	var blist = nextIntArray();
	var asum = 0;
	var bsum = 0;
	for(var i = 0; i < N; i++){
		asum += alist[i];
		bsum += blist[i];
	}
	if(asum >= bsum){
		myout("Yes");
	}else{
		myout("No");
	}
}

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

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

  if (c === 1) {
    c++;
    arr1 = d.split(' ').map(Number);
    return;
  }

  arr2 = d.split(' ').map(Number);
  let ans = 0;

  for (let i = 0; i < arr1.length; i++) {
    ans += arr1[i];
  }

  for (let i = 0; i < arr2.length; i++) {
    ans -= arr2[i];
  }

  if (ans >= 0) {
    console.log('YES');
  }
  else {
    console.log('NO');
  }

  c++;
});

var n= readline();
var x = readline().split(" ").map(function(x) { return parseInt(x); });;
var y = readline().split(" ").map(function(x) { return parseInt(x); });;
var sumX = x.reduce((total, x)=>{
    if(x >=0 && x<=1000)
    return total;
});
var sumY = y.reduce((total, x)=>{
    if(x >= 0 && x <= 1000)
    return total;
});
if(sumX <= sumY && n>=1 && n <= 50){
    print('Yes');
}else{
    print('No');
}

var n= readline('n');
var x = readline().split(" ").map(function(x) { return parseInt(x); });;
var y = readline().split(" ").map(function(x) { return parseInt(x); });;
var sumX = x.reduce((total, x)=>{
    if(x >=0 && x<=1000)
    return total;
});
var sumY = y.reduce((total, x)=>{
    if(x >= 0 && x <= 1000)
    return total;
});
if(sumX <= sumY && n>=1 && n <= 50 && n == x.length && n == y.length){
    print('Yes');
}else{
    print('No');
}

var n= readline('n');
var x = readline().split(" ").map(function(x) { return parseInt(x); });;
var y = readline().split(" ").map(function(x) { return parseInt(x); });;
var sumX = x.reduce((total, x)=>{
    if(x >=0 && x<=1000)
    return total;
});
var sumY = y.reduce((total, x)=>{
    if(x >=0 && x<=1000)
    return total;
});
if(sumX <= sumY && n>=1 && n <= 50){
    print('Yes');
}else{
    print('No');
}

var n= readline('n');
var x = readline().split(" ").map(function(x) { return parseInt(x); });;
var y = readline().split(" ").map(function(x) { return parseInt(x); });;
var sumX = x.reduce((total, x)=>{
    return total;
});
var sumY = y.reduce((total, x)=>{
    return total;
});
if(sumX <= sumY){
    print('Yes');
}else{
    print('No');
}

var n= readline('n');
var x = readline().split(" ").map(function(x) { return parseInt(x); });;
var y = readline().split(" ").map(function(x) { return parseInt(x); });;
var sumX = x.reduce((total, x)=>{
    if(x >=0 && x<=1000)
    return total;
});
var sumY = y.reduce((total, x)=>{
    if(x >= 0 && x <= 1000)
    return total;
});
if(sumX <= sumY && n>=1 && n <= 50){
    print('Yes');
}else{
    print('No');
}

var n= readline('n');
var x = readline().split(" ").map(function(x) { return parseInt(x); });;
var y = readline().split(" ").map(function(x) { return parseInt(x); });;
var sumX = x.reduce((total, x)=>{
    return total;
});
var sumY = y.reduce((total, x)=>{
    return total;
});
if(sumX <= sumY && n>=1 && n <= 50){
    print('Yes');
}else{
    print('No');
}

var n= readline('n');
var x = readline().split(" ").map(function(x) { return parseInt(x); });;
var y = readline().split(" ").map(function(x) { return parseInt(x); });;
var sumX = x.reduce((total, x)=>{
    if(x >=0 && x<=1000)
    return total;
});
var sumY = y.reduce((total, x)=>{
    if(x >= 0 && x <= 1000)
    return total;
});
if(sumX >= sumY && n>=1 && n <= 50){
    print('Yes');
}else{
    print('No');
}

 var n = readline();
var sum1 = readline().split(' ').reduce((a, b) => a + b);
var sum2 = readline().split(' ').reduce((a, b) => a + b);
if(sum1 >= sum2){print("YES")}
else{print("NO")}

n = readline();
var sum1 = readline().split(' ').reduce((a, b) => parseInt(a) + parseInt(b));
var sum2 = readline().split(' ').reduce((a, b) => parseInt(a) + parseInt(b));
if(sum2 > sum1){print("NO")}
else{print("YES")}

n = readline();
var sum1 = readline().split(' ').reduce((a, b) => a + b);
var sum2 = readline().split(' ').reduce((a, b) => a + b);
if(sum2 > sum1){print("NO")}
else{print("YES")}

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

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

  if (c === 1) {
    c++;
    arr1 = d.split(' ').map(Number);
    return;
  }

  arr2 = d.split(' ').map(Number);
  const sum = arr1.reduce((a, b) => a + b, 0) + arr2.reduce((a, b) => a + b, 0);

  if (sum % 2 === 0) {
    console.log('YES');
  }
  else {
    console.log('NO');
  }

  c++;
});


You are given two integers n and k. Find k-th smallest divisor of n, or report that it doesn't exist.Divisor of n is any such natural number, that n can be divided by it without remainder.

The first line contains two integers n and k (1 ≤ n ≤ 1015, 1 ≤ k ≤ 109).

If n has less than k divisors, output -1. Otherwise, output the k-th smallest divisor of n.

NoteIn the first example, number 4 has three divisors: 1, 2 and 4. The second one is 2.In the second example, number 5 has only two divisors: 1 and 5. The third divisor doesn't exist, so the answer is -1.

function main(){
	var numbers = readline().split(" ").map(Number);

	var num = numbers[0];
	var kthdiv = numbers[1];
	var divs = [];

	if(numbers[1] === 1)
		return 1;

	if(numbers[0] === 1 && numbers[1] !== 1)
        return -1;

	divs.push(1);

	var numDiv = 1;

	for(var i = 2; i <= Math.sqrt(num); i++)
		if(num % i === 0 && ++numDiv === kthdiv)
			return i;
		else if(num % i === 0)
			divs.push(i);

	for(i = divs.length-1; i >= 0; i--)
        if(num / divs[i] !== divs[i])
            divs.push(num/divs[i]);

	if(kthdiv <= divs.length)
		return divs[kthdiv-1];

	return -1;
}

print(main());

function main() {
    var data = readline().split(' ').map(Number);
    var n = data[0];
    var k= data[1];

    var endDivisors = [];
    var startDivisors = [];
    var num = n;
    var square_root = Math.floor(Math.sqrt(num)) + 1;
    for (var i = 1; i < square_root; i++) {
        if (num % i == 0&&i*i!=num){
            startDivisors.push(i);
            endDivisors.push(num/i)
        }
        if (num % i == 0&&i*i==num){
            startDivisors.push(i)
        }
    }
    var res = -1;
    if(startDivisors[k-1]){
        res = startDivisors[k-1];
    } else if (endDivisors[endDivisors.length - (k-startDivisors.length) ]){
        res = endDivisors[endDivisors.length - (k-startDivisors.length) ]
    }
    print(res);
}

main()

function main(){
	var numbers = readline().split(" ").map(Number);

	var num = numbers[0];
	var kthdiv = numbers[1];
	var divs = [];

	if(numbers[1] === 1)
		return 1;

	divs.push(1);

	var numDiv = 1;

	for(var i = 2; i <= Math.sqrt(num); i++)
		if(num % i === 0 && ++numDiv === kthdiv)
			return i;
		else if(num % i === 0)
			divs.push(i);

	if(kthdiv <= divs.length*2)
		return num/divs[divs.length*2-kthdiv];

	return -1;
}

print(main());