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(),
            )+
        )
    }}
}

fn div_and_ceil(a: i32, b: i32) -> i32 {
    if a % b == 0 { a / b } else { a / b + 1 }
}

fn main() {
    let (guests, lists) = readln(i32, i32);

    let red = div_and_ceil(2 * guests, lists);
    let green = div_and_ceil(5 * guests, lists);
    let blue = div_and_ceil(8 * guests, lists);

    println!("{}", red + green + blue);
}


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 solve() {
    let (n, m) = parse_line!(usize, usize);
    let l = parse_line_to_vec!(usize);
    let mut result = vec![0; n];
    let mut ok = true;
    for i in 1..m {
        let leader = l[i - 1] - 1;
        let diff = (n + l[i] - l[i - 1]) % n;
        if result[leader] == 0 {
            result[leader] = diff;
        }else if result[leader] != diff {
            ok = false;
        }
    }
    for i in 0..n {
        if result[i] == 0 {
            continue;
        }
        let mut local = true;
        for j in 0..i {
            local &= result[i] != result[j];
        }
        ok &= local;
    }
    if !ok {
        return println!("-1");
    }
    let mut s = std::collections::HashSet::<usize>::new();
    s.extend(result.iter());
    let mut next = 1;
    for i in 0..n {
        if result[i] != 0 {
            continue;
        }
        while s.contains(&next) {
            next += 1;
        }
        result[i] = next;
        next += 1;
    }
    for x in result {
        print!("{} ", x);
    }
    println!();
}

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


use std::io::{self, BufRead};
use std::fs;

fn main() {
    let stdin = io::stdin();
    let line = stdin.lock()
        .lines()
        .next()
        .expect("there was no next line")
        .expect("the line could not be read");

    let numbers: Vec<_> = line.split(" ").collect();
    let v: i32 = numbers[0].parse().unwrap();
//    let b: i32 = numbers[1].parse().unwrap();

    println!("{}", 1);
}

//fn main() {
//    let mut line = String::new();
//    let stdin = io::stdin();
//    stdin.lock().read_line(&mut line).expect("Could not read line");
//    println!("{}", line)
//}

/*
fn main() {
    let stdin = io::stdin();
    let lines: Vec<String> = stdin.lock().lines().map(|x| x.unwrap()).collect();

    let line = &lines[0];

//    let data = fs::read_to_string("test").expect("Unable to read file");
//    println!("{}", data);

    let numbers: Vec<_> = line.split(" ").collect();
    let a: i32 = numbers[0].parse().unwrap();
    let b: i32 = numbers[1].parse().unwrap();

    println!("{}", a + b);
}

*/


const INF: i64 = 1_000_000_000i64;

struct Graph {
    size: usize,
    edge: Vec<(usize, usize, i64, i64)>,
}

impl Graph {
    fn new(size: usize) -> Self {
        Graph {
            size: size,
            edge: vec![],
        }
    }
    fn add_edge(&mut self, src: usize, dst: usize, capa: i64, cost: i64) {
        assert!(src < self.size && dst < self.size && src != dst);
        self.edge.push((src, dst, capa, cost));
    }
    fn solve(&self, src: usize, dst: usize, flow: i64) -> Option<i64> {
        if src == dst {
            return Some(0);
        }
        let size = self.size;
        let edge = &self.edge;
        let mut deg = vec![0; size];
        for &(a, b, _, _) in edge.iter() {
            deg[a] += 1;
            deg[b] += 1;
        }
        let mut graph: Vec<_> = deg.into_iter().map(|d| Vec::with_capacity(d)).collect();
        for &(a, b, capa, cost) in edge.iter() {
            let x = graph[a].len();
            let y = graph[b].len();
            graph[a].push((b, capa, cost, y));
            graph[b].push((a, 0, -cost, x));
        }
        let mut ans = 0;
        let mut dp = Vec::with_capacity(size);
        let mut elem = Vec::with_capacity(size);
        let mut que = std::collections::VecDeque::new();
        for _ in 0..flow {
            dp.clear();
            dp.resize(size, (INF, src, 0));// コスト、親、親からの番号
            dp[src] = (0, src, 0);
            elem.clear();
            elem.resize(size, false);
            elem[src] = true;
            que.push_back(src);
            while let Some(v) = que.pop_front() {
                elem[v] = false;
                let (c, _, _) = dp[v];
                for (i, &(u, capa, cost, _)) in graph[v].iter().enumerate() {
                    if capa == 0 {
                        continue;
                    }
                    let c = c + cost;
                    if c < dp[u].0 {
                        dp[u] = (c, v, i);
                        if !elem[u] {
                            elem[u] = true;
                            que.push_back(u);
                        }
                    }
                }
            }
            if dp[dst].0 == INF {
                return None;
            }
            ans += dp[dst].0;
            let mut pos = dst;
            while pos != src {
                let (_, parent, k) = dp[pos];
                let inv = graph[parent][k].3;
                graph[parent][k].1 -= 1;
                graph[pos][inv].1 += 1;
                pos = parent;
            }
        }
        Some(ans)
    }
}

//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")
    };
}

//

fn run() {
    input! {
        n: usize,
        m: usize,
        k: usize,
        c: i64,
        d: i64,
        a: [usize1; k],
        e: [(usize1, usize1); m],
    }
    let w = 101;
    let size = n * w + 2;
    let mut graph = Graph::new(size);
    let src = size - 1;
    let dst = src - 1;
    let pos = |a: usize, b: usize| -> usize {
        assert!(a < 101 && b < n);
        a * n + b
    };
    for a in a {
        graph.add_edge(src, pos(0, a), 1, 0);
    }
    for i in 0..w {
        graph.add_edge(pos(i, 0), dst, 50, c * i as i64);
    }
    for (a, b) in e {
        for i in 1..w {
            for j in 1..=n {
                let x = j as i64;
                graph.add_edge(pos(i - 1, a), pos(i, b), 1, d * (2 * x - 1));
                graph.add_edge(pos(i - 1, b), pos(i, a), 1, d * (2 * x - 1));
            }
        }
    }
    for i in 1..w {
        for j in 0..n {
            graph.add_edge(pos(i - 1, j), pos(i, j), 50, 0);
        }
    }
    let ans = graph.solve(src, dst, k as i64).unwrap();
    println!("{}", ans);
}

fn main() {
    run();
}


use std::io;
use std::io::Write;

// Outline
// read in numberse first and parse

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

    io::stdin().read_line(&mut input)
        .expect("Couldn't read line.");

    let input: Vec<u32> = input
        .split_whitespace()
        .map(|s| s.parse().unwrap())
        .collect();

    let number_of_pages: u32 = input[0];
    let current_page: u32 = input[1];
    let range_of_pages: u32 = input[2];

    let lower_bound = {
        if current_page - range_of_pages <= 0 {
            1
        } else {
            current_page - range_of_pages
        }
    };

    let higher_bound = {
        if current_page + range_of_pages > number_of_pages {
            number_of_pages
        } else {
            current_page + range_of_pages
        }
    };

    if higher_bound != number_of_pages && lower_bound != 1 {
        print!("<< ");
        io::stdout().flush().unwrap();
        for page in lower_bound..higher_bound+1 {
            if page == current_page {
                print!("({}) ", page);
                io::stdout().flush().unwrap();
            } else {
                print!("{} ", page);
                io::stdout().flush().unwrap();
            }
        }
        print!(">>");
        io::stdout().flush().unwrap();
    } else if higher_bound == number_of_pages && lower_bound != 1 {
        print!("<< ");
        io::stdout().flush().unwrap();
        for page in lower_bound..higher_bound+1 {
            if page == current_page {
                print!("({}) ", page);
                io::stdout().flush().unwrap();
            } else {
                print!("{} ", page);
                io::stdout().flush().unwrap();
            }
        }
    } else if higher_bound == number_of_pages && lower_bound == 1 {
        for page in lower_bound..higher_bound+1 {
            if page == current_page {
                print!("({}) ", page);
                io::stdout().flush().unwrap();
            } else {
                print!("{} ", page);
                io::stdout().flush().unwrap();
            }
        }
    } else if higher_bound != number_of_pages && lower_bound == 1 {
        for page in lower_bound..higher_bound+1 {
            if page == current_page {
                print!("({}) ", page);
                io::stdout().flush().unwrap();
            } else {
                print!("{} ", page);
                io::stdout().flush().unwrap();
            }
        }
        print!(">>");
        io::stdout().flush().unwrap();
    }
}


//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, usize1) => {
        read_value!($iter, usize) - 1
    };
    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

//

fn run() {
    input! {
        n: usize,
        a: [usize; n],
    }
    let mut cnt = vec![0; 10];
    for a in a {
        for i in 0..10 {
            cnt[i] += (a >> i) & 1;
        }
    }
    for i in 0..10 {
        if cnt[i] % (n / 2) != 0 {
            println!("Alice");
            return;
        }
    }
    println!("Bob");
}

fn main() {
    run();
}


#[allow(unused_imports)]
use std::io::stdin;

