from heapq import heappush, heappop import sys input = sys.stdin.readline N, A, B, C = map(int, input().split()) L = 31 ans = [10**18] * N dist = [10**18] * (N*L) heap = [] for z in range(L): heappush(heap, (A+B+z*C, N*z+(2**z)%N)) while heap: d, v = heappop(heap) if d > dist[v]: continue z, i = divmod(v, N) ans[i] = min(ans[i], d) # same nd, u = d+A, N*z+(i+2**z)%N if dist[u] > nd: dist[u] = nd heappush(heap, (nd, u)) # change for w in range(z+1, L): nd, u = d+B+(w-z)*C, N*w+i if dist[u] > nd: dist[u] = nd heappush(heap, (nd, u)) print(*ans, sep="\n")