#include#include #include #define N 34typedef long long LL;using namespace std;struct T{ LL zs,fz,fm; T() { zs = 0; fz = 0; fm = 1; } T(LL a, LL b, LL c) { zs = a; fz = b; fm = c; } void Add(struct T t) { zs += t.zs; fz = fz*t.fm+t.fz*fm; fm = fm*t.fm; Standard(); } void Standard() { zs += fz/fm; fz = fz%fm; LL g=gcd(fz,fm); fz = fz/g; fm = fm/g; } LL gcd(LL a, LL b) { return b==0?a:gcd(b,a%b); }};struct T ans[N];void Init(){ for(int i=1;i