package main

import (
	"fmt"
	"math"
)

var dp [][]int64

func main() {
	var n, w int64
	fmt.Scanf("%d%d", &n, &w)
	weight := make([]int64, n)
	values := make([]int64, n)
	for i := 0; i < int(n); i++ {
		fmt.Scanf("%d%d", &weight[i], &values[i])
	}
	ans := maximumPossibleSumKnapsack2(n, w, values, weight)
	fmt.Println(ans)
}

func createDPTable(n int64, v int64) [][]int64 {
	dp = make([][]int64, n+1)
	for i := range dp {
		dp[i] = make([]int64, v+1)
		for j := range dp[i] {
			dp[i][j] = 1 << 32
		}
	}
	dp[0][0] = 0
	return dp
}

func maximumPossibleSumKnapsack2(n int64, w int64, values []int64, weight []int64) int64 {
	var totalValues int64
	for i := range values {
		totalValues += values[i]
	}
	dp = createDPTable(n, totalValues)
	var ans int64
	for i := totalValues; i >= 0; i-- {
		if solve(n, i, values, weight) <= w {
			ans = int64(i)
			break
		}
	}
	return ans
}

func solve(n int64, v int64, values []int64, weight []int64) int64 {
	if n == 0 {
		if v == 0 {
			return 0
		}
		return 1 << 32
	}
	if dp[n][v] != 1<<32 {
		return dp[n][v]
	}
	ans := solve(n-1, v, values, weight)
	if values[n-1] <= v {
		ans = int64(math.Min(float64(ans), float64(weight[n-1]+solve(n-1, v-values[n-1], values, weight))))
	}
	dp[n][v] = ans
	return ans
}


package main

import (
	"fmt"
	"math"
)

func main() {
	var n, w int64
	fmt.Scanf("%d%d", &n, &w)
	weight := make([]int64, n)
	values := make([]int64, n)
	for i := 0; i < int(n); i++ {
		fmt.Scanf("%d%d", &weight[i], &values[i])
	}
	ans := maximumPossibleSum(n, w, values, weight)
	fmt.Println(ans)
}

// https://atcoder.jp/contests/dp/tasks/dp_d
func maximumPossibleSum(n int64, w int64, values []int64, weight []int64) int64 {
	dp := make([][]int64, n+1)
	for i := 0; i <= int(n); i++ {
		dp[i] = make([]int64, w+1)
	}
	for i := 1; i <= int(n); i++ {
		for j := 1; j <= int(w); j++ {
			if weight[i-1] > int64(j) {
				dp[i][j] = dp[i-1][j]
			} else {
				dp[i][j] = int64(math.Max(float64(dp[i-1][j]), float64(values[i-1]+dp[i-1][int64(j)-weight[i-1]])))
			}
		}
	}
	return dp[n][w]
}


#参考 #4023546 by kamina_zzz
N,W = gets.split.map &:to_i
D = [[0, 0]]
m = 0
N.times {
  w,v = gets.split.map &:to_i
  next if w+m > W
  D[0,D.size].each {|d|
    D << [d[0]+w, d[1]-v] if d[0]+w+m <= W
  }
  m = 0
  D.sort!.uniq! {|d| m>d[1] ? m=d[1] : m}
  m = D[0][0]
}
p -D[-1][1]


N, W = gets.split.map(&:to_i)
d = [[0, 0]]

(0..(N-1)).each do
  w, v = gets.split.map(&:to_i)
  next if w > W

  (0..(d.size - 1)).each do |i|
    d << [d[i][0] + w, d[i][1] + v] if d[i][0] + w <= W
  end
  d.sort!

  idx = 1
  while idx < d.size do
    if d[idx-1][1] >= d[idx][1]
      d.delete_at(idx)
    else
      idx += 1
    end
  end
end

puts d[-1][1]


def r;gets.split.map &:to_i;end

N,W = r
DP = [[0,0]] # weight, value

N.times do
  w,v = r
  DP.size.times do |i|
    next if DP[i][0] + w > W
    DP << [DP[i][0] + w, DP[i][1] + v]
  end

  DP.sort!

  i = 0
  while i < DP.size - 1
    unless DP[i][1] < DP[i+1][1]
      DP.delete_at(i+1)
    else
      i += 1
    end
  end
end

p DP[-1][1]


N, W = gets.split.map(&:to_i)
wv = N.times.map { gets.split.map(&:to_i) }

dp =[]
dp[0] = [10 ** 9 + 1] * (10 ** 5)
dp[0][0] = 0

1.upto(N) do |i|
  dp[i] = [10 ** 9 + 1] * (10 ** 5)
  0.upto(10 ** 5 - 1) do |j|
    if j - wv[i - 1][1] >= 0
      dp[i][j] = [dp[i - 1][j], dp[i - 1][j - wv[i - 1][1]] + wv[i - 1][0]].min
    else
      dp[i][j] = dp[i - 1][j]
    end
  end
end

(10 ** 5 - 1).downto(0) do |i|
  if dp[N][i] <= W
    puts i
    break
  end
end


N, W = gets.split.map(&:to_i)
wv = N.times.map { gets.split.map(&:to_i) }

dp =[]
dp[0] = [10 ** 9 + 1] * (10 ** 5)
dp[0][0] = 0

1.upto(N + 1) do |i|
  dp[i] = [10 ** 9 + 1] * (10 ** 5)
  0.upto(10 ** 5 - 1) do |j|
    if j - wv[i - 1][1] >= 0
      dp[i][j] = [dp[i - 1][j], dp[i - 1][j - wv[i - 1][1]] + wv[i - 1][0]].min
    else
      dp[i][j] = dp[i - 1][j]
    end
  end
end

10000.downto(0) do |i|
  if dp[N + 1][i] <= W
    puts i
    break
  end
end


N, W = gets.split.map(&:to_i)
wv = N.times.map { gets.split.map(&:to_i) }

dp =[]
dp[0] = [10 ** 9 + 1] * (10 ** 5)
dp[0][0] = 0

1.upto(N) do |i|
  dp[i] = [10 ** 9 + 1] * (10 ** 5)
  0.upto(10 ** 5 - 1) do |j|
    if j - wv[i - 1][1] >= 0
      dp[i][j] = [dp[i - 1][j], dp[i - 1][j - wv[i - 1][1]] + wv[i - 1][0]].min
    else
      dp[i][j] = dp[i - 1][j]
    end
  end
end

10000.downto(0) do |i|
  if dp[N][i] <= W
    puts i
    break
  end
end


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 , mut $ var : ident : $ t : tt $ ( $ r : tt ) * ) => { let mut $ var = read_value ! ( $ iter , $ t ) ; input_inner ! { $ iter $ ( $ r ) * } } ; ( $ iter : expr , mut $ var : ident $ ( $ r : tt ) * ) => { let mut $ var = $ iter . next ( ) . unwrap ( ) . parse ::< usize > ( ) . unwrap ( ) ; input_inner ! { $ iter $ ( $ r ) * } } ; ( $ iter : expr , $ var : ident : $ t : tt $ ( $ r : tt ) * ) => { let $ var = read_value ! ( $ iter , $ t ) ; input_inner ! { $ iter $ ( $ r ) * } } ; ( $ iter : expr , $ var : ident $ ( $ r : tt ) * ) => { let $ var = $ iter . next ( ) . unwrap ( ) . parse ::< usize > ( ) . unwrap ( ) ; 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 > ( ) . unwrap ( ) } ; }
use std::cmp::min;
fn main() {
    input! { n, cap, wv: [(usize, usize); n] };
    const V: usize = 1_000_00;
    let mut dp = vec![std::usize::MAX; V + 1];
    dp[0] = 0;
    for &(w, v) in &wv {
        for vi in (0..(V + 1)).rev() {
            if dp[vi] == std::usize::MAX {
                continue;
            }
            if vi + v <= V {
                dp[vi + v] = min(dp[vi + v], dp[vi] + w);
            }
        }
    }
    println!(
        "{}",
        dp.iter()
            .enumerate()
            .filter_map(|(v, &w)| if w <= cap { Some(v) } else { None })
            .max()
            .unwrap()
    );
}


#![allow(unused_mut)]
#![allow(non_snake_case)]
#![allow(unused_macros)]
#![allow(unused_variables)]
#![allow(unused_imports)]
#![allow(dead_code)]
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

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

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

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

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

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

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

macro_rules! max {
    ($x: expr) => ($x);
    ($x: expr, $($y: expr),+) => {
        ::std::cmp::max($x, max!($($y),+))
    };
}

macro_rules! min {
    ($x: expr) => ($x);
    ($x: expr, $($y: expr),+) => {
        ::std::cmp::min($x, max!($($y),+))
    };
}

