fixed a newline bug at file reading
Made a generator for inputs. Probem is, it requires far too much memory when N's high. Gotta change the algorithm.