import math def cmp_fracs(a, b) : return a[0] * b[1] < a[1] * b[0] def add_frac(a, b) : return [ a[0] * b[1] + a[1] * b[0], a[1] * b[1] ] def sub_frac(a, b) : return [ a[0] * b[1] - a[1] * b[0], a[1] * b[1] ] def mul_frac(a, b) : return [ a[0] * b[0], a[1] * b[1] ] def div_frac(a, b) : return [ a[0] * b[1], a[1] * b[0] ] def refine_frac(a) : g = math.gcd(a[0], a[1]) return [ a[0] // g, a[1] // g ] ZERO_FRAC = [0,1] def verify2(a : list[list[int]], b : list[list[int]], max_t : int) : a2 = [[ZERO_FRAC,ZERO_FRAC]] for x in a : a2.append([ add_frac(a2[-1][0], [x[0],1]), add_frac(a2[-1][1], [x[1],1]) ]) b2 = [[ZERO_FRAC,ZERO_FRAC]] for x in b : b2.append([ add_frac(b2[-1][0], [x[0],1]), add_frac(b2[-1][1], [x[1],1]) ]) px = ZERO_FRAC py = ZERO_FRAC t = 0 while cmp_fracs(px, b2[-1][0]) : t += 1 if t > max_t : return False min_slope = [1,0] for bp in b2 : if not cmp_fracs(px, bp[0]) : continue dx = sub_frac(bp[0], px) dy = sub_frac(bp[1], py) slope = div_frac(dy, dx) if cmp_fracs(slope, min_slope) : min_slope = slope min_slope = refine_frac(min_slope) found = 0 for ap0,ap1 in zip(a2[:-1],a2[1:]) : if not cmp_fracs(px, ap1[0]) : continue a1xf = sub_frac(ap1[0], px) a1yf = sub_frac(ap1[1], py) slope = div_frac(a1yf, a1xf) if not cmp_fracs(min_slope, slope) : continue a1yf = sub_frac(a1yf, mul_frac(a1xf, min_slope)) dxa = sub_frac(ap1[0],ap0[0]) dya = sub_frac(ap1[1],ap0[1]) aslope = sub_frac(div_frac(dya, dxa), min_slope) crossx = sub_frac(ap1[0], div_frac(a1yf, aslope)) crossy = add_frac(py, mul_frac(min_slope, sub_frac(crossx, px))) px = refine_frac(crossx) py = refine_frac(crossy) found = 1 break if found == 0 : break return True def input_positions(n) : ax = list(map(int,input().split())) ay = list(map(int,input().split())) return [ [ax[i],ay[i]] for i in range(n) ] def get_arg_order(a : list[list[int]]) : a = [[x[0],x[1]] for x in a] res = [i for i in range(len(a))] for i in range(n) : for j in range(n-1) : if a[j][0] * a[j+1][1] < a[j][1] * a[j+1][0] : res[j], res[j+1] = res[j+1], res[j] a[j], a[j+1] = a[j+1], a[j] return res n = int(input()) a = input_positions(n) b = input_positions(n) a_ord = get_arg_order(a) b_ord = get_arg_order(b) a_sorted = [a[i] for i in a_ord] b_sorted = [b[i] for i in b_ord] a_model = [a[i] for i in b_ord] b_model = [b[i] for i in b_ord] if verify2(a_model, b_model, n) : print("Yes") exit() if verify2(a_sorted, b_sorted, n-1) : print("Yes") exit() print("No")