Sketch implementation attempt of Algorithm W