const MOD: usize = 1_000_000_007;
const MAX: usize = 510_000;
fn com_init(fac: &mut [usize], finv: &mut [usize], inv: &mut [usize]) {
    fac[0] = 1;
    fac[1] = 1;
    finv[0] = 1;
    finv[1] = 1;
    inv[1] = 1;
    for i in 2..MAX {
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

fn bin_coef(n: usize, k: usize, fac: &mut [usize], finv: &mut [usize], inv: &mut [usize]) -> usize {
    if k > n/2 {
        bin_coef(n-k, k, fac, finv, inv)
    } else {
        fac[n] * (finv[k] * finv[n - k] % MOD) % MOD
    }
}

use std::cmp;
use std::collections::{HashSet, BinaryHeap, VecDeque, HashMap};
use std::iter::FromIterator;
fn main() {
    input!{
        N: usize,
        W: usize,
        budget: [(usize, usize); N],
    }

    let vmax = budget.iter().fold(0usize, |acc, &(_, v)| acc+v);
    let mut weights = vec![0; vmax+1];
    for &(w, v) in budget.iter() {
        for prev in (1..vmax+1-v).rev() {
            if weights[prev] > 0 && weights[prev+v] > 0 {
                weights[prev+v] = min!(weights[prev+v], weights[prev]+w);
            } else if weights[prev] > 0 {
                weights[prev+v] = weights[prev] + w;
            }
        }
        if weights[v] == 0 {
            weights[v] = w;
        } else {
            weights[v] = min!(weights[v], w)
        }
    }

    let (v, _) = weights.iter().enumerate().filter(|&(_, &w)| 0<w && w<=W).last().unwrap();
    println!("{}", v);
}


use std::cmp::*;
use std::io::*;
use std::str::FromStr;
use utils::*;

pub fn main() {
    let i = stdin();
    let mut o = Vec::new();
    run(i.lock(), &mut o);
    stdout().write_all(&o).unwrap();
}

fn run<R: BufRead, W: Write>(i: R, o: &mut W) {
    let mut i = CpReader::new(i);
    let (n, w) = i.read2::<usize, usize>();
    let mut wv = Vec::new();
    for _ in 0..n {
        wv.push(i.read2::<usize, usize>())
    }
    writeln!(o, "{}", solve(w, &wv)).unwrap();
}
fn solve(w: usize, wv: &[(usize, usize)]) -> usize {
    let mut ws = vec![usize::max_value(); wv.len() * 1000 + 1]; // 現時点でのws[v] は価値vの品物の最小の重さ
    let mut v_max = 0;
    ws[0] = 0;

    for &(wi, vi) in wv {
        for j in (0..v_max + 1).rev() {
            let w_next = min(ws[j + vi], ws[j] + wi);
            if w_next <= w {
                ws[vi + j] = w_next;
                v_max = max(v_max, vi + j);
            }
        }
        for j in 0..vi {
            if ws[vi] < ws[j] {
                ws[j] = ws[vi];
            }
        }
    }
    v_max
}

mod utils {
    use super::*;

    pub struct CpReader<R: BufRead> {
        r: R,
        s: String,
    }

    macro_rules! fn_read {
        { $f:ident($($t:ident),*) } => {
            #[allow(dead_code)]
            pub fn $f<$($t: FromStr),*>(&mut self) -> ($($t),*) {
                let i = &mut self.read_line().split(' ');
                ($(read_next::<$t,_>(i)),*)
            }
        };
    }

    impl<R: BufRead> CpReader<R> {
        pub fn new(r: R) -> Self {
            CpReader {
                r: r,
                s: String::new(),
            }
        }
        pub fn read_line(&mut self) -> &str {
            self.s.clear();
            self.r.read_line(&mut self.s).unwrap();
            self.s.trim()
        }

        fn_read! { read2(T1, T2) }
        fn_read! { read3(T1, T2, T3) }
        fn_read! { read4(T1, T2, T3, T4) }
        fn_read! { read5(T1, T2, T3, T4, T5) }
    }
    fn read_next<'a, T: FromStr, I: Iterator<Item = &'a str>>(i: &mut I) -> T {
        i.next().unwrap().parse().ok().unwrap()
    }

}


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

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

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

#[derive(Debug)]
struct Load {
    weight: i64,
    value: i64,
}

use std::collections::BTreeMap;

fn main() {
    input! {
        n: i64,
        w: i64,
        loads: [[Load; weight, value]; n as usize]
    }
    let mut cache = BTreeMap::new();
    let v = max_value(&loads, &mut cache, n - 1, w);
    println!("{}", v)
}

fn max_value(loads: &Vec<Load>, cache: &mut BTreeMap<(i64, i64), i64>, k: i64, y: i64) -> i64 {
    if k < 0 || y < 0 {
        0
    } else {
        if let Some(v) = cache.get(&(k, y)) {
            return *v;
        }
        let using = if y - loads[k as usize].weight < 0 {
            0
        } else {
            max_value(loads, cache, k - 1, y - loads[k as usize].weight) + loads[k as usize].value
        };
        let not_using = max_value(loads, cache, k - 1, y);
        let value = i64::max(using, not_using);
        cache.insert((k, y), value);
        value
    }
}


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

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

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

#[derive(Debug)]
struct Load {
    weight: i64,
    value: i64,
}

use std::collections::HashMap;

fn main() {
    input! {
        n: i64,
        w: i64,
        loads: [[Load; weight, value]; n as usize]
    }
    let mut cache = HashMap::new();
    let v = max_value(&loads, &mut cache, n - 1, w);
    println!("{}", v)
}

fn max_value(loads: &Vec<Load>, cache: &mut HashMap<(i64, i64), i64>, k: i64, y: i64) -> i64 {
    if k < 0 || y < 0 {
        0
    } else {
        if let Some(v) = cache.get(&(k, y)) {
            return *v;
        }
        let using = if y - loads[k as usize].weight < 0 {
            0
        } else {
            max_value(loads, cache, k - 1, y - loads[k as usize].weight) + loads[k as usize].value
        };
        let not_using = max_value(loads, cache, k - 1, y);
        let value = i64::max(using, not_using);
        cache.insert((k, y), value);
        value
    }
}


use proconio::input;
use std::cmp;

fn main() {
    input! {
        n: usize,
        w: usize,
        items: [(usize, usize); n],
    }

    let inf = 10usize.pow(10);
    let max_v = 1001;
    let mut dp = vec![vec![inf; max_v]; n + 1];
    dp[0][0] = 0;

    for i in 1..=n {
        for j in 0..max_v {
            dp[i][j] = dp[i - 1][j];
            if j >= items[i - 1].1 {
                dp[i][j] = cmp::min(dp[i][j], dp[i - 1][j - items[i - 1].1] + items[i - 1].0);
            }
        }
    }

    let mut ans = 0;
    for i in 0..max_v {
        if dp[n][i] <= w {
            ans = i;
        }
    }
    println!("{}", ans);
}


import Foundation

func readWords<T>(_ f: (Substring) -> T) -> [T] {
    return readLine()!.split(separator: " ").map(f)
}

func main() {
    let nw = readWords { Int($0)! }
    let n = nw[0]
    let w = nw[1]

    var items = [(w: Int, v: Int)]()
    var totalWeight = 0
    var totalValue = 0
    for _ in 1...n {
        let wv = readWords { Int($0)! }
        items.append((w: wv[0], v: wv[1]))
        totalWeight += wv[0]
        totalValue += wv[1]
    }

    // ある価値での最小の重さ
    var dp = [Int](repeating: totalWeight, count: totalValue+1)
    dp[0] = 0

    for i in 0..<n {
        let item = items[i]
        for value in (0...totalValue).reversed() {
            if value + item.v <= totalValue {
                dp[value+item.v] = min(dp[value+item.v], dp[value]+item.w)
            }
        }
    }

    let ans = dp.enumerated().filter { $0.1 <= w }
    print(ans.last!.0)
}

main()


let input = readLine()!.split(separator: " ").map { Int($0)! }

let N = input[0]
let W = input[1]

var weights: [Int] = .init(repeating: 0, count: N)
var values: [Int] = .init(repeating: 0, count: N)

for i in 0..<N {
  let inp = readLine()!.split(separator: " ").map { Int($0)! }
  weights[i] = inp[0]
  values[i] = inp[1]
}

let V = values.reduce(0, +)

var dp: [[Int]] = .init(repeating: .init(repeating: .max, count: V + 1), count: N + 1)
dp[0][0] = 0
for i in 1...N {
  for j in 0...V {
   	let prev = j - values[i - 1]
    if prev < 0 || dp[i-1][prev] == .max {
      dp[i][j] = dp[i-1][j]
      continue
    }
    dp[i][j] = min(dp[i-1][prev] + weights[i - 1], dp[i-1][j])
  }
}
for j in (0..<dp[N].count).reversed() {
  if dp[N][j] <= W {
    print(j)
    break
  }
}


/// Swift5 -> Swift2.2

extension String {
    // split(separator:maxSplits:omittingEmptySubsequences:)
    func split(separator separator: Character) -> [String] {
        return self.characters.split(separator).map(String.init)
    }
}
extension Array {
    // init(repeating:count:)
    init(repeating: Element, count: Int) {
        self.init(count: count, repeatedValue: repeating)
    }
  	// func lastIndex(where predicate: (Element) throws -> Bool) rethrows -> Int?
    func lastIndex(where predicate: (Element) -> Bool) -> Int? {
      	for i in stride(from: count - 1, through: 0, by: -1) {
          	if predicate(self[i]) {
              	return i
            }
        }
      	return nil
    }
}
extension Array where Element: Comparable {
    // sorted()
    func sorted() -> [Element] {
        return self.sort( { $0 < $1 } )
    }
}
// stride(from:through:by:)
func stride(from start: Int, through end: Int, by stride: Int) -> StrideThrough<Int> {
    return start.stride(through: end, by: stride)
}
// stride(from:to:by)
func stride(from start: Int, to end: Int, by stride: Int) -> StrideTo<Int> {
    return start.stride(to: end, by: stride)
}
extension Range {
    func reversed() -> [Element] {
        return self.reverse()
    }
}

/// end

let input = readLine()!.split(separator: " ").map { Int($0)! }
let N = input[0]
let W = input[1]

var dp = Array(repeating: 1_000_000_000 + 1, count: 1_000 * N + 1)
dp[0] = 0

for _ in 0 ..< N {
    let knapsack = readLine()!.split(separator: " ").map { Int($0)! }
    let weight = knapsack[0]
    let value = knapsack[1]

    for i in stride(from: 1_000 * N, through: value, by: -1) {
        dp[i] = min(dp[i], dp[i - value] + weight)
    }
}

print(dp.lastIndex { $0 <= W }!)


let input = readLine()!.split(separator: " ").map { Int($0)! }

let N = input[0]
let W = input[1]

var weights: [Int] = .init(repeating: 0, count: N)
var values: [Int] = .init(repeating: 0, count: N)

for i in 0..<N {
  let inp = readLine()!.split(separator: " ").map { Int($0)! }
  weights[i] = inp[0]
  values[i] = inp[1]
}

var dp: [[Int]] = .init(repeating: .init(repeating: 0, count: W + 1), count: N + 1)

for i in 1...N {
  for j in 1...W {
   	let prev = j - weights[i - 1]
    if prev < 0 {
      dp[i][j] = dp[i-1][j]
      continue
    }
    dp[i][j] = max(dp[i-1][prev] + values[i - 1], dp[i-1][j])
  }
}
print(dp[N][W])


/// Swift5 -> Swift2.2

extension String {
    // split(separator:maxSplits:omittingEmptySubsequences:)
    func split(separator separator: Character) -> [String] {
        return self.characters.split(separator).map(String.init)
    }
}
extension Array {
    // init(repeating:count:)
    init(repeating: Element, count: Int) {
        self.init(count: count, repeatedValue: repeating)
    }
}
extension Array where Element: Comparable {
    // sorted()
    func sorted() -> [Element] {
        return self.sort( { $0 < $1 } )
    }
    // lastIndex(where:)
    func lastIndex(where predicate: (Element) -> Bool) -> Int? {
        for i in (0 ..< self.count).reverse() {
            if predicate(self[i]) {
                return i
            }
        }
        return nil
    }
}
// stride(from:through:by:)
func stride(from start: Int, through end: Int, by stride: Int) -> StrideThrough<Int> {
    return start.stride(through: end, by: stride)
}
// stride(from:to:by)
func stride(from start: Int, to end: Int, by stride: Int) -> StrideTo<Int> {
    return start.stride(to: end, by: stride)
}
extension Range {
    func reversed() -> [Element] {
        return self.reverse()
    }
}

/// end

let input = readLine()!.split(separator: " ").map { Int($0)! }
let N = input[0]
let W = input[1]

var dp = Array(repeating: 1_000_000_000 + 1, count: 1_000 * N + 1)
dp[0] = 0

for _ in 0 ..< N {
    let knapsack = readLine()!.split(separator: " ").map { Int($0)! }
    let weight = knapsack[0]
    let value = knapsack[1]

    for i in (value ... 1_000 * N).reversed() {
        dp[i] = min(dp[i], dp[i - value] + weight)
    }
}

print(dp.lastIndex { $0 <= W }!)


'use strict';
process.stdin.resume();
process.stdin.setEncoding('utf8');

// Your code here!
const max = (a)=>{
    let i = a.length;
    let max=-Infinity;
    while (i--) {
        if (a[i] > max)max = a[i];
    }
    return max;
}
const min = (a)=>{
    let i = a.length;
    let max=Infinity;
    while (i--) {
        if (a[i] < max)max = a[i];
    }
    return max;
}
const Main = (p)=>{
	p = p.split("\n");//2 or more
	//let N = parseInt(p[0]);//N
	const N = parseInt(p[0].split(" ")[0]);//N M
	const W = parseInt(p[0].split(" ")[1]);//N M
	//let h = (p[1].split(" ").map(Number));//a1 a2 a3...

	let w = new Array(N);
	let v = new Array(N);
	//let c=new Array(N);
    //let z=new Array(N);
    for(let i=0;i<N;i++){
        let h = (p[i+1].split(" ").map(Number));
        w[i]=h[0];
        v[i]=h[1];
    }

    const maxv=100000;
	let m = new Array(N+1);
    //console.log(N,W,w,v);return;
    m[0]=new Array(maxv+1).fill(Infinity);
    m[0][0]=0;
    for(let i=0;i<=N;i++){
        m[i+1]=m[i].concat();
        for(let j=0;j<=maxv;j++){
            if(j-v[i]>=0){
                //console.log(m[i][j-w[i]]+v[i],m[i][j])
                m[i+1][j]=Math.min(m[i][j-v[i]]+w[i],m[i][j]);
            }

        }
        //console.log(i,m[i])
    }
	//console.log(m[N][maxv-1]);
	let i=maxv;
	while(m[N][i--]>W);//console.log(m[N][i--]);
	console.log(i+1);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8").trim());


const lines: string[] = [];
const reader = require("readline").createInterface({
  input: process.stdin,
  output: process.stdout,
});
reader.on("line", function (line: string) {
  lines.push(line);
});

reader.on("close", function () {
  const rule = lines.shift().split(" ").map(Number);
  const itemNum = rule[0];
  const weightMax = rule[1];

  const data: any = lines.map((line) => {
    return line.split(" ").map((int) => parseInt(int));
  });

  const dp = [];
  dp.push(new Array(weightMax + 1).fill(0));
  for (let i = 0; i < itemNum; i++) {
    dp.push(new Array(weightMax + 1).fill(-1));
  }

  for (let i = 0; i < itemNum; i++) {
    for (let w = 0; w <= weightMax; w++) {
      if (w - data[i][0] >= 0) {
        dp[i + 1][w] = Math.max(
          dp[i + 1][w],
          dp[i][w - data[i][0]] + data[i][1]
        );
      }
      dp[i + 1][w] = Math.max(dp[i + 1][w], dp[i][w]);
    }
  }

  console.log(Math.max.apply(null, dp[itemNum]));
});


S = input()

if S <= "2019/04/30":
    print("Heisei")
else:
    print("TBD")


s = input()
if int(s[5:7]) > 4:
  print("TBD")
else:
  print("Heisei")


y,m,d = map(int,input().split("/"))
if y <= 2018:
    print("Heisei")
elif y >= 2020:
    print("TBD")
elif y == 2019 and m <= 4:
    print("Heisei")
else:
    print("TBD")


s = input()

year = s[:4]
mo = s[5:7]
da = s[8:]

if year < 2019:
  ans = "Heisei"
elif year == 2019 and mo<= 4:
  ans ='Heisei'
else:
  ans = 'TBD'
print(ans)


s = map(str,input().split())
if int(s[5]) == 1:
  print("TBD")
elif int(s[6]) <= 4:
  print("Heisei")
else:
  print("TBD")


s = [int(x) for x in input().split("/")]

if s[1] < 4:
  print("Heisei")
elif s[1] == 4 and s[2] < 30:
  print("Heisei")
else:
  print("TBD")


import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.AbstractMap;
import java.util.NoSuchElementException;

/** テンプレート */
public class Main {
	public static void main(String[] args) {
		FastScanner sc = new FastScanner();
		String s = sc.next();

//		int N = sc.nextInt();
//		int M =  sc.nextInt();
//
//		int[] ary = new int[N];
//		for(int i = 0; i < N; i++) {
//			ary[i] = sc.nextInt();
//		}

		//************************************/
		// ここから出力処理
		//************************************/
		PrintWriter out = new PrintWriter(System.out);

		if(s.compareTo("2019/04/30") <=0) {
			out.println("Heisei");
		}else {
			out.println("TBD");
		}

		// 最後に必ずFlush
		out.flush();
	}
}

///** テンプレート */
//public class Main {
//	public static void main(String[] args) {
//		FastScanner sc = new FastScanner();
//		int N = sc.nextInt();
//		int M =  sc.nextInt();
//
//		int[] ary = new int[N];
//		for(int i = 0; i < N; i++) {
//			ary[i] = sc.nextInt();
//		}
//
//		//************************************/
//		// ここから出力処理
//		//************************************/
//		PrintWriter out = new PrintWriter(System.out);
//
//
//		out.println("hoge");
//
//		// 最後に必ずFlush
//		out.flush();
//	}
//}

/** スキャン用 */
class FastScanner {
	private final InputStream in = System.in;
	private final byte[] buffer = new byte[1024];
	private int ptr = 0;
	private int buflen = 0;

	/** クラス内部用だよ */
	private boolean hasNextByte() {
		if (ptr < buflen) {
			return true;
		} else {
			ptr = 0;
			try {
				buflen = in.read(buffer);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (buflen <= 0) {
				return false;
			}
		}
		return true;
	}

	/** クラス内部用だよ */
	private int readByte() {
		if (hasNextByte()) {
			return buffer[ptr++];
		} else {
			return -1;
		}
	}

	/**
	 * クラス内部用だよ
	 * ASCII の文字の内、表示用の文字を返す関数
	 *
	 * @return 改行とか制御文字じゃない、表示用文字ならtrue
	 * */
	private static boolean isPrintableChar(int c) {
		return 33 <= c && c <= 126;
	}

	/**
	 * @return 改行文字とか空白以外を除いた、次の文字があればtrue
	 * */
	public boolean hasNext() {
		while (hasNextByte() && !isPrintableChar(buffer[ptr])) {
			ptr++;
		}
		return hasNextByte();
	}

	/**
	 *
	 * @return 次の文字列
	 */
	public String next() {
		if (!hasNext()) {
			throw new NoSuchElementException();
		}

		StringBuilder sb = new StringBuilder();
		int b = readByte();
		while (isPrintableChar(b)) {
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}

	/**
	 *
	 * @return 次のLong
	 */
	public long nextLong() {
		if (!hasNext())
			throw new NoSuchElementException();
		long n = 0;
		boolean minus = false;
		int b = readByte();
		if (b == '-') {
			minus = true;
			b = readByte();
		}
		if (b < '0' || '9' < b) {
			throw new NumberFormatException();
		}
		while (true) {
			if ('0' <= b && b <= '9') {
				n *= 10;
				n += b - '0';
			} else if (b == -1 || !isPrintableChar(b)) {
				return minus ? -n : n;
			} else {
				throw new NumberFormatException();
			}
			b = readByte();
		}
	}

	/**
	 *
	 * @return 次のInt
	 */
	public int nextInt() {
		long nl = nextLong();
		if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
			throw new NumberFormatException();
		return (int) nl;
	}

	/**
	 *
	 * @return 次のDouble
	 */
	public double nextDouble() {
		return Double.parseDouble(next());
	}
}

class Pair<K, V> extends AbstractMap.SimpleEntry<K, V> {
	/** serialVersionUID. */
	private static final long serialVersionUID = 6411527075103472113L;

	public Pair(final K key, final V value) {
		super(key, value);
	}
}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.*;
import java.math.*;

public class Main {
	public static void main(String[] args)throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringBuilder sb = new StringBuilder();

		String[] str = br.readLine().split("/");
		int y = Integer.parseInt(str[0]);
		int m = Integer.parseInt(str[1]);
		if(y>2019 || (y<=2019 && m>4)){
			System.out.println("TBD");
		}else{
			System.out.println("Heisei");
		}
	}
}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
  private static class FastScanner {
    private BufferedReader reader = null;
    private StringTokenizer tokenizer = null;

    public FastScanner(InputStream in) {
      reader = new BufferedReader(new InputStreamReader(in));
      tokenizer = null;
    }

    public String next() {
      if (tokenizer == null || !tokenizer.hasMoreTokens()) {
        try {
          tokenizer = new StringTokenizer(reader.readLine());
        } catch (IOException e) {
          throw new RuntimeException(e);
        }
      }
      return tokenizer.nextToken();
    }

    public String nextLine() {
      if (tokenizer == null || !tokenizer.hasMoreTokens()) {
        try {
          return reader.readLine();
        } catch (IOException e) {
          throw new RuntimeException(e);
        }
      }

      return tokenizer.nextToken("\n");
    }

    public long nextLong() {
      return Long.parseLong(next());
    }

    public int nextInt() {
      return Integer.parseInt(next());
    }

    public double nextDouble() {
      return Double.parseDouble(next());
    }

    public int[] nextIntArray(int n) {
      int[] a = new int[n];
      for (int i = 0; i < n; i++)
        a[i] = nextInt();
      return a;
    }

    public long[] nextLongArray(int n) {
      long[] a = new long[n];
      for (int i = 0; i < n; i++)
        a[i] = nextLong();
      return a;
    }
  }

  public static void main(String[] args) {
    FastScanner sc = new FastScanner(System.in);
    String[] s = sc.next().split("/");
    int year = Integer.parseInt(s[0]);
    int month = Integer.parseInt(s[1]);
    int day = Integer.parseInt(s[2]);
    String result = "TBD";
    if (year < 2019) result = "Heisei";
    else if (year == 2019 && month < 4) result = "Heisei";
    else if (year == 2019 && month == 4 && day <= 30) result = "Heisei";
    System.out.println(result);
  }
}


import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        try (Scanner in = new Scanner(System.in)) {
            String S = in.next();

            int yyyy = Integer.parseInt(S.substring(0, 4));
            int mm = Integer.parseInt(S.substring(5, 7));
            int dd = Integer.parseInt(S.substring(8, 10));

            System.out.println(isHeisei(yyyy, mm, dd) ? "Heisei" : "TBD");
        }
    }

    private static boolean isHeisei(int yyyy, int mm, int dd) {
        if (yyyy < 2019) {
            return true;
        }
        if (yyyy > 2019) {
            return false;
        }
        if (dd < 5) {
            return true;
        }
        return false;
    }
}


import java.util.*;
public class Main{
	public static void main(String[] args){
    	Scanner sc = new Scanner(System.in);
      	String s = sc.next();
		s.replaceAll("/", "");
      	if(s.compareTo("20190430") <= 0) System.out.println("Heisei");
        else System.out.println("TBD");
    }
}


import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		String s=scan.nextLine();
		String t="";
		t+=s.charAt(5);
		t+=s.charAt(6);
		int a=Integer.parseInt(t);
		System.out.println(a);
		if(a<=04) System.out.println("Heisei");
		else System.out.println("TBD");
	}

}