#[derive(Default)]
struct Scanner {
    buffer: Vec<String>
}
impl Scanner {
    fn next<T: std::str::FromStr>(&mut self) -> T {
        loop {
            if let Some(token) = self.buffer.pop() {
                return token.parse().ok().expect("Failed parse");
            }
            let mut input = String::new();
            stdin().read_line(&mut input).expect("Failed read");
            self.buffer = input.split_whitespace().rev().map(String::from).collect();
        }
    }
}

use std::cmp::{ min, max };

type Point = (i128, i128);

fn intersect(a: &Point, b: &Point, c: &Point, d: &Point) -> (Point, Point) {
    let l = max(min(a.0, b.0), min(c.0, d.0));
    let r = min(max(a.0, b.0), max(c.0, d.0));
    let u = min(max(a.1, b.1), max(c.1, d.1));
    let d = max(min(a.1, b.1), min(c.1, d.1));
    if l >= r || u <= d {
        ((0,0), (0,0))
    } else {
        ((l, d), (r, u))
    }
}

fn area(x: &Point, y: &Point) -> i128 {
    (x.0 - y.0).abs() * (x.1 - y.1).abs()
}

fn main() {
    let mut scan = Scanner::default();
    let (p1, p2): (Point, Point) = ((scan.next::<i128>(), scan.next::<i128>()),(scan.next::<i128>(), scan.next::<i128>()));
    let (p3, p4): (Point, Point) = ((scan.next::<i128>(), scan.next::<i128>()),(scan.next::<i128>(), scan.next::<i128>()));
    let (p5, p6): (Point, Point) = ((scan.next::<i128>(), scan.next::<i128>()),(scan.next::<i128>(), scan.next::<i128>()));
    let wb1 = intersect(&p1, &p2, &p3, &p4);
    let wb2 = intersect(&p1, &p2, &p5, &p6);
    let sb1b2 = intersect(&wb1.0, &wb1.1, &wb2.0, &wb2.1);
    let a = area(&p1, &p2);
    let b = area(&wb1.0, &wb1.0);
    let c = area(&wb2.0, &wb2.0);
    let d = area(&sb1b2.0, &sb1b2.0);
    println!("{}", if a > b + c -d { "YES" } else { "NO" });
}


use std::collections::HashMap;
use std::io;

fn solve() -> Vec<String> {
    let mut input = "".split_ascii_whitespace();
    let mut read = || loop {
        if let Some(word) = input.next() {
            break word;
        }
        input = {
            let mut input = "".to_owned();
            io::stdin().read_line(&mut input).unwrap();
            if input.is_empty() {
                panic!("reached EOF");
            }
            Box::leak(input.into_boxed_str()).split_ascii_whitespace()
        };
    };
    macro_rules! read(($ty:ty) => (read().parse::<$ty>().unwrap()));

    let mut rr = vec!["".to_string(); 0];

    let t = 1;
    for _ in 0..t {
        let n = read!(usize);
        let mut a = vec![0; n];
        for i in 0..n {
            a[i] = read!(usize);
        }

        let mut c: HashMap<usize, usize> = HashMap::new();
        for i in 0..n {
            *(c.entry(a[i]).or_insert(0)) += 1;
        }

        let mut r = 1;
        for (k, t) in c.iter() {
            if r < *t {
                r = *t;
            }
        }

        rr.push(format!("{}", r));
    }

    rr
}

#[allow(dead_code)]
fn main() {
    let output = solve();
    println!("{}", output.join("\n"));
}


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

fn get_num() -> usize{
    let mut input = String::new();

    io::stdin().read_line(&mut input)
        .expect("");

    usize::from_str(input.trim()).unwrap()
}

fn main() {
    let n = get_num();

    let m = n / 7;
    let r = n % 7;

    println!("{} {}", m * 2, m * 2 + if r == 0  { 0 } else if r == 1 { 1 } else { 2 });
}


#![allow(unused_imports, unused_variables, dead_code, non_snake_case, unused_macros)]
use std::io::{stdin, Read, StdinLock};
use std::str::FromStr;
use std::fmt::*;
use std::str::*;
use std::cmp::*;
use std::collections::*;

fn getline() -> String{
    let mut res = String::new();
    std::io::stdin().read_line(&mut res).ok();
    res
}

macro_rules! readl {
    ($t: ty) => {
        {
            let s = getline();
            s.trim().parse::<$t>().unwrap()
        }
    };
    ($( $t: ty),+ ) => {
        {
            let s = getline();
            let mut iter = s.trim().split(' ');
            ($(iter.next().unwrap().parse::<$t>().unwrap(),)*)
        }
    };
}

macro_rules! readlvec {
    ($t: ty) => {
        {
            let s = getline();
            let iter = s.trim().split(' ');
            iter.map(|x| x.parse().unwrap()).collect::<Vec<$t>>()
        }
    }
}

macro_rules! mvec {
    ($v: expr, $s: expr) => {
        vec![$v; $s]
    };
    ($v: expr, $s: expr, $($t: expr),*) => {
        vec![mvec!($v, $($t),*); $s]
    };
}

macro_rules! debug {
    ($x: expr) => {
        println!("{}: {:?}", stringify!($x), $x)
    }
}

fn printiter<'a, T>(v: &'a T)
where
    &'a T: std::iter::IntoIterator,
    <&'a T as std::iter::IntoIterator>::Item: std::fmt::Display {
    for (i,e) in v.into_iter().enumerate() {
        if i != 0 {
            print!(" ");
        }
        print!("{}", e);
    }
    println!("");
}

struct ContestPrinter {
    s: String,
}

impl ContestPrinter {
    fn new() -> ContestPrinter {
        ContestPrinter {
        s: String::new(),
        }
    }

    fn print<T>(&mut self, x: T)
        where T: std::fmt::Display {
        self.s.push_str(format!("{}", x).as_str());
    }

    fn println<T>(&mut self, x: T)
        where T: std::fmt::Display {
        self.s.push_str(format!("{}\n", x).as_str());
    }
}

impl std::ops::Drop for ContestPrinter {
    fn drop(&mut self) {
        print!("{}", self.s);
    }
}

fn main() {
    let mut printer = ContestPrinter::new();

    let _ = readl!(usize);
    let vs = readlvec!(i32);

    let mut ans: i32 = 0;
    for i in 0..(vs.len()+1) {
        let mut b: i32 = 0;
        for j in 0..i {
            b += vs[j];
        }
        let mut c: i32 = 0;
        for j in i..vs.len() {
            c += vs[j];
        }
        ans = max(ans, b - c);
    }
    printer.println(ans);
}


use std::cmp;
use std::io;
use std::str::SplitWhitespace;

fn main() {
    let size = read_size();

    let mut v: Vec<i32> = vec![0; size as usize];

    let array_str = read_line();
    let mut iter = array_str.split_whitespace();

    for i in 0..size {
        v[i as usize] = read_split(&mut iter);
    }

    v.sort();

    let mut total = 0;
    for el in v.iter() {
        total += *el;
    }

    let mut answer = total;

    for el in v.iter() {
        total -= *el;
        answer = cmp::max(answer, total - *el);
    }

    println!("{}", answer);
}

fn read_size() -> i32 {
    let size_str = read_line();
    let mut iter = size_str.split_whitespace();
    read_split(&mut iter)
}

fn read_split(iter: &mut SplitWhitespace) -> i32 {
    iter.next().unwrap_or("-1").parse::<i32>().unwrap_or(-1)
}

fn read_line() -> String {
    let mut first_line = String::new();
    io::stdin()
        .read_line(&mut first_line)
        .expect("stdin read error");
    first_line
}


use std::collections::VecDeque;

fn main() {
    let mut queue = VecDeque::new();
    queue.push_back("Sheldon");
    queue.push_back("Leonard");
    queue.push_back("Penny");
    queue.push_back("Rajesh");
    queue.push_back("Howard");

    let mut n = {
        let mut buf = String::new();
        std::io::stdin().read_line(&mut buf).unwrap();
        buf.trim().parse::<usize>().expect("Invalid input.") - 1
    };

    while n >= queue.len() {
        let first = queue
            .pop_front()
            .expect("Problems extracting first element");
        queue.push_back(first);
        queue.push_back(first);
        n -= 1;
    }

    println!("{}", queue.get(n).expect("Couldn't get nth element"));
}


use std::io;

fn main() {
    let mut ss: String = String::new();
    io::stdin().read_line(&mut ss).unwrap();
    let n: u64 = ss.trim().parse().unwrap();

    let mut l: u64 = 1;
    let mut r: u64 = (n/2) + (n%2);
    let mut m: u64;

    if tryv(n, 1) { println!("1"); return; }

    loop {
        if l + 1 == r {
            break;
        }
        m = (l + r) / 2;
        if tryv(n, m) {
            r = m;
        } else {
            l = m;
        }
    }

    println!("{}", r);
    return;
}

fn tryv(nn: u64, k: u64) -> bool {
    // println!("n: {}, k: {}", nn, k);
    // println!("=====================");
    if k == 0 { return false; }
    let mut n = nn;
    let mut v: u64 = 0;
    loop {
        if v >= nn/2 {
            return true;
        } else if v + n < nn/2 {
            return false;
        }

        if k >= n {
            v += n;
            n = 0;
        } else {
            v += k;
            n -= k;
        }

        n -= n/10;
        // println!("left: {}, vasya: {}", n, v);
    }
}


