# 方針 2: 特定の日からの日付に帰着させる. def is_leap(year: int) -> bool: """ 西暦 year 年はうるう年? Args: year (int): 西暦 Returns: bool: うるう年? """ if year % 100 == 0: return year % 400 == 0 return year % 4 == 0 def days_in_month(year: int, month: int) -> int: """ 西暦 year 年 month 月の日数 Args: year (int): 西暦 month (int): 月 Returns: int: 日数 """ if month == 2: return 29 if is_leap(year) else 28 return 30 if month in [4, 6, 9, 11] else 31 def get_total_days_from_19321231(year: int, month: int, day: int) -> int: """ 1932/12/31 を 0 日目とした場合の通算日数を求める. Args: year (int): 年 month (int): 月 day (int): 日 Returns: int: 通算日数 """ total_days = 0 # I: 1933 年から (year - 1) 年まで for y in range(1933, year): total_days += 366 if is_leap(y) else 365 # II: year 年 1 月から year 年 (month - 1) 月まで for m in range(1, month): total_days += days_in_month(year, m) # III: year 年 month 月の day 日間 total_days += day return total_days #================================================== def solve(): ys, ms, ds = map(int, input().split()) ye, me, de = map(int, input().split()) N_s = get_total_days_from_19321231(ys, ms, ds) N_e = get_total_days_from_19321231(ye, me, de) b = N_e - N_s + 1 Q = int(input()) ans = [None] * Q for q in range(Q): y, m, d = map(int, input().split()) N_q = get_total_days_from_19321231(y, m, d) a = N_q - (N_e + 1) + 1 if a < b: ans[q] = "Less" elif a == b: ans[q] = "Same" elif a > b: ans[q] = "More" return ans #================================================== import sys input = sys.stdin.readline write = sys.stdout.write write("\n".join(map(str, solve())))