Alice and Bob decided to eat some fruit. In the kitchen they found a large bag of oranges and apples. Alice immediately took an orange for herself, Bob took an apple. To make the process of sharing the remaining fruit more fun, the friends decided to play a game. They put multiple cards and on each one they wrote a letter, either 'A', or the letter 'B'. Then they began to remove the cards one by one from left to right, every time they removed a card with the letter 'A', Alice gave Bob all the fruits she had at that moment and took out of the bag as many apples and as many oranges as she had before. Thus the number of oranges and apples Alice had, did not change. If the card had written letter 'B', then Bob did the same, that is, he gave Alice all the fruit that he had, and took from the bag the same set of fruit. After the last card way removed, all the fruit in the bag were over.You know how many oranges and apples was in the bag at first. Your task is to find any sequence of cards that Alice and Bob could have played with.

The first line of the input contains two integers, x, y (1 ≤ x, y ≤ 1018, xy > 1) — the number of oranges and apples that were initially in the bag.

Print any sequence of cards that would meet the problem conditions as a compressed string of characters 'A' and 'B. That means that you need to replace the segments of identical consecutive characters by the number of repetitions of the characters and the actual character. For example, string AAABAABBB should be replaced by string 3A1B2A3B, but cannot be replaced by 2A1A1B2A3B or by 3AB2A3B. See the samples for clarifications of the output format. The string that you print should consist of at most 106 characters. It is guaranteed that if the answer exists, its compressed representation exists, consisting of at most 106 characters. If there are several possible answers, you are allowed to print any of them. If the sequence of cards that meet the problem statement does not not exist, print a single word Impossible.

NoteIn the first sample, if the row contained three cards with letter 'B', then Bob should give one apple to Alice three times. So, in the end of the game Alice has one orange and three apples, and Bob has one apple, in total it is one orange and four apples.In second sample, there is no answer since one card is not enough for game to finish, and two cards will produce at least three apples or three oranges.In the third sample, cards contain letters 'AB', so after removing the first card Bob has one orange and one apple, and after removal of second card Alice has two oranges and one apple. So, in total it is three oranges and two apples.

// ---------- begin input macro ----------
// reference: https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};
    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };
    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };
    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };
    ($iter:expr, bytes) => {
        read_value!($iter, String).bytes().collect::<Vec<u8>>()
    };
    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };
    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}
// ---------- end input macro ----------

fn gcd(a: u128, b: u128) -> u128 {
    if b == 0 {
        a
    } else {
        gcd(b, a % b)
    }
}

fn run() {
    input! {
        x: u128,
        y: u128,
    }
    if gcd(x, y) > 1 {
        println!("Impossible");
        return;
    }
    // a / b < c / d
    let small = |a, b, c, d| a * d < b * c;
    // a / b > c / d
    let large = |a, b, c, d| a * d > b * c;
    let mut l = (0, 1);
    let mut r = (1, 0);
    let mut ans = vec![];
    while l.0 + r.0 < x || l.1 + r.1 < y {
        let (p, q) = (l.0 + r.0, l.1 + r.1);
        if small(p, q, x, y) {
            let mut ok = 1;
            let mut ng = 2;
            while small(l.0 + ng * r.0, l.1 + ng * r.1, x, y) {
                ok = ng;
                ng *= 2;
            }
            while ng - ok > 1 {
                let mid = (ok + ng) / 2;
                if small(l.0 + mid * r.0, l.1 + mid * r.1, x, y) {
                    ok = mid;
                } else {
                    ng = mid;
                }
            }
            ans.push((ok, 'A'));
            l = (l.0 + ok * r.0, l.1 + ok * r.1);
        } else {
            let mut ok = 1;
            let mut ng = 2;
            while large(ng * l.0 + r.0, ng * l.1 + r.1, x, y) {
                ok = ng;
                ng *= 2;
            }
            while ng - ok > 1 {
                let mid = (ok + ng) / 2;
                if large(mid * l.0 + r.0, mid * l.1 + r.1, x, y) {
                    ok = mid;
                } else {
                    ng = mid;
                }
            }
            ans.push((ok, 'B'));
            r = (ok * l.0 + r.0, ok * l.1 + r.1);
        }
    }
    let mut s = String::new();
    for (c, op) in ans {
        s.push_str(&format!("{}{}", c, op));
    }
    println!("{}", s);
}

fn main() {
    run();
}


Calendars in widespread use today include the Gregorian calendar, which is the de facto international standard, and is used almost everywhere in the world for civil purposes. The Gregorian reform modified the Julian calendar's scheme of leap years as follows: Every year that is exactly divisible by four is a leap year, except for years that are exactly divisible by 100; the centurial years that are exactly divisible by 400 are still leap years. For example, the year 1900 is not a leap year; the year 2000 is a leap year.   In this problem, you have been given two dates and your task is to calculate how many days are between them. Note, that leap years have unusual number of days in February.Look at the sample to understand what borders are included in the aswer.

The first two lines contain two dates, each date is in the format yyyy:mm:dd (1900 ≤ yyyy ≤ 2038 and yyyy:mm:dd is a legal date).

Print a single integer — the answer to the problem.

macro_rules! parse_line {
    ($t: ty) => ({
        let mut a_str = String::new();
        std::io::stdin().read_line(&mut a_str).expect("read error");
        let a_str = a_str.trim();
        a_str.parse::<$t>().expect("parse error")
    });
    ($($t: ty),+) => ({
        let mut a_str = String::new();
        std::io::stdin().read_line(&mut a_str).expect("read error");
        let mut a_iter = a_str.split_whitespace();
        (
            $(
            a_iter.next().unwrap().parse::<$t>().expect("parse error"),
            )+
        )
    })
}

macro_rules! parse_line_to_vec {
    ($t: ty) => {{
        let mut a_str = String::new();
        std::io::stdin().read_line(&mut a_str).expect("read error");
        (a_str
            .split_whitespace()
            .map(|x| x.parse::<$t>().unwrap())
            .collect::<Vec<$t>>())
    }};
}

fn is_leap(y: i64) -> bool {
    y % 400 == 0 || y % 4 == 0 && y % 100 != 0
}

fn parse_date() -> i64 {
    let s = parse_line!(String);
    let mut it = s.split(':');
    let y: i64 = it.next().unwrap().parse().unwrap();
    let m: i64 = it.next().unwrap().parse().unwrap();
    let d: i64 = it.next().unwrap().parse().unwrap();
    let mut result = d;
    for i in 0..y {
        result += 365;
        if is_leap(i) {
            result += 1;
        }
    }
    let days = [31, 28 + if is_leap(y) {1} else {0}, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
    for i in 0..m - 1 {
        result += days[i as usize];
    }
    return result;
}

fn solve() {
    let from = parse_date();
    let to = parse_date();
    println!("{}", (from - to).abs());
}

fn main() {
    let tests = 1; // parse_line!(usize);
    for _ in 0..tests {
        solve();
    }
}


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).

#[allow(unused)] use std::io::*;
#[allow(unused)] use std::collections::*;
#[allow(unused)] use std::mem::*;
#[allow(unused)] use std::num::*;
#[allow(unused)] use std::cmp::*;
#[allow(unused)] use std::thread::*;
#[allow(unused)] use std::ops::*;
#[allow(unused)] use std::marker::*;
#[allow(unused)] macro_rules! scan { ($($x:ty), +) => {{
    let mut inp = String::new(); stdin().read_line(&mut inp).ok();
    let s = inp.split(' ').map(|x| x.trim()).filter(|x| x.len() != 0).collect();
    let mut cnt : usize = 0;
    fn next<T>(cnt: &mut usize, p: &Vec<&str>) -> T where T:std::str::FromStr
    { *cnt += 1; p[*cnt-1].parse().ok().unwrap() }
    ($(next::<$x>(&mut cnt, &s)), +)
    }}; }
#[allow(unused)] macro_rules! arr { ($($n:expr, $T:ty), +) => {{
    let mut inp = String::new(); stdin().read_line(&mut inp).ok();
    let mut s = inp.split(' ').map(|x| x.trim()).filter(|x| x.len() != 0);
    ($({let mut v = Vec::new(); v.reserve(($n) as usize);
        for _ in 0..$n { let t = s.next(); if t == None { break; }
        v.push(t.unwrap().parse::<$T>().unwrap()); } v }),+)
    }}; }
///////////////////////////////////////////////////////////////////////////////

fn main()
{
    let (n, mut s) = scan!(usize, u64);
    if n == 1 && s == 0 { println!("0 0"); return; }
    if (9 * n as u64) < s || s < 1 { println!("-1 -1"); return; }
    let mut a = vec![0; n];
    for i in 0..n { a[i] += min(s, 9); s -= min(s, 9); }
    let mut b = a.iter().rev().map(|&x| x).collect::<Vec<u64>>();
    if b[0] == 0 { for i in 0..n { if b[i] > 0 { b[i] -= 1; b[0] += 1; break; } } }
    for i in 0..n { print!("{}", b[i]); } print!(" ");
    for i in 0..n { print!("{}", a[i]); } println!();
}

fn find_min(m: usize, s: usize) -> String {
    let mut num = vec![0; m];
    num[0] = 1;
    let mut i = m - 1;
    let mut sum = 1;

    while sum + 9 < s {
        num[i] = 9;
        i -= 1;
        sum += 9;
    }

    num[i] += (s - sum) as u8;
    vec_to_num(&num)
}

fn find_max(m: usize, s: usize) -> String {
    let mut num = vec![9; m];
    let mut i = m - 1;
    let mut sum = 9 * m;

    while sum - 9 > s {
        num[i] = 0;
        i -= 1;
        sum -= 9;
    }

    num[i] -= (sum - s) as u8;
    vec_to_num(&num)
}

fn vec_to_num(v: &Vec<u8>) -> String {
    v.into_iter()
        .map(|digit| (digit + 48) as char)
        .collect::<String>()
}

fn main() {
    let (m, s) = {
        let mut buf = String::new();
        std::io::stdin().read_line(&mut buf).unwrap();
        let temp: Vec<usize> = buf
            .trim()
            .split_whitespace()
            .map(|elem| elem.parse().unwrap())
            .collect();
        (temp[0], temp[1])
    };

    if m == 1 && s == 0 {
        println!("0 0");
    } else if s < 1 || s > 9 * m {
        println!("-1 -1");
    } else {
        println!("{} {}", find_min(m, s), find_max(m, s))
    }
}

fn get_max_digits(length: usize, sum: u32) -> Option<Vec<u32>> {
    if length == 0 {
        return None;
    }
    if (sum == 0) && (length > 1) {
        return None;
    }
    if sum == 0 {
        return Some(vec![0]);
    }
    let mut result: Vec<u32> = Vec::with_capacity(length);
    let mut rest_sum: u32 = sum;
    let first_digit: u32;
    if rest_sum > 9 {
        first_digit = 9;
    } else {
        first_digit = rest_sum;
    }
    result.push(first_digit);
    rest_sum -= first_digit;

    for _ in 1..length {
        let digit: u32;
        if rest_sum > 9 {
            digit = 9;
        } else {
            digit = rest_sum;
        }
        result.push(digit);
        rest_sum -= digit;
    }

    if rest_sum == 0 {
        return Some(result);
    } else {
        return None;
    }
}

