def just_ship(prefix, x1, y1, size, d, cache={}):
"prefix is ignored"
if (x1, y1, size, d) in cache:
return cache[(x1, y1, size, d)]
if d == 'E':
points = [(x1+i,y1) for i in range(size)]
elif d == 'S':
points = [(x1,y1+i) for i in range(size)]
else:
raise
cache[(x1, y1, size, d)] = points
return points