fn main() {
    let mut input = String::new();
    use std::io::{self, prelude::*};
    io::stdin().read_to_string(&mut input).unwrap();

    let n: u64 = input.trim().parse().unwrap();

    let check = |k| {
        let mut n = n;

        let mut v = 0;
        let mut p = 0;
        loop {
            if n < k {
                n = 0;
                v += n;
                break;
            }
            n -= k;
            v += k;

            let q = n / 10;
            n -= q;
            p += q;
        }

        p <= v
    };

    let mut low = 0;
    let mut up = (n + 1) / 2;

    while low + 1 != up {
        let cur = (low + up) / 2;
        if check(cur) {
            up = cur;
        } else {
            low = cur;
        }
    }

    println!("{}", up);
}


use std::io;

fn main() {
    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();

    let mut input = buf
        .split_whitespace()
        .map(|s| s.parse::<i32>().unwrap());

    // length
    let n = input.next().unwrap();
    // route 1 (+)
    let a = input.next().unwrap();
    let x = input.next().unwrap();
    // route 2 (-)
    let b = input.next().unwrap();
    let y = input.next().unwrap();

    println!("{}", match solve(n, a, x, b, y) {
        true => "YES",
        false => "NO",
    });
}

fn solve(n: i32, a: i32, x: i32, b: i32, y: i32) -> bool {
    let x = if x < a { x + n } else { x };
    let y = if y > b { y - n } else { y };
    (y .. b + 1).rev().zip(a .. x + 1).any(|(i, j)| i % n == j % n)
}

#[cfg(test)]
mod test {

    use super::solve;
    #[test]
    fn test1() {
        assert_eq!(solve(5, 1, 4, 3, 2), true);
    }
    #[test]
    fn test2() {
        assert_eq!(solve(10, 2, 1, 9, 10), false);
    }
    #[test]
    fn test3() {
        assert_eq!(solve(82, 9, 11, 15, 79), false);
    }
}


fn read_string() -> String {
    let mut input = String::new();
    std::io::stdin().read_line(&mut input).expect("Failed");
    input
}

fn main(){
    let now_time = read_string().replace("\n", "").replace("\r", "");
    let sleep_time = read_string().replace("\n", "").replace("\r", "");
    let now_vec: Vec<&str> = now_time.split(":").collect();
    let sleep_vec: Vec<&str> = sleep_time.split(":").collect();
    let mut hours = now_vec[0].parse::<i16>().unwrap() - sleep_vec[0].parse::<i16>().unwrap();
    let mut minutes = now_vec[1].parse::<i16>().unwrap() - sleep_vec[1].parse::<i16>().unwrap();
    if hours < 0{
        hours = 24+hours;
    }
    if minutes < 0{
        minutes = 60+minutes
    }
    println!("{}{}:{}{}", if hours<10 {"0"} else {""}, hours, if minutes<10 {"0"} else {""},minutes);
    }


macro_rules! read {
    ( $( $type_:ty ),+ ) => {
        {
            let mut line = String::new();
            io::stdin().read_line(&mut line).expect("error while reading line");
            let tokens : Vec<String> = line.as_str().split_whitespace().map(|x| x.to_string()).collect();
            let mut _tokens : &[String] = &tokens;
            ($(
                {
                    let tmp : $type_ = _tokens[0].parse().expect("error while parsing value");
                    _tokens = &_tokens[1..];
                    tmp
                }
            ),*)
        }
    };
}
macro_rules! read_vec {
    ( $type_:ty ) => {
        {
            let mut line = String::new();
            io::stdin().read_line(&mut line).expect("error while reading line");
            line.as_str().split_whitespace().map(|x| x.parse().expect("error while parsing")).collect::<Vec<$type_>>()
        }
    };
}
macro_rules! lazy_constant {
    (static $name:ident: $type_:ty = $initializer:expr;) => {
        use std::sync::{Once, ONCE_INIT};
        use std::boxed::Box;
        static INIT: Once = ONCE_INIT;
        static mut VALUE: *const $type_ = 0 as * const $type_;
        INIT.call_once(|| {
            unsafe {
                VALUE = Box::into_raw(Box::new($initializer));
            }
        });
        let $name: & $type_ = unsafe { VALUE.as_ref().unwrap() };
    };
}
use std::io;
fn main() {
    let _ = read!(i32);
    let text = read!(String);
    let text = text.as_bytes();

    for i in 0 .. text.len() {
        if text[i] == *text.get(i + 1).unwrap_or(&b'#') {
            if text[i] != b'?' {
                println!("No");
                return;
            }
            else if i > 0 && i + 2 < text.len() && text[i - 1] != text[i + 2] && text[i - 1] != b'?' &&  text[i + 2] != b'?' {
                println!("No");
                return;
            }
        }
    }
    println!("Yes");
}


use std::io;

#[derive(Debug, Copy, Clone, PartialEq)]
enum Color {
    C,
    Y,
    M,
    U,
}

impl Color {
    fn create(c: char) -> Self {
        match c {
            'C' => Color::C,
            'Y' => Color::Y,
            'M' => Color::M,
            _ => Color::U,
        }
    }
}

pub fn main() {
    let input = get_input();
    let length = input.len();
    let mut unknowns = 0;
    let mut unknown_location = 0;
    //println!("{:?}", input);
    if input[0] == Color::U {
        unknowns += 1;
        unknown_location = 0;
    }
    for i in 1..length {
        if input[i] == Color::U {
            unknowns += 1;
            unknown_location = i;
        } else if input[i] == input[i - 1] {
            println!("No");
            return;
        }
    }
    //println!("{}", unknowns);
    if unknowns == 0 {
        println!("No");
        return;
    } else if unknowns >= 2 {
        println!("Yes");
        return;
    } else {
        if unknown_location == 0 || unknown_location == length - 1 {
            println!("Yes");
            return;
        } else if input[unknown_location + 1] == input[unknown_location - 1] {
            println!("Yes");
            return;
        } else {
            println!("No");
            return;
        }
    }
    println!("Yes");
}

fn get_input() -> Vec<Color> {
    let mut input = String::new();
    io::stdin().read_line(&mut input);
    let mut input = String::new();
    io::stdin().read_line(&mut input);
    input.trim().chars().map(|c| Color::create(c)).collect()
}


use std::io::stdin;
use std::isize;
fn main() {
    let (x,y) = parse_input();
    let abs_x = x.abs();
    let abs_y = y.abs();
    let a =  abs_x+abs_y;
    if abs_x == x && abs_y == y{
        print(0,a ,a,0)
    }else if abs_x != x && abs_y !=y{
        print(-a,0,0,a)
    }else if abs_x !=x {
        print(-a,0,0,a)
    }else{
        print(0,-a,a,0)
    }
}
fn parse_input()->(isize,isize){
    let mut input = String::new();
    stdin().read_line(&mut input).unwrap();
    let v:Vec<isize> = input.trim().split_whitespace().map(|e| e.parse().unwrap()).collect();
    (v[0],v[1])
}
fn print(a:isize,b:isize,c:isize,d:isize){
    println!("{} {} {} {}",a,b,c,d)
}


//! http://codeforces.com/contest/742/problem/A

#[macro_export]
macro_rules! scanln {
  ($($var:ident : $ty:path),+) => {
    $(let $var: $ty;)+
    {
      use std::io;
      let mut __buf = String::new();
      io::stdin().read_line(&mut __buf).unwrap();
      let mut eles = __buf.split_whitespace();
      $($var = Scan::scan(&mut eles);)+
    }
  }
}

pub trait Scan {
  fn scan<'a, I>(eles: &mut I) -> Self where I: Iterator<Item=&'a str>;
}

macro_rules! impl_scan_single {
  ($ty:ty) => {
    impl Scan for $ty {
      fn scan<'a, I>(eles: &mut I) -> Self where I: Iterator<Item=&'a str> {
        let next = eles.next().unwrap();
        match next.parse() {
          Ok(res) => res,
          Err(_) => panic!()
        }
      }
    }
  }
}

impl_scan_single!(u8);
impl_scan_single!(u16);
impl_scan_single!(u32);
impl_scan_single!(u64);
impl_scan_single!(usize);
impl_scan_single!(i8);
impl_scan_single!(i16);
impl_scan_single!(i32);
impl_scan_single!(i64);
impl_scan_single!(f32);
impl_scan_single!(f64);
impl_scan_single!(isize);
impl_scan_single!(String);

const __IMPL_SCAN_FOR_VEC: () = {
  use std::str::FromStr;
  impl<T> Scan for Vec<T> where T: FromStr {
    fn scan<'a, I>(eles: &mut I) -> Self where I: Iterator<Item=&'a str> {
      eles.map(|str| match str.parse() {
        Ok(res) => res,
        Err(_) => panic!()
      }).collect()
    }
  }
};

// -----------------------------------------------------------------------------

