#!/usr/bin/env python3
import sys
import random

n = int(sys.argv[1])
q = int(sys.argv[2])
maxa = int(sys.argv[3])
maxk = int(sys.argv[4])
seed = int(sys.argv[5])

random.seed(seed)

LIMIT = 10**9

print(n, q)

a = []
mx = 0
sm = 0

for _ in range(n):
    t = random.randint(1, 100)

    # Manteniamo abbastanza spazio per gli elementi rimanenti
    remaining = n - len(a) - 1
    current_max = min(maxa, LIMIT - 1 - sm - remaining)
    current_max = max(1, current_max)

    if t <= 50:
        x = random.randint(1, min(50, current_max))

    elif t <= 85:
        L = min(51, current_max)
        R = min(10_000, current_max)
        x = random.randint(L, R) if L <= R else random.randint(1, current_max)

    else:
        L = min(10_001, current_max)
        x = random.randint(L, current_max) if L <= current_max else random.randint(1, current_max)

    a.append(x)
    mx = max(mx, x)
    sm += x

print(*a)

if q == 1:
    t = random.randint(1, 100)

    if t <= 30:
        # Probably YES
        k = random.randint(1, min(mx, maxk))

    else:
        # Sure NO
        k = min(sm + 1, maxk)

    print(k)

else:
    for _ in range(q):
        t = random.randint(1, 100)

        if t <= 2:
            # Sure YES
            k = 1

        elif t <= 40:
            # Probably YES
            k = random.randint(1, min(mx, maxk))

        elif t <= 95:
            # Probably NO
            low = mx + 1
            if low <= maxk:
                k = random.randint(low, maxk)
            else:
                k = maxk

        else:
            # Sure NO
            k = min(sm + 1, maxk)

        print(k)