#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
char ch[15];
int main()
{
  scanf("%s",ch+1);
  int a=0;
  for(int i=1;i<=4;i++)
    a=a*10+ch[i]-'0';
  if(a<2019){puts("Heisei");return 0;}
  if(a>2019){puts("TBD");return 0;}
  a=(ch[6]-'0')*10+ch[7]-'0';
  if(a<4){puts("Heisei");return 0;}
  if(a>4){puts("TBD");return 0;}
  a=(ch[9]-'0')*10+ch[10]-'0';
  if(a<=30){puts("Heisei");return 0;}
  else {puts("TBD");return 0;}
}


#include <stdio.h>

int main(){
	int yyyy, mm, dd;
	scanf("%d/%d/%d", &yyyy, &mm, &dd);

	if (yyyy >= 2019 && mm >= 5) {
		printf("TBD");
	}
	else {
		printf("Heisei");
	}

	return 0;
}


#include <cstdio>
using namespace std;

int num_of(char ch){return ch-'0';}
int main(){
  char buf[100];
  scanf("%s", buf);
  int y = num_of(buf[0])*1000 + num_of(buf[1])*100 + num_of(buf[2])*10 + num_of(buf[3]);
  int m = num_of(buf[5])*10 + num_of(buf[6]);
  int d = num_of(buf[8])*10 + num_of(buf[9]);
  bool flag;
  if(y>2019){
    flag = true;
  }else if(y<2019){
    flag = false;
  }else if(m>4){
    flag = true;
  }else if(m<4){
    flag = false;
  }else if(d>30){
    flag = true;
  }else if(d<=30){
    flag = false;
  }
  printf("%s", flag ? "TBD" : "Heisei");
  return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//cout << fixed << setprecision(15);
vector<int> forintinput(int n) {
	vector<int> x;
	for(int i = 0;i < n;i++){
		int ia;
		cin >> ia;
		x.push_back(ia);
	}
	return x;
}
int main(){
	string s;
	cin >> s;
	if((s[0]-'0')*1000+(s[1]-'0')*100+(s[2]-'0')*10+(s[3]-'0') >= 2019){
		if((s[5]-'0')*10+(s[6]-'0') >= 4){
			if((s[8]-'0')*10+(s[9]-'0') >= 30){
				cout << "Heisei" << endl;
				return 0;
			}
		}
	}
	cout << "TBD" << endl;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//cout << fixed << setprecision(15);
vector<int> forintinput(int n) {
	vector<int> x;
	for(int i = 0;i < n;i++){
		int ia;
		cin >> ia;
		x.push_back(ia);
	}
	return x;
}
int main(){
	string s;
	cin >> s;
	if((s[0]-'0')*1000+(s[1]-'0')*100+(s[2]-'0')*10+(s[3]-'0') >= 2019){
		if((s[5]-'0')*10+(s[6]-'0') >= 4){
			if((s[8]-'0')*10+(s[9]-'0') >= 30){
				cout << "Heisei" << endl;
			}else{
				cout << "TBD" << endl;
			}
		}else{
			cout << "TBD" << endl;
		}
	}else{
		cout << "TBD" << endl;
	}
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//cout << fixed << setprecision(15);
vector<int> forintinput(int n) {
	vector<int> x;
	for(int i = 0;i < n;i++){
		int ia;
		cin >> ia;
		x.push_back(ia);
	}
	return x;
}
int main(){
	string s;
	cin >> s;
	if((s[0]-'0')*1000+(s[1]-'0')*100+(s[2]-'0')*10+(s[3]-'0') >= 2019){
		if((s[5]-'0')*10+(s[6]-'0') >= 4){
			if((s[8]-'0')*10+(s[9]-'0') >= 30){
				cout << "Heisei" << endl;
			}else{
				cout << "TBD" << endl;
			}
		}
	}
}


#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <limits.h>
#include <math.h>

int main(int argc, char *argv[])
{
    int y, m, d;
    int ans;

    scanf("%d/%d/%d", &y, &m, &d);

    if (y >= 2019 && m >= 5) {
        printf("TBD\n");
    } else {
        printf("Heisei\n");
    }

    return 0;
}


#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <stdio.h>
int compare(const void *a,const void *b){
    if(*(long long*)a>*(long long *)b )return 1;
    return -1;
}
int main()
{   int i,j,a,b,x,y,n,m,k;
char s[11];
    scanf("%s",s);
    char h[11]="2019/04/30";
    if(strcmp(s,h)<=0)
    printf("Heisei");
    else printf("TBD");

    return 0;
}


#include <stdio.h>
int main(void){
    unsigned int y=0,m=0,d=0;
    scanf("%4d/%2d/%2d",&y,&m,&d);
    if(y<2019 ){
        printf("Heisei");
    }else  if(m<5){
        printf("Heisei");
    }else{
        printf("TBD");
    }
    return 0;
}


#include<stdio.h>

int main(void){
  char s[100];
  scanf("%s",s);
  if(s[6]<='4'){
    printf("Heisei\n");
  }else if(s[6]>='5'){
    printf("TBD\n");
  }
  return 0;
}


#include<stdio.h>

int main(void){
  char s[100];
  scanf("%s",s);
  if(s[6]<='4'){
    printf("Heisei\n");
  }else{
    printf("TBD\n");
  }
  return 0;
}


#include<stdio.h>

int main(void){
  char s[100];
  scanf("%s",s);
  if(s[6]<=4){
    printf("Heisei\n");
  }else{
    printf("TBD\n");
  }
  return 0;
}


function Main(input) {
  input = input.trim()
  input = input.split("/").map(Number);
  if(input[1]<=4) console.log("Heisei");
  else console.log("TBD")
}Main(require("fs").readFileSync("/dev/stdin", "utf8"));


function Main(input){
  	input = input.trim();

    if(input > "2019/04/30"){
    console.log("TBD");
    }else{
    console.log("Heisei");
    }
}

Main(require("fs").readFileSync("/dev/stdin","utf8"));


function Main(input) {
  input = input.split("\n");
  var S = input[0].split("/");
  var ans = "Heisei";
  if(parseInt(S[0])>=2020||(parseInt(S[0])>=2019&&parseInt(S[1])>=5)){
    ans ="TBD";
  }

  console.log('%s', ans);
}

// "実行する"ボタンを押した時に実行される関数 (デバッグ用)
function debug(){
  var input = document.getElementById("input").value;
  Main(input);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


function main(input) {
  const args = input.split('/').map(n => parseInt(n, 10));
  const M = args[1];

  if (M >= 4) {
    console.log('TBD');
  } else {
    console.log('Heisei');
  }

}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));


var stdin = require("fs").readFileSync("/dev/stdin", "utf8");
stdin = stdin.trim().split("\n").reverse();
function input(){return stdin.pop()}
var stdout = [];

s = input().split("/")
if (parseInt(s[1], 10) < 5){
    stdout.push("Heisei")
}else{
    stdout.push("TBD")
}

console.log(stdout);


function Main(input) {
  input = input.trim()
  input = input.split("/").map(Number);
  if(input[1]<=5) console.log("Heisei");
  else console.log("TBD")
}Main(require("fs").readFileSync("/dev/stdin", "utf8"));


package main

import (
	"fmt"
	"strconv"
	"strings"
)

func main() {
	var s string
	fmt.Scan(&s)
	ymd := strings.Split(s, "/")
	y, _ := strconv.Atoi(ymd[0])
	m, _ := strconv.Atoi(ymd[1])
	d, _ := strconv.Atoi(ymd[2])
	if y <= 2019 && m <= 4 && d <= 30 {
		fmt.Println("Heisei")
	} else {
		fmt.Println("TBD")
	}
}


package main

import (
	"bufio"
	"container/heap"
	"fmt"
	"math"
	"os"
	"strconv"
	"strings"
)

const (
	initialBufSize = 10000
	maxBufSize     = 1000000
	mod            = 1e9 + 7
)

var (
	sc *bufio.Scanner = func() *bufio.Scanner {
		sc := bufio.NewScanner(os.Stdin)
		buf := make([]byte, initialBufSize)
		sc.Buffer(buf, maxBufSize)
		sc.Split(bufio.ScanWords)
		return sc
	}()
)

func main() {
	S := getString()
	datetime, _ := strconv.Atoi(strings.Replace(S, "/", "", -1))

	if datetime <= 20190430 {
		fmt.Println("Heisei")
	} else {
		fmt.Println("TBD")
	}
}

type Graph struct {
	n     int
	edges [][]int
}

func NewGraph(n int) *Graph {
	g := &Graph{
		n:     n,
		edges: make([][]int, n),
	}
	return g
}

func (g *Graph) AddEdge(u, v int) {
	g.edges[v] = append(g.edges[v], u)
	g.edges[u] = append(g.edges[u], v)
}

func dfs(c int, edges [][]int, visited map[int]struct{}) {
	visited[c] = struct{}{}

	for _, v := range edges[c] {
		_, flag := visited[v]
		if flag {
			continue
		}
		dfs(v, edges, visited)
	}
}

func bfs(c int, graph *Graph) {
	next := make([]int, 0)
	next = append(next, c)
	visited := make(map[int]struct{})

	for ; len(next) != 0; {
		u := next[0]
		next = next[1:]
		visited[u] = struct{}{}

		for _, v := range graph.edges[u] {
			_, flag := visited[v]
			if flag {
				continue
			}

			// なにか処理

			next = append(next, v)
		}
	}
}

func getInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func getIntArray(n int) []int {
	array := make([]int, n)
	for i := 0; i < n; i++ {
		array[i] = getInt()
	}
	return array
}

func getString() string {
	sc.Scan()
	return sc.Text()
}

func abs(a int) int {
	return int(math.Abs(float64(a)))
}

func pow(p, q int) int {
	return int(math.Pow(float64(p), float64(q)))
}

func powMod(n, p int) int {
	if p == 0 {
		return 1
	} else if p%2 == 0 {
		t := powMod(n, p/2)
		return calcMod(t * t)
	} else {
		return calcMod(n * powMod(n, p-1))
	}
}

func min(nums ...int) int {
	if len(nums) == 0 {
		panic("funciton min() requires at least one argument.")
	}
	res := nums[0]
	for i := 0; i < len(nums); i++ {
		res = int(math.Min(float64(res), float64(nums[i])))
	}
	return res
}

func max(nums ...int) int {
	if len(nums) == 0 {
		panic("funciton max() requires at least one argument.")
	}
	res := nums[0]
	for i := 0; i < len(nums); i++ {
		res = int(math.Max(float64(res), float64(nums[i])))
	}
	return res
}

func strSearch(a []string, b string) bool {
	for i := 0; i < len(a); i++ {
		if a[i] == b {
			return true
		}
	}
	return false
}

func printIntArray(array []int) {
	strArray := fmt.Sprint(array)
	fmt.Println(strArray[1 : len(strArray)-1])
}

func calcMod(x int) int {
	return x % mod
}

func reverse(s string) string {
	runes := []rune(s)
	for i, j := 0, len(runes)-1; i < j; i, j = i+1, j-1 {
		runes[i], runes[j] = runes[j], runes[i]
	}
	return string(runes)
}

func isPrime(n int) bool {
	if n < 2 {
		return false
	} else if n == 2 {
		return true
	} else if n % 2 == 0 {
		return false
	}

	sqrtN := int(math.Sqrt(float64(n)))
	for i := 3; i <= sqrtN; i += 2 {
		if n % i == 0 {
			return false
		}
	}

	return true
}

func contains(s []int, e int) bool {
	for _, v := range s {
		if e == v {
			return true
		}
	}
	return false
}

func makeRange(min, max int) []int {
	a := make([]int, max-min+1)
	for i := range a {
		a[i] = min + i
	}
	return a
}

func powerset2(nums []int) [][]int {
	length := int(math.Pow(2, float64(len(nums))))
	result := make([][]int, length)

	index := 0
	result[index] = []int{}
	index++

	for _, n := range nums {
		max := index
		for i := 0; i < max; i++ {
			result[index] = copyAndAppend(result[i], n)
			index++
		}
	}

	return result
}

func copyAndAppend(nums []int, n int) []int {
	dst := make([]int, len(nums)+1)
	copy(dst, nums)
	dst[len(nums)] = n
	return dst
}

func calcGcd(x, y int) int {
	if y == 0 {
		return x
	} else if x >= y {
		return calcGcd(y, x % y)
	} else {
		return calcGcd(x, y % x)
	}
}

func getDivisor(n int) []int {
	var divisor []int
	divisor = append(divisor, 1)
	if n != 1 {
		divisor = append(divisor, n)
	}

	sqrt := int(math.Sqrt(float64(n)))
	for i := 2; i <= sqrt; i++ {
		if n % i == 0 {
			divisor = append(divisor, i)
			divisor = append(divisor, n/i)
		}
	}
	return divisor
}

type intHeap []int

func (h intHeap) Len() int {
	return len(h)
}

func (h intHeap) Less(i, j int) bool {
	return h[i] > h[j]
}

func (h intHeap) Swap(i, j int) {
	h[i], h[j] = h[j], h[i]
}

func (h *intHeap) Push(x interface{}) {
	*h = append(*h, x.(int))
}

func (h *intHeap) Pop() interface{} {
	old := *h
	n := len(old)
	x := old[n-1]
	*h = old[0 : n-1]
	return x
}

func initHeap() *intHeap {
	ih := &intHeap{}
	heap.Init(ih)
	return ih
}

func (h *intHeap) pushHeap(n int) {
	heap.Push(h, n)
}

func (h *intHeap) popHeap() int {
	return heap.Pop(h).(int)
}

func factMod(n int) int {
	value := 1
	for ; n > 1; n-- {
		value = calcMod(value * n)
	}
	return value
}

func combinationMod(n, k int) int {
	factN := factMod(n)
	factK := factMod(k)
	factNK := factMod(n - k)
	factKR := powMod(factK, mod - 2)
	factNKR := powMod(factNK, mod - 2)
	return calcMod(factN * calcMod(factKR * factNKR))
}


package main

import (
	"fmt"
	"time"
)

func main() {
	var s string
	fmt.Scan(&s)

	layout := "2006/01/02"
	date, _ := time.Parse(layout, s)
	if date.After(time.Date(2019, 4, 30, 0, 0, 0, 0, time.UTC)) {
		fmt.Println("TBD")
	} else {
		fmt.Println("Heisei")
	}
}


package main

import (
  "fmt"
)

func main() {
  var s string
  fmt.Scan(&s)
  ans := "TBD"
  if s[6] <= '4' {ans = "Heisei"}
  fmt.Println(ans)
}


package main

import "fmt"

func main(){
var s string
  fmt.Scanf("%s",&s)
  if s<="2019/04/30"{
    fmt.Println("Heisei")
  }else {
    fmt.println("TBD")
  }
}


package main

import (
	"fmt"
	"strconv"
	"strings"
)

func main() {
	// 勉強用。先人の丸パクリです
	var s string
	fmt.Scan(&s)
	//スラッシュでsplitさせてAtoi
	ss := strings.Split(s, "/")
	fmt.Println(ss)
	a ,_ := strconv.Atoi(ss[0])
	b ,_ := strconv.Atoi(ss[1])
	c ,_ := strconv.Atoi(ss[2])
	if a <= 2019 && b <= 4 && c <= 30 {
		fmt.Println("Heisei")
		return
	}
	fmt.Println("TBD")
  //ひどいなこれは
}


s = gets.chomp
puts s <= '2019/04/30' ? 'Heisei' : 'TBD'


s = gets.chomp
puts s > "2019/04/30" ? "TBD" : "Heisei"


#
# File    : A.rb
# Author  : Kazune Takahashi
# Created : 2/24/2019, 8:54:51 PM
# Powered by Visual Studio Code
#

s = gets.chomp
if s <= "2019/04/30"
  puts "Heisei"
else
  puts "TBD"
end


puts gets.split.map(&:to_i)[1]<=4?'Heisei':'TBD'


require 'date'
puts Date.new(gets.split('/').map(&:to_i).join(','))<=Date.new(2019,4,30) ?'Heisei':'TBD'


require 'date'
puts Date.new(gets.split('/').map(&:to_i).join(','))<=Date.new(2019,4,30)?'Heisei':'TBD'


use std::io;

fn main() {
	let mut buf = String::new();
	io::stdin().read_line(&mut buf).expect("");
	let v:Vec<&str> = buf.trim().split('/').collect();
	let mut x:Vec<i32> = Vec::new();
	for i in 0..3 {
		x.push(v[i].parse().ok().unwrap());
	}
	if x[0] > 2019 ||  x[1] > 4 || x[2] > 30{
		println!("TBD");
	}else{
		println!("Heisei");
	}
}


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

fn input<T:FromStr>() -> T {
    let mut line: String = String::new();
    io::stdin().read_line(&mut line);
    line.trim().parse().ok().unwrap()
}

fn main() {
    let s: String = input();
    let s: Vec<&str> = s.split("/").collect();
    let year: i32 = s[0].parse().unwrap();
    let month: i32 = s[1].parse().unwrap();
    let day: i32 = s[2].parse().unwrap();
    let mut heisei = true;
    if year > 2019 {
        heisei = false;
    } else if year == 2019 {
        if month > 4 {
            heisei = false;
        } else if month == 4 {
            if day > 30 {
                heisei = false;
            }
        }
    }
    if heisei {
        println!("Heisei");
    } else {
        println!("TBD");
    }

}


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

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

    let y: i32 = (&s[0..4]).parse().unwrap();
    let m: i32 = (&s[5..7]).parse().unwrap();
    let d: i32 = (&s[8..10]).parse().unwrap();

    if y <= 2018 {
        println!("Heisei");
    } else if m <= 3 || m == 4 && d <= 30 {
        println!("Heisei");
    } else {
        println!("TBD");
    }

}


fn main() {
    proconio::input!(
        s: String
    );
    let s: String = s;
    let date: Vec<usize> = s.split("/").map(|c| c.parse::<usize>().unwrap()).collect();
    let ans = if let [y, m, d] = date[..] {
        if y < 2019 {
            "Heisei"
        } else if y > 2019 {
            "TBD"
        } else if m > 5 {
            "TBD"
        } else {
            "Heisei"
        }
    } else {
        ""
    };
    println!("{}", ans);
}


import datetime

def main():
    s = datetime.datetime.strptime(input(), "%Y/%m/%d")
    if s <= datetime.datetime(2019,4,30):
        print("Heisei")
    else:
        print("TBD")

if __name__ == '__main__':
    main()


#![allow(non_snake_case)]

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

macro_rules! stdin {
    () => {{
        use std::io::Read;
        let mut s = String::new();
        std::io::stdin().read_to_string(&mut s).unwrap();
        s
    }};
}

macro_rules! test {
    ($(($testid:expr, $input:expr) => ($expected_output:expr)),* $(,)*) => {
        $(
            paste::item! {
                #[test]
                fn [<solve_test_ $testid>]() {
                    println!("[in]\n{}", $input);
                    println!("[out]\n{}", solve($input));
                    println!("[expected out]\n{}", $expected_output);
                    assert_eq!(solve($input), $expected_output);
                }
            }
         )*
    }
}

test! {
    (1, "2019/04/30") => ("Heisei"),
    (2, "2019/11/01") => ("TBD")
}

fn main() {
    println!("{}", solve(&stdin!()));
}

fn solve(src: &str) -> String {
    input! {
        source = src,
        S: String
    }

    let mut ans = "Heisei";
    if S.as_str() > "2019/04/30" {
        ans = "TBD"
    }

    return ans.to_string();
}


import Foundation;print(Int(readLine()!.componentsSeparatedByString("/")[1])!<=4 ?"Heisei":"TBD")


import Foundation;Int(readLine()!.componentsSeparatedByString("/")[1])!<=4 ?print("Heisei"):print("TBD")


extension String:CollectionType{};print(Int(readLine()!.split("/")[1])!<=4 ?"Heisei":"TBD")


import Foundation; Int(readLine()!.characters.split("/")[1])!<=4 ? print("Heisei") : print("TBD")


import Foundation
var r = ""
Int(readLine()!.componentsSeparatedByString("/")[1])!<=4 ? r="Heisei" : r="TBD"
print(r)


import Foundation

let input = readLine()!componentsSeparatedByString("/").map { Int($0)! }
let month = input[1]

if month <= 4 {
    print("Heisei")
} else {
  	print("TBD")
}


const input = require('fs').readFileSync('/dev/stdin', 'utf8');
const inputList = input.split('/'); // 空白文字に注意
// const inputNumberList = inputList.map(Number);

// const input = require('fs').readFileSync('/dev/stdin', 'utf8');
// const inputList = input.split('\n');
// const inputNumberList = inputList.map(Number);

const month_str = inputList[1];
let month;

if (month_str[0] === '0') {
  month = Number(month_str[1]);
} else {
  month = Number(month_str);
}

if (month > 4) {
  console.log('TBD');
} else {
  console.log('Heisei');
}


((input: string): void => {
    const s: number = Number(input.split("/").join(""));
    console.log(s <= 20190430 ? 'Heisei' : 'TBD');
})(require('fs').readFileSync('/dev/stdin', 'utf8'));


import * as fs from 'fs';

//in
// 2019/04/30
//out
// Heisei
const main = (inp: string) => {
    if (inp <= '2019/04/30') {
        console.log('Heisei');
    } else {
        console.log('TBD');
    }
};

main(fs.readFileSync('/dev/stdin', 'utf8').trim());


const fs = require('fs')
const stdin = fs.readFileSync('/dev/stdin', 'utf8')

const S = stdin.split('\n')[0]

const [y,m,d] = S.split('/').map(Number)

let res = ''

console.log(y,m,d)

if(m > 4){
  res = 'TBD'
} else if(m === 4 && d === 31){
  res = 'TBD'
} else {
  res = 'Heisei'
}

console.log(res)


const fs = require('fs')
const stdin = fs.readFileSync('/dev/stdin', 'utf8')

const S = stdin.split('\n')[0]

const [y,m,d] = S.split('/').map(Number)

let res = ''

if(m > 5){
  res = 'TBD'
} else if(m === 4 && d === 31){
  res = 'TBD'
} else {
  res = 'Heisei'
}

console.log(res)


function solve(Y,M,D):boolean{
    if(Y<2019)return true;
    if(Y>2019)return false;
    if(M<4)return true;
    if(M>4)return false;
    return D<=30
}
function Main(raw) {
    const input = raw.split("\n");
    const S = input[0].split("/");
    const Y= parseInt(S[0],10)
    const M= parseInt(S[1],10)
    const D= parseInt(S[2],10)

    //出力
    console.log("%d", solve(Y,M,D)?'Heisei':'TBD');
  }

  //DO NOT EDIT
  Main(require("fs").readFileSync("/dev/stdin", "utf8"));


import math
X = int(input())
a1 = math.ceil(X**(1/5))
N = int(1e10)
c = 0
b = 0
while c <= N:
    if b**5 < -X:
        b2 = b + 1
        break
    b -= 1
c = 0
while c <= N:
    c += 1
    b1 = math.floor((a1**5-X)**(1/5))
    a2 = math.floor((X+b2**5)**(1/5))
    if a1**5 - b1**5 == X:
        print(a1, b1)
        break
    elif a2**5 - b2**5 == X:
        print(a2, b2)
        break
    a1 += 1
    b2 += 1


#!python3

iim = lambda: map(int, input().rstrip().split())

def resolve():
    X = int(input())

    if X == 1:
        print(1, 0)
        return

    ii = 2 if X % 2 else 1

    N = 10**9

    for x in range(1, N, ii):
        if X % x:
            continue
        for i in range(N):
            j = i - x

            ij = i**5 - j**5
            diff = ij - X
            if diff == 0:
                print(i, j)
                return
            elif j > 0 and diff > 0:
                break

if __name__ == "__main__":
    resolve()


import math
x = int(input())
i = 0
while True:
  if (i**5 <= x):
    s = (x-i**5)**0.2
    s = math.floor(s*(10**7))/(10**7)
  t = (x+i**5)**0.2
  t = math.floor(t*(10**7))/(10**7)
  if s.is_integer() and i**5 <= x:
    print(int(s),-i)
    break
  elif t.is_integer():
    print(int(t), i)
    break
  i += 1


x=int(input())
for i in range(40):
  for j in range(-40,40):
    if i**5-j**5==x:
      print(i,j)
      exit()


x=int(input())
for i in range(-118,120):
  for j in range(-119,1119):
    if i**5+j**5==x:
      print(i,j)
      exit()


x=int(input())
y=0
while True:
  z=x+y**5
  if z**(1/5)==int(z**(1/5)):
    print(int(z**(1/5)), y)
    exit()
  w=x-y**5
  if w**(1/5)==int(w**(1/5)):
    print(int(w**(1/5)), -y)
    exit()
  y+=1


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.List;
import java.util.Queue;
import java.util.StringTokenizer;

public class Main {

    private static FastScanner scanner = new FastScanner(System.in);

    public static void main(String[] args) {
        int x = scanner.nextInt();
        for (int a = -120; a < 120; a++) {
            for (int b = -120; b < 120; b++) {
                int result = a * a * a * a * a - b * b * b * b * b;
                if (x == result) {
                    System.out.println(a + " " + b);
                    return;
                }
            }
        }
    }

    // 最大公約数（大小の指定は問わない）
    private static int gcd(int s, int t) {
        int high = Math.max(s, t);
        int low = Math.min(s, t);

        int r = high % low;
        if (r == 0) return low;
        return gcd(low, r);
    }

    // 最小公倍数（大小の指定は問わない）
    private int lcm(int s, int t) {
        return s * t / gcd(s, t);
    }

    // グリッドグラフ
    private static class GridGraph {
        private int rLength;
        private int cLength;
        private String[][] gridGraph;
        private int[][] distance;

        public GridGraph(int r, int c) {
            this.rLength = r;
            this.cLength = c;
            this.gridGraph = new String[r][c];
            this.distance = new int[r][c];

            for (int i = 0; i < r; i++) {
                for (int j = 0; j < c; j++) {
                    this.distance[i][j] = -1;
                }
            }
        }

        public void setNode(int r, int c, String s) {
            this.gridGraph[r][c] = s;
        }

        // 幅優先探索
        public void bfs(int r, int c) {
            Queue<Coordinate> queue = new ArrayDeque<>();
            int[] dc = {1, 0, -1, 0};
            int[] dr = {0, 1, 0, -1};

            // スタート座標を探索キューに入れる
            queue.add(new Coordinate(r, c));
            // スタート座標の距離は0
            this.distance[r][c] = 0;

            while(!queue.isEmpty()) {
                Coordinate coo = queue.poll();

                for (int i = 0; i < 4; i++) {
                    int nc = coo.c + dc[i];
                    int nr = coo.r + dr[i];

                    // 範囲外座標はスルー
                    if (nc < 0 || nc >= this.cLength || nr < 0 || nr >= this.rLength) continue;
                    // 壁座標はスルー
                    if (this.gridGraph[nr][nc].equals("#")) continue;
                    // 到達済み座標はスルー
                    if (this.distance[nr][nc] >=0) continue;
                    // それ以外の座標は到達可能点として距離を記録して探索キューに入れる
                    this.distance[nr][nc] = this.distance[coo.r][coo.c] + 1;
                    queue.add(new Coordinate(nr, nc));
                }
            }
        }

        // 幅優先探索実施後にスタート座標からの距離を返す
        private int getDistance(int r, int c) {
            return this.distance[r][c];
        }

        // 座標
        private class Coordinate {
            int r;
            int c;
            public Coordinate(int r, int c) {
                this.r = r;
                this.c = c;
            }
        }
    }

    // グラフ
    private static class Graph {
        private Vertex[] vertexes;
        private int size;
        private boolean[] seen;

        public Graph(int n) {
            this.size = n;
            this.vertexes = new Vertex[n];
            for (int i = 0; i < n; i++) {
                this.vertexes[i] = new Vertex();
            }
            this.seen = new boolean[n];
        }

        public Graph(int[] vertexes) {
            this.size = vertexes.length;
            this. vertexes = new Vertex[vertexes.length];
            for (int i = 0; i < vertexes.length; i++) {
                this.vertexes[i] = new Vertex(vertexes[i]);
            }
            this.seen = new boolean[vertexes.length];
        }

        public void addEdge(int from, int to) {
            this.addEdge(from, to, 0);
        }

        public void addEdge(int from, int to, int weight) {
            this.vertexes[from].addEdge(to, weight);
        }

        // 深さ優先探索を実施し、到達可能な頂点をすべて辿り閉路かどうかをチェックする
        public boolean dfs(int now, int from) {
            this.seen[now] = true;
            boolean isCycle = false;
            for (Edge e : this.vertexes[now].getEdges()) {
                if (e.getTo() == from) {
                    continue;
                }
                if (seen[e.getTo()]) {
                    isCycle = true;
                } else {
                    isCycle = isCycle || dfs(e.getTo(), now);
                }
            }
            return isCycle;
        }

        // 深さ優先探索実施後に到達済みノードかどうかを返す
        public boolean seen(int now) {
            return this.seen[now];
        }

    }

    private static class Vertex {
        private int value;
        private List<Edge> edges = new ArrayList<>();

        public Vertex() {};
        public Vertex(int value) {
            this.value = value;
        }

        public void setValue(int value) {
            this.value = value;
        }

        public void addEdge(int to, int weight) {
            edges.add(new Edge(to, weight));
        }

        public List<Edge> getEdges() {
            return this.edges;
        }
    }

    private static class Edge {
        private int to;
        private int weight;

        public Edge(int to, int weight) {
            this.to = to;
            this.weight = weight;
        }

        public int getTo() {
            return this.to;
        }

        public int getWeight() {
            return this.weight;
        }
    }

    private static class FastScanner {

        private BufferedReader reader;
        private StringTokenizer tokenizer;

        public FastScanner(InputStream in) {
            this.reader = new BufferedReader(new InputStreamReader(in));
        }

        public int[] nextLineToIntArray() {
            String[] stringArray = nextLineToStringArray();
            int[] intArray = new int[stringArray.length];
            for (int i = 0; i < stringArray.length; i++) {
                intArray[i] = Integer.parseInt(stringArray[i]);
            }
            return intArray;
        }

        public String[] nextLineToStringArray() {
            return nextLine().split("");
        }

        public String nextLine() {
            try {
                return reader.readLine();
            } catch (IOException e) {
                e.printStackTrace();
                throw new RuntimeException(e);
            }
        }

        public String next() {
            if (this.tokenizer == null || !this.tokenizer.hasMoreElements()) {
                try {
                    this.tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                    throw new RuntimeException(e);
                }
            }
            return this.tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

        public long nextLong() {
            return Long.parseLong(next());
        }

        public double nextDouble() {
            return Double.parseDouble(next());
        }

        public String[] nextStringArray(int n) {
            String[] stringArray = new String[n];
            for (int i = 0; i < n; i++) {
                stringArray[i] = next();
            }
            return stringArray;
        }

        public int[] nextIntArray(int n) {
            int[] intArray = new int[n];
            for (int i = 0; i < n; i++) {
                intArray[i] = nextInt();
            }
            return intArray;
        }

        public long[] nextLongArray(int n) {
            long[] longArray = new long[n];
            for (int i = 0; i < n; i++) {
                longArray[i] = nextLong();
            }
            return longArray;
        }

        public double[] nextDoubleArray(int n) {
            double[] doubleArray = new double[n];
            for (int i = 0; i < n; i++) {
                doubleArray[i] = nextDouble();
            }
            return doubleArray;
        }
    }
}


import java.io.IOException;
import java.io.InputStream;
import java.util.NoSuchElementException;

public class Main {

  public static void main(String[] args) {
    FastScanner sc = new FastScanner();

    long X = sc.nextInt();
    String ans = "";

    long t[] = new long[200];
    for (int i = 0; i < 200; i++) {
      t[i] = (long) Math.pow(i, 5);
    }
    for (int i = 0; i < 200; i++) {
      for (int j = 0; j < 200; j++) {
        if (t[i] - t[j] == X) {
          ans = i + " " + j;
          break;
        }
        if (t[i] + t[j] == X) {
          ans = i + " " + j * -1;
          break;
        }
        if (!ans.equals("")) {
          break;
        }
      }
    }

    System.out.println(ans);

  }
}

class FastScanner {
  private final InputStream in = System.in;
  private final byte[] buffer = new byte[1024];
  private int ptr = 0;
  private int buflen = 0;

  private boolean hasNextByte() {
    if (ptr < buflen) {
      return true;
    } else {
      ptr = 0;
      try {
        buflen = in.read(buffer);
      } catch (IOException e) {
        e.printStackTrace();
      }
      if (buflen <= 0) {
        return false;
      }
    }
    return true;
  }

  private int readByte() {
    if (hasNextByte()) {
      return buffer[ptr++];
    } else {
      return -1;
    }
  }

  private static boolean isPrintableChar(int c) {
    return 33 <= c && c <= 126;
  }

  private void skipUnprintable() {
    while (hasNextByte() && !isPrintableChar(buffer[ptr])) {
      ptr++;
    }
  }

  public boolean hasNext() {
    skipUnprintable();
    return hasNextByte();
  }

  public String next() {
    if (!hasNext()) {
      throw new NoSuchElementException();
    }
    StringBuilder sb = new StringBuilder();
    int b = readByte();
    while (isPrintableChar(b)) {
      sb.appendCodePoint(b);
      b = readByte();
    }
    return sb.toString();
  }

  public int nextInt() {
    if (!hasNext()) {
      throw new NoSuchElementException();
    }
    int n = 0;
    boolean minus = false;
    int b = readByte();
    if (b == '-') {
      minus = true;
      b = readByte();
    }
    if (b < '0' || '9' < b) {
      throw new NumberFormatException();
    }
    while (true) {
      if ('0' <= b && b <= '9') {
        n *= 10;
        n += b - '0';
      } else if (b == -1 || !isPrintableChar(b)) {
        return minus ? -n : n;
      } else {
        throw new NumberFormatException();
      }
      b = readByte();
    }
  }

  public long nextLong() {
    if (!hasNext()) {
      throw new NoSuchElementException();
    }
    long n = 0;
    boolean minus = false;
    int b = readByte();
    if (b == '-') {
      minus = true;
      b = readByte();
    }
    if (b < '0' || '9' < b) {
      throw new NumberFormatException();
    }
    while (true) {
      if ('0' <= b && b <= '9') {
        n *= 10;
        n += b - '0';
      } else if (b == -1 || !isPrintableChar(b)) {
        return minus ? -n : n;
      } else {
        throw new NumberFormatException();
      }
      b = readByte();
    }
  }
}


import java.io.*;
import java.util.*;
import java.math.*;
import java.awt.Point;

public class Main {
	//static final long MOD = 998244353L;
	//static final long INF = 1000000000000000007L;
	static final long MOD = 1000000007L;
	static final int INF = 1000000007;

	public static void main(String[] args) {
		FastScanner sc = new FastScanner();
		PrintWriter pw = new PrintWriter(System.out);

		long X = sc.nl();
		for (int i = 1; i*i <= X; i++) {
			if (X%i == 0) {
				for (int j = -500; j <= 500; j++) {
					long a = j+i;
					long b = j;
					if (a*a*a*a*a-b*b*b*b*b == X) {
						pw.println(a + " " + b);
						pw.close();
						return;
					}
				}
			}
		}

		pw.close();
	}

	public static long dist(long[] p1, long[] p2) {
		return (Math.abs(p2[0]-p1[0])+Math.abs(p2[1]-p1[1]));
	}

	//Find the GCD of two numbers
	public static long gcd(long a, long b) {
		if (a < b) return gcd(b,a);
		if (b == 0)
			return a;
		else
			return gcd(b,a%b);
	}

	//Fast exponentiation (x^y mod m)
	public static long power(long x, long y, long m) {
		if (y < 0) return 0L;
		long ans = 1;
		x %= m;
		while (y > 0) {
			if(y % 2 == 1)
				ans = (ans * x) % m;
			y /= 2;
			x = (x * x) % m;
		}
		return ans;
	}

	public static int[] shuffle(int[] array) {
		Random rgen = new Random();
		for (int i = 0; i < array.length; i++) {
		    int randomPosition = rgen.nextInt(array.length);
		    int temp = array[i];
		    array[i] = array[randomPosition];
		    array[randomPosition] = temp;
		}
		return array;
	}

	public static long[] shuffle(long[] array) {
		Random rgen = new Random();
		for (int i = 0; i < array.length; i++) {
		    int randomPosition = rgen.nextInt(array.length);
		    long temp = array[i];
		    array[i] = array[randomPosition];
		    array[randomPosition] = temp;
		}
		return array;
	}

	public static int[][] shuffle(int[][] array) {
		Random rgen = new Random();
		for (int i = 0; i < array.length; i++) {
		    int randomPosition = rgen.nextInt(array.length);
		    int[] temp = array[i];
		    array[i] = array[randomPosition];
		    array[randomPosition] = temp;
		}
		return array;
	}

    public static int[][] sort(int[][] array) {
    	//Sort an array (immune to quicksort TLE)

		Arrays.sort(array, new Comparator<int[]>() {
			  @Override
        	  public int compare(int[] a, int[] b) {
				  return a[0]-b[0]; //ascending order
	          }
		});
		return array;
	}

    public static long[][] sort(long[][] array) {
    	//Sort an array (immune to quicksort TLE)
		Random rgen = new Random();
		for (int i = 0; i < array.length; i++) {
		    int randomPosition = rgen.nextInt(array.length);
		    long[] temp = array[i];
		    array[i] = array[randomPosition];
		    array[randomPosition] = temp;
		}
		Arrays.sort(array, new Comparator<long[]>() {
			  @Override
        	  public int compare(long[] a, long[] b) {
				  if (a[0] < b[0])
					  return -1;
				  else if (a[0] > b[0])
					  return 1;
				  else
					  return 0;
	          }
		});
		return array;
	}

    static class FastScanner {
        BufferedReader br;
        StringTokenizer st;

        public FastScanner() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException  e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int ni() {
            return Integer.parseInt(next());
        }

        long nl() {
            return Long.parseLong(next());
        }

        double nd() {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }
}


import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long x = sc.nextLong();
        if(x == 1) {
            System.out.println("0 -1");
            return;
        }
        long xx = (long) Math.ceil(Math.sqrt(Math.cbrt(x)));
        for (long i = 1; i <= xx; i--) {
            for (long j = -1; j < xx; j--) {
                long a = (long) Math.pow(i, 5);
                long b = (long) Math.pow(j, 5);
                if(a - b == x) {
                    System.out.println(i + " " + j);
                    return;
                }
            }
        }
    }
}


import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long x = sc.nextLong();
        if(x == 1) {
            System.out.println("0 -1");
            return;
        }
        long xx = (long) Math.ceil(Math.sqrt(Math.cbrt(x)));
        for (long i = xx; i > 0; i--) {
            for (long j = -1; j < xx; j--) {
                long a = (long) Math.pow(i, 5);
                long b = (long) Math.pow(j, 5);
                if(a - b == x) {
                    System.out.println(i + " " + j);
                    return;
                }
            }
        }
    }
}


