print+(<>+<>x<>)*grep$$_++,<>