fn main() {
  scanln!(n: u32);
  if n == 0 { println!("1"); }
  else {
    println!("{}",
      match n % 4 {
        1 => 8,
        2 => 4,
        3 => 2,
        4 => 6,
        _ => unreachable!()
      }
    );
  }
}


//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 }
    }};
}
use std::io::*;
use std::str::*;
use std::fmt::Debug;
struct WordReader<'a> { it : SplitAsciiWhitespace<'a>, }
#[allow(dead_code)]
impl<'a> WordReader<'a> {
    fn new<T: Read>(b: &mut String, mut r: T) -> WordReader {
        b.clear();
        r.read_to_string(b).unwrap();
        WordReader { it: b.split_ascii_whitespace() }
    }
    fn from_stdin(b: &mut String) -> WordReader {
        WordReader::new(b, stdin())
    }
    fn sl(&mut self) ->  &str { self.it.next().unwrap() }
    fn bs(&mut self) -> &[u8] { self.sl().as_bytes()    }
    fn s(&mut self) -> String { String::from(self.sl()) }
    fn i(&mut self) ->    i32 { self.p()                }
    fn p<T: FromStr>(&mut self) -> T where T::Err: Debug {
        self.sl().parse::<T>().unwrap()
    }
    fn vp<T: FromStr>(&mut self, n: usize) -> Vec<T> where T::Err: Debug {
        (0..n).map(|_| self.p()).collect()
    }
}

fn main() {
    let mut bin = String::new();
    let mut input = WordReader::from_stdin(&mut bin);

    let n = input.i();
    println!("{}", [6,8,4,2][(n % 4) as usize]);
}


//spnauti-rusT {{{
use std::io::*; use std::str::{self,*}; use std::fmt::Debug;
#[allow(unused_imports)] use std::cmp::Ordering::{self,*};
#[allow(unused_imports)] use std::ops::{self,*};
#[allow(unused_imports)] use std::iter::{self,*};
#[allow(unused_imports)] use std::collections::*;
#[allow(unused_imports)] use std::cell::*;
#[allow(unused_macros)] macro_rules! m {
	($c:tt,$x:expr,$y:expr) => {{
		let b=$y; let a=&mut$x; if b$c*a {*a=b; true} else {false}
	}};
}
#[allow(unused_macros)] macro_rules! l {
	($($v:ident),+ =$e:expr) => {$(let$v=$e;)+};
	($($v:ident),+:$t:ty=$e:expr) => {$(let$v:$t=$e;)+};
	(mut $($v:ident),+ =$e:expr) => {$(let mut$v=$e;)+};
	(mut $($v:ident),+:$t:ty=$e:expr) => {$(let mut$v:$t=$e;)+};
}
#[allow(unused_macros)] macro_rules! vec_dim {
	([$d:expr]$($s:tt)+) => {vec![vec_dim!($($s)+);$d]}; (=$e:expr) => {$e};
}
#[allow(unused_macros)] macro_rules! rep { {[$c:expr]$($s:tt)+} => {for _ in 0..$c {$($s)+}} }
#[allow(dead_code)] fn reader() -> WordReaderC { WordReaderC::new() }
#[allow(dead_code)] fn writer() -> BufWriter<Stdout> { BufWriter::new(stdout()) }
struct WordReaderC {buf: Vec<u8>, pos: usize, q: std::io::StdinLock<'static>}//'
#[allow(dead_code)] impl WordReaderC {
	fn new() -> Self {
		let r = unsafe {&*Box::into_raw(Box::new(stdin()))};
		Self { q: r.lock(), buf: Vec::new(), pos: 0 }
	}
	fn next_line(&mut self) -> bool {
		self.buf.clear(); self.pos = 0;
		self.q.read_until(b'\n', &mut self.buf).unwrap_or(0) > 0
	}
	fn is_ws(c: u8) -> bool {
		c == b' ' || c == b'\r' || c == b'\n' || c == b'\t'
	}
	fn byte(&mut self) -> Option<u8> {
		if self.pos == self.buf.len() { if !self.next_line() { return None; } }
		self.pos += 1; Some(self.buf[self.pos - 1])
	}
	fn vb(&mut self) -> Vec<u8> {
		let mut s = Vec::with_capacity(8);
		let mut f = false;
		loop {
			if let Some(c) = self.byte() {
				if !Self::is_ws(c) {
					s.push(c);
					f = true;
				} else if f { break; }
			} else { break; }
		}
		s
	}
	fn s(&mut self) -> String { String::from_utf8(self.vb()).expect("invalid utf8") }
	fn i(&mut self) ->    i32 { self.p() }
	fn l(&mut self) ->    i64 { self.p() }
	fn u(&mut self) ->  usize { self.p() }
	fn f(&mut self) ->    f64 { self.p() }
	fn vi(&mut self, n: usize) -> Vec<i32> { self.vp(n) }
	fn vl(&mut self, n: usize) -> Vec<i64> { self.vp(n) }
	fn vu(&mut self, n: usize) -> Vec<usize> { self.vp(n) }
	fn ii(&mut self, n: usize) -> impl Iterator<Item=i32> { self.ip(n).into_iter() }
	fn iu(&mut self, n: usize) -> impl Iterator<Item=usize> { self.ip(n).into_iter() }
	fn p<T: FromStr>(&mut self) -> T where T::Err: Debug {
		let w = self.vb(); str::from_utf8(w.as_ref()).unwrap().parse::<T>().unwrap()
	}
	fn vp<T: FromStr>(&mut self, n: usize) -> Vec<T> where T::Err: Debug {
		(0..n).map(|_|self.p()).collect()
	}
	fn ip<T: FromStr>(&mut self, n: usize) -> impl Iterator<Item=T> where T::Err: Debug {
		self.vp(n).into_iter()
	}
}
//------------------- End rusT }}}

// Field (mod prime) {{{
mod field {
	use std::ops::*;
	const P5: i32 = 1_000_000_007;
	const P6: i64 = P5 as i64;
	#[derive(Debug,Clone,Copy,PartialEq,Eq,PartialOrd,Ord,Default)] pub struct Field(i32);
	#[allow(dead_code)] impl Field {
		pub fn new<T: Into<i64>>(a: T) -> Self { Self(Self::cv(a)) }
		pub fn new_unchecked(a: i32) -> Self { Self(a) }
		fn hi(mut a: i32) -> i32 { if a >= P5 { a -= P5; } a }
		fn lo(mut a: i32) -> i32 { if a < 0 { a += P5; } a }
		fn cv<T: Into<i64>>(a: T) -> i32 { Self::lo((a.into() % P6) as i32) }
		pub fn inv(self) -> Self { self.pow(P5-2) }
		pub fn pow<T: Into<i64>>(self, b: T) -> Self {
			let b = b.into(); if b == 0 { Self(1) } else {
				let mut res = self.pow(b/2); res *= res; if b % 2 == 1 {res *= self;} res
			}
		}
	}
	impl Add for Field { type Output = Self; fn add(self, a: Self) -> Self::Output { Self(Self::hi(self.0 + a.0)) }}
	impl Sub for Field { type Output = Self; fn sub(self, a: Self) -> Self::Output { Self(Self::lo(self.0 - a.0)) }}
	impl Mul for Field { type Output = Self; fn mul(self, a: Self) -> Self::Output { Self(Self::cv(self.0 as i64 * a.0 as i64)) }}
	impl Div for Field { type Output = Self; fn div(self, a: Self) -> Self::Output { self * a.inv() }}
	impl Neg for Field { type Output = Self; fn neg(self) -> Self::Output { Self(Self::lo(-self.0)) }}
	impl AddAssign for Field { fn add_assign(&mut self, a: Self) { *self = *self + a; } }
	impl SubAssign for Field { fn sub_assign(&mut self, a: Self) { *self = *self - a; } }
	impl MulAssign for Field { fn mul_assign(&mut self, a: Self) { *self = *self * a; } }
	impl DivAssign for Field { fn div_assign(&mut self, a: Self) { *self = *self / a; } }
	use std::fmt::{Display, Formatter, Result};
	impl Display for Field { fn fmt(&self, f: &mut Formatter) -> Result { write!(f, "{}", self.0) } }
}
use field::Field as Z;
//}}}

fn main() {
	let mut rin = reader();
	let mut rout = writer();

	l!(r,g = rin.u());
	let mut dp = vec![ (r,g,Z::new(1)) ];
	let mut sum = dp[0].2;
	let mut sol = sum;
	for n in 1.. {
		if dp.len() == 0 {
			break;
		}
		sol = sum;
		let mut dp1 = Vec::new();
		for (r,g,v) in dp.drain(..) {
			if r >= n {
				dp1.push( (r-n,g,v) );
			}
			if g >= n {
				dp1.push( (r,g-n,v) );
			}
		}
		dp1.sort();
		let mut last_r = r+1;
		sum = Z::new(0);
		for (r,g,v) in dp1 {
			sum += v;
			if r == last_r {
				dp.last_mut().unwrap().2 += v;
			} else {
				last_r = r;
				dp.push( (r,g,v) );
			}
		}
	}
	writeln!(rout, "{}", sol).ok();
}


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 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();
}


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);
}


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()
}


