import java.io.IOException; import java.io.InputStream; import java.util.Arrays; import java.util.NoSuchElementException; class Fq { static int deg; static long irrPoly; long poly; public Fq(long poly) { this.poly=poly; } static void setDegree(int d) { deg=d;// F_{2^d}, deg(irrPoly)=d irrPoly=new long[]{1,2,5,11,23}[d]; } Fq add(Fq o) { return new Fq(poly^o.poly); } Fq mul(Fq o) { Fq ret=new Fq(0); for (int i=0;i<=deg+1;++i) { if ((o.poly>>i)%2==1) { ret.poly^=poly<=0;--shift) {; if ((ret.poly>>(shift+deg))%2==1) { ret.poly^=irrPoly< Integer.MAX_VALUE) throw new NumberFormatException(); return (int) nl; } public double nextDouble() { return Double.parseDouble(next());} }