import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long x = sc.nextLong();
        if(x == 1) {
            System.out.println("0 -1");
            return;
        }
        long xx = (long) Math.sqrt(Math.sqrt(x));
        for (long i = xx; i > 0; i--) {
            for (long j = -1; j < xx; j--) {
                long a = (long) Math.pow(i, 5);
                long b = (long) Math.pow(j, 5);
                if(a - b == x) {
                    System.out.println(i + " " + j);
                    return;
                }
            }
        }
    }
}


// #pragma GCC target("avx")  // CPU 処理並列化
// #pragma GCC optimize("O3")  // CPU 処理並列化
// #pragma GCC optimize("unroll-loops")  // 条件処理の呼び出しを減らす
// #define BEGIN_STACK_EXTEND(size) void * stack_extend_memory_ = malloc(size);void * stack_extend_origin_memory_;char * stack_extend_dummy_memory_ = (char*)alloca((1+(int)(((long long)stack_extend_memory_)&127))*16);*stack_extend_dummy_memory_ = 0;asm volatile("mov %%rsp, %%rbx\nmov %%rax, %%rsp":"=b"(stack_extend_origin_memory_):"a"((char*)stack_extend_memory_+(size)-1024));
// #define END_STACK_EXTEND asm volatile("mov %%rax, %%rsp"::"a"(stack_extend_origin_memory_));free(stack_extend_memory_);

