from collections import deque import math n=int(input()) a=[0]*n b=[0]*n for i in range(n): a[i], b[i]=map(int, input().split()) deq=deque(zip(a, b)) while len(deq)>1: p=deq.popleft() q=deq.popleft() deq.append((p[0]*q[1]+p[1]*q[0], p[1]*q[1])) p=deq[0] g=math.gcd(p[0],p[1]) MOD=998244353 print(p[0]//g%MOD, p[1]//g%MOD)