Initial commit. Works as a complete program with specific input now, but not tested rigorously.