// 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);
}


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) {
        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 {
        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();
}


#![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");
    }
}


#[allow(unused_imports)]
use std::cmp::{max,min};
#[allow(unused_imports)]
use std::collections::{HashMap,HashSet,VecDeque};

#[allow(unused_macros)]
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(),
            )+
        )
    }}
}

#[allow(unused_macros)]
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 (a,b,s) = readln!(i32,i32,i32);
    println!("{}", if s >= a+b && ((s-(a+b))%2) == 0 { "Yes" } else { "No" });
}


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 a: usize = scan.next();
    let b: usize = scan.next();
    let s: usize = scan.next();
    let result: bool = s >= (a + b) && (s - (a + b)) % 2 == 0;
    println!("{}", if result { "Yes" } else { "No" });
}

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


use std::io;

const LETTERS: &str = "abcdefghijklmnopqrstuvwxyzABCEFGHIJKLMNOPQRSTUVWXYZ";

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

    io::stdin().read_line(&mut x).expect("error");

    let lenght = x.len();

    if lenght >= 1 && lenght <= 100 {

        let mut _z = 0;

        let mut _upper = 0;
        let mut _down = 0;

        for y in x.trim().as_bytes() {

            for z in LETTERS.as_bytes() {
                if z.eq_ignore_ascii_case(&y) {
                    _z += 1;
                }
            }

            if _z > 0 {
                _z = 0;
            } else {
                panic!("phrase contains non-latin characters");
            }

            if y.is_ascii_uppercase() {
                _upper += 1;
            } else if y.is_ascii_lowercase() {
                _down += 1;
            }

        }

        if _upper < _down || _upper == _down {
            println!("{}", x.to_lowercase());
        } else {
            println!("{}", x.to_uppercase());
        }
    }
}


use std::io::stdin;

fn main() {
    let mut buf = String::new();
    let _ = stdin().read_line(&mut buf);
    let (mut l, mut h) = (0, 0);
    for i in buf.trim_end().as_bytes() {
        if *i >= 65 && *i <= 91 {
            h += 1;
        } else {
            l += 1;
        }
    }
    if l == h {
        println!("{}", buf.to_lowercase());
    } else {
        println!("{}", buf.to_uppercase());
    }
}


use std::io;
use std::io::{Error, ErrorKind};
use std::str::FromStr;

struct IO {
    buffer: Vec<String>
}

impl IO {
    fn new() -> IO {
        IO { buffer: Vec::new() }
    }
    /*
    pub fn reset(&mut self) {
        self.buffer = Vec::new();
    }
    */

    fn try_parse<T>(s: String) -> Result<T, T::Err>
        where T: FromStr {
        let res = (&s).parse::<T>()?;
        Ok(res)
    }

    fn receive<T>(&mut self) -> Result<T, Error>
        where T: FromStr {
        let ref mut stdio = &mut io::stdin();
        if let Some(s) = self.buffer.pop() {
            return match IO::try_parse::<T>(s) {
                Ok(value) => Ok(value),
                _ => Err(Error::new(ErrorKind::Other, "cannot parse to desired type"))
            }
        }

        let mut input = String::new();
        if let Err(error) = stdio.read_line(&mut input) {
            return Err(error)
        }

        input = input.trim().to_string();

        self.buffer.extend::<Vec<String> >(input.split(' ').map(|s| s.to_string()).collect());

        return self.receive::<T>()
    }
}

fn main() {
    let mut sio = IO::new();
    let s = sio.receive::<String>().unwrap();
    let q = s.bytes().collect::<Vec<u8> >();
    let mut diff = 0;
    for i in 0..s.len() {
        if q[i] != q[s.len() - 1 - i] {
            diff += 1;
        }
    }
    if diff == 2 || (diff == 1 && s.len() % 2 == 1){
        println!("YES");
    } else {
        println!("NO");
    }
}


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 input: Vec<char> = scan.next::<String>().chars().collect();
    let mut changes = 0;
    for i in 0..(input.len() / 2) {
        if input[i] != input[input.len() - i - 1] {
            changes += 1;
            if changes > 1 {
                println!("NO");
                return;
            }
        }
    }
    println!("{}", if changes == 1 { "YES" } else { "NO" });
}

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


use std::io::{Read, stdin};

fn main() {
    let mut buf = String::new();
    stdin().read_to_string(&mut buf).unwrap();
    let mut tok = buf.split_whitespace();
    let mut get = || tok.next().unwrap();
    macro_rules! get {
        ($t:ty) => (get().parse::<$t>().unwrap());
        () => (get!(usize));
    }

    let _n = get!();
    let k = get!();
    let s = get().as_bytes();
    let mut xs = vec![false; 30];
    for &ch in s {
        xs[ch as usize - b'a' as usize] = true;
    }
    let xs: Vec<_> = xs
        .into_iter()
        .enumerate()
        .filter(|(_, v)| *v)
        .collect();

    if k * 2 > 26 || xs.len() < k {
        println!("-1");
        return;
    }

    let mut ans = 0;
    let mut b = xs.len();
    let mut c = 0;
    for (i, _) in xs.iter() {
        let i = *i;
        if b + 1 != i {
            ans += i + 1;
            b = i;
            c += 1;
            if c >= k {
                break;
            }
        }
    }
    if c < k {
        println!("-1");
    } else {
        println!("{}", ans);
    }

}


fn count_ways(n: usize) -> usize {
    let mut dynamic = vec![vec![0; 4]; n + 1];
    dynamic[1] = vec![1usize; 4];
    *dynamic[1].last_mut().unwrap() = 0;

    for step_count in 2..=n {
        for vertex_id in 0..=3 {
            for neighbor_id in (0..=3).filter(|&x| x != vertex_id) {
                dynamic[step_count][vertex_id] += dynamic[step_count - 1][neighbor_id];
            }
            dynamic[step_count] %= 1000000007;
        }
    }
    *dynamic.last().unwrap().last().unwrap()
}

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_line(&mut buf).unwrap();
    let n = buf.trim().parse::<usize>().unwrap();
    println!("{}", count_ways(n));
}


use std::cmp::min;
use std::io::stdin;

fn main() {
    let (a, b) = {
        let mut buf = String::new();
        stdin().read_line(&mut buf).expect("Failed to read");
        let nums: Vec<i32> = buf
            .trim()
            .split_ascii_whitespace()
            .map(|c| c.parse().unwrap())
            .collect();
        (nums[0], nums[1])
    };
    let (k, j) = {
        let mut i = b;
        let mut j = 0;
        while i % 2 == 0 {
            i /= 2;
            j += 1;
        }
        (i, j)
    };
    if a >= k {
        println!("{}", a - k + j);
    } else {
        let mut moves = 0;
        let mut a = a;
        while k > 2 * a {
            moves += 1;
            a *= 2;
        }
        let type_a = 2 * a - k + 1;
        let type_b = (2 * a - k - 1) / 2 + 2;
        println!("{}", moves + min(type_a, type_b) + j);
    }
    // if a > b {
    //     println!("{}", a - b);
    // } else {
    //     let k = {
    //         let mut i = b;
    //         while i % 2 == 0 {
    //             i /= 2;
    //         }
    //         i
    //     };
    //     let mut moves = 0;
    //     let mut a = a;
    //     while k > 2 * a {
    //         a *= 2;
    //         moves += 1;
    //     }
    //     let type_a = 2 * a - k + 1;
    //     let type_b = (2 * a - k - 1) / 2 + 2;
    //     println!("{}", moves + min(type_a, type_b) + (b / k - 1));
}


#![allow(unused_parens)]
#![allow(unused_imports)]
#![allow(non_upper_case_globals)]
#![allow(non_snake_case)]
#![allow(unused_mut)]
#![allow(unused_variables)]
#![allow(dead_code)]

#[allow(unused_macros)]
macro_rules! invec {
    ( $ t : ty ) => {{
        let mut s = String::new();
        match std::io::stdin().read_line(&mut s) {
            Ok(0) => Vec::<$t>::new(),
            Ok(n) => s
                .trim()
                .split_whitespace()
                .map(|s| s.parse::<$t>().unwrap())
                .collect::<Vec<$t>>(),
            Err(_) => Vec::<$t>::new(),
        }
    }};
}

#[allow(unused_macros)]
macro_rules! get {
      ($t:ty) => {
          {
              let mut line: String = String::new();
              std::io::stdin().read_line(&mut line).unwrap();
              line.trim().parse::<$t>().unwrap()
          }
      };
      ($($t:ty),*) => {
          {
              let mut line: String = String::new();
              std::io::stdin().read_line(&mut line).unwrap();
              let mut iter = line.split_whitespace();
              (
                  $(iter.next().unwrap().parse::<$t>().unwrap(),)*
              )
          }
      };
      ($t:ty; $n:expr) => {
          (0..$n).map(|_|
              get!($t)
          ).collect::<Vec<_>>()
      };
      ($($t:ty),*; $n:expr) => {
          (0..$n).map(|_|
              get!($($t),*)
          ).collect::<Vec<_>>()
      };
      ($t:ty ;;) => {
          {
              let mut line: String = String::new();
              std::io::stdin().read_line(&mut line).unwrap();
              line.split_whitespace()
                  .map(|t| t.parse::<$t>().unwrap())
                  .collect::<Vec<_>>()
          }
      };
      ($t:ty ;; $n:expr) => {
          (0..$n).map(|_| get!($t ;;)).collect::<Vec<_>>()
      };
}