#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<stack>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
#include<time.h>
#include<bitset>
#include<numeric>
#include<unordered_set>
#include<unordered_map>
#include<complex>
using namespace std;
const long long mod=1000000007;
const long long inf=mod*mod;
const long long d2=(mod+1)/2;
const double EPS=1e-9;
const double INF=1e+10;
const double PI=acos(-1.0);
const int C_SIZE = 3100000;
const int UF_SIZE = 3100000;
namespace{
	long long fact[C_SIZE];
	long long finv[C_SIZE];
	long long inv[C_SIZE];
	inline long long Comb(int a,int b){
	 	if(a<b||b<0)return 0;
	 	return fact[a]*finv[b]%mod*finv[a-b]%mod;
	}
	void init_C(int n){
		fact[0]=finv[0]=inv[1]=1;
		for(int i=2;i<n;i++){
			inv[i]=(mod-(mod/i)*inv[mod%i]%mod)%mod;
		}
		for(int i=1;i<n;i++){
			fact[i]=fact[i-1]*i%mod;
			finv[i]=finv[i-1]*inv[i]%mod;
		}
	}
	long long pw(long long a,long long b){
		if(a<0LL)return 0;
		if(b<0LL)return 0;
		long long ret=1;
		while(b){
			if(b%2)ret=ret*a%mod;
			a=a*a%mod;
			b/=2;
		}
		return ret;
	}
	long long pw_mod(long long a,long long b,long long M){
		if(a<0LL)return 0;
		if(b<0LL)return 0;
		long long ret=1;
		while(b){
			if(b%2)ret=ret*a%M;
			a=a*a%M;
			b/=2;
		}
		return ret;
	}
	int pw_mod_int(int a,int b,int M){
		if(a<0)return 0;
		if(b<0)return 0;
		int ret=1;
		while(b){
			if(b%2)ret=(long long)ret*a%M;
			a=(long long)a*a%M;
			b/=2;
		}
		return ret;
	}
	int ABS(int a){return max(a,-a);}
	long long ABS(long long a){return max(a,-a);}
	double ABS(double a){return max(a,-a);}
	int sig(double r) { return (r < -EPS) ? -1 : (r > +EPS) ? +1 : 0; }
	int UF[UF_SIZE];
	void init_UF(int n){
		for(int i=0;i<n;i++)UF[i]=-1;
	}
	int FIND(int a){
		if(UF[a]<0)return a;
		return UF[a]=FIND(UF[a]);
	}
	void UNION(int a,int b){
		a=FIND(a);b=FIND(b);if(a==b)return;
		// if(UF[a]>UF[b])swap(a,b);
		UF[a]+=UF[b];UF[b]=a;
	}
}
// ここから編集しろ
long long p[110000];
int main(){
	int a;scanf("%d",&a);
	int sz=0;
	for(int i=-200;i<=200;i++){
		p[sz++]=(long long)i*i*i*i*i;
	}
	for(int i=0;i<sz;i++)for(int j=0;j<sz;j++){
		if(p[i]-p[j]==a){
			printf("%d %d\n",i-200,j-200);return 0;
		}
	}
}


