Problem:
Score : 100 points

Problem Statement

You are given a string S as input. This represents a valid date in the year 2019 in the yyyy/mm/dd format. (For example, April 30, 2019 is represented as 2019/04/30.)

Write a program that prints Heisei if the date represented by S is not later than April 30, 2019, and prints TBD otherwise.

Constraints

S is a string that represents a valid date in the year 2019 in the yyyy/mm/dd format.

Input

Input is given from Standard Input in the following format:

S

Output

Print Heisei if the date represented by S is not later than April 30, 2019, and print TBD otherwise.

Sample Input 1

2019/04/30

Sample Output 1

Heisei

Sample Input 2

2019/11/01

Sample Output 2

TBD

Solution in Ruby (2.3.3) (judge verdict: Runtime Error)

A, B, Q = gets.split.map(&:to_i)
@s = []
@t = []
@q = []
A.times do
  @s << gets.to_i
end
B.times do
  @t << gets.to_i
end
Q.times do
  @q << gets.to_i
end

q_a = []
@q.each do |q|
  original_sorted_a = @s.sort{ |_a| (_a - q).abs }
  original_sorted_b = @t.sort{ |_a| (_a - q).abs }
  sorted_a = @s.map{ |_a| (_a - q).abs }.sort
  sorted_b = @t.map{ |_b| (_b - q).abs }.sort
  first_a = 10 ** 20
  first_b = 10 ** 20

  if [@s,@t].flatten.count > 2
    first_a = (original_sorted_b.sort do |_b|
    (original_sorted_a.first - _b).abs
  end.first - original_sorted_a.first).abs + (original_sorted_a.first - q).abs
  first_b = (original_sorted_a.sort do |_a|
    (original_sorted_b.first - _a).abs
  end.first - original_sorted_a.first).abs + (original_sorted_b.first - q).abs
  end

  if q.between?([@s,@t].flatten.min, [@s,@t].flatten.max)
    q_a << [sorted_b.first * 2 + sorted_a.first, sorted_a.first * 2 + sorted_b.first, first_a, first_b].min
  else
    f = [sorted_a.first, sorted_b.first].flatten
    q_a << f.first(2).inject(:+) - f.last
  end
end

puts q_a