#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut 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)*}
    };
    ($iter:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

#[allow(unused_macros)]
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<_>>()
    };

    ($next:expr, [$t:tt]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };
    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_macros)]
#[cfg(debug_assertions)]
macro_rules! mydbg {
    //($arg:expr) => (dbg!($arg))
    //($arg:expr) => (println!("{:?}",$arg));
      ($($a:expr),*) => {
          eprintln!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
      }
}
#[cfg(not(debug_assertions))]
macro_rules! mydbg {
    ($($arg:expr),*) => {};
}

macro_rules! echo {
    ($($a:expr),*) => {
          $(println!("{}",$a))*
      }
}

use std::cmp::*;
use std::collections::*;
use std::ops::{Add, Div, Mul, Sub};

#[allow(dead_code)]
static INF_I64: i64 = i64::max_value() / 2;
#[allow(dead_code)]
static INF_I32: i32 = i32::max_value() / 2;
#[allow(dead_code)]
static INF_USIZE: usize = usize::max_value() / 2;
#[allow(dead_code)]
static M_O_D: usize = 1000000007;
#[allow(dead_code)]
static PAI: f64 = 3.1415926535897932;

trait IteratorExt: Iterator {
    fn toVec(self) -> Vec<Self::Item>;
}

impl<T: Iterator> IteratorExt for T {
    fn toVec(self) -> Vec<Self::Item> {
        self.collect()
    }
}

trait CharExt {
    fn toNum(&self) -> usize;
    fn toAlphabetIndex(&self) -> usize;
    fn toNumIndex(&self) -> usize;
}
impl CharExt for char {
    fn toNum(&self) -> usize {
        return *self as usize;
    }
    fn toAlphabetIndex(&self) -> usize {
        return self.toNum() - 'a' as usize;
    }
    fn toNumIndex(&self) -> usize {
        return self.toNum() - '0' as usize;
    }
}

trait VectorExt {
    fn joinToString(&self, s: &str) -> String;
}
impl<T: ToString> VectorExt for Vec<T> {
    fn joinToString(&self, s: &str) -> String {
        return self
            .iter()
            .map(|x| x.to_string())
            .collect::<Vec<_>>()
            .join(s);
    }
}

trait StringExt {
    fn get_reverse(&self) -> String;
}
impl StringExt for String {
    fn get_reverse(&self) -> String {
        self.chars().rev().collect::<String>()
    }
}

trait UsizeExt {
    fn pow(&self, n: usize) -> usize;
}
impl UsizeExt for usize {
    fn pow(&self, n: usize) -> usize {
        return ((*self as u64).pow(n as u32)) as usize;
    }
}

fn main() {
    let (n, m) = get!(usize, usize);
    let mut ans = INF_USIZE;
    let mut kouho = VecDeque::new();
    let n = 99;
    let m = 100;
    kouho.push_back((n, 0));
    while !kouho.is_empty() {
        let (a, depth) = kouho.pop_front().unwrap();
        mydbg!(a);
        if a == m {
            echo!(depth);
            return;
        }
        if a - 1 != 0 {
            kouho.push_back((a - 1, depth + 1));
        }
        if a * 2 < m * 3 {
            kouho.push_back((a * 2, depth + 1));
        }
    }
}


#![allow(unused_parens)]
#![allow(unused_imports)]
#![allow(non_upper_case_globals)]
#![allow(non_snake_case)]
#![allow(unused_mut)]
#![allow(unused_variables)]
#![allow(dead_code)]

#[allow(unused_macros)]
macro_rules! invec {
    ( $ t : ty ) => {{
        let mut s = String::new();
        match std::io::stdin().read_line(&mut s) {
            Ok(0) => Vec::<$t>::new(),
            Ok(n) => s
                .trim()
                .split_whitespace()
                .map(|s| s.parse::<$t>().unwrap())
                .collect::<Vec<$t>>(),
            Err(_) => Vec::<$t>::new(),
        }
    }};
}

#[allow(unused_macros)]
macro_rules! get {
      ($t:ty) => {
          {
              let mut line: String = String::new();
              std::io::stdin().read_line(&mut line).unwrap();
              line.trim().parse::<$t>().unwrap()
          }
      };
      ($($t:ty),*) => {
          {
              let mut line: String = String::new();
              std::io::stdin().read_line(&mut line).unwrap();
              let mut iter = line.split_whitespace();
              (
                  $(iter.next().unwrap().parse::<$t>().unwrap(),)*
              )
          }
      };
      ($t:ty; $n:expr) => {
          (0..$n).map(|_|
              get!($t)
          ).collect::<Vec<_>>()
      };
      ($($t:ty),*; $n:expr) => {
          (0..$n).map(|_|
              get!($($t),*)
          ).collect::<Vec<_>>()
      };
      ($t:ty ;;) => {
          {
              let mut line: String = String::new();
              std::io::stdin().read_line(&mut line).unwrap();
              line.split_whitespace()
                  .map(|t| t.parse::<$t>().unwrap())
                  .collect::<Vec<_>>()
          }
      };
      ($t:ty ;; $n:expr) => {
          (0..$n).map(|_| get!($t ;;)).collect::<Vec<_>>()
      };
}

#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut 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)*}
    };
    ($iter:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

#[allow(unused_macros)]
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<_>>()
    };

    ($next:expr, [$t:tt]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };
    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_macros)]
#[cfg(debug_assertions)]
macro_rules! mydbg {
    //($arg:expr) => (dbg!($arg))
    //($arg:expr) => (println!("{:?}",$arg));
      ($($a:expr),*) => {
          eprintln!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
      }
}
#[cfg(not(debug_assertions))]
macro_rules! mydbg {
    ($($arg:expr),*) => {};
}

macro_rules! echo {
    ($($a:expr),*) => {
          $(println!("{}",$a))*
      }
}

use std::cmp::*;
use std::collections::*;
use std::ops::{Add, Div, Mul, Sub};

#[allow(dead_code)]
static INF_I64: i64 = i64::max_value() / 2;
#[allow(dead_code)]
static INF_I32: i32 = i32::max_value() / 2;
#[allow(dead_code)]
static INF_USIZE: usize = usize::max_value() / 2;
#[allow(dead_code)]
static M_O_D: usize = 1000000007;
#[allow(dead_code)]
static PAI: f64 = 3.1415926535897932;

trait IteratorExt: Iterator {
    fn toVec(self) -> Vec<Self::Item>;
}

impl<T: Iterator> IteratorExt for T {
    fn toVec(self) -> Vec<Self::Item> {
        self.collect()
    }
}

trait CharExt {
    fn toNum(&self) -> usize;
    fn toAlphabetIndex(&self) -> usize;
    fn toNumIndex(&self) -> usize;
}
impl CharExt for char {
    fn toNum(&self) -> usize {
        return *self as usize;
    }
    fn toAlphabetIndex(&self) -> usize {
        return self.toNum() - 'a' as usize;
    }
    fn toNumIndex(&self) -> usize {
        return self.toNum() - '0' as usize;
    }
}

trait VectorExt {
    fn joinToString(&self, s: &str) -> String;
}
impl<T: ToString> VectorExt for Vec<T> {
    fn joinToString(&self, s: &str) -> String {
        return self
            .iter()
            .map(|x| x.to_string())
            .collect::<Vec<_>>()
            .join(s);
    }
}

trait StringExt {
    fn get_reverse(&self) -> String;
}
impl StringExt for String {
    fn get_reverse(&self) -> String {
        self.chars().rev().collect::<String>()
    }
}

trait UsizeExt {
    fn pow(&self, n: usize) -> usize;
}
impl UsizeExt for usize {
    fn pow(&self, n: usize) -> usize {
        return ((*self as u64).pow(n as u32)) as usize;
    }
}

fn main() {
    let (n, m) = get!(usize, usize);
    let mut ans = INF_USIZE;
    let mut kouho = VecDeque::new();
    kouho.push_back((n, 0));
    while !kouho.is_empty() {
        let (a, depth) = kouho.pop_front().unwrap();
        //mydbg!(a);
        if a == m {
            echo!(depth);
            return;
        }
        if a - 1 != 0 {
            kouho.push_back((a - 1, depth + 1));
        }
        if a * 2 < m * 2 {
            kouho.push_back((a * 2, depth + 1));
        }
    }
}


#[allow(unused_imports)]
use std::cmp::{max,min};

#[allow(unused_macros)]
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(),
            )+
        )
    }}
}

#[allow(unused_macros)]
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);
    let mut x = m;
    let mut res = 0;
    while x>n {
        if x%2 == 1 {
            res += 1;
        }
        res += 1;
        x /= 2;
    }
    res += n-x;
    println!("{}",res);
}