#include <stdio.h>
typedef long long ll;

ll mpow(ll a) {
  return a * a * a * a * a;
}

int main(void) {
  ll i, j, x;
  scanf("%lld", &x);
  for(i = -200; i < 201; ++i) for(j = -200; j < 201; ++j) if(mpow(i) - mpow(j) == x) {
    printf("%lld %lld", i, j);
    return 0;
  }
  return 0;
}


#include <cctype>
#include <cstdio>
#include <cstring>
#include <vector>
#include <algorithm>
#define pk putchar(' ')
#define ph puts("")
typedef long long ll;
using namespace std;
template <class T>
void rd(T &x)
{
    x = 0;
    int f = 1;
    char c = getchar();
    while (!isdigit(c)) {if (c == '-') f = -1; c = getchar();}
    while (isdigit(c)) x = (x << 3) + (x << 1) + (c ^ 48), c = getchar();
    x *= f;
}
template <class T>
void pt(T x)
{
    if (x < 0)
        putchar('-'), x = (~x) + 1;
    if (x > 9)
        pt(x / 10);
    putchar(x % 10 ^ 48);
}
int n;
int main()
{
	rd(n);
	for (int i = 0; ; i++)
		for (int j = -1280; j <= 1280; j++)
			if (i * i * i * i * i - j * j * j * j * j == n)
				return !printf("%d %d\n", i, j);
    return 0;
}