fn get_min_digits(length: usize, sum: u32) -> Option<Vec<u32>> {
    if (sum == 0) && (length > 1) {
        return None;
    }
    if sum == 0 {
        return Some(vec![0]);
    }
    let mut result: Vec<u32> = Vec::with_capacity(length);
    let mut rest_sum: u32 = sum - 1;

    for _ in 1..length {
        let digit: u32;
        if rest_sum > 9 {
            digit = 9;
        } else {
            digit = rest_sum;
        }
        result.push(digit);
        rest_sum -= digit;
    }

    if rest_sum >= 9 {
        return None;
    }

    let last_digit: u32 = rest_sum + 1;
    result.push(last_digit);

    result.reverse();
    return Some(result);
}

#[cfg(test)]
mod tests {
    use super::{get_max_digits, get_min_digits};

    #[test]
    fn test1() {
        assert_eq!(get_max_digits(2, 15), Some(vec![9, 6]));
        assert_eq!(get_min_digits(2, 15), Some(vec![6, 9]));
    }
    #[test]
    fn test2() {
        assert_eq!(get_max_digits(3, 0), None);
        assert_eq!(get_min_digits(3, 0), None);
    }
    #[test]
    fn test3() {
        assert_eq!(get_max_digits(1, 0), Some(vec![0]));
        assert_eq!(get_min_digits(1, 0), Some(vec![0]));
    }
    #[test]
    fn test4() {
        assert_eq!(get_max_digits(1, 9), Some(vec![9]));
        assert_eq!(get_min_digits(1, 9), Some(vec![9]));
    }
    #[test]
    fn test5() {
        assert_eq!(get_max_digits(2, 12), Some(vec![9, 3]));
        assert_eq!(get_min_digits(2, 12), Some(vec![3, 9]));
    }
}

use std::io::{stdin, stdout, BufRead, Write};

fn main() {
    let stdin = stdin();
    let mut stdin_lock = stdin.lock();

    let stdout = stdout();
    let mut stdout_lock = stdout.lock();

    let mut input_str: String = String::new();
    stdin_lock.read_line(&mut input_str).unwrap();
    let mut input_tokens = input_str.trim().split_whitespace();
    let length: usize = input_tokens.next().unwrap().parse().unwrap();
    let sum: u32 = input_tokens.next().unwrap().parse().unwrap();

    if let Some(min_digits_array) = get_min_digits(length, sum) {
        for digit in min_digits_array {
            write!(stdout_lock, "{}", digit).unwrap();
        }
    } else {
        write!(stdout_lock, "-1").unwrap();
    }

    write!(stdout_lock, " ").unwrap();

    if let Some(max_digits_array) = get_max_digits(length, sum) {
        for digit in max_digits_array {
            write!(stdout_lock, "{}", digit).unwrap();
        }
    } else {
        write!(stdout_lock, "-1").unwrap();
    }

    writeln!(stdout_lock, "").unwrap();
}

//spnauti-rust
#[allow(unused_macros)]
macro_rules! a {
    ($c: tt, $x: expr, $y: expr) => {{
        let b = $y; let a = &mut $x;
        if b $c *a { *a = b; true } else { false }
    }};
}
struct WordReader {
    it : std::vec::IntoIter<String>,
}
#[allow(dead_code)]
impl WordReader {
    fn new<T: std::io::Read>(mut reader: T) -> WordReader {
        let mut s = String::new();
        reader.read_to_string(&mut s).unwrap();
        WordReader {
            it : s.split_ascii_whitespace().map(String::from)
            .collect::<Vec<_>>().into_iter()
        }
    }
    fn from_stdin() -> WordReader {
        WordReader::new(std::io::stdin())
    }
    fn s(&mut self) -> String {
        self.it.next().unwrap()
    }
    fn ab(&mut self) -> Vec<u8> {
        self.it.next().unwrap().into_bytes()
    }
    fn i(&mut self) -> i32 {
        self.it.next().unwrap().parse().unwrap()
    }
    fn ai(&mut self, n: usize) -> Vec<i32> {
        let mut a = Vec::with_capacity(n);
        for _ in 0..n { a.push(self.i()); }
        a
    }
}

fn main() {
    let mut input = WordReader::from_stdin();
    let n = input.i();
    let s = input.i();
    if (s == 0 && n > 1) || n * 9 < s {
        println!("-1 -1");
    } else if n == 1 {
        println!("{} {}", s, s);
    } else {
        let ok = |i,d,t| {
            if i == n - 1 && d == 0 { return false; }
            let t1 = t - d;
            t1 >= 0 && t1 <= 9 * i
        };
        (0..n).rev().fold(s, |t,i| {
            let d = (0..10).filter(|&d| ok(i,d,t)).min().unwrap();
            print!("{}", d);
            t - d
        });
        print!(" ");
        (0..n).rev().fold(s, |t,i| {
            let d = (0..10).filter(|&d| ok(i,d,t)).max().unwrap();
            print!("{}", d);
            t - d
        });
        println!("");
    }
}

macro_rules! readln {
    () => {{
        use std::io;

        let mut buf = String::new();
        io::stdin().read_line(&mut buf).unwrap();
        buf.trim().to_string()
    }};
    ( $t:ty ) => {{
        let input = readln!();
        input.parse::<$t>().unwrap()
    }};
    ( $( $t:ty ),+ ) => {{
        let input = readln!();
        let mut input = input.split_whitespace();
        (
            $(
                input.next().unwrap().parse::<$t>().unwrap(),
            )+
        )
    }}
}

macro_rules! readvec {
    ( $t:ty ) => {{
        let input = readln!();
        let mut input = input.split_whitespace();
        let mut result = Vec::new();
        for elem in input {
            result.push(elem.parse::<$t>().unwrap());
        }
        result
    }}
}

fn main() {
    let (n,m) = readln!(i32,i32);
    if n==1 && m==0 {
      println!("0 0");
      return;
    }
    if (9*n < m || m==0) {
        println!("-1 -1");
        return;
    }
    let mut m1 = m;
    if (9*(n-1) >= m) {
        m1 -= 1;
    }

    let mut l = String::from("");
    let mut used = 0;
    for i in 0..n {
        let mut touse = 0;
        if i == n-1 {
            touse = m-used;
        } else {
            touse = std::cmp::min(m1-used,9);
        }
        l.push((('0' as u8) + (touse as u8)) as char);
        used += touse;
    }

    let mut r = String::from("");
    let mut used = 0;
    for i in 0..n {
        let touse = std::cmp::min(m-used,9);
        r.push((('0' as u8) + (touse as u8)) as char);
        used += touse;
    }
    println!("{} {}",l.chars().rev().collect::<String>(),r);
}

use std::io;
use std::cmp;
use std::process;
fn main()
{
    let mut s=String::new();
    io::stdin().read_line(&mut s).expect("read error");
    let vec=s.split_whitespace()
        .map(|x|
            x.parse::<i64>().expect("parse error"))
        .collect::<Vec<i64>>();
    if (vec[0]>1 && vec[1]<1) || (vec[0]*9<vec[1]){
        println!("-1 -1");
        process::exit(0);
    }
    let mut ans1=String::new();
    let mut ans2=String::new();
    let mut n1=vec[0];
    let mut n2=vec[1];

    while n1>0
    {
        n1=n1-1;
        let x:i64=cmp::min(9,n2);
        n2-=x;
        ans1+=&x.to_string();
    }
    n1=vec[0];
    n2=vec[1];
    while n1>0{
        n1=n1-1;
        let mut x:i64=0;
        if n1==vec[0]-1{
            x=cmp::min(1,n2);
        }
        x=cmp::max(x,n2-9*n1);
        n2-=x;
        ans2+=&x.to_string();
    }
    println!("{} {}",ans2,ans1);
}

// {{{ by shik

use std::io;