// https://codeforces.com/problemset/problem/520/B
use std::io;

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 mut n = words[0];
    let m = words[1];

    let mut j = 1;

    while 2*n < m {
        j += 1;
        n = 2*n;
    }

    j -= 1;

    println!("{}", j+i64::abs(m-n));
}


// https://codeforces.com/problemset/problem/520/B
use std::io;
use std::collections::VecDeque;

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 n = words[0];
    let m = words[1];

    let mut distance = [1<<30;10005];
    distance[n as usize] = 0;

    let mut q = VecDeque::<i64>::new();
    q.push_back(n);

    while !q.is_empty() {
        let u = q.pop_front().unwrap();
        let v = (2*u) as usize;
        let x = (u-1) as usize;

        if distance[v] == 1<<30 && (v as i64) < 2*m {
            distance[v] = distance[u as usize] + 1;
            q.push_back(v as i64);
        }

        if distance[x] == 1<<30 && x > 0 {
            distance[x] = distance[u as usize] + 1;
            q.push_back(u-1);
        }
    }
    println!("{}", distance[m as usize]);
}


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 dfs_moves(acc: usize, current: usize, goal: usize, visited: &mut [bool;20000]) -> usize {
    if visited[current] { return std::usize::MAX; }
    visited[current] = true;
    if current >= goal {
        return acc + current - goal;
    }
    let mut result = dfs_moves(acc + 1, current*2, goal, visited);
    if current > 1 {
        let decr_move = dfs_moves(acc + 1, current-1, goal, visited);
        result = result.min(decr_move);
    }
    result
}

fn _main() {
    let mut scan = Scan::new();
    let n: usize = scan.next();
    let m: usize = scan.next();
    if m<= n {
        println!("{}", n - m);
        return;
    }
    let mut seen = [false; 20000];
    let result = dfs_moves(0, n, m, &mut seen);
    println!("{}", result);
}

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


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

    let mut dp = vec![100000; 10010];
    dp[n] = 0;
    for i in 0..n {
        dp[i] = n as i32 - i as i32;
    }

    for i in (n + 1)..10000 {
        if i % 2 == 0 {
            dp[i] = dp[i / 2] + 1;
        }
    }

    for i in (0..10000).rev() {
        dp[i] = dp[i].min(dp[i + 1] + 1);
    }

    println!("{}", dp[m]);
}

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 (n, m): (i32, i32) = {
        let mut buf = String::new();
        std::io::stdin().read_line(&mut buf).unwrap();
        let mut ws = buf.split_whitespace();
        let n = ws.next().unwrap().parse().unwrap();
        let m = ws.next().unwrap().parse().unwrap();
        (n, m)
    };

    println!("{}", bfs(n, m));
}

fn bfs(n: i32, m: i32) -> i32 {
    let mut q = std::collections::VecDeque::new();

    q.push_back((n, 0));
    while !q.is_empty() {
        let x = q.pop_front().unwrap();
        if x.0 == m {
            return x.1;
        }
        if x.0 < 0 {
            continue;
        }
        q.push_back((x.0 - 1, x.1 + 1));
        q.push_back((x.0 * 2, x.1 + 1));
    }

    1
}

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 main() {
    let a = {
        let mut line = String::new();
        std::io::stdin().read_line(&mut line);
        line.trim().to_string()
    };
    let b = {
        let mut line = String::new();
        std::io::stdin().read_line(&mut line);
        line.trim().to_string()
    };
    let x = i32::from_str_radix(&a, 2).unwrap();
    let y = i32::from_str_radix(&b, 2).unwrap();
    let z = x ^ y;

    println!("{}", format!("{:b}", z));
}


use std::io::stdin;

fn main() {
    let mut a = String::new();
    let mut b = String::new();
    stdin().read_line(&mut a).unwrap();
    stdin().read_line(&mut b).unwrap();
    let a: Vec<char> = a.chars().collect();
    let b: Vec<char> = b.chars().collect();

    let mut answer = String::new();

    for i in 0..a.len() {
        if a[i] != b[i] {
            answer.push_str("1");
        } else {
            answer.push_str("0");
        }
    }

    println!("{}", answer);
}


use proconio::input;

fn main() {
    input! {
        s:String,
        t:String,
    }

    let s: Vec<char> = s.chars().collect();
    let t: Vec<char> = t.chars().collect();
    let n = s.len();
    let mut ans = String::new();

    for i in 0..n {
        ans.push(if s.get(i) != t.get(i) { '1' } else { '0' });
    }

    println!("{}", ans);
}


use std::io;
use std::str;

pub struct Scanner<R> {
    reader: R,
    buffer: Vec<String>,
}

impl<R: io::BufRead> Scanner<R> {
    pub fn new(reader: R) -> Self {
        Self {
            reader,
            buffer: vec![],
        }
    }

    pub fn token<T: str::FromStr>(&mut self) -> T {
        loop {
            if let Some(token) = self.buffer.pop() {
                return token.parse().ok().expect("Failed parse");
            }
            let mut input = String::new();
            self.reader.read_line(&mut input).expect("Failed read");
            self.buffer = input.split_whitespace().rev().map(String::from).collect();
        }
    }
}

fn egcd(a: i64, b: i64) -> (i64, i64, i64) {
    if b == 0 {
        return (a, 1, 0);
    }
    let (g, x1, y1) = egcd(b, a % b);
    (g, y1, x1 - (a / b) * y1)
}

fn ceil_div(num: i64, denom: i64) -> i64 {
    (num + denom - 1).div_euclid(denom)
}

// Check if the diophantine equation a * x + b * y = c has non-negative solutions.
fn solve<R: io::BufRead, W: io::Write>(scan: &mut Scanner<R>, out: &mut W) {
    let a: i64 = scan.token();
    let b: i64 = scan.token();
    let c: i64 = scan.token();
    let (g, xg, yg) = egcd(a, b);
    if c % g == 0 {
        let x0 = xg * c / g;
        let y0 = yg * c / g;
        // xk = x0 + k * b / g
        // yk = y0 - k * a / g
        // xk >= 0 and yk >= 0
        // After solving for k:
        let ans = y0 * g / a - ceil_div(-x0 * g, b) + 1;
        if ans >= 0 {
            writeln!(out, "Yes").ok();
        } else {
            writeln!(out, "No").ok();
        }
    } else {
        writeln!(out, "No").ok();
    }
}

fn main() {
    let (stdin, stdout) = (io::stdin(), io::stdout());
    let mut scan = Scanner::new(stdin.lock());
    let mut out = io::BufWriter::new(stdout.lock());
    solve(&mut scan, &mut out);
}


use std::io;

fn main() {
    let mut inp = String::new();
    io::stdin().read_line(&mut inp)
        .expect("F#K");
    let mut ct = 0;
    let mut lchar: char = '2';
    for sym in inp.chars(){
        if sym==lchar {
            ct += 1;
            if ct == 6 {
                println!("YES");
                ::std::process::exit(0);
            }
        }else{
            ct == 0;
        }
        lchar = sym;
    }
    println!("NO");
}


use std::io::{self};

fn read_line() -> String {
    let mut a_str = String::new();
    io::stdin().read_line(&mut a_str).expect("read error");
    a_str.trim().to_string()
}

fn main() -> io::Result<()> {
    let a = read_line();
    let mut ceros = 0;
    let mut unos = 0;
    for x in a.chars() {
        if x == '0' {
            ceros += 1;
        } else {
            unos += 1;
        }
        if ceros == 7 || unos == 7 {
            println!("YES");
            return Ok(())
        }
    }
    println!("NO");
    Ok(())
}


use std::io;
use std::io::prelude::*;
fn main() {
    let mut score = String::new();
    io::stdin().read_line(&mut score).expect("Error");
    if score.len()<=7||score.contains("0000000") || score.contains("1111111") {
        println!("YES");
    } else {
        println!("NO");
    }
}


use std::io::{self};
use std::cmp::max;

fn main() {
    let input = read_string();
    let max_seq_len = count_max_sequence_length(input);
    if max_seq_len >= 7 {
        println!("YES")
    } else {
        println!("NO")
    }

}

fn read_string() -> String {
    let mut input = String::new();
    let _read_result = io::stdin().read_line(&mut input);
    return input.trim().parse().unwrap();
}

fn count_max_sequence_length(input_str: String) -> u16 {
    let bytes = input_str.as_bytes();
    let mut max_sequence_length = 1;
    let mut current_sequence_length = 1;
    for i in 1..input_str.len() {
        if bytes[i - 1] == bytes[i] {
            current_sequence_length += 1
        } else {
            max_sequence_length = max(max_sequence_length, current_sequence_length);
            current_sequence_length = 1
        }
    }
    return max_sequence_length;
}


#![allow(unused_macros)]
#![allow(unused_mut)]

#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
use std::io;
use std::io::Write;
use std::str;
#[allow(unused_imports)]
use std::prelude::*;

// credit tanakh input macro
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut 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, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

// credit ebtech scanner
pub struct UnsafeScanner<R> {
    reader: R,
    buf_str: Vec<u8>,
    buf_iter: str::SplitAsciiWhitespace<'static>,
}