#include<bits/stdc++.h>
using namespace std;

int main()
{
   int x,c=0,p,q;
   long int i,j;
   cin>>x;
   for(i=0;i<=sqrt(x);i++)
   {
       for(j=-sqrt(x);j<=sqrt(x);j++)
       {
           if(pow(i,5)-pow(j,5)==x)
           {
               c=1;
                p=i;
               q=j;
               break;
           }
       }
   }
   if(c==1)
    cout<<p<<" "<<q<<endl;
    return 0;
}


#include<bits/stdc++.h>
using namespace std;

int main()
{
   long long int i,j;
   int x,c=0,p,q;
   cin>>x;
   for(i=0;i<=sqrt(x);i++)
   {
       for(j=-sqrt(x);j<=sqrt(x);j++)
       {
           if(pow(i,5)-pow(j,5)==x)
           {
               c=1;
                p=i;
               q=j;
               break;
           }
       }
   }
   if(c==1)
    cout<<p<<" "<<q<<endl;
    return 0;
}


#include<bits/stdc++.h>
using namespace std;

int main()
{
   long long int x,i,j,c=0,p,q,r;
   cin>>x;
   r=sqrt(x);
   for(i=0;i<=r;i++)
   {
       for(j=-r;j<=r;j++)
       {
           if(pow(i,5)-pow(j,5)==x)
           {
               c=1;
               p=i;
               q=j;
               break;
           }
       }
   }
   if(c==1)
    cout<<p<<" "<<q<<endl;
    return 0;
}


#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <stdint.h> // uint64_t

#define max(a,b) ((a) > (b) ? (a) : (b))
#define min(a,b) ((a) > (b) ? (b) : (a))

int get_int(void) {
  int num;
  scanf("%d", &num);
  return num;
}

// 1000**5 - 999**5 = 4.99001e+12
#define NUM_MAX 1000

struct pair {
    int a;
    int b;
};

int main(void) {
    int64_t target = get_int();
    int a, b;
    struct pair ans = {0, 0};
    for(a = 0; a <= NUM_MAX; a++) {
        for(b = 0; b <= NUM_MAX; b++) {
            int64_t a5 = (int64_t)a*a*a*a*a;
            int64_t b5 = (int64_t)b*b*b*b*b;
            if(a5+b5 == target) {
                ans = (struct pair){a, -b};
                goto finish;
            }
            if(a5-b5==target) {
                ans = (struct pair){a, b};
                goto finish;
            }
        }
    }
finish:
    printf("%d %d\n", ans.a, ans.b);
    return 0;
}


int main(void)
{
  long x;
  scanf("%ld",&x);
  long long i, j;
  for (i = -120; i < 121; i++)
  {
    for (long long j = -120;j < 121;j++)
    {
      if(i * i * i * i * i - j * j * j * j * j == x)
      {
        printf("%lld %lld",i,j);
        return 0;
      }
    }
  }
}


#include<stdio.h>
int main()
{
    int x;
    scanf("%d",&x);
    for(int i=-120;i<=120;i++)
    {
        for(int j=-120;j<=120;j++)
        {
            if(i*i*i*i*i-j*j*j*j*j==x)
            {
                printf("%d %d\n",i,j);
                return 0;
            }
        }
    }
}


#include<stdio.h>
#include<math.h>
int main()
{
long int x,i,j,a,b,sw;
  scanf("%ld",&x);
  sw=0;
  a=-100;
  while(sw==0)
  {
  b=100;
   for(i=-b;i<b;++i)
   {if(pow(a,5)-pow(i,5)==x) {sw++;
                              b=i;
                             }
   }
    a++;
  }

  printf("%ld %ld",a,b);

return 0;}


#include <stdio.h>
#include <math.h>
int main(void){
  long long a,b,n,k,i;
  scanf("%lld %lld %lld",&a,&b,&n);
  k= floor((long double)a*n/b);
  if(b==1){
    printf("0");
    } else if(n<b) {
      printf("%lld",k);
    }else{
    k= floor((long double)a*(b-1)/b)-floor((long double)(b-1)/b);
          printf("%lld",k);
  }

  return 0;
}


#include <stdio.h>
#include <math.h>

int main(void){
  long long x,a=0,b;
  scanf("%lld",&x);
  b=0;
     while(a==0){
    if (ceil((double) pow(x+pow(b,5),(double)1.0/5.0))==floor((double) pow(x+pow(b,5),(double)1.0/5.0))){
      a=(double) pow(x+pow(b,5),(double)1.0/5.0);
      break;
    }
    if(b==0){
      b++;
    }else if(b>0){
      b=b-2*fabs(b);
        }else{
      b=b+2*fabs(b)+1;
    }
    }
   printf("%lld %lld",a,b);

  return 0;
}


"use strict";

// read lines from stdin
const input = require("fs").readFileSync("/dev/stdin", "utf8").split("\n");

const X = parseInt(input[0]);

let i = 0;
const resultStockList = [];

while (true) {
  const result = Math.pow(i, 5);
  resultStockList.push(result);

  for (let j = 0; j < resultStockList.length; j++) {
    if (
      result - resultStockList[j] === X ||
      resultStockList[j] - result === X
    ) {
      console.log(`${i} ${j}`);
      return;
    }

    if (result + resultStockList[j] === X) {
      console.log(`${i} ${-j}`);
      return;
    }
  }

  i++;
}


"use strict";

const main = arg => {
    const input = arg.trim().split("\n");

    const x = parseInt(input[0]);
    for(let a = -120; a<= 120; a++){
        for(let b = -120; b<= 120; b++){
            let tmp = a*a*a*a*a - b*b*b*b*b
            if(x === tmp){
                console.log(`${a} ${b}`)
                return
            }
        }
    }
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));


function D166(_input) {
    var lines = _input.split("\n");
    var x = lines.shift()*1;

    for (var i = 119; i > -118; i--) {
        for (var j = 118; j > -119; j--) {
            const fi = i*i*i*i*i;
            const fj = j*j*j*j*j;
            if (fi - fj === x) {
                console.log(`${i} ${j}`);
                return;
            }
        }
    }
}
D166(require("fs").readFileSync("/dev/stdin", "utf8"));


const main = (input) => {
  const s = Number(input.trim())

  for (let x=0; x<=100; x++) {
    for (let y=-100; y<=99; y++) {
      if (x**5 - y**5 === s) return console.log(`${x} ${y}`)
    }
  }
}

process.env.MYTEST
  ? (process.env.MYTEST === 'test' ? test() : main(require('fs').readFileSync('dev/stdin', 'utf8')))
  : main(require('fs').readFileSync('/dev/stdin', 'utf8'))


const main = (input) => {
  const s = BigInt(input.trim())

  for (let x=0n; x<100n; x++) {
    for (let y=0n; y<100n; y++) {
      if (x**5n - y**5n === s) {
        return console.log(`${x} ${y}`)
      } else if (x**5n + y**5n === s) {
        return console.log(`${x} -${y}`)
      }
    }
  }
}

process.env.MYTEST
  ? (process.env.MYTEST === 'test' ? test() : main(require('fs').readFileSync('dev/stdin', 'utf8')))
  : main(require('fs').readFileSync('/dev/stdin', 'utf8'))


const main = (input) => {
  const s = BigInt(input.trim())

  for (let x=0n; x<100n; x++) {
    for (let y=0n; y<100n; y++) {
      if (x**5n - y**5n === s) {
        return console.log(`${x} ${y}`)
      } else if (x**5n + y**5n === s) {
        return console.log(`${x} ${-y}`)
      }
    }
  }
}

process.env.MYTEST
  ? (process.env.MYTEST === 'test' ? test() : main(require('fs').readFileSync('dev/stdin', 'utf8')))
  : main(require('fs').readFileSync('/dev/stdin', 'utf8'))


package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"strconv"
)

const (
	initialBufSize = 10000
	maxBufSize     = 100000000
)

var sc *bufio.Scanner = func() *bufio.Scanner {
	sc := bufio.NewScanner(os.Stdin)
	buf := make([]byte, initialBufSize)
	sc.Buffer(buf, maxBufSize)
	return sc
}()

func scanIntNum() (num int) {
	sc.Scan()

	num, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return num
}

func main() {
	input := scanIntNum()
	bminf := root(float64(input), 5)
	bmin := -1 * int(math.Floor(bminf))
	var a float64

	for i := bmin; ; i++ {
		a5 := input + int(math.Pow(float64(i), 5))
		if a5 == 0 {
			a = 0
		} else {
			a = root(float64(a5), 5)
		}
		if a-math.Floor(a) == 0.0 {
			fmt.Println(int(math.Floor(a)), i)
			return
		}
	}
}

func root(a float64, n int) float64 {
	n1 := n - 1
	n1f, rn := float64(n1), 1/float64(n)
	x, x0 := 1., 0.
	for {
		potx, t2 := 1/x, a
		for b := n1; b > 0; b >>= 1 {
			if b&1 == 1 {
				t2 *= potx
			}
			potx *= potx
		}
		x0, x = x, rn*(n1f*x+t2)
		if math.Abs(x-x0)*1e15 < x {
			break
		}
	}
	return x
}


package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

const (
	initialBufSize = 1e4
	maxBufSize     = 1e6 + 7
)

var buf []byte = make([]byte, maxBufSize)
var sc = bufio.NewScanner(os.Stdin)

func init() {
	sc.Split(bufio.ScanWords)
	sc.Buffer(buf, maxBufSize)
}

