Mark crew sail sea Aeolus Greek mythology Aeolus keeper wind they map represent NxM matrix land sea field want port port consider sea field they hurry wind strong changeable food K days sea maximum carry ship John guy Marks crew know predict direction wind daily basis W day time reach port run food Mark ship direction north east south west field day stay place Wind blow direction north east south west blow day the wind strong sea Aeolus move ship field direction blow the ship result movement sum ship action wind day Mark careful order ship sea result movement end sea field 4connected path sea start field a 4connected path path cell share sidefor example follow image ship can not port 4connected path sea in image ship port 4connected path sea show red arrow Furthermore ship port follow happen wind blow east Mark move ship north wind blow north Mark move ship east in scenario ship end port Mark ship map do not know outside Lucky Mark crew t fish shop sea replenish food supply maximum shop work day that mean Mark crew shop position exact work day order replenish food supply help Mark find minimum day crew need reach port print 1 impossible food supply