#[allow(dead_code)]
fn gets() -> String {
    let mut s = String::new();
    io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

#[allow(unused_macros)]
macro_rules! R {
    ( $ty:ty, ... ) => {
        gets().split_whitespace().map(|x| x.parse::<$ty>().unwrap()).collect::<Vec<_>>()
    };
    ( $($ty:ty),* ) => {{
        let line = gets();
        let mut it = line.split_whitespace();
        ( $(it.next().unwrap().parse::<$ty>().unwrap(),)* )
    }}
}

#[allow(unused_macros)]
macro_rules! W {
    ( $x:expr ) => {{
        println!("{}", $x);
    }};
    ( $x:expr, $($xs:expr),* ) => {{
        print!("{} ", $x);
        W!($($xs),*);
    }}
}

#[allow(unused_macros)]
macro_rules! join {
    ($x:expr, $($xs:expr),*; $sep:expr) => { concat!($x, $($sep, $xs),*) }
}

#[allow(unused_macros)]
macro_rules! dump {
    ($($x:expr),*) => {
        eprintln!(join!($(concat!(stringify!($x), " = {:?}")),*; ", "), $($x),*);
    }
}

// }}}

use std::cmp;

fn build_max(m: usize, s: usize) -> String {
    if m * 9 < s {
        return "-1".to_string();
    } else if s == 0 {
        if m == 1 {
            return "0".to_string();
        } else {
            return "-1".to_string();
        }
    } else {
        let mut ns = 0;
        let mut ans = String::new();
        for _ in 0..m {
            let d = cmp::min(9, s - ns);
            ans += &d.to_string();
            ns += d;
        }
        return ans;
    }
}

fn build_min(m: usize, s: usize) -> String {
    if m * 9 < s {
        return "-1".to_string();
    } else if s == 0 {
        if m == 1 {
            return "0".to_string();
        } else {
            return "-1".to_string();
        }
    } else {
        let mut ns = 0;
        let mut ans = String::new();
        for _ in 0..(m-1) {
            let d = cmp::min(9, s - ns - 1);
            ans += &d.to_string();
            ns += d;
        }
        ans += &(s - ns).to_string();
        return ans.chars().rev().collect::<String>();
    }
}

fn main() {
    let (m, s) = R!(usize, usize);
    println!("{} {}", build_min(m, s), build_max(m, s));
}

fn main() -> Result<(), Box<dyn std::error::Error>> {
    let data = read_input();
    let (len, sum) = (data[0], data[1]);

    if 9 * len < sum {
        println!("-1 -1");
        return Ok(());
    }

    if sum == 0 {
        if len > 1 {
            println!("-1 -1");
        } else {
            println!("0 0");
        }
        return Ok(());
    }

    if sum == 1 {
        let mut ans = String::with_capacity(len);
        ans.push('1');

        for _ in 1..len {
            ans.push('0');
        }
        println!("{} {}", ans, ans);
        return Ok(());
    }

    if (sum >= 1 && sum <= 9) && (len == 1) {
        println!("{} {}", sum, sum);
        return Ok(());
    }

    if sum % 9 == 0 && sum / 9 == len {
        let mut ans = String::with_capacity(len);
        for _ in 0..len {
            ans.push('9')
        }
        println!("{} {}", ans, ans);
        return Ok(());
    }

    let mut digits = vec![0; len];
    let mut max_digits = vec![0; len];

    let nines = sum / 9;
    let rem = sum % 9;

    let start = len - nines;
    for i in (start..len).rev() {
        digits[i] = 9;
    }

    if len - nines > 1 {
        if rem > 0 {
            digits[start - 1] = rem - 1;
            digits[0] = 1;
        } else {
            digits[start] -= 1;
            digits[0] = 1;
        }
    } else {
        if rem > 0 {
            digits[0] = rem;
        } else {
            digits[start] -= 1;
            digits[0] = 1;
        }
    }

    for i in 0..nines {
        max_digits[i] = 9;
    }
    if rem != 0 {
        max_digits[nines] = rem;
    }

    for d in digits {
        print!("{}", d);
    }
    print!(" ");

    for d in max_digits {
        print!("{}", d);
    }
    println!();

    Ok(())
}

fn read_input() -> Vec<usize> {
    let mut buffer = String::new();

    std::io::stdin()
        .read_line(&mut buffer)
        .expect("Failed to get input");

    buffer
        .trim()
        .split_whitespace()
        .map(|x| x.parse().expect("Failed to parse number"))
        .collect()
}

// https://codeforces.com/problemset/problem/489/C
use std::io;
use std::char;

fn reverse(cadena: &String) -> String {
    let mut ans = String::from("");
    for ch in cadena.chars().rev() {
        ans.push(ch);
    }
    ans
}

fn main() {
    let mut line = String::new();

    io::stdin()
        .read_line(&mut line)
        .unwrap();

    let words: Vec<i64> =
        line
        .split_whitespace()
        .map(|x| x.parse().unwrap())
        .collect();

    let m = words[0] as usize;
    let mut s = words[1];
    let mut _t = words[1];

    if s == 0 && m != 1 {
        println!("-1 -1");
        return;
    }

    if s == 0 && m == 1 {
        println!("0 0");
        return;
    }

    // lets construct maxima
    let mut maxima = String::from("");

    while s > 0 {
        if s >= 9 {
            maxima = format!("9{}", maxima);
            s -= 9;
        } else {
            maxima = format!("{}{}", maxima, s);
            s -= s;
        }
    }

    if maxima.len() > m {
        println!("-1 -1");
        return;
    }

    while maxima.len() < m {
        maxima = format!("{}0", maxima);
    }

    // lets construct minima
    let mut chars: Vec<char> = reverse(&maxima).chars().collect();
    let mut minima = String::from("");

    if chars[0] == '0' {
        chars[0] = '1';
        for i in 1..chars.len() {
            if chars[i] != '0' {
                chars[i] = char::from_digit(chars[i].to_digit(10).unwrap()-1,10).unwrap();
                break;
            }
        }
    }

    for ch in chars {
        minima.push(ch);
    }

    println!("{} {}", minima, maxima);
}

// https://codeforces.com/problemset/problem/489/C
use std::io;
use std::char;

fn reverse(cadena: &String) -> String {
    let mut ans = String::from("");
    for ch in cadena.chars().rev() {
        ans.push(ch);
    }
    ans
}

fn main() {
    let mut line = String::new();

    io::stdin()
        .read_line(&mut line)
        .unwrap();

    let words: Vec<i64> =
        line
        .split_whitespace()
        .map(|x| x.parse().unwrap())
        .collect();

    let m = words[0] as usize;
    let mut s = words[1];
    let mut _t = words[1];

    if s == 0 && m != 1 {
        println!("-1 -1");
        return;
    }

    if s == 0 && m == 1 {
        println!("0 0");
        return;
    }

    // lets construct maxima
    let mut maxima = String::from("");

    while s > 0 {
        if s >= 9 {
            maxima = format!("9{}", maxima);
            s -= 9;
        } else {
            maxima = format!("{}{}", maxima, s);
            s -= s;
        }
    }

    if maxima.len() > m {
        println!("-1 -1");
        return;
    }

    while maxima.len() < m {
        maxima = format!("{}0", maxima);
    }

    // lets construct minima
    let mut chars: Vec<char> = reverse(&maxima).chars().collect();
    let mut minima = String::from("");

    if chars[0] == '0' {
        chars[0] = '1';
        for i in 1..chars.len() {
            if chars[i] != '0' {
                chars[i] = char::from_digit(chars[i].to_digit(10).unwrap()-1,10).unwrap();
                break;
            }
        }
    }

    for ch in chars {
        minima.push(ch);
    }

    if maxima == "-1" {
        minima = String::from("-1");
    }

    println!("{} {}", minima, maxima);
}

struct Scan {
    buffer: std::collections::VecDeque<String>
}

impl Scan {
    fn new() -> Scan {
        Scan { buffer: std::collections::VecDeque::new() }
    }

    fn next<T: std::str::FromStr>(&mut self)-> T {
        loop {
            if let Some(token) = self.buffer.pop_front() {
                break token.parse::<T>().ok().unwrap();
            }
            let mut line = String::new();
            std::io::stdin().read_line(&mut line).expect("Fail to read");
            self.buffer = line.split_whitespace().map(String::from).collect();
        }
    }

}

fn _main() {
    let mut scan = Scan::new();
    let m: isize = scan.next();
    let s: isize = scan.next();
    let nnines = s / 9;
    let last = s % 9;
    if nnines > m || nnines == m && last != 0 || m>1 && s == 0 {
        println!("-1 -1");
    } else if m == 1 && s == 0 {
        println!("0 0");
    } else if m == 1 {
        println!("{} {}", s, s);
    } else if nnines == m {
        let sol = format!("{}", "9".repeat(nnines as usize));
        println!("{} {}", sol, sol);
    } else {
        let mut result = String::new();
        let mut s1 = s;
        for i in 1..=m {
            for d in 0..=9 {
                if i==1 && d==0 { continue; }
                if s1-d <= 9*(m-i) && s1-d >= 0 {
                    result = format!("{}{}", result, d);
                    s1 -= d;
                    break;
                }
            }
        }
        print!("{}", result);
        result.clear();
        s1 = s;
        for i in 1..=m {
            for d in (0..=9).rev() {
                if  s1-d <= 9*(m-i) && s1-d >= 0 {
                    result = format!("{}{}", result, d);
                    s1 -= d;
                    break;
                }
            }
        }
        println!(" {}", result);
    }
}

fn main() {
    std::thread::Builder::new()
        .stack_size(1<<23).spawn(_main).unwrap().join().unwrap();
}

use std::io;

fn read_line(buf: &mut String) {
    buf.clear();
    match io::stdin().read_line(buf) {
        Err(error) => println!("error! {}",error),
        _ => {}
    }
}

fn is_valid(m: i32, n: i32) -> bool {
    if n==0 || n>9*m {
        return false;
    }
    return true;
}
fn get_max(m:i32,n:i32) {
    let mut max = Vec::<u8>::new();
    max.reserve(m as usize);
    for _ in 0..m {
        max.push(0);
    }
    let mut n_copy = n;
    for index in 0..m {
        if n_copy > 9 {
            max[index as usize]+=9;
            n_copy -= 9;
        }
        else {
            max[index as usize]+= n_copy as u8;
            break;
        }
    }
    print!(" ");
    for x in max {
        print!("{}",x);
    }
    println!("");

}
fn get_min(m:i32, n:i32) {
    let mut min = Vec::<u8>::new();
    min.reserve(m as usize);
    min.push(1);
    for _ in 1..m {
        min.push(0);
    }
    let mut n_copy = n-1;
    for index in (0..(m)).rev() {
        if n_copy > 9 {
            min[index as usize]+=9;
            n_copy -= 9;
        }
        else {
            min[index as usize]+= n_copy as u8;
            break;
        }
    }
    for x in min {
        print!("{}",x);
    }

}

fn main() {
    let mut buf : String = String::new();
    read_line(&mut buf);
    let mut string_iter = buf.trim().split_whitespace();
    let m = string_iter.next().unwrap().parse::<i32>().unwrap();
    let n = string_iter.next().unwrap().parse::<i32>().unwrap();

    if !is_valid(m,n) {
        if m==1 && n==0 {
            println!("0 0");
        }
        else{
            println!("-1 -1");
        }
    }
    else {
        get_min(m,n);
        get_max(m,n);
    }
}

use std::io;
use std::io::Stdin;
use std::str::FromStr;

fn read_line(stdin : &Stdin, line : &mut String) {
    match stdin.read_line(line) {
        Ok(_) => return,
        Err(msg) => panic!("Could not read line! Message: {}.", msg),
    }
}

fn parse_t<T : FromStr>(s : &str) -> T {
    match s.trim().parse() {
        Ok(y) => y,
        Err(_) => panic!("Could not read from string!"),
    }
}

fn read_ts<T : FromStr>(stdin : &Stdin, ts : &mut Vec<T>) {
    let mut line = String::new();
    read_line(stdin, &mut line);
    let word_iter = line.split_whitespace();
    for word in word_iter {
        let x = parse_t(word);
        ts.push(x);
    }
}

fn max_num_with_m_digits_and_digit_sum(m : usize, s : usize, max_num : &mut Vec<u8>) {
    if (m * 9) < s {
        // Do nothing ...
    } else {
        if s == 0 {
            if m == 1 {
                max_num.push(0);
            } else {
                // Do nothing ...
            }
        } else {
            let mut cur_sum = 0;
            for _ in 0 .. m {
                let diff = s - cur_sum;
                if diff >= 9 {
                    max_num.push(9);
                    cur_sum = cur_sum + 9;
                } else {
                    max_num.push(diff as u8);
                    cur_sum = cur_sum + diff;
                }
            }
        }
    }
}

fn min_num_with_m_digits_and_digit_sum(m : usize, max_num : &mut Vec<u8>) {
    if max_num.is_empty() {
        // Do nothing ...
    } else {
        max_num.reverse();
        if max_num[0] == 0 {
            if m == 1 {
                // Do nothing ...
            } else {
                max_num[0] = 1;
                for i in 1 .. m {
                    if max_num[i] == 0 {
                        // Do nothing ...
                    } else {
                        max_num[i] = max_num[i] - 1;
                        break;
                    }
                }
            }
        }
    }
}

fn print_vec(v : &Vec<u8>) {
    for &x in v.iter() {
        print!("{}", x);
    }
}

fn main() {
    let stdin = io::stdin();
    let mut m_s = vec![];
    read_ts(&stdin, &mut m_s);
    let m = m_s[0];
    let s = m_s[1];
    let mut max_num = vec![];
    max_num_with_m_digits_and_digit_sum(m, s, &mut max_num);
    if max_num.is_empty() {
        println!("-1 -1");
    } else {
        let mut max_num_copy = max_num.to_vec();
        min_num_with_m_digits_and_digit_sum(m, &mut max_num_copy);
        print_vec(&max_num_copy);
        print!(" ");
        print_vec(&max_num);
        println!();
    }
}

fn solve() {
    let (m, s): (i32, i32) = {
        let mut buf = String::new();
        std::io::stdin().read_line(&mut buf).unwrap();
        let mut ws = buf.split_whitespace();
        let m = ws.next().unwrap().parse().unwrap();
        let s = ws.next().unwrap().parse().unwrap();
        (m, s)
    };

    if s == 0 {
        match m {
            1 => println!("0 0"),
            _ => println!("-1 -1"),
        }
        return;
    }
    if s > 9 * m {
        println!("-1 -1");
        return;
    }

    let check = |m: i32, s: i32| (s >= 0) && s <= 9 * m;

    let mut min = String::new();
    let mut sum = s;
    for i in 0..m {
        for d in 0..10 {
            if (i > 0 || d > 0 || (m == 1 && d == 0)) && check(m - i - 1, sum - d) {
                sum -= d;
                min.push_str(&d.to_string());
                break;
            }
        }
    }

    let mut max = String::new();
    sum = s;
    for i in 0..m {
        for d in (0..10).rev() {
            if (i > 0 || d > 0 || (m == 1 && d == 0)) && check(m - i - 1, sum - d) {
                sum -= d;
                max.push_str(&d.to_string());
                break;
            }
        }
    }

    println!("{} {}", min, max);
}

fn main() {
    // let t: u32 = {
    //     let mut buf = String::new();
    //     std::io::stdin().read_line(&mut buf).unwrap();
    //     buf.trim_end().parse().unwrap()
    // };

    // for _ in 0..t {}
    solve();
}

#![allow(unused_imports)]
#![allow(unused_macros)]
use std::io::{StdinLock, stdin, BufRead};
use std::collections::*;
use std::cmp::*;

fn scan_helper(lock : &mut StdinLock) -> String {
    let mut buffer = String::new();
    lock.read_line(&mut buffer).ok();
    buffer
}

macro_rules! scan {
    ($lock:ident, $t:ty) => ({
        scan_helper(&mut $lock).split_whitespace()
            .next().unwrap()
            .parse::<$t>().unwrap()
    });
    ($lock:ident, $($t:ty),+) => ({
        let buffer = scan_helper(&mut $lock);
        let mut iter = buffer.split_whitespace();
        ($(
            {
                iter.next().unwrap()
                    .parse::<$t>().unwrap()
            },
        )+)
    })
}

macro_rules! scan_iter {
    ($lock:ident, $t:ty) => ({
        scan_helper(&mut $lock).split_whitespace()
            .map(|x| x.parse::<$t>().unwrap())
            .collect()
    })
}

trait Ext {
    fn idx(&self) -> usize;
    fn num(&self) -> i64;
}

macro_rules! ext {
    ($t:ty) => (
        impl Ext for $t {
            #[inline]
            fn idx(&self) -> usize {
                *self as usize
            }

            #[inline]
            fn num(&self) -> i64 {
                *self as i64
            }
        }
    )
}
ext!(i64);
ext!(usize);

fn main() {
    let stdin = stdin();
    let mut s = stdin.lock();
    let (m, s) = scan!(s, usize, i64);
    let mut smallest = vec![0; m];
    let mut largest = vec![0; m];
    let lower_bound = if m == 1 { 0 } else { 1 };
    let upper_bound = (9*m).num();

    if s >= lower_bound && s <= upper_bound {
        let mut temp = s;
        for i in 0..m {
            if temp > 9 {
                largest[i] = 9;
                temp -= 9;
            } else {
                largest[i] = temp;
                break;
            }
        }

        temp = s;
        for i in (0..m).rev() {
            if temp > 9 {
                smallest[i] = 9;
                temp -= 9;
            } else {
                smallest[i] = temp - 1;
                smallest[0] += 1;
                break;
            }
        }

        let mut flag = false;
        for i in 0..m {
            if smallest[i] != 0 || flag {
                flag = true;
                print!("{}", smallest[i]);
            }
        }
        if !flag {
            print!("0");
        }
        print!(" ");

        flag = false;
        for i in 0..m {
            if largest[i] != 0 || flag {
                flag = true;
                print!("{}", largest[i]);
            }
        }
        if !flag {
            print!("0");
        }
    } else {
        println!("-1 -1");
    }
}

fn find_min(m: usize, s: usize) -> String {
    let mut num = vec![0; m];
    num[0] = 1;
    let mut i = m - 1;
    let mut sum = 1;

    while sum + 9 < s {
        num[i] = 9;
        i -= 1;
        sum += 9;
    }

    num[i] += (s - sum) as u8;
    vec_to_num(&num)
}

fn find_max(m: usize, s: usize) -> String {
    let mut num = vec![9; m];
    let mut i = m - 1;
    let mut sum = 9 * m;

    while sum - 9 > s {
        num[i] = 0;
        i -= 1;
        sum -= 9;
    }

    num[i] -= (sum - s) as u8;
    vec_to_num(&num)
}

fn vec_to_num(v: &Vec<u8>) -> String {
    v.into_iter()
        .map(|digit| (digit + 48) as char)
        .collect::<String>()
}

fn main() {
    let (m, s) = {
        let mut buf = String::new();
        std::io::stdin().read_line(&mut buf).unwrap();
        let temp: Vec<usize> = buf
            .trim()
            .split_whitespace()
            .map(|elem| elem.parse().unwrap())
            .collect();
        (temp[0], temp[1])
    };

    if s < 1 || s > 9 * m {
        println!("-1 -1");
    } else if m == 1 && s == 0 {
        println!("0 0");
    } else {
        println!("{} {}", find_min(m, s), find_max(m, s))
    }
}

fn find_min(m: usize, s: usize) -> String {
    let mut num = vec![0; m];
    num[0] = 1;
    let mut i = m - 1;
    let mut sum = 1;

    while sum + 9 < s {
        num[i] = 9;
        i -= 1;
        sum += 9;
    }

    num[i] += (s - sum) as u8;
    vec_to_num(&num)
}

fn find_max(m: usize, s: usize) -> String {
    let mut num = vec![9; m];
    let mut i = m - 1;
    let mut sum = 9 * m;

    while sum - 9 > s {
        num[i] = 0;
        i -= 1;
        sum -= 9;
    }

    num[i] -= (sum - s) as u8;
    vec_to_num(&num)
}

fn vec_to_num(v: &Vec<u8>) -> String {
    v.into_iter()
        .map(|digit| (digit + 48) as char)
        .collect::<String>()
}

fn main() {
    let (m, s) = {
        let mut buf = String::new();
        std::io::stdin().read_line(&mut buf).unwrap();
        let temp: Vec<usize> = buf
            .trim()
            .split_whitespace()
            .map(|elem| elem.parse().unwrap())
            .collect();
        (temp[0], temp[1])
    };

    if s < 1 || s > 9 * m {
        println!("-1 -1");
    } else if s == 1 && m == 0 {
        println!("0 0");
    } else {
        println!("{} {}", find_min(m, s), find_max(m, s))
    }
}

fn find_min(m: usize, s: usize) -> String {
    let mut num = vec![0; m];
    num[0] = 1;
    let mut i = m - 1;
    let mut sum = 1;

    while sum + 9 < s {
        num[i] = 9;
        i -= 1;
        sum += 9;
    }

    num[i] += (s - sum) as u8;
    vec_to_num(&num)
}

fn find_max(m: usize, s: usize) -> String {
    let mut num = vec![9; m];
    let mut i = m - 1;
    let mut sum = 9 * m;

    while sum - 9 > s {
        num[i] = 0;
        i -= 1;
        sum -= 9;
    }

    num[i] -= (sum - s) as u8;
    vec_to_num(&num)
}

fn vec_to_num(v: &Vec<u8>) -> String {
    v.into_iter()
        .map(|digit| (digit + 48) as char)
        .collect::<String>()
}

fn main() {
    let (m, s) = {
        let mut buf = String::new();
        std::io::stdin().read_line(&mut buf).unwrap();
        let temp: Vec<usize> = buf
            .trim()
            .split_whitespace()
            .map(|elem| elem.parse().unwrap())
            .collect();
        (temp[0], temp[1])
    };

    if s < 1 || s > 9 * m {
        println!("-1 -1");
    } else {
        println!("{} {}", find_min(m, s), find_max(m, s))
    }
}

fn find_min(m: usize, s: usize) -> String {
    let mut num = vec![0; m];
    num[0] = 1;
    let mut i = m - 1;
    let mut sum = 1;

    while sum + 9 < s {
        num[i] = 9;
        i -= 1;
        sum += 9;
    }

    num[i] += (s - sum) as u8;
    vec_to_num(&num)
}

fn find_max(m: usize, s: usize) -> String {
    let mut num = vec![9; m];
    let mut i = m - 1;
    let mut sum = 9 * m;

    while sum - 9 > s {
        num[i] = 0;
        i -= 1;
        sum -= 9;
    }

    num[i] -= (sum - s) as u8;
    vec_to_num(&num)
}

fn vec_to_num(v: &Vec<u8>) -> String {
    v.into_iter()
        .map(|digit| (digit + 48) as char)
        .collect::<String>()
}

fn main() {
    let (m, s) = {
        let mut buf = String::new();
        std::io::stdin().read_line(&mut buf).unwrap();
        let temp: Vec<usize> = buf
            .trim()
            .split_whitespace()
            .map(|elem| elem.parse().unwrap())
            .collect();
        (temp[0], temp[1])
    };

    if s < 2 || s > 9 * m {
        println!("-1 -1");
    } else {
        println!("{} {}", find_min(m, s), find_max(m, s))
    }
}

fn find_min(m: usize, s: usize) -> String {
    let mut num = vec![0; m];
    num[0] = 1;
    let mut i = m - 1;
    let mut sum = 1;

    while sum + 9 < s {
        num[i] = 9;
        i -= 1;
        sum += 9;
    }

    num[i] = (s - sum) as u8;
    vec_to_num(&num)
}

fn find_max(m: usize, s: usize) -> String {
    let mut num = vec![9; m];
    let mut i = m - 1;
    let mut sum = 9 * m;

    while sum - 9 > s {
        num[i] = 0;
        i -= 1;
        sum -= 9;
    }

    num[i] -= (sum - s) as u8;
    vec_to_num(&num)
}

fn vec_to_num(v: &Vec<u8>) -> String {
    v.into_iter()
        .map(|digit| (digit + 48) as char)
        .collect::<String>()
}

fn main() {
    let (m, s) = {
        let mut buf = String::new();
        std::io::stdin().read_line(&mut buf).unwrap();
        let temp: Vec<usize> = buf
            .trim()
            .split_whitespace()
            .map(|elem| elem.parse().unwrap())
            .collect();
        (temp[0], temp[1])
    };

    if s < 2 || s > 9 * m {
        println!("-1 -1");
    } else {
        println!("{} {}", find_min(m, s), find_max(m, s))
    }
}

fn get_max_digits(length: usize, sum: u32) -> Option<Vec<u32>> {
    if length == 0 {
        return None;
    }
    if (sum == 0) && (length > 1) {
        return None;
    }
    if sum == 0 {
        return Some(vec![0]);
    }
    let mut result: Vec<u32> = Vec::with_capacity(length);
    let mut rest_sum: u32 = sum;
    let first_digit: u32;
    if rest_sum > 9 {
        first_digit = 9;
    } else {
        first_digit = rest_sum;
    }
    result.push(first_digit);
    rest_sum -= first_digit;

    for _ in 1..length {
        let digit: u32;
        if rest_sum > 9 {
            digit = 9;
        } else {
            digit = rest_sum;
        }
        result.push(digit);
        rest_sum -= digit;
    }

    if rest_sum == 0 {
        return Some(result);
    } else {
        return None;
    }
}

fn get_min_digits(length: usize, sum: u32) -> Option<Vec<u32>> {
    if (sum == 0) && (length > 1) {
        return None;
    }
    if sum == 0 {
        return Some(vec![0]);
    }
    let mut result: Vec<u32> = Vec::with_capacity(length);
    let mut rest_sum: u32 = sum - 1;

    for _ in 1..length {
        let digit: u32;
        if rest_sum > 9 {
            digit = 9;
        } else {
            digit = rest_sum;
        }
        result.push(digit);
        rest_sum -= digit;
    }

    if rest_sum >= 9 {
        return None;
    }

    let last_digit: u32 = rest_sum + 1;
    result.push(last_digit);

    result.reverse();
    return Some(result);
}

#[cfg(test)]
mod tests {
    use super::{get_max_digits, get_min_digits};

    #[test]
    fn test1() {
        assert_eq!(get_max_digits(2, 15), Some(vec![9, 6]));
        assert_eq!(get_min_digits(2, 15), Some(vec![6, 9]));
    }
    #[test]
    fn test2() {
        assert_eq!(get_max_digits(3, 0), None);
        assert_eq!(get_min_digits(3, 0), None);
    }
    #[test]
    fn test3() {
        assert_eq!(get_max_digits(1, 0), Some(vec![0]));
        assert_eq!(get_min_digits(1, 0), Some(vec![0]));
    }
    #[test]
    fn test4() {
        assert_eq!(get_max_digits(1, 9), Some(vec![9]));
        assert_eq!(get_min_digits(1, 9), Some(vec![9]));
    }
    #[test]
    fn test5() {
        assert_eq!(get_max_digits(2, 12), Some(vec![9, 3]));
        assert_eq!(get_min_digits(2, 12), Some(vec![3, 9]));
    }
}

use std::io::{stdin, stdout, BufRead, Write};

fn main() {
    let stdin = stdin();
    let mut stdin_lock = stdin.lock();

    let stdout = stdout();
    let mut stdout_lock = stdout.lock();

    let mut input_str: String = String::new();
    stdin_lock.read_line(&mut input_str).unwrap();
    let mut input_tokens = input_str.trim().split_whitespace();
    let length: usize = input_tokens.next().unwrap().parse().unwrap();
    let sum: u32 = input_tokens.next().unwrap().parse().unwrap();

    if let Some(max_digits_array) = get_max_digits(length, sum) {
        for digit in max_digits_array {
            write!(stdout_lock, "{}", digit).unwrap();
        }
    } else {
        write!(stdout_lock, "-1").unwrap();
    }
    write!(stdout_lock, " ").unwrap();

    if let Some(min_digits_array) = get_min_digits(length, sum) {
        for digit in min_digits_array {
            write!(stdout_lock, "{}", digit).unwrap();
        }
    } else {
        write!(stdout_lock, "-1").unwrap();
    }

    writeln!(stdout_lock, "").unwrap();
}

fn get_max_digits(length: usize, sum: u32) -> Option<Vec<u32>> {
    if length == 0 {
        return None;
    }
    if (sum == 0) && (length > 1) {
        return None;
    }
    if sum == 0 {
        return Some(vec![0]);
    }
    let mut result: Vec<u32> = Vec::with_capacity(length);
    let mut rest_sum: u32 = sum;
    let first_digit: u32;
    if rest_sum > 9 {
        first_digit = 9;
    } else {
        first_digit = rest_sum;
    }
    result.push(first_digit);
    rest_sum -= first_digit;

    for _ in 1..length {
        let digit: u32;
        if rest_sum > 9 {
            digit = 9;
        } else {
            digit = rest_sum;
        }
        result.push(digit);
        rest_sum -= digit;
    }

    if rest_sum == 0 {
        return Some(result);
    } else {
        return None;
    }
}

fn get_min_digits(length: usize, sum: u32) -> Option<Vec<u32>> {
    if (sum == 0) && (length > 1) {
        return None;
    }
    if sum == 0 {
        return Some(vec![0]);
    }
    let mut result: Vec<u32> = Vec::with_capacity(length);
    let mut rest_sum: u32 = sum - 1;

    for _ in 1..length {
        let digit: u32;
        if rest_sum > 9 {
            digit = 9;
        } else {
            digit = rest_sum;
        }
        result.push(digit);
        rest_sum -= digit;
    }

    if rest_sum >= 9 {
        return None;
    }

    let last_digit: u32 = rest_sum + 1;
    result.push(last_digit);

    result.reverse();
    return Some(result);
}

#[cfg(test)]
mod tests {
    use super::{get_max_digits, get_min_digits};

    #[test]
    fn test1() {
        assert_eq!(get_max_digits(2, 15), Some(vec![9, 6]));
        assert_eq!(get_min_digits(2, 15), Some(vec![6, 9]));
    }
    #[test]
    fn test2() {
        assert_eq!(get_max_digits(3, 0), None);
        assert_eq!(get_min_digits(3, 0), None);
    }
    #[test]
    fn test3() {
        assert_eq!(get_max_digits(1, 0), Some(vec![0]));
        assert_eq!(get_min_digits(1, 0), Some(vec![0]));
    }
    #[test]
    fn test4() {
        assert_eq!(get_max_digits(1, 9), Some(vec![9]));
        assert_eq!(get_min_digits(1, 9), Some(vec![9]));
    }
    #[test]
    fn test5() {
        assert_eq!(get_max_digits(2, 12), Some(vec![9, 3]));
        assert_eq!(get_min_digits(2, 12), Some(vec![3, 9]));
    }
}

use std::io::{stdin, stdout, BufRead, Write};

fn main() {
    let stdin = stdin();
    let mut stdin_lock = stdin.lock();

    let stdout = stdout();
    let mut stdout_lock = stdout.lock();

    let mut input_str: String = String::new();
    stdin_lock.read_line(&mut input_str).unwrap();
    let mut input_tokens = input_str.trim().split_whitespace();
    let length: usize = input_tokens.next().unwrap().parse().unwrap();
    let sum: u32 = input_tokens.next().unwrap().parse().unwrap();

    if let Some(min_digits_array) = get_min_digits(length, sum) {
        for digit in min_digits_array {
            write!(stdout_lock, "{}", digit).unwrap();
        }
    } else {
        write!(stdout_lock, "-1").unwrap();
    }

    if let Some(max_digits_array) = get_max_digits(length, sum) {
        for digit in max_digits_array {
            write!(stdout_lock, "{}", digit).unwrap();
        }
    } else {
        write!(stdout_lock, "-1").unwrap();
    }
    write!(stdout_lock, " ").unwrap();

    writeln!(stdout_lock, "").unwrap();
}

use std::io;
use std::cmp;
use std::process;
fn main()
{
    let mut s=String::new();
    io::stdin().read_line(&mut s).expect("read error");
    let vec=s.split_whitespace()
        .map(|x|
            x.parse::<i64>().expect("parse error"))
        .collect::<Vec<i64>>();
    if (vec[0]>1 && vec[1]<1) || (vec[0]*9<vec[1]){
        println!("-1 -1");
        process::exit(0);
    }
    let mut ans1=String::new();
    let mut ans2=String::new();
    let mut n1=vec[0];
    let mut n2=vec[1];

    while n1>0
    {
        n1=n1-1;
        let x:i64=cmp::min(9,n2);
        n2-=x;
        ans1+=&x.to_string();
    }
    n1=vec[0];
    n2=vec[1];
    while n1>0{
        n1=n1-1;
        let mut x:i64=0;
        if n1==vec[0]-1{
            x=1;
        }
        x=cmp::max(x,n2-9*n1);
        n2-=x;
        ans2+=&x.to_string();
    }
    println!("{} {}",ans2,ans1);
}

use std::io;
use std::cmp;
use std::process;
fn main()
{
    let mut s=String::new();
    io::stdin().read_line(&mut s).expect("read error");
    let mut vec=s.split_whitespace()
        .map(|x|
            x.parse::<i64>().expect("parse error"))
        .collect::<Vec<i64>>();
    if (vec[0]>1 && vec[1]<2) || (vec[0]*9<vec[1]){
        println!("-1 -1");
        process::exit(0);
    }
    let mut ans=String::new();
    while vec[0]>0
    {
        vec[0]=vec[0]-1;
        if vec[0]==0{
            ans=ans+&vec[1].to_string();
        }
        else{
            let x: i64=cmp::min(9,vec[1]-1);
            ans=ans+&x.to_string();
            vec[1]=vec[1]-x;
        }
    }
    println!("{} {}",ans.chars().rev().collect::<String>(),ans);
}

use std::io;
use std::cmp;
use std::process;
fn main()
{
    let mut s=String::new();
    io::stdin().read_line(&mut s).expect("read error");
    let mut vec=s.split_whitespace()
        .map(|x|
            x.parse::<i64>().expect("parse error"))
        .collect::<Vec<i64>>();
    if (vec[0]>1 && vec[1]<1) || (vec[0]*9<vec[1]){
        println!("-1 -1");
        process::exit(0);
    }
    let mut ans=String::new();
    if vec[1]==1
    {
        ans+="1";
        vec[0]=vec[0]-1;
        while vec[0]>0
        {
            vec[0]=vec[0]-1;
            ans+="0";
        }
        println!("{} {}",ans, ans);
        process::exit(0);
    }
    while vec[0]>0
    {
        vec[0]=vec[0]-1;
        if vec[0]==0{
            ans=ans+&vec[1].to_string();
        }
        else{
            let x: i64=cmp::min(9,vec[1]-1);
            ans=ans+&x.to_string();
            vec[1]=vec[1]-x;
        }
    }
    println!("{} {}",ans.chars().rev().collect::<String>(),ans);
}

fn main() -> Result<(), Box<dyn std::error::Error>> {
    let data = read_input();
    let (len, sum) = (data[0], data[1]);

    if sum == 0 || (sum == 1 && len > 1) || 9 * len < sum {
        println!("-1 -1");
        return Ok(());
    }

    if (sum >= 1 && sum <= 9) && (len == 1) {
        println!("{} {}", sum, sum);
        return Ok(());
    }

    if sum % 9 == 0 && sum / 9 == len {
        let mut ans = String::with_capacity(len);
        for _ in 0..len {
            ans.push('9')
        }
        println!("{} {}", ans, ans);
        return Ok(());
    }

    let mut digits = vec![0; len];

    let nines = sum / 9;
    let rem = sum % 9;

    let start = len - 1 - nines;
    for i in (start..len).rev() {
        digits[i] = 9;
    }

    if len - nines > 1 {
        if rem > 0 {
            digits[start - 1] = rem - 1;
            digits[0] = 1;
        } else {
            digits[start] -= 1;
            digits[0] = 1;
        }
    } else {
        if rem > 0 {
            digits[0] = rem;
        } else {
            digits[start] -= 1;
            digits[0] = 1;
        }
    }

    for d in digits.iter() {
        print!("{}", d);
    }
    print!(" ");

    for d in digits.iter().rev() {
        print!("{}", d);
    }
    println!();

    Ok(())
}

fn read_input() -> Vec<usize> {
    let mut buffer = String::new();

    std::io::stdin()
        .read_line(&mut buffer)
        .expect("Failed to get input");

    buffer
        .trim()
        .split_whitespace()
        .map(|x| x.parse().expect("Failed to parse number"))
        .collect()
}

fn main() -> Result<(), Box<dyn std::error::Error>> {
    let data = read_input();
    let (len, sum) = (data[0], data[1]);

    if sum == 0 || 9 * len < sum {
        println!("-1 -1");
        return Ok(());
    }

    if sum == 1 {
        let mut ans = String::with_capacity(len);
        ans.push('1');

        for _ in 1..len {
            ans.push('0');
        }
        println!("{} {}", ans, ans);
        return Ok(());
    }

    if (sum >= 1 && sum <= 9) && (len == 1) {
        println!("{} {}", sum, sum);
        return Ok(());
    }

    if sum % 9 == 0 && sum / 9 == len {
        let mut ans = String::with_capacity(len);
        for _ in 0..len {
            ans.push('9')
        }
        println!("{} {}", ans, ans);
        return Ok(());
    }

    let mut digits = vec![0; len];

    let nines = sum / 9;
    let rem = sum % 9;

    let start = len - 1 - nines;
    for i in (start..len).rev() {
        digits[i] = 9;
    }

    if len - nines > 1 {
        if rem > 0 {
            digits[start - 1] = rem - 1;
            digits[0] = 1;
        } else {
            digits[start] -= 1;
            digits[0] = 1;
        }
    } else {
        if rem > 0 {
            digits[0] = rem;
        } else {
            digits[start] -= 1;
            digits[0] = 1;
        }
    }

    for d in digits.iter() {
        print!("{}", d);
    }
    print!(" ");

    for d in digits.iter().rev() {
        print!("{}", d);
    }
    println!();

    Ok(())
}

fn read_input() -> Vec<usize> {
    let mut buffer = String::new();

    std::io::stdin()
        .read_line(&mut buffer)
        .expect("Failed to get input");

    buffer
        .trim()
        .split_whitespace()
        .map(|x| x.parse().expect("Failed to parse number"))
        .collect()
}

fn main() -> Result<(), Box<dyn std::error::Error>> {
    let data = read_input();
    let (len, sum) = (data[0], data[1]);

    if 9 * len < sum {
        println!("-1 -1");
        return Ok(());
    }

    if sum == 0 {
        println!("0 0");
        return Ok(());
    }

    if sum == 1 {
        let mut ans = String::with_capacity(len);
        ans.push('1');

        for _ in 1..len {
            ans.push('0');
        }
        println!("{} {}", ans, ans);
        return Ok(());
    }

    if (sum >= 1 && sum <= 9) && (len == 1) {
        println!("{} {}", sum, sum);
        return Ok(());
    }

    if sum % 9 == 0 && sum / 9 == len {
        let mut ans = String::with_capacity(len);
        for _ in 0..len {
            ans.push('9')
        }
        println!("{} {}", ans, ans);
        return Ok(());
    }

    let mut digits = vec![0; len];
    let mut max_digits = vec![0; len];

    let nines = sum / 9;
    let rem = sum % 9;

    let start = len - nines;
    for i in (start..len).rev() {
        digits[i] = 9;
    }

    if len - nines > 1 {
        if rem > 0 {
            digits[start - 1] = rem - 1;
            digits[0] = 1;
        } else {
            digits[start] -= 1;
            digits[0] = 1;
        }
    } else {
        if rem > 0 {
            digits[0] = rem;
        } else {
            digits[start] -= 1;
            digits[0] = 1;
        }
    }

    for i in 0..nines {
        max_digits[i] = 9;
    }
    if rem != 0 {
        max_digits[nines] = rem;
    }

    for d in digits {
        print!("{}", d);
    }
    print!(" ");

    for d in max_digits {
        print!("{}", d);
    }
    println!();

    Ok(())
}

fn read_input() -> Vec<usize> {
    let mut buffer = String::new();

    std::io::stdin()
        .read_line(&mut buffer)
        .expect("Failed to get input");

    buffer
        .trim()
        .split_whitespace()
        .map(|x| x.parse().expect("Failed to parse number"))
        .collect()
}

fn main() -> Result<(), Box<dyn std::error::Error>> {
    let data = read_input();
    let (len, sum) = (data[0], data[1]);

    if sum == 0 || 9 * len < sum {
        println!("-1 -1");
        return Ok(());
    }

    if sum == 1 {
        let mut ans = String::with_capacity(len);
        ans.push('1');

        for _ in 1..len {
            ans.push('0');
        }
        println!("{} {}", ans, ans);
        return Ok(());
    }

    if (sum >= 1 && sum <= 9) && (len == 1) {
        println!("{} {}", sum, sum);
        return Ok(());
    }

    if sum % 9 == 0 && sum / 9 == len {
        let mut ans = String::with_capacity(len);
        for _ in 0..len {
            ans.push('9')
        }
        println!("{} {}", ans, ans);
        return Ok(());
    }

    let mut digits = vec![0; len];
    let mut max_digits = vec![0; len];

    let nines = sum / 9;
    let rem = sum % 9;

    let start = len - nines;
    for i in (start..len).rev() {
        digits[i] = 9;
    }

    if len - nines > 1 {
        if rem > 0 {
            digits[start - 1] = rem - 1;
            digits[0] = 1;
        } else {
            digits[start] -= 1;
            digits[0] = 1;
        }
    } else {
        if rem > 0 {
            digits[0] = rem;
        } else {
            digits[start] -= 1;
            digits[0] = 1;
        }
    }

    for i in 0..nines {
        max_digits[i] = 9;
    }
    if rem != 0 {
        max_digits[nines] = rem;
    }

    for d in digits {
        print!("{}", d);
    }
    print!(" ");

    for d in max_digits {
        print!("{}", d);
    }
    println!();

    Ok(())
}

fn read_input() -> Vec<usize> {
    let mut buffer = String::new();

    std::io::stdin()
        .read_line(&mut buffer)
        .expect("Failed to get input");

    buffer
        .trim()
        .split_whitespace()
        .map(|x| x.parse().expect("Failed to parse number"))
        .collect()
}

// https://codeforces.com/problemset/problem/489/C
use std::io;
use std::char;

fn reverse(cadena: &String) -> String {
    let mut ans = String::from("");
    for ch in cadena.chars().rev() {
        ans.push(ch);
    }
    ans
}

fn main() {
    let mut line = String::new();

    io::stdin()
        .read_line(&mut line)
        .unwrap();

    let words: Vec<i64> =
        line
        .split_whitespace()
        .map(|x| x.parse().unwrap())
        .collect();

    let m = words[0] as usize;
    let mut s = words[1];
    let mut _t = words[1];

    if s == 0 {
        println!("-1 -1");
        return;
    }

    // lets construct maxima
    let mut maxima = String::from("");

    while s > 0 {
        if s >= 9 {
            maxima = format!("9{}", maxima);
            s -= 9;
        } else {
            maxima = format!("{}{}", maxima, s);
            s -= s;
        }
    }

    if maxima.len() > m {
        maxima = String::from("-1");
    }

    while maxima.len() < m {
        maxima = format!("{}0", maxima);
    }

    // lets construct minima
    let mut chars: Vec<char> = reverse(&maxima).chars().collect();
    let mut minima = String::from("");

    if chars[0] == '0' {
        chars[0] = '1';
        for i in 1..chars.len() {
            if chars[i] != '0' {
                chars[i] = char::from_digit(chars[i].to_digit(10).unwrap()-1,10).unwrap();
                break;
            }
        }
    }

    for ch in chars {
        minima.push(ch);
    }

    println!("{} {}", minima, maxima);
}

// https://codeforces.com/problemset/problem/489/C
use std::io;
use std::char;

fn reverse(cadena: &String) -> String {
    let mut ans = String::from("");
    for ch in cadena.chars().rev() {
        ans.push(ch);
    }
    ans
}

fn main() {
    let mut line = String::new();

    io::stdin()
        .read_line(&mut line)
        .unwrap();

    let words: Vec<i64> =
        line
        .split_whitespace()
        .map(|x| x.parse().unwrap())
        .collect();

    let m = words[0] as usize;
    let mut s = words[1];
    let mut _t = words[1];

    if s == 0 {
        println!("-1 -1");
        return;
    }

    // lets construct maxima
    let mut maxima = String::from("");

    while s > 0 {
        if s >= 9 {
            maxima = format!("9{}", maxima);
            s -= 9;
        } else {
            maxima = format!("{}{}", maxima, s);
            s -= s;
        }
    }

    if maxima.len() > m {
        maxima = String::from("-1");
    }

    while maxima.len() < m {
        maxima = format!("{}0", maxima);
    }

    // lets construct minima
    let mut chars: Vec<char> = reverse(&maxima).chars().collect();
    let mut minima = String::from("");

    if chars[0] == '0' {
        chars[0] = '1';
        for i in 1..chars.len() {
            if chars[i] != '0' {
                chars[i] = char::from_digit(chars[i].to_digit(10).unwrap()-1,10).unwrap();
                break;
            }
        }
    }

    for ch in chars {
        minima.push(ch);
    }

    if maxima == "-1" {
        minima = String::from("-1");
    }

    println!("{} {}", minima, maxima);
}

// https://codeforces.com/problemset/problem/489/C
use std::io;
use std::char;

fn reverse(cadena: &String) -> String {
    let mut ans = String::from("");
    for ch in cadena.chars().rev() {
        ans.push(ch);
    }
    ans
}

fn main() {
    let mut line = String::new();

    io::stdin()
        .read_line(&mut line)
        .unwrap();

    let words: Vec<i64> =
        line
        .split_whitespace()
        .map(|x| x.parse().unwrap())
        .collect();

    let m = words[0] as usize;
    let mut s = words[1];
    let mut _t = words[1];

    if s == 0 && m != 1 {
        println!("-1 -1");
        return;
    }

    if s == 0 && m == 1 {
        println!("0 0");
        return;
    }

    // lets construct maxima
    let mut maxima = String::from("");

    while s > 0 {
        if s >= 9 {
            maxima = format!("9{}", maxima);
            s -= 9;
        } else {
            maxima = format!("{}{}", maxima, s);
            s -= s;
        }
    }

    if maxima.len() > m {
        maxima = String::from("-1");
    }

    while maxima.len() < m {
        maxima = format!("{}0", maxima);
    }

    // lets construct minima
    let mut chars: Vec<char> = reverse(&maxima).chars().collect();
    let mut minima = String::from("");

    if chars[0] == '0' {
        chars[0] = '1';
        for i in 1..chars.len() {
            if chars[i] != '0' {
                chars[i] = char::from_digit(chars[i].to_digit(10).unwrap()-1,10).unwrap();
                break;
            }
        }
    }

    for ch in chars {
        minima.push(ch);
    }

    if maxima == "-1" {
        minima = String::from("-1");
    }

    println!("{} {}", minima, maxima);
}

// https://codeforces.com/problemset/problem/489/C
use std::io;
use std::char;

fn reverse(cadena: &String) -> String {
    let mut ans = String::from("");
    for ch in cadena.chars().rev() {
        ans.push(ch);
    }
    ans
}

fn main() {
    let mut line = String::new();

    io::stdin()
        .read_line(&mut line)
        .unwrap();

    let words: Vec<i64> =
        line
        .split_whitespace()
        .map(|x| x.parse().unwrap())
        .collect();

    let m = words[0] as usize;
    let mut s = words[1];
    let mut _t = words[1];

    if s == 0 {
        println!("-1 -1");
        return;
    }

    // lets construct maxima
    let mut maxima = String::from("");

    while s > 0 {
        if s >= 9 {
            maxima = format!("9{}", maxima);
            s -= 9;
        } else {
            maxima = format!("{}{}", maxima, s);
            s -= s;
        }
    }

    if maxima.len() > m {
        maxima = String::from("-1");
    }

    while maxima.len() < m {
        maxima = format!("{}0", maxima);
    }

    // lets construct minima
    let mut chars: Vec<char> = reverse(&maxima).chars().collect();
    let mut minima = String::from("");

    if chars[0] == '0' {
        chars[0] = '1';
    }

    for i in 1..chars.len() {
        if chars[i] != '0' {
            chars[i] = char::from_digit(chars[i].to_digit(10).unwrap()-1,10).unwrap();
            break;
        }
    }

    for ch in chars {
        minima.push(ch);
    }

    println!("{} {}", maxima, minima);
}

// https://codeforces.com/problemset/problem/489/C
use std::io;
use std::char;

fn reverse(cadena: &String) -> String {
    let mut ans = String::from("");
    for ch in cadena.chars().rev() {
        ans.push(ch);
    }
    ans
}

fn main() {
    let mut line = String::new();

    io::stdin()
        .read_line(&mut line)
        .unwrap();

    let words: Vec<i64> =
        line
        .split_whitespace()
        .map(|x| x.parse().unwrap())
        .collect();

    let m = words[0] as usize;
    let mut s = words[1];
    let mut _t = words[1];

    if s == 0 {
        println!("-1 -1");
        return;
    }

    // lets construct maxima
    let mut maxima = String::from("");

    while s > 0 {
        if s >= 9 {
            maxima = format!("9{}", maxima);
            s -= 9;
        } else {
            maxima = format!("{}{}", maxima, s);
            s -= s;
        }
    }

    if maxima.len() > m {
        maxima = String::from("-1");
    }

    while maxima.len() < m {
        maxima = format!("{}0", maxima);
    }

    // lets construct minima
    let mut chars: Vec<char> = reverse(&maxima).chars().collect();
    let mut minima = String::from("");

    if chars[0] == '0' {
        chars[0] = '1';
        for i in 1..chars.len() {
            if chars[i] != '0' {
                chars[i] = char::from_digit(chars[i].to_digit(10).unwrap()-1,10).unwrap();
                break;
            }
        }
    }

    for ch in chars {
        minima.push(ch);
    }

    println!("{} {}", maxima, minima);
}

struct Scan {
    buffer: std::collections::VecDeque<String>
}

impl Scan {
    fn new() -> Scan {
        Scan { buffer: std::collections::VecDeque::new() }
    }

    fn next<T: std::str::FromStr>(&mut self)-> T {
        loop {
            if let Some(token) = self.buffer.pop_front() {
                break token.parse::<T>().ok().unwrap();
            }
            let mut line = String::new();
            std::io::stdin().read_line(&mut line).expect("Fail to read");
            self.buffer = line.split_whitespace().map(String::from).collect();
        }
    }

}

fn _main() {
    let mut scan = Scan::new();
    let m: isize = scan.next();
    let s: isize = scan.next();
    let nnines = s / 9;
    let last = s % 9;
    if nnines > m {
        println!("-1 -1");
    } else {
        let sol_max = format!("{}{}{}", "9".repeat(nnines as usize), last,
            "0".repeat((m -nnines -1).max(0) as usize));
        let mut sol_min: String = String::new();
        if nnines == 0 {
            sol_min = format!("1{}{}","0".repeat((m -2).max(0) as usize ), last-1);
        } else {
            if last == 0 {
                sol_min = format!("1{}8{}", "0".repeat((m -nnines -1).max(0) as usize),
                    "9".repeat((nnines -1).max(0) as usize));
            } else {
                sol_min = format!("{}{}{}", last,
                    "0".repeat((m -nnines -1).max(0) as usize),
                    "9".repeat(nnines as usize));
            }
        }
        println!("{} {}", sol_min, sol_max);
    }
}

fn main() {
    std::thread::Builder::new()
        .stack_size(1<<23).spawn(_main).unwrap().join().unwrap();
}

struct Scan {
    buffer: std::collections::VecDeque<String>
}

impl Scan {
    fn new() -> Scan {
        Scan { buffer: std::collections::VecDeque::new() }
    }

    fn next<T: std::str::FromStr>(&mut self)-> T {
        loop {
            if let Some(token) = self.buffer.pop_front() {
                break token.parse::<T>().ok().unwrap();
            }
            let mut line = String::new();
            std::io::stdin().read_line(&mut line).expect("Fail to read");
            self.buffer = line.split_whitespace().map(String::from).collect();
        }
    }

}

fn _main() {
    let mut scan = Scan::new();
    let m: isize = scan.next();
    let s: isize = scan.next();
    let nnines = s / 9;
    let last = s % 9;
    if nnines > m || m>1 && s == 0 {
        println!("-1 -1");
    } else if m == 1 && s == 0 {
        println!("0 0");
    } else {
        let sol_max = format!("{}{}{}", "9".repeat(nnines as usize), last,
            "0".repeat((m -nnines -1).max(0) as usize));
        let mut sol_min: String = String::new();
        if nnines == 0 {
            sol_min = format!("1{}{}","0".repeat((m -2).max(0) as usize ), last-1);
        } else {
            if last == 0 {
                sol_min = format!("1{}8{}", "0".repeat((m -nnines -1).max(0) as usize),
                    "9".repeat((nnines -1).max(0) as usize));
            } else {
                sol_min = format!("{}{}{}", last,
                    "0".repeat((m -nnines -1).max(0) as usize),
                    "9".repeat(nnines as usize));
            }
        }
        println!("{} {}", sol_min, sol_max);
    }
}

fn main() {
    std::thread::Builder::new()
        .stack_size(1<<23).spawn(_main).unwrap().join().unwrap();
}

struct Scan {
    buffer: std::collections::VecDeque<String>
}

impl Scan {
    fn new() -> Scan {
        Scan { buffer: std::collections::VecDeque::new() }
    }

    fn next<T: std::str::FromStr>(&mut self)-> T {
        loop {
            if let Some(token) = self.buffer.pop_front() {
                break token.parse::<T>().ok().unwrap();
            }
            let mut line = String::new();
            std::io::stdin().read_line(&mut line).expect("Fail to read");
            self.buffer = line.split_whitespace().map(String::from).collect();
        }
    }

}

fn _main() {
    let mut scan = Scan::new();
    let m: isize = scan.next();
    let s: isize = scan.next();
    let nnines = s / 9;
    let last = s % 9;
    if nnines > m || nnines == m && last != 0 || m>1 && s == 0 {
        println!("-1 -1");
    } else if m == 1 && s == 0 {
        println!("0 0");
    } else if m == 1 {
        println!("{} {}", s, s);
    } else {
        let sol_max = format!("{}{}{}", "9".repeat(nnines as usize), last,
            "0".repeat((m -nnines -1).max(0) as usize));
        let mut sol_min: String = String::new();
        if nnines == 0 {
            sol_min = format!("1{}{}","0".repeat((m -2).max(0) as usize ), last-1);
        } else {
            if last == 0 && m>1 {
                sol_min = format!("1{}8{}", "0".repeat((m -nnines -1).max(0) as usize),
                    "9".repeat((nnines -1).max(0) as usize));
            } else {
                sol_min = format!("{}{}{}", last,
                    "0".repeat((m -nnines -1).max(0) as usize),
                    "9".repeat(nnines as usize));
            }
        }
        println!("{} {}", sol_min, sol_max);
    }
}

fn main() {
    std::thread::Builder::new()
        .stack_size(1<<23).spawn(_main).unwrap().join().unwrap();
}

struct Scan {
    buffer: std::collections::VecDeque<String>
}

impl Scan {
    fn new() -> Scan {
        Scan { buffer: std::collections::VecDeque::new() }
    }

    fn next<T: std::str::FromStr>(&mut self)-> T {
        loop {
            if let Some(token) = self.buffer.pop_front() {
                break token.parse::<T>().ok().unwrap();
            }
            let mut line = String::new();
            std::io::stdin().read_line(&mut line).expect("Fail to read");
            self.buffer = line.split_whitespace().map(String::from).collect();
        }
    }

}

fn _main() {
    let mut scan = Scan::new();
    let m: isize = scan.next();
    let s: isize = scan.next();
    let nnines = s / 9;
    let last = s % 9;
    if nnines > m || nnines == m && last != 0 || m>1 && s == 0 {
        println!("-1 -1");
    } else if m == 1 && s == 0 {
        println!("0 0");
    } else if m == 1 {
        println!("{} {}", s, s);
    } else if nnines == m {
        let sol = format!("{}", "9".repeat(nnines as usize));
        println!("{} {}", sol, sol);
    } else {
        let sol_max = format!("{}{}{}", "9".repeat(nnines as usize), last,
            "0".repeat((m -nnines -1).max(0) as usize));
        let mut sol_min: String = String::new();
        if nnines == 0 {
            sol_min = format!("1{}{}","0".repeat((m - 2).max(0) as usize ), last-1);
        } else {
            if last == 0 {
                sol_min = format!("1{}8{}", "0".repeat((m -nnines -1).max(0) as usize),
                    "9".repeat((nnines -1).max(0) as usize));
            } else {
                sol_min = format!("{}{}{}", last,
                    "0".repeat((m -nnines -1).max(0) as usize),
                    "9".repeat(nnines as usize));
            }
        }
        println!("{} {}", sol_min, sol_max);
    }
}

fn main() {
    std::thread::Builder::new()
        .stack_size(1<<23).spawn(_main).unwrap().join().unwrap();
}

use std::io;

fn read_line(buf: &mut String) {
    buf.clear();
    match io::stdin().read_line(buf) {
        Err(error) => println!("error! {}",error),
        _ => {}
    }
}

fn is_valid(m: i32, n: i32) -> bool {
    if n==0 || n>9*m {
        return false;
    }
    return true;
}
fn get_max(m:i32,n:i32) {
    let mut max = Vec::<u8>::new();
    max.reserve(m as usize);
    for _ in 0..m {
        max.push(0);
    }
    let mut n_copy = n;
    for index in 0..m {
        if n_copy > 9 {
            max[index as usize]+=9;
            n_copy -= 9;
        }
        else {
            max[index as usize]+= n_copy as u8;
            break;
        }
    }
    print!(" ");
    for x in max {
        print!("{}",x);
    }
    println!("");

}
fn get_min(m:i32, n:i32) {
    let mut min = Vec::<u8>::new();
    min.reserve(m as usize);
    min.push(1);
    for _ in 1..m {
        min.push(0);
    }
    let mut n_copy = n-1;
    for index in (0..(m)).rev() {
        if n_copy > 9 {
            min[index as usize]+=9;
            n_copy -= 9;
        }
        else {
            min[index as usize]+= n_copy as u8;
            break;
        }
    }
    for x in min {
        print!("{}",x);
    }

}

fn main() {
    let mut buf : String = String::new();
    read_line(&mut buf);
    let mut string_iter = buf.trim().split_whitespace();
    let m = string_iter.next().unwrap().parse::<i32>().unwrap();
    let n = string_iter.next().unwrap().parse::<i32>().unwrap();

    if !is_valid(m,n) {
        println!{"-1 -1"};
    }
    else {
        get_min(m,n);
        get_max(m,n);
    }
}

use std::io;

fn read_line(buf: &mut String) {
    buf.clear();
    match io::stdin().read_line(buf) {
        Err(error) => println!("error! {}",error),
        _ => {}
    }
}

fn is_valid(m: i32, n: i32) -> bool {
    if n==0 || n>9*m {
        return false;
    }
    return true;
}
fn get_max(m:i32,n:i32) {
    let mut max = Vec::<u8>::new();
    max.reserve(m as usize);
    for _ in 0..m {
        max.push(0);
    }
    let mut n_copy = n;
    for index in 0..m {
        if n_copy > 9 {
            max[index as usize]+=9;
            n_copy -= 9;
        }
        else {
            max[index as usize]+= n_copy as u8;
            break;
        }
    }
    print!(" ");
    for x in max {
        print!("{}",x);
    }
    println!("");

}
fn get_min(m:i32, n:i32) {
    let mut min = Vec::<u8>::new();
    min.reserve(m as usize);
    min.push(1);
    for _ in 1..m {
        min.push(0);
    }
    let mut n_copy = n-1;
    for index in (0..(m)).rev() {
        if n_copy > 9 {
            min[index as usize]+=9;
            n_copy -= 9;
        }
        else {
            min[index as usize]+= n_copy as u8;
            break;
        }
    }
    for x in min {
        print!("{}",x);
    }

}

fn main() {
    let mut buf : String = String::new();
    read_line(&mut buf);
    let mut string_iter = buf.trim().split_whitespace();
    let m = string_iter.next().unwrap().parse::<i32>().unwrap();
    let n = string_iter.next().unwrap().parse::<i32>().unwrap();

    if !is_valid(m,n) {
        if m==0 {
            println!("0 0");
        }
        else{
            println!("-1 -1");
        }
    }
    else {
        get_min(m,n);
        get_max(m,n);
    }
}

use std::io;
use std::io::Stdin;
use std::str::FromStr;

fn read_line(stdin : &Stdin, line : &mut String) {
    match stdin.read_line(line) {
        Ok(_) => return,
        Err(msg) => panic!("Could not read line! Message: {}.", msg),
    }
}

fn parse_t<T : FromStr>(s : &str) -> T {
    match s.trim().parse() {
        Ok(y) => y,
        Err(_) => panic!("Could not read from string!"),
    }
}

fn read_ts<T : FromStr>(stdin : &Stdin, ts : &mut Vec<T>) {
    let mut line = String::new();
    read_line(stdin, &mut line);
    let word_iter = line.split_whitespace();
    for word in word_iter {
        let x = parse_t(word);
        ts.push(x);
    }
}

fn max_num_with_m_digits_and_digit_sum(m : usize, s : usize, max_num : &mut Vec<u8>) {
    if s == 0 {
        if m == 1 {
            max_num.push(0);
        } else {
            // Do nothing ...
        }
    } else {
        let mut cur_sum = 0;
        for _ in 0 .. m {
            let diff = s - cur_sum;
            if diff >= 9 {
                max_num.push(9);
                cur_sum = cur_sum + 9;
            } else {
                max_num.push(diff as u8);
                cur_sum = cur_sum + diff;
            }
        }
    }
}

fn min_num_with_m_digits_and_digit_sum(m : usize, max_num : &mut Vec<u8>) {
    if max_num.is_empty() {
        // Do nothing ...
    } else {
        max_num.reverse();
        if max_num[0] == 0 {
            if m == 1 {
                // Do nothing ...
            } else {
                max_num[0] = 1;
                for i in 1 .. m {
                    if max_num[i] == 0 {
                        // Do nothing ...
                    } else {
                        max_num[i] = max_num[i] - 1;
                        break;
                    }
                }
            }
        }
    }
}

fn print_vec(v : &Vec<u8>) {
    for &x in v.iter() {
        print!("{}", x);
    }
}

fn main() {
    let stdin = io::stdin();
    let mut m_s = vec![];
    read_ts(&stdin, &mut m_s);
    let m = m_s[0];
    let s = m_s[1];
    let mut max_num = vec![];
    max_num_with_m_digits_and_digit_sum(m, s, &mut max_num);
    if max_num.is_empty() {
        println!("-1 -1");
    } else {
        print_vec(&max_num);
        print!(" ");
        min_num_with_m_digits_and_digit_sum(m, &mut max_num);
        print_vec(&max_num);
        println!();
    }
}

use std::io;
use std::io::Stdin;
use std::str::FromStr;

fn read_line(stdin : &Stdin, line : &mut String) {
    match stdin.read_line(line) {
        Ok(_) => return,
        Err(msg) => panic!("Could not read line! Message: {}.", msg),
    }
}

fn parse_t<T : FromStr>(s : &str) -> T {
    match s.trim().parse() {
        Ok(y) => y,
        Err(_) => panic!("Could not read from string!"),
    }
}

fn read_ts<T : FromStr>(stdin : &Stdin, ts : &mut Vec<T>) {
    let mut line = String::new();
    read_line(stdin, &mut line);
    let word_iter = line.split_whitespace();
    for word in word_iter {
        let x = parse_t(word);
        ts.push(x);
    }
}

fn max_num_with_m_digits_and_digit_sum(m : usize, s : usize, max_num : &mut Vec<u8>) {
    if s == 0 {
        if m == 1 {
            max_num.push(0);
        } else {
            // Do nothing ...
        }
    } else {
        let mut cur_sum = 0;
        for _ in 0 .. m {
            let diff = s - cur_sum;
            if diff >= 9 {
                max_num.push(9);
                cur_sum = cur_sum + 9;
            } else {
                max_num.push(diff as u8);
                cur_sum = cur_sum + diff;
            }
        }
    }
}

fn min_num_with_m_digits_and_digit_sum(m : usize, max_num : &mut Vec<u8>) {
    if max_num.is_empty() {
        // Do nothing ...
    } else {
        max_num.reverse();
        if max_num[0] == 0 {
            if m == 1 {
                // Do nothing ...
            } else {
                max_num[0] = 1;
                for i in 1 .. m {
                    if max_num[i] == 0 {
                        // Do nothing ...
                    } else {
                        max_num[i] = max_num[i] - 1;
                        break;
                    }
                }
            }
        }
    }
}

fn print_vec(v : &Vec<u8>) {
    for &x in v.iter() {
        print!("{}", x);
    }
}

fn main() {
    let stdin = io::stdin();
    let mut m_s = vec![];
    read_ts(&stdin, &mut m_s);
    let m = m_s[0];
    let s = m_s[1];
    let mut max_num = vec![];
    max_num_with_m_digits_and_digit_sum(m, s, &mut max_num);
    if max_num.is_empty() {
        println!("-1 -1");
    } else {
        let mut max_num_copy = max_num.to_vec();
        min_num_with_m_digits_and_digit_sum(m, &mut max_num_copy);
        print_vec(&max_num_copy);
        print!(" ");
        print_vec(&max_num);
        println!();
    }
}

fn solve() {
    let (m, s): (i32, i32) = {
        let mut buf = String::new();
        std::io::stdin().read_line(&mut buf).unwrap();
        let mut ws = buf.split_whitespace();
        let m = ws.next().unwrap().parse().unwrap();
        let s = ws.next().unwrap().parse().unwrap();
        (m, s)
    };

    let check = |m: i32, s: i32| (s >= 0) && s <= 9 * m;

    let mut ans = String::new();
    let mut sum = s;
    for i in 0..m {
        for d in 0..10 {
            if (i > 0 || d > 0 || (m == 1 && d == 0)) && check(m - i - 1, sum - d) {
                sum -= d;
                ans.push_str(&d.to_string());
                break;
            }
        }
    }

    ans.push(' ');
    sum = s;
    for i in 0..m {
        for d in (0..10).rev() {
            if (i > 0 || d > 0 || (m == 1 && d == 0)) && check(m - i - 1, sum - d) {
                sum -= d;
                ans.push_str(&d.to_string());
                break;
            }
        }
    }

    if ans.chars().next().unwrap() == '0' {
        println!("-1 -1");
        return;
    }
    println!("{}", ans);
}

fn main() {
    // let t: u32 = {
    //     let mut buf = String::new();
    //     std::io::stdin().read_line(&mut buf).unwrap();
    //     buf.trim_end().parse().unwrap()
    // };

    // for _ in 0..t {}
    solve();
}

fn solve() {
    let (m, s): (i32, i32) = {
        let mut buf = String::new();
        std::io::stdin().read_line(&mut buf).unwrap();
        let mut ws = buf.split_whitespace();
        let m = ws.next().unwrap().parse().unwrap();
        let s = ws.next().unwrap().parse().unwrap();
        (m, s)
    };

    let check = |m: i32, s: i32| (s >= 0) && s <= 9 * m;

    let mut ans = String::new();
    let mut sum = s;
    for i in 0..m {
        for d in 0..10 {
            if (i > 0 || d > 0 || (m == 1 && d == 0)) && check(m - i - 1, sum - d) {
                sum -= d;
                ans.push_str(&d.to_string());
                break;
            }
        }
    }

    ans.push(' ');
    sum = s;
    for i in 0..m {
        for d in (0..10).rev() {
            if (i > 0 || d > 0 || (m == 1 && d == 0)) && check(m - i - 1, sum - d) {
                sum -= d;
                ans.push_str(&d.to_string());
                break;
            }
        }
    }

    match ans.chars().next().unwrap() {
        '0' => println!("-1 -1"),
        ' ' => println!("-1 -1"),
        _ => println!("{}", ans),
    }
}

fn main() {
    // let t: u32 = {
    //     let mut buf = String::new();
    //     std::io::stdin().read_line(&mut buf).unwrap();
    //     buf.trim_end().parse().unwrap()
    // };

    // for _ in 0..t {}
    solve();
}

#![allow(unused_imports)]
#![allow(unused_macros)]
use std::io::{StdinLock, stdin, BufRead};
use std::collections::*;
use std::cmp::*;

fn scan_helper(lock : &mut StdinLock) -> String {
    let mut buffer = String::new();
    lock.read_line(&mut buffer).ok();
    buffer
}

macro_rules! scan {
    ($lock:ident, $t:ty) => ({
        scan_helper(&mut $lock).split_whitespace()
            .next().unwrap()
            .parse::<$t>().unwrap()
    });
    ($lock:ident, $($t:ty),+) => ({
        let buffer = scan_helper(&mut $lock);
        let mut iter = buffer.split_whitespace();
        ($(
            {
                iter.next().unwrap()
                    .parse::<$t>().unwrap()
            },
        )+)
    })
}

macro_rules! scan_iter {
    ($lock:ident, $t:ty) => ({
        scan_helper(&mut $lock).split_whitespace()
            .map(|x| x.parse::<$t>().unwrap())
            .collect()
    })
}

trait Ext {
    fn idx(&self) -> usize;
    fn num(&self) -> i64;
}

macro_rules! ext {
    ($t:ty) => (
        impl Ext for $t {
            #[inline]
            fn idx(&self) -> usize {
                *self as usize
            }

            #[inline]
            fn num(&self) -> i64 {
                *self as i64
            }
        }
    )
}
ext!(i64);
ext!(usize);

fn main() {
    let stdin = stdin();
    let mut s = stdin.lock();
    let (m, s) = scan!(s, usize, i64);
    let mut smallest = vec![0; m];
    let mut largest = vec![0; m];
    let lower_bound = if m == 1 { 0 } else { 1 };
    let upper_bound = (9*m).num();

    if s >= lower_bound && s <= upper_bound {
        let mut temp = s;
        for i in 0..m {
            if temp > 9 {
                largest[i] = 9;
                temp -= 9;
            } else {
                largest[i] = temp;
                break;
            }
        }

        temp = s;
        for i in (0..m).rev() {
            if temp > 9 {
                smallest[i] = 9;
                temp -= 9;
            } else {
                smallest[i] = temp;
                break;
            }
        }

        let mut flag = false;
        for i in 0..m {
            if smallest[i] != 0 || flag {
                flag = true;
                print!("{}", smallest[i]);
            }
        }
        if !flag {
            print!("0");
        }
        print!(" ");

        flag = false;
        for i in 0..m {
            if largest[i] != 0 || flag {
                flag = true;
                print!("{}", largest[i]);
            }
        }
        if !flag {
            print!("0");
        }
    } else {
        println!("-1 -1");
    }
}