func main() {
	X := nextInt()
	var n int
	// 一応、値決め打ちでなくてちゃんと計算させた場合
	for i := 0; i*i*i*i*i-(i-1)*(i-1)*(i-1)*(i-1)*(i-1) < 1e9; i++ {
		n = i + 1
	}
	for i := 0; i <= n; i++ {
		for j := 0; j <= i; j++ {
			if i*i*i*i*i-j*j*j*j*j == X {
				fmt.Println(i, j)
				return
			} else if i*i*i*i*i+j*j*j*j*j == X {
				fmt.Println(i, -j)
			}
		}
	}
}

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}


package main

import (
	"fmt"
)

func pow(n int) int64 {
	m := int64(n)
	return m * m * m * m * m
}

func f(a, b int) int64 {
	return pow(a) - pow(b)
}

func main() {
	var x int64
	fmt.Scan(&x)

	var maxInd int
	for maxInd = 1; f(maxInd, maxInd-1) <= x; maxInd++ {
	}
	for a := -maxInd; a < maxInd; a++ {
		for b := -maxInd; b < maxInd; b++ {
			if f(a, b) == x {
				fmt.Println(a, b)
				return
			}
		}
	}
}


package main

import "fmt"

func main() {
	// Code for D - I hate Factorization
	var X int
	fmt.Scan(&X)

	for A := -100; A <= 100; A++ {
		for B := -100; B <= 100; B++ {
			//fmt.Println((A*A*A*A*A)-(B*B*B*B*B), A, B)
			if (A*A*A*A*A)-(B*B*B*B*B) == X {
				fmt.Println(A, B)
				return
			}
		}
	}
}


package main

import "fmt"

func main() {
	// Code for D - I hate Factorization
	var X int

	for A := -100; A <= 100; A++ {
		for B := -100; B <= 100; B++ {
			if (A*A*A*A*A)-(B*B*B*B*B) == X {
				fmt.Println(A, B)
				break
			}
		}
	}
}


package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func main() {
	scanInit()

	x := nextInt()

	for i := -100; i < 100; i++ {
		i5 := i * i * i * i * i
		for j := -100; j < 100; j++ {
			j5 := j * j * j * j * j
			if i5-j5 == x {
				fmt.Println(i, j)
				return
			}
		}
	}

	fmt.Println("DBG") //! DBG
}

// ---- readfunc
func scanInit() {
	const cap = 200 * 1024 // default=64*1024
	var buf = make([]byte, cap)
	sc.Buffer(buf, cap)
	sc.Split(bufio.ScanWords)
	return
}
func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}
func nextStr() string {
	sc.Scan()
	return sc.Text()
}


H = {}
120.times {|i| H[n=i**5] = i; H[-n] = -i}
X = gets.to_i
F =->(b,y) { a=H[X+y] and puts([a,b]*' ') || exit }
120.times {|b| y = b**5; F[b,y]; F[-b,-y]}


X = gets.chomp.to_i

def calc_b(a)
  b5 = (a**5 - X)
  if b5 >= 0
    b5.pow(1.0/5).to_i
  else
    (-b5).pow(1.0/5).to_i * -1
  end
end

def val(a, b)
  a**5 - b**5
end

a = 1
b = calc_b(a)

until (v = val(a, b)) == X
  a += 1
  b = calc_b(a)
end

puts [a, b].join(" ")


X = gets.to_i
sq = []
prev = 0
0.upto(100000) do |i|
  d = i*i*i*i*i
  sq << d
  break if d - prev > 1000000000
  prev = d
end

sq2 = sq.dup
sq.each do |a|
    sq2.shift
    sq2.each do |b|
        if a - b == X
            puts "#{sq.index(a)} #{sq.index(b)}"
            exit
        elsif (-a) - b == X
            puts "-#{sq.index(a)} #{sq.index(b)}"
            exit
        elsif a + b == X
            puts "#{sq.index(a)} -#{sq.index(b)}"
            exit
        elsif (-a) + b == X
            puts "-#{sq.index(a)} -#{sq.index(b)}"
            exit
        end
    end
end


x = gets.to_i

(-120..120).each do |i|
  (-120..120).each do |j|
    if (i ** 5 - j ** j) == x
      puts "#{i} #{j}"
      return
    end
  end
end


x = gets.to_i

(-120..120).each do |i|
  (-120..120).each do |j|
    if i ** 5 - j ** j == x
      puts "#{i} #{j}"
      return
    end
  end
end


x = gets.to_i

require "prime"

def divisors(n)
  n.prime_division.inject([1]) do |ary, (p, e)|
    (0..e).map{ |e1| p ** e1 }.product(ary).map{ |a, b| a * b }
  end.sort
end

divisors(x).each do |num|
  d = x / num
  a = 0
  b = -num
  line = a ** 4
  m = a ** 4 + (a ** 3) * b + (a ** 2) * (b ** 2) + a * (b ** 3) + b ** 4

  while line < x
    if m == d
      puts "#{a} #{b}"
      return
    end

    a += 1
    b += 1
    line = a ** 5
    m = a ** 4 + (a ** 3) * b + (a ** 2) * (b ** 2) + a * (b ** 3) + b ** 4
  end
end


use proconio::fastout;
use proconio::input;
#[allow(unused_imports)]
use proconio::marker::*;

#[fastout]
fn main() {
    input! {
        x: isize,
    }
    for i in -120..120_isize {
        for j in -120..120_isize {
            if i.pow(5) - j.pow(5) == x {
                println!("{} {}", i, j);
                return;
            }
        }
    }
}


use proconio::input;

fn main() {
    input! {
        n: i64
    }

    let max = {
        let mut max:i64 = 1;
        let mut k = 1;
        while k < n {
            k = (max+1).pow(5) - max.pow(5);
            max += 1;
        }
        max
    };

    let mut a: i64 = 0;
    let mut b: i64 = 0;
    let mut flag = false;
    for i in -max..=max {
        for j in -max..=max {
            if n == i.pow(5) - j.pow(5) {
                a = i as i64;
                b = j as i64;
                flag = true;
                break;
            }
        if flag {
            break;
        }
        }
    }

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


use proconio::{input, fastout};

#[fastout]
fn main() {
    input! {
        x: i64,
    }

    let pow5: Vec<i64> = (0i64..120).map(|x| x.pow(5)).collect();
    for (a, a5) in pow5.iter().enumerate() {
        for (b, b5) in pow5.iter().enumerate() {
            if a5 - b5 == x {
                println!("{} {}", a, b);
                return;
            }
            if a5 + b5 == x {
                println!("{} -{}", a, b);
                return;
            }
        }
    }
}


#[allow(unused_imports)]
use std::cmp::{max, min};
#[allow(unused_imports)]
use std::collections::HashMap;
#[allow(unused_imports)]
use std::f64::consts::PI;
#[allow(unused_imports)]
use std::fmt;
#[allow(unused_imports)]
use std::fmt::Debug;
#[allow(unused_imports)]
use std::io;
#[allow(unused_imports)]
use std::str::FromStr;

fn main() {
    // setup
    let x: i128 = get_vec_input()[0];

    // exercise
    for i in -1..10i128.pow(9) {
        for j in i + 1..10i128.pow(9) {
            if j.pow(5) - i.pow(5) == x {
                println!("{} {}", j, i);
                return;
            }
        }
    }
}

#[allow(dead_code)]
fn get_radian_from(degree: f64) -> f64 {
    (degree * PI) / 180.0
}

#[allow(dead_code)]
fn get_alphabet() -> Vec<char> {
    (0..26).map(|x| (x + b'a') as char).collect::<Vec<char>>()
}

#[allow(dead_code)]
fn get_binary_string(digit: usize) -> Vec<Vec<String>> {
    (0..2i64.pow(digit as u32))
        .map(|x| format!("{:0>1$b}", x, digit))
        .map(|x| x.chars().map(|x| x.to_string()).collect::<Vec<String>>())
        .collect::<Vec<Vec<_>>>()
}

#[allow(dead_code)]
fn check_prime(value: i64) -> bool {
    if value == 2 {
        return true;
    }
    if value % 2 == 0 {
        return false;
    }
    for i in 3..(value as f64).sqrt().floor() as i64 {
        if value % i == 0 {
            return false;
        }
    }
    return true;
}

#[allow(dead_code)]
fn get_digit(value: i64) -> i64 {
    let mut digit = 0i64;
    let mut value = value;
    while value != 0 {
        value /= 10;
        digit += 1;
    }
    digit
}

#[allow(dead_code)]
fn sum_digit2(value: String) -> u32 {
    return value.chars().fold(0u32, |a, b| a + b.to_digit(10).unwrap());
}

#[allow(dead_code)]
fn sum_digit(value: i64) -> i64 {
    if value < 10 {
        return value;
    }
    return sum_digit(value / 10) + value % 10;
}

#[allow(dead_code)]
fn update_max<T>(left: &mut T, right: T)
where
    T: std::cmp::Ord + std::clone::Clone,
{
    if *left < right {
        *left = right.clone();
    }
}

#[allow(dead_code)]
fn update_min<T>(left: &mut T, right: T)
where
    T: std::cmp::Ord + std::clone::Clone,
{
    if *left > right {
        *left = right.clone();
    }
}

#[allow(dead_code)]
fn get_vec_input<T>() -> Vec<T>
where
    T: FromStr,
    T::Err: Debug,
{
    let mut input = String::new();
    io::stdin()
        .read_line(&mut input)
        .expect("Failed to read line");
    let vec: Vec<T> = input
        .split_whitespace()
        .map(|x| x.parse().unwrap())
        .collect();
    vec
}

#[allow(dead_code)]
fn get_tuple_input() -> (u64, f32) {
    let mut s = String::new();
    io::stdin().read_line(&mut s).expect("");
    let mut iter = s.trim().split_whitespace();
    let c: u64 = iter.next().unwrap().parse().unwrap();
    let n: f32 = iter.next().unwrap().parse().unwrap();
    (c, n)
}

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

/// https://github.com/bluss/permutohedron/blob/master/src/lexical.rs
pub trait LexicalPermutation {
    /// Return `true` if the slice was permuted, `false` if it is already
    /// at the last ordered permutation.
    fn next_permutation(&mut self) -> bool;
}

impl<T> LexicalPermutation for [T]
where
    T: Ord,
{
    /// Original author in Rust: Thomas Backman <serenity@exscape.org>
    fn next_permutation(&mut self) -> bool {
        // These cases only have 1 permutation each, so we can't do anything.
        if self.len() < 2 {
            return false;
        }

        // Step 1: Identify the longest, rightmost weakly decreasing part of the vector
        let mut i = self.len() - 1;
        while i > 0 && self[i - 1] >= self[i] {
            i -= 1;
        }

        // If that is the entire vector, this is the last-ordered permutation.
        if i == 0 {
            return false;
        }

        // Step 2: Find the rightmost element larger than the pivot (i-1)
        let mut j = self.len() - 1;
        while j >= i && self[j] <= self[i - 1] {
            j -= 1;
        }

        // Step 3: Swap that element with the pivot
        self.swap(j, i - 1);

        // Step 4: Reverse the (previously) weakly decreasing part
        self[i..].reverse();

        true
    }
}


// -*- coding:utf-8-unix -*-

use proconio::input;

fn main() {
    input! {
        x: u64,
    }
    println!("{} -1", ((x - 1) as f64).powf(1.0/5.0));
}


use proconio::{fastout, input};

#[fastout]
fn main() {
    input! {x: usize};
    let x: usize = x;
    let mut t = false;

    for a in 0..((x as f64).sqrt() as usize) * 2 {
        for b in 0..(x as f64).sqrt() as usize * 2 {
            if a.pow(5) + (b * b * b * b * b) == x || a.pow(5) - (b * b * b * b * b) == x {
                if b == 0 {
                    println!("{} {}", a, b);
                } else {
                    println!("{} -{}", a, b);
                }
                t = true;
            }
            if t {
                break;
            }
        }
        if t {
            break;
        }
    }
}


import Foundation

let X = Int(readLine()!)!

func powFive(_ x: Int) -> Int {
    return x * x * x * x * x
}

outer: for A in -200...200 {
    for B in -200...200 {
        if powFive(A) - powFive(B) == X {
            print(A, B)
            break outer
        }
    }
}


let x = Int(readLine()!)!

let nums = Array(-999...999).map { n -> (Int, Int) in
    var r = 1
    for _ in 0..<5 {
        r *= n
    }
    return (n, r)
}

root: for a in nums {
    for b in nums {
        if a.1 - b.1 == x {
            print("\(a.0) \(b.0)")
            break root
        }
    }
}