impl<R: io::BufRead> UnsafeScanner<R> {
    pub fn new(reader: R) -> Self {
        Self {
            reader,
            buf_str: vec![],
            buf_iter: "".split_ascii_whitespace(),
        }
    }

    /// This function should be marked unsafe, but noone has time for that in a
    /// programming contest. Use at your own risk!
    pub fn token<T: str::FromStr>(&mut self) -> T {
        loop {
            if let Some(token) = self.buf_iter.next() {
                return token.parse().ok().expect("Failed parse");
            }
            self.buf_str.clear();
            self.reader
                .read_until(b'\n', &mut self.buf_str)
                .expect("Failed read");
            self.buf_iter = unsafe {
                let slice = str::from_utf8_unchecked(&self.buf_str);
                std::mem::transmute(slice.split_ascii_whitespace())
            }
        }
    }
}

fn solve() {
    #[allow(unused_variables)]
    let (stdin, stdout) = (io::stdin(), io::stdout());
    //let mut scan = UnsafeScanner::new(stdin.lock());
    let mut out = io::BufWriter::new(stdout.lock());

    input! {
        s: String,
    }

    let mut l = 0;
    let mut r = 1;
    let mut v = vec![];

    for c in s.chars() {
        v.push(c);
    }
    let length = v.len();
    if length < 7 {
        writeln!(out, "{}", "NO").ok();
        return;
    }

    while r != length + 1{
        if r - l >= 7 {
            writeln!(out, "{}", "YES").ok();
            return;
        } else if v[r - 1] == v[r] {
            r += 1;
        } else {
            l = r;
            r += 1;
        }
    }
    writeln!(out, "{}", "NO").ok();

}

// credit kobae964
fn main() {
    // In order to avoid potential stack overflow, spawn a new thread.
    let stack_size = 104_857_600; // 100 MB
    let thd = std::thread::Builder::new().stack_size(stack_size);
    thd.spawn(|| solve()).unwrap().join().unwrap();
}


use std::io;

fn is_dangerous(input: &str) -> bool {
    let danger = 7;
    let bytes = input.as_bytes();

    let mut max = 0;
    let mut seq0 = 0;
    let mut seq1 = 0;
    for (i, &byte) in bytes.iter().enumerate(){
        match byte {
            b'0' => {
                seq0 += 1;
                if seq1 > max {
                    max = seq1;
                }
                seq1 = 0;
            },
            b'1' => {
                seq1 += 1;
                if seq0 > max {
                    max = seq0;
                }
                seq0 = 0;
            },
            _    => (),
        }
    }

    max >= danger
}

fn main() {
    let mut input = String::new();
    io::stdin().read_line(&mut input)
        .expect("Failed to read line˜!");

    if is_dangerous(&input) {
        println!("YES");
    } else {
        println!("NO");
    }
}


fn read() -> String {
    let mut res = String::new();
    std::io::stdin().read_line(&mut res).expect("???");
    res
}

fn parse_int(s: &str) -> usize {
    s.trim().parse().expect("???")
}

fn parse_ints(s: &str) -> Vec<usize> {
    s.split_whitespace().map(parse_int).collect()
}

fn main() {
    let s = read().into_bytes();

    let mut n = 0;
    let mut curr = b' ';

    for c in s.into_iter() {
        if c == curr {
            n += 1;
        } else {
            curr = c;
        }
    }

    println!("{}", if n >= 7 { "YES" } else { "NO" });
}


use std::io::*;

fn read<T: std::str::FromStr>(i: &mut StdinLock) -> T {
    let mut s = String::new();
    i.by_ref().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn main() {
    // initialize stdin
    let sin = std::io::stdin();
    let mut sin = sin.lock();
    let sin = &mut sin;

    let positions: String = read(sin);

    if positions.contains("01111111") || positions.contains("10000000") {
        println!("YES");
    } else {
        println!("NO");
    }
}


use std::io;

fn main() {
    let mut s = String::new();
    io::stdin().read_line(&mut s).unwrap();
    s = s.trim().to_string();
    let len = s.len();
    let mut cnt = 1;
    let mut ans = 1;
    for i in 1..len {
        if s.chars().nth(i) == s.chars().nth(i-1) {
            cnt += 1;
            if cnt > ans {
                ans = cnt;
            }
        } else {
            cnt = 1;
        }
    }
    if ans >= len / 2 {
        println!("YES");
    } else {
        println!("NO");
    }
}


use std::io;
fn main() {
    let input = read();
    let mut val = 'a';
    let mut count = 1;
    let mut danger = 0;
    for d in input.chars(){
        if d == val{
            count += 1;
            if count == 7 {
                danger = 1;
                break;
            }
        }
        else {
            count = 1;
            val = d;
        }
    }
    if danger == 1{
        println!("Yes");
    }
    else{
        println!("No");
    }
}
fn read() -> String{
    let mut input = String::new();
    io::stdin().read_line(&mut input).unwrap();
    input.trim().parse::<String>().unwrap()
}


pub fn main(){
    let input = input();
    let chars: Vec<char> = input.trim().chars().collect();
    let mut team = chars[0];
    let mut streak = 0;
    for c in chars {
        let current = c;
        if current != team {
            streak = 0;
            team = current;
        } else {
            streak += 1;
        }
        if streak >= 7 {
            println!("YES");
            return;
        }
    }
    println!("NO");
}

fn input() -> String {
    let mut input = String::new();
    std::io::stdin().read_line(&mut input);
    input
}


#[allow(unused_imports)]
use std::cmp::{min,max};
use std::collections::{*};
use std::io::{BufWriter, stdin, stdout, Write};
const BITS: usize = 19;

#[derive(Default)]
struct Scanner {
    buffer: Vec<String>
}
impl Scanner {
    fn next<T: std::str::FromStr>(&mut self) -> T {
        loop {
            if let Some(token) = self.buffer.pop() {
                return token.parse().ok().expect("Failed parse");
            }
            let mut input = String::new();
            stdin().read_line(&mut input).expect("Failed read");
            self.buffer = input.split_whitespace().rev().map(String::from).collect();
        }
    }
}

fn main() {
    let mut scanner = Scanner::default();
    let (n, m): (u64, u64) = (scanner.next(), scanner.next());
    let mut ans: u64 = 0;
    for i in 1..(m+1) {
    	if m % i == 0 {
    		ans+=1;
    	}
    }
    if ans > 2 {
    	print!["NO"];
    } else {
    	print!["YES"];
    }

}


use std::io::{self, prelude::*};

#[allow(unused_must_use)]
fn solve<B: BufRead, W: Write>(mut scan: Scanner<B>, mut w: W) {
    let n = scan.token::<usize>();
    let m = scan.token::<usize>();

    let mut primes = [true; 51];

    primes[0] = false;
    primes[1] = false;

    for i in 2usize..=50 {
        for j in ((2*i)..=50).step_by(i) {
            primes[j] = false;
        }
    }

    let mut i = n;
    assert!(primes[i]);

    let mut ans = "YES";
    while i < 50 {
        i += 1;
        if primes[i] == true {
            if i != m {
                ans = "NO"
            }
            break;
        }
    }

    writeln!(w, "{}", ans);
}

fn main() {
    let stdin = io::stdin();
    let stdout = io::stdout();
    let reader = Scanner::new(stdin.lock());
    let writer = io::BufWriter::new(stdout.lock());
    solve(reader, writer);
}

#[allow(dead_code)]
fn matrix_to_str<T: ToString>(matrix: &Vec<Vec<T>>, separator: &str) -> String {
    use std::fmt::Write;
    let mut ans = String::new();
    for line in matrix.iter() {
        for elem in line.iter() {
            write!(&mut ans, "{}{}", elem.to_string(), separator).unwrap();
        }
        write!(&mut ans, "\n").unwrap();
    }
    ans
}
pub struct Scanner<B> {
    reader: B,
    buf_str: Vec<u8>,
    buf_iter: std::str::SplitWhitespace<'static>,
}
impl<B: BufRead> Scanner<B> {
    pub fn new(reader: B) -> Self {
        Self {
            reader,
            buf_str: Vec::new(),
            buf_iter: "".split_whitespace()
        }
    }
    pub fn token<T: std::str::FromStr>(&mut self) -> T {
        loop {
            if let Some(token) = self.buf_iter.next() {
                return token.parse().ok().expect("Failed parse");
            }
            self.buf_str.clear();
            self.reader.read_until(b'\n', &mut self.buf_str).expect("Failed read");
            self.buf_iter = unsafe {
                let slice = std::str::from_utf8_unchecked(&self.buf_str);
                std::mem::transmute(slice.split_whitespace()) }
        }
    }
    pub fn get_matrix<T: std::str::FromStr>(&mut self, m: usize, n: usize) -> Vec<Vec<T>> {
        // m rows and n columns
        let mut ans: Vec<Vec<T>> = Vec::with_capacity(m);
        for i in 0..m {
            ans.push(Vec::with_capacity(n));
            for _ in 0..n {
                ans[i].push(self.token::<T>());
            }
        }
        ans
    }
}