Reads input and parses it into 3 arrays