import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        BDZYLovesFFT solver = new BDZYLovesFFT();
        solver.solve(1, in, out);
        out.close();
    }

    static class BDZYLovesFFT {
        int n;
        int d;
        long x;
        int[] a;
        int[] b;

        public void solve(int testNumber, InputReader in, PrintWriter out) {
            n = in.readInt();
            d = in.readInt();
            x = in.readLong();
            a = new int[n];
            b = new int[n];
            initAB();
            int s = 50;
            int[] idx = new int[n + 1];
            for (int i = 0; i < n; i++) idx[a[i]] = i;

            int[] q = new int[n];
            int t = 0;
            for (int i = 0; i < n; i++) if (b[i] == 1) q[t++] = i;

            int[] c = new int[n];
            Arrays.fill(c, -1);
            c[0] = a[0] * b[0];
            for (int i = 1; i < n; i++) {
                for (int j = 0; j < s; j++) {
                    if (n - j >= 0 && idx[n - j] <= i && b[i - idx[n - j]] == 1) {
                        c[i] = n - j;
                        break;
                    }
                }
                if (c[i] < 0) {
                    c[i] = 0;
                    for (int j = 0; j < t && q[j] <= i; j++) {
                        c[i] = Math.max(c[i], a[i - q[j]]);
                    }
                }
            }
            for (int i : c) out.println(i);

        }

        int getNextX() {
            x = (x * 37 + 10007) % 1000000007;
            return (int) x;
        }

        void initAB() {
            for (int i = 0; i < n; i = i + 1) {
                a[i] = i + 1;
            }
            for (int i = 0; i < n; i = i + 1) {
                int t = a[i];
                int v = getNextX() % (i + 1);
                a[i] = a[v];
                a[v] = t;
            }
            for (int i = 0; i < n; i = i + 1) {
                if (i < d)
                    b[i] = 1;
                else
                    b[i] = 0;
            }
            for (int i = 0; i < n; i = i + 1) {
                int v = getNextX() % (i + 1);
                int t = b[i];
                b[i] = b[v];
                b[v] = t;
            }
        }

    }

    static class InputReader {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;
        private InputReader.SpaceCharFilter filter;

        public InputReader(InputStream stream) {
            this.stream = stream;
        }

        public int read() {
            if (numChars == -1)
                throw new InputMismatchException();
            if (curChar >= numChars) {
                curChar = 0;
                try {
                    numChars = stream.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
                if (numChars <= 0)
                    return -1;
            }
            return buf[curChar++];
        }

        public int readInt() {
            int c = read();
            while (isSpaceChar(c))
                c = read();
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = read();
            }
            int res = 0;
            do {
                if (c < '0' || c > '9')
                    throw new InputMismatchException();
                res *= 10;
                res += c - '0';
                c = read();
            } while (!isSpaceChar(c));
            return res * sgn;
        }

        public long readLong() {
            int c = read();
            while (isSpaceChar(c))
                c = read();
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = read();
            }
            long res = 0;
            do {
                if (c < '0' || c > '9')
                    throw new InputMismatchException();
                res *= 10;
                res += c - '0';
                c = read();
            } while (!isSpaceChar(c));
            return res * sgn;
        }

        public boolean isSpaceChar(int c) {
            if (filter != null)
                return filter.isSpaceChar(c);
            return isWhitespace(c);
        }

        public static boolean isWhitespace(int c) {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        public interface SpaceCharFilter {
            public boolean isSpaceChar(int ch);

        }

    }
}

import java.io.*;
import java.util.*;

public class CF {
	FastScanner in;
	PrintWriter out;

	long x;

	final int LOG = 6;
	final int DIV = 1 << LOG;
	final int DIVM1 = DIV - 1;

	long getNextX() {
		x = (x * 37 + 10007) % 1000000007;
		return x;
	}

	int n;
	int[] a;
	int[] b;
	int d;

	void swap(int[] a, int p1, int p2) {
		int v1 = a[p1];
		a[p1] = a[p2];
		a[p2] = v1;
	}

	void initAB() {
		for (int i = 0; i < n; i = i + 1) {
			a[i] = i + 1;
		}
		for (int i = 0; i < n; i = i + 1) {
			swap(a, i, (int) (getNextX() % (i + 1)));
		}
		for (int i = 0; i < n; i = i + 1) {
			if (i < d)
				b[i] = 1;
			else
				b[i] = 0;
		}
		for (int i = 0; i < n; i = i + 1) {
			swap(b, i, (int) (getNextX() % (i + 1)));
		}
	}

	class MBitSet {
		long[] vals;
		int n;

		MBitSet(int[] a, int shift) {
			n = 1 + a.length / DIV + 1;
			vals = new long[n];
			for (int i = 0; i < a.length; i++)
				if (a[i] == 1) {
					int pos = i + shift;
					vals[pos >> LOG] |= 1L << (pos & DIVM1);
				}
		}

		MBitSet(int n) {
			this.n = 1 + n / DIV + 1;
			vals = new long[this.n];
		}

		void set(int pos) {
			vals[pos >> LOG] ^= 1L << (pos & DIVM1);
		}

	}

	void solve() {
		n = in.nextInt();
		d = in.nextInt();
		x = in.nextInt();
		int[] c = new int[n];
		a = new int[n];
		b = new int[n];
		initAB();
		int[] pos = new int[n];
		for (int i = 0; i < n; i++) {
			pos[a[i] - 1] = i;
		}
		MBitSet[] bs = new MBitSet[DIV];
		for (int i = 0; i < DIV; i++)
			bs[i] = new MBitSet(b, i);
		MBitSet curNotSet = new MBitSet(n);
		for (int i = 0; i < n; i++)
			curNotSet.set(i);
		for (int i = n - 1; i >= 0; i--) {
			int p = pos[i];
			int start = p / DIV;
			int xx = p & DIVM1;
			for (int j = start; j < curNotSet.n; j++) {
				long tt = curNotSet.vals[j] & (bs[xx].vals[j - start]);
				while (tt != 0) {
					int v = Long.numberOfTrailingZeros(tt);
					int posit = j * DIV + v;
					c[posit] = i + 1;
					curNotSet.set(posit);
					tt ^= 1L << v;
				}
			}

		}
		for (int i = 0; i < n; i++) {
			 out.println(c[i]);
		}
	}

	void run() {
		try {
			in = new FastScanner(new File("CF.in"));
			out = new PrintWriter(new File("CF.out"));

			solve();

			out.close();
		} catch (FileNotFoundException e) {
			e.printStackTrace();
		}
	}

	void runIO() {

		in = new FastScanner(System.in);
		out = new PrintWriter(System.out);

		solve();

		out.close();
	}

	class FastScanner {
		BufferedReader br;
		StringTokenizer st;

		public FastScanner(File f) {
			try {
				br = new BufferedReader(new FileReader(f));
			} catch (FileNotFoundException e) {
				e.printStackTrace();
			}
		}

		public FastScanner(InputStream f) {
			br = new BufferedReader(new InputStreamReader(f));
		}

		String next() {
			while (st == null || !st.hasMoreTokens()) {
				String s = null;
				try {
					s = br.readLine();
				} catch (IOException e) {
					e.printStackTrace();
				}
				if (s == null)
					return null;
				st = new StringTokenizer(s);
			}
			return st.nextToken();
		}

		boolean hasMoreTokens() {
			while (st == null || !st.hasMoreTokens()) {
				String s = null;
				try {
					s = br.readLine();
				} catch (IOException e) {
					e.printStackTrace();
				}
				if (s == null)
					return false;
				st = new StringTokenizer(s);
			}
			return true;
		}

		int nextInt() {
			return Integer.parseInt(next());
		}

		long nextLong() {
			return Long.parseLong(next());
		}

		double nextDouble() {
			return Double.parseDouble(next());
		}
	}

	public static void main(String[] args) {
		new CF().runIO();
	}
}

import java.io.*;
import java.util.*;

public class CF {
	FastScanner in;
	PrintWriter out;

	long x;

	final int LOG = 5;
	final int DIV = 1 << LOG;
	final int DIVM1 = DIV - 1;

	long getNextX() {
		x = (x * 37 + 10007) % 1000000007;
		return x;
	}

	int n;
	int[] a;
	int[] b;
	int d;

	void swap(int[] a, int p1, int p2) {
		int v1 = a[p1];
		a[p1] = a[p2];
		a[p2] = v1;
	}

	void initAB() {
		for (int i = 0; i < n; i = i + 1) {
			a[i] = i + 1;
		}
		for (int i = 0; i < n; i = i + 1) {
			swap(a, i, (int) (getNextX() % (i + 1)));
		}
		for (int i = 0; i < n; i = i + 1) {
			if (i < d)
				b[i] = 1;
			else
				b[i] = 0;
		}
		for (int i = 0; i < n; i = i + 1) {
			swap(b, i, (int) (getNextX() % (i + 1)));
		}
	}

	class MBitSet {
		int[] vals;
		int n;

		MBitSet(int[] a, int shift) {
			n = 1 + a.length / DIV + 1;
			vals = new int[n];
			for (int i = 0; i < a.length; i++)
				if (a[i] == 1) {
					int pos = i + shift;
					vals[pos >> LOG] |= 1 << (pos & DIVM1);
				}
		}

		MBitSet(int n) {
			this.n = 1 + n / DIV + 1;
			vals = new int[this.n];
		}

		void set(int pos) {
			vals[pos >> LOG] ^= 1 << (pos & DIVM1);
		}

	}

	void solve() {
		n = in.nextInt();
		d = in.nextInt();
		x = in.nextInt();
		int[] c = new int[n];
		a = new int[n];
		b = new int[n];
		initAB();
		int[] pos = new int[n];
		for (int i = 0; i < n; i++) {
			pos[a[i] - 1] = i;
		}
		MBitSet[] bs = new MBitSet[DIV];
		for (int i = 0; i < DIV; i++)
			bs[i] = new MBitSet(b, i);
		MBitSet curNotSet = new MBitSet(n);
		for (int i = 0; i < n; i++)
			curNotSet.set(i);
		for (int i = n - 1; i >= 0; i--) {
			int p = pos[i];
			int start = p / DIV;
			int xx = p & DIVM1;
			for (int j = start; j < curNotSet.n; j++) {
				int tt = curNotSet.vals[j] & (bs[xx].vals[j - start]);
				while (tt != 0) {
					int v = Integer.numberOfTrailingZeros(tt);
					int posit = j * DIV + v;
					c[posit] = i + 1;
					curNotSet.set(posit);
					tt ^= 1 << v;
				}
			}

		}
		for (int i = 0; i < n; i++) {
			 out.println(c[i]);
		}
	}

	void run() {
		try {
			in = new FastScanner(new File("CF.in"));
			out = new PrintWriter(new File("CF.out"));

			solve();

			out.close();
		} catch (FileNotFoundException e) {
			e.printStackTrace();
		}
	}

	void runIO() {

		in = new FastScanner(System.in);
		out = new PrintWriter(System.out);

		solve();

		out.close();
	}

	class FastScanner {
		BufferedReader br;
		StringTokenizer st;

		public FastScanner(File f) {
			try {
				br = new BufferedReader(new FileReader(f));
			} catch (FileNotFoundException e) {
				e.printStackTrace();
			}
		}

		public FastScanner(InputStream f) {
			br = new BufferedReader(new InputStreamReader(f));
		}

		String next() {
			while (st == null || !st.hasMoreTokens()) {
				String s = null;
				try {
					s = br.readLine();
				} catch (IOException e) {
					e.printStackTrace();
				}
				if (s == null)
					return null;
				st = new StringTokenizer(s);
			}
			return st.nextToken();
		}

		boolean hasMoreTokens() {
			while (st == null || !st.hasMoreTokens()) {
				String s = null;
				try {
					s = br.readLine();
				} catch (IOException e) {
					e.printStackTrace();
				}
				if (s == null)
					return false;
				st = new StringTokenizer(s);
			}
			return true;
		}

		int nextInt() {
			return Integer.parseInt(next());
		}

		long nextLong() {
			return Long.parseLong(next());
		}

		double nextDouble() {
			return Double.parseDouble(next());
		}
	}

	public static void main(String[] args) {
		new CF().runIO();
	}
}

import java.io.*;
import java.util.*;

public class CF {
	FastScanner in;
	PrintWriter out;

	long x;

	long getNextX() {
		x = (x * 37 + 10007) % 1000000007;
		return x;
	}

	int n;
	int[] a;
	int[] b;
	int d;

	void swap(int[] a, int p1, int p2) {
		int v1 = a[p1];
		a[p1] = a[p2];
		a[p2] = v1;
	}

	void initAB() {
		for (int i = 0; i < n; i = i + 1) {
			a[i] = i + 1;
		}
		for (int i = 0; i < n; i = i + 1) {
			swap(a, i, (int) (getNextX() % (i + 1)));
		}
		for (int i = 0; i < n; i = i + 1) {
			if (i < d)
				b[i] = 1;
			else
				b[i] = 0;
		}
		for (int i = 0; i < n; i = i + 1) {
			swap(b, i, (int) (getNextX() % (i + 1)));
		}
	}

	class MBitSet {
		long[] vals;
		int n;

		MBitSet(int[] a, int go) {
			n = 1 + a.length / 64 + 1;
			vals = new long[n];
			for (int i = 0; i < a.length; i++)
				if (a[i] == 1) {
					int pos = i + go;
					vals[pos >> 6] |= 1L << (pos & 63);
				}
		}

		MBitSet(MBitSet an) {
			this.n = an.n;
			this.vals = new long[this.n];
			for (int i = 0; i < n; i++) {
				vals[i] = an.vals[i];
			}
		}

		void shift(int f) {
			for (int i = n - 1; i >= 0; i--) {
				if (i - f >= 0) {
					vals[i] = vals[i - f];
				} else {
					vals[i] = 0;
				}
			}
		}

		void update(MBitSet x) {
			for (int i = 0; i < x.n; i++) {
				vals[i] = x.vals[i];
			}
		}

		MBitSet(int n) {
			this.n = 1 + n / 64 + 1;
			vals = new long[this.n];
		}

		void and(MBitSet another) {
			for (int i = 0; i < Math.min(n, another.n); i++) {
				vals[i] &= another.vals[i];
			}
		}

		void set(int pos) {
			vals[pos >> 6] ^= 1L << (pos & 63);
		}

	}

	void solve() {
		long st = System.currentTimeMillis();
		n = in.nextInt();
		d = in.nextInt();
		x = in.nextInt();
		int[] c = new int[n];
		a = new int[n];
		b = new int[n];
		initAB();
		int[] pos = new int[n];
		for (int i = 0; i < n; i++) {
			pos[a[i] - 1] = i;
		}
		MBitSet[] bs = new MBitSet[64];
		for (int i = 0; i < 64; i++)
			bs[i] = new MBitSet(b, i);
		MBitSet curNotSet = new MBitSet(n);
		for (int i = 0; i < n; i++)
			curNotSet.set(i);
		for (int i = n - 1; i >= 0; i--) {
			int p = pos[i];
			int start = p / 64;
			int xx = p & 63;
			for (int j = start; j < curNotSet.n; j++) {
				long tt = curNotSet.vals[j] & (bs[xx].vals[j - start]);

				while (tt != 0) {
					int v = Long.numberOfTrailingZeros(tt);
					int posit = j * 64 + v;
					c[posit] = i + 1;
					curNotSet.set(posit);
					tt ^= 1L << v;
				}
			}

		}
		for (int i = 0; i < n; i++) {
			 out.println(c[i]);
		}
		System.err.println(System.currentTimeMillis() - st);
//		System.err.println(z);
	}

	void run() {
		try {
			in = new FastScanner(new File("CF.in"));
			out = new PrintWriter(new File("CF.out"));

			solve();

			out.close();
		} catch (FileNotFoundException e) {
			e.printStackTrace();
		}
	}

	void runIO() {

		in = new FastScanner(System.in);
		out = new PrintWriter(System.out);

		solve();

		out.close();
	}

	class FastScanner {
		BufferedReader br;
		StringTokenizer st;

		public FastScanner(File f) {
			try {
				br = new BufferedReader(new FileReader(f));
			} catch (FileNotFoundException e) {
				e.printStackTrace();
			}
		}

		public FastScanner(InputStream f) {
			br = new BufferedReader(new InputStreamReader(f));
		}

		String next() {
			while (st == null || !st.hasMoreTokens()) {
				String s = null;
				try {
					s = br.readLine();
				} catch (IOException e) {
					e.printStackTrace();
				}
				if (s == null)
					return null;
				st = new StringTokenizer(s);
			}
			return st.nextToken();
		}

		boolean hasMoreTokens() {
			while (st == null || !st.hasMoreTokens()) {
				String s = null;
				try {
					s = br.readLine();
				} catch (IOException e) {
					e.printStackTrace();
				}
				if (s == null)
					return false;
				st = new StringTokenizer(s);
			}
			return true;
		}

		int nextInt() {
			return Integer.parseInt(next());
		}

		long nextLong() {
			return Long.parseLong(next());
		}

		double nextDouble() {
			return Double.parseDouble(next());
		}
	}

	public static void main(String[] args) {
		new CF().runIO();
	}
}

import java.io.*;
import java.util.*;

public class CF {
	FastScanner in;
	PrintWriter out;

	long x;

	final int LOG = 5;
	final int DIV = 1 << LOG;
	final int DIVM1 = DIV - 1;

	long getNextX() {
		x = (x * 37 + 10007) % 1000000007;
		return x;
	}

	int n;
	int[] a;
	int[] b;
	int d;

	void swap(int[] a, int p1, int p2) {
		int v1 = a[p1];
		a[p1] = a[p2];
		a[p2] = v1;
	}

	void initAB() {
		for (int i = 0; i < n; i = i + 1) {
			a[i] = i + 1;
		}
		for (int i = 0; i < n; i = i + 1) {
			swap(a, i, (int) (getNextX() % (i + 1)));
		}
		for (int i = 0; i < n; i = i + 1) {
			if (i < d)
				b[i] = 1;
			else
				b[i] = 0;
		}
		for (int i = 0; i < n; i = i + 1) {
			swap(b, i, (int) (getNextX() % (i + 1)));
		}
	}

	class MBitSet {
		int[] vals;
		int n;

		MBitSet(int[] a, int shift) {
			n = 1 + a.length / DIV + 1;
			vals = new int[n];
			for (int i = 0; i < a.length; i++)
				if (a[i] == 1) {
					int pos = i + shift;
					vals[pos >> LOG] |= 1 << (pos & DIVM1);
				}
		}

		MBitSet(MBitSet an) {
			this.n = an.n;
			this.vals = new int[this.n];
			for (int i = 0; i < n; i++) {
				vals[i] = an.vals[i];
			}
		}

		MBitSet(int n) {
			this.n = 1 + n / DIV + 1;
			vals = new int[this.n];
		}

		void set(int pos) {
			vals[pos >> LOG] ^= 1 << (pos & DIVM1);
		}

	}

	void solve() {
		n = in.nextInt();
		d = in.nextInt();
		x = in.nextInt();
		int[] c = new int[n];
		a = new int[n];
		b = new int[n];
		initAB();
		int[] pos = new int[n];
		for (int i = 0; i < n; i++) {
			pos[a[i] - 1] = i;
		}
		MBitSet[] bs = new MBitSet[DIV];
		for (int i = 0; i < DIV; i++)
			bs[i] = new MBitSet(b, i);
		MBitSet curNotSet = new MBitSet(n);
		for (int i = 0; i < n; i++)
			curNotSet.set(i);
		for (int i = n - 1; i >= 0; i--) {
			int p = pos[i];
			int start = p / DIV;
			int xx = p & DIVM1;
			for (int j = start; j < curNotSet.n; j++) {
				long tt = curNotSet.vals[j] & (bs[xx].vals[j - start]);
				while (tt != 0) {
					int v = Long.numberOfTrailingZeros(tt);
					int posit = j * DIV + v;
					c[posit] = i + 1;
					curNotSet.set(posit);
					tt ^= 1 << v;
				}
			}

		}
		for (int i = 0; i < n; i++) {
			 out.println(c[i]);
		}
	}

	void run() {
		try {
			in = new FastScanner(new File("CF.in"));
			out = new PrintWriter(new File("CF.out"));

			solve();

			out.close();
		} catch (FileNotFoundException e) {
			e.printStackTrace();
		}
	}

	void runIO() {

		in = new FastScanner(System.in);
		out = new PrintWriter(System.out);

		solve();

		out.close();
	}

	class FastScanner {
		BufferedReader br;
		StringTokenizer st;

		public FastScanner(File f) {
			try {
				br = new BufferedReader(new FileReader(f));
			} catch (FileNotFoundException e) {
				e.printStackTrace();
			}
		}

		public FastScanner(InputStream f) {
			br = new BufferedReader(new InputStreamReader(f));
		}

		String next() {
			while (st == null || !st.hasMoreTokens()) {
				String s = null;
				try {
					s = br.readLine();
				} catch (IOException e) {
					e.printStackTrace();
				}
				if (s == null)
					return null;
				st = new StringTokenizer(s);
			}
			return st.nextToken();
		}

		boolean hasMoreTokens() {
			while (st == null || !st.hasMoreTokens()) {
				String s = null;
				try {
					s = br.readLine();
				} catch (IOException e) {
					e.printStackTrace();
				}
				if (s == null)
					return false;
				st = new StringTokenizer(s);
			}
			return true;
		}

		int nextInt() {
			return Integer.parseInt(next());
		}

		long nextLong() {
			return Long.parseLong(next());
		}

		double nextDouble() {
			return Double.parseDouble(next());
		}
	}

	public static void main(String[] args) {
		new CF().runIO();
	}
}

import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Collections;
import java.util.StringTokenizer;

public class B {

    static StringTokenizer st;
    static BufferedReader br;
    static PrintWriter pw;
    static long x;
    public static void main(String[] args) throws IOException {
        br = new BufferedReader(new InputStreamReader(System.in));
        pw = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));
        int n = nextInt();
        int d = nextInt();
        x = nextInt();
        long[]a = new long[n], b = new long[n];
        for (int i = 0; i < n; i++) {
            a[i] = i+1;
        }
        for (int i = 0; i < n; i++) {
            int id = (int) (getNext() % (i+1));
            long t = a[i];
            a[i] = a[id];
            a[id] = t;
        }
        for(int i = 0; i < n; i++){
            if (i < d)
                b[i] = 1;
            else
                b[i] = 0;
        }
        for (int i = 0; i < n; i++) {
            int id = (int) (getNext() % (i+1));
            long t = b[i];
            b[i] = b[id];
            b[id] = t;
        }
        ArrayList<Integer> B = new ArrayList<>();
        for (int i = 0; i < n; i++) {
            if (b[i]==1)
                B.add(i);
        }
        int[]ans = new int[n];
        int[]id = new int[n+1];
        for (int i = 0; i < n; i++) {
            id[(int) a[i]] = i;
        }
        for (int i = 0; i < n; i++) {
            for (int j = n; j >= n-45; j--) {
                if (j <= 0)
                    break;
                int pos = id[j];
                if (pos <= i && b[i-pos]==1) {
                    ans[i] = j;
                    break;
                }
            }
            if (ans[i]==0) {
                for (int j : B) {
                    int pos = i-j;
                    if (pos >= 0)
                        ans[i] = (int) Math.max(ans[i], a[pos]);
                    else
                        break;
                }
            }
        }
        for (int i = 0; i < n; i++) {
            pw.println(ans[i]);
        }
        pw.close();
    }
    private static long getNext() {
        x = (x * 37 + 10007) % 1000000007;
        return x;
    }
    private static int nextInt() throws IOException {
        return Integer.parseInt(next());
    }
    private static long nextLong() throws IOException {
        return Long.parseLong(next());
    }
    private static double nextDouble() throws IOException {
        return Double.parseDouble(next());
    }
    private static String next() throws IOException {
        while (st==null || !st.hasMoreTokens())
            st = new StringTokenizer(br.readLine());
        return st.nextToken();
    }
}

import java.util.Map;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.TreeMap;
import java.util.Set;
import java.util.Comparator;
import java.io.BufferedReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.io.Reader;
import java.util.TreeSet;
import java.util.Collections;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 * @author Vadim
 */
public class Main {
	public static void main(String[] args) {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		TaskD solver = new TaskD();
		solver.solve(1, in, out);
		out.close();
	}
}

class TaskD {
    long x;
    long getNextX() {
        x = (x * 37 + 10007) % 1000000007;
        return x;
    }
    void swap (int[] a, int i, int j) {
        int t = a[i];
        a[i] = a[j];
        a[j] = t;
    }
    void initAB(int a[], int b[], int d, int n) {
        for(int i = 0; i < n; i = i + 1){
            a[i] = i + 1;
        }
        for(int i = 0; i < n; i = i + 1){
            swap(a, i, (int)(getNextX() % (i + 1)));
        }
        for(int i = 0; i < n; i = i + 1){
            if (i < d)
                b[i] = 1;
            else
                b[i] = 0;
        }
        for(int i = 0; i < n; i = i + 1){
            swap(b, i, (int)(getNextX() % (i + 1)));
        }
    }
    public void solve(int testNumber, InputReader in, PrintWriter out) {
        int n = in.ni();
        int d = in.ni();
        x = in.nl();
        int [] a = new int[n];
        int [] b = new int[n];
        initAB(a, b, d, n);
        TreeMap<Integer, Integer> maxValues = new TreeMap<Integer, Integer>(Collections.reverseOrder());
        TreeSet<Integer> ones = new TreeSet<Integer>();
        for (int i = 0; i < n; i++) {
            if(b[i] == 1) {
                ones.add(i);
            }
            maxValues.put(a[i], i);
            int ans = 0;
            if(i < 200 || ones.size() > 100) {
                for (Map.Entry<Integer, Integer> entry : maxValues.entrySet()) {
                    if(b[i-entry.getValue()] == 1) {
                        ans = entry.getKey();
                        break;
                    }
                }
            } else {
                for (Integer index : ones) {
                    if(index > i) {
                        break;
                    }
                    ans = Math.max(ans, a[i-index]);
                }
            }
            out.println(ans);
        }
    }
}

class InputReader  extends BufferedReader {
    public InputReader(InputStream st) {
        super(new InputStreamReader(st));
    }

    public int nextInt() {
        try {
            int c = read();

            while (isWhiteSpace(c)) {
                c = read();
            }
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = read();
            }
            int ret = 0;
            while (c >= 0 && !isWhiteSpace(c)) {
                if (c < '0' || c > '9') {
                    throw new RuntimeException();
                }
                ret = ret * 10 + c - '0';
                c = read();
            }
            return ret * sgn;
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }

    public long nextLong() {
        try {
            int c = read();

            while (isWhiteSpace(c)) {
                c = read();
            }
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = read();
            }
            long ret = 0;
            while (c >= 0 && !isWhiteSpace(c)) {
                if (c < '0' || c > '9') {
                    throw new RuntimeException();
                }
                ret = ret * 10 + c - '0';
                c = read();
            }
            return ret * sgn;
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }

    public int ni() {
        return nextInt();
    }

    public long nl() {
        return nextLong();
    }

    public String readLine() {
        try {
            return super.readLine();
        } catch (IOException e) {
            return null;
        }
    }

    static boolean isWhiteSpace(int c) {
        return c >= 0 && c <= 32;
    }

}

import java.util.Map;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.TreeMap;
import java.util.Set;
import java.util.Comparator;
import java.io.BufferedReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.io.Reader;
import java.util.TreeSet;
import java.util.Collections;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 * @author Vadim
 */
public class Main {
	public static void main(String[] args) {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		TaskD solver = new TaskD();
		solver.solve(1, in, out);
		out.close();
	}
}

class TaskD {
    long x;
    long getNextX() {
        x = (x * 37 + 10007) % 1000000007;
        return x;
    }
    void swap (int[] a, int i, int j) {
        int t = a[i];
        a[i] = a[j];
        a[j] = t;
    }
    void initAB(int a[], int b[], int d, int n) {
        for(int i = 0; i < n; i = i + 1){
            a[i] = i + 1;
        }
        for(int i = 0; i < n; i = i + 1){
            swap(a, i, (int)(getNextX() % (i + 1)));
        }
        for(int i = 0; i < n; i = i + 1){
            if (i < d)
                b[i] = 1;
            else
                b[i] = 0;
        }
        for(int i = 0; i < n; i = i + 1){
            swap(b, i, (int)(getNextX() % (i + 1)));
        }
    }
    public void solve(int testNumber, InputReader in, PrintWriter out) {
        int n = in.ni();
        int d = in.ni();
        x = in.nl();
        int [] a = new int[n];
        int [] b = new int[n];
        initAB(a, b, d, n);
        TreeMap<Integer, Integer> maxValues = new TreeMap<Integer, Integer>(Collections.reverseOrder());
        TreeSet<Integer> ones = new TreeSet<Integer>();
        for (int i = 0; i < n; i++) {
            if(b[i] == 1) {
                ones.add(i);
            }
            maxValues.put(a[i], i);
            int ans = 0;
            if(i < 200 || ones.size() > 1000) {
                for (Map.Entry<Integer, Integer> entry : maxValues.entrySet()) {
                    if(b[i-entry.getValue()] == 1) {
                        ans = entry.getKey();
                        break;
                    }
                }
            } else {
                for (Integer index : ones) {
                    if(index > i) {
                        break;
                    }
                    ans = Math.max(ans, a[i-index]);
                }
            }
            out.println(ans);
        }
    }
}

class InputReader  extends BufferedReader {
    public InputReader(InputStream st) {
        super(new InputStreamReader(st));
    }

    public int nextInt() {
        try {
            int c = read();

            while (isWhiteSpace(c)) {
                c = read();
            }
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = read();
            }
            int ret = 0;
            while (c >= 0 && !isWhiteSpace(c)) {
                if (c < '0' || c > '9') {
                    throw new RuntimeException();
                }
                ret = ret * 10 + c - '0';
                c = read();
            }
            return ret * sgn;
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }

    public long nextLong() {
        try {
            int c = read();

            while (isWhiteSpace(c)) {
                c = read();
            }
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = read();
            }
            long ret = 0;
            while (c >= 0 && !isWhiteSpace(c)) {
                if (c < '0' || c > '9') {
                    throw new RuntimeException();
                }
                ret = ret * 10 + c - '0';
                c = read();
            }
            return ret * sgn;
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }

    public int ni() {
        return nextInt();
    }

    public long nl() {
        return nextLong();
    }

    public String readLine() {
        try {
            return super.readLine();
        } catch (IOException e) {
            return null;
        }
    }

    static boolean isWhiteSpace(int c) {
        return c >= 0 && c <= 32;
    }

}

import java.util.Map;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.TreeMap;
import java.util.Set;
import java.util.Comparator;
import java.io.BufferedReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.io.Reader;
import java.util.TreeSet;
import java.util.Collections;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 * @author Vadim
 */
public class Main {
	public static void main(String[] args) {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		TaskD solver = new TaskD();
		solver.solve(1, in, out);
		out.close();
	}
}

class TaskD {
    long x;
    long getNextX() {
        x = (x * 37 + 10007) % 1000000007;
        return x;
    }
    void swap (int[] a, int i, int j) {
        int t = a[i];
        a[i] = a[j];
        a[j] = t;
    }
    void initAB(int a[], int b[], int d, int n) {
        for(int i = 0; i < n; i = i + 1){
            a[i] = i + 1;
        }
        for(int i = 0; i < n; i = i + 1){
            swap(a, i, (int)(getNextX() % (i + 1)));
        }
        for(int i = 0; i < n; i = i + 1){
            if (i < d)
                b[i] = 1;
            else
                b[i] = 0;
        }
        for(int i = 0; i < n; i = i + 1){
            swap(b, i, (int)(getNextX() % (i + 1)));
        }
    }
    public void solve(int testNumber, InputReader in, PrintWriter out) {
        int n = in.ni();
        int d = in.ni();
        x = in.nl();
        int [] a = new int[n];
        int [] b = new int[n];
        initAB(a, b, d, n);
        TreeMap<Integer, Integer> maxValues = new TreeMap<Integer, Integer>(Collections.reverseOrder());
        TreeSet<Integer> ones = new TreeSet<Integer>();
        for (int i = 0; i < n; i++) {
            if(b[i] == 1) {
                ones.add(i);
            }
            maxValues.put(a[i], i);
            int ans = 0;
            if(i < 200 || ones.size() > 500) {
                for (Map.Entry<Integer, Integer> entry : maxValues.entrySet()) {
                    if(b[i-entry.getValue()] == 1) {
                        ans = entry.getKey();
                        break;
                    }
                }
            } else {
                for (Integer index : ones) {
                    if(index > i) {
                        break;
                    }
                    ans = Math.max(ans, a[i-index]);
                }
            }
            out.println(ans);
        }
    }
}

class InputReader  extends BufferedReader {
    public InputReader(InputStream st) {
        super(new InputStreamReader(st));
    }

    public int nextInt() {
        try {
            int c = read();

            while (isWhiteSpace(c)) {
                c = read();
            }
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = read();
            }
            int ret = 0;
            while (c >= 0 && !isWhiteSpace(c)) {
                if (c < '0' || c > '9') {
                    throw new RuntimeException();
                }
                ret = ret * 10 + c - '0';
                c = read();
            }
            return ret * sgn;
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }

    public long nextLong() {
        try {
            int c = read();

            while (isWhiteSpace(c)) {
                c = read();
            }
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = read();
            }
            long ret = 0;
            while (c >= 0 && !isWhiteSpace(c)) {
                if (c < '0' || c > '9') {
                    throw new RuntimeException();
                }
                ret = ret * 10 + c - '0';
                c = read();
            }
            return ret * sgn;
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }

    public int ni() {
        return nextInt();
    }

    public long nl() {
        return nextLong();
    }

    public String readLine() {
        try {
            return super.readLine();
        } catch (IOException e) {
            return null;
        }
    }

    static boolean isWhiteSpace(int c) {
        return c >= 0 && c <= 32;
    }

}

import java.util.Map;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.TreeMap;
import java.util.Set;
import java.util.Comparator;
import java.io.BufferedReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.io.Reader;
import java.util.TreeSet;
import java.util.Collections;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 * @author Vadim
 */
public class Main {
	public static void main(String[] args) {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		TaskD solver = new TaskD();
		solver.solve(1, in, out);
		out.close();
	}
}

class TaskD {
    long x;
    long getNextX() {
        x = (x * 37 + 10007) % 1000000007;
        return x;
    }
    void swap (int[] a, int i, int j) {
        int t = a[i];
        a[i] = a[j];
        a[j] = t;
    }
    void initAB(int a[], int b[], int d, int n) {
        for(int i = 0; i < n; i = i + 1){
            a[i] = i + 1;
        }
        for(int i = 0; i < n; i = i + 1){
            swap(a, i, (int)(getNextX() % (i + 1)));
        }
        for(int i = 0; i < n; i = i + 1){
            if (i < d)
                b[i] = 1;
            else
                b[i] = 0;
        }
        for(int i = 0; i < n; i = i + 1){
            swap(b, i, (int)(getNextX() % (i + 1)));
        }
    }
    public void solve(int testNumber, InputReader in, PrintWriter out) {
        int n = in.ni();
        int d = in.ni();
        x = in.nl();
        int [] a = new int[n];
        int [] b = new int[n];
        initAB(a, b, d, n);
        TreeMap<Integer, Integer> maxValues = new TreeMap<Integer, Integer>(Collections.reverseOrder());
        TreeSet<Integer> ones = new TreeSet<Integer>();
        for (int i = 0; i < n; i++) {
            if(b[i] == 1) {
                ones.add(i);
            }
            maxValues.put(a[i], i);
            int ans = 0;
            if(i < 200 || ones.size() > 300) {
                for (Map.Entry<Integer, Integer> entry : maxValues.entrySet()) {
                    if(b[i-entry.getValue()] == 1) {
                        ans = entry.getKey();
                        break;
                    }
                }
            } else {
                for (Integer index : ones) {
                    if(index > i) {
                        break;
                    }
                    ans = Math.max(ans, a[i-index]);
                }
            }
            out.println(ans);
        }
    }
}

class InputReader  extends BufferedReader {
    public InputReader(InputStream st) {
        super(new InputStreamReader(st));
    }

    public int nextInt() {
        try {
            int c = read();

            while (isWhiteSpace(c)) {
                c = read();
            }
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = read();
            }
            int ret = 0;
            while (c >= 0 && !isWhiteSpace(c)) {
                if (c < '0' || c > '9') {
                    throw new RuntimeException();
                }
                ret = ret * 10 + c - '0';
                c = read();
            }
            return ret * sgn;
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }

    public long nextLong() {
        try {
            int c = read();

            while (isWhiteSpace(c)) {
                c = read();
            }
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = read();
            }
            long ret = 0;
            while (c >= 0 && !isWhiteSpace(c)) {
                if (c < '0' || c > '9') {
                    throw new RuntimeException();
                }
                ret = ret * 10 + c - '0';
                c = read();
            }
            return ret * sgn;
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }

    public int ni() {
        return nextInt();
    }

    public long nl() {
        return nextLong();
    }

    public String readLine() {
        try {
            return super.readLine();
        } catch (IOException e) {
            return null;
        }
    }

    static boolean isWhiteSpace(int c) {
        return c >= 0 && c <= 32;
    }

}

import java.lang.*;
import java.io.*;
import java.util.*;
import java.math.*;

public class Main {
    public static void main(String[] args) {
        new Solver().run();
    }
}

class Solver {

    void run() {
        in = new BufferedReader(new InputStreamReader(System.in));
        out = new PrintWriter(System.out);
        //in = new BufferedReader(new FileReader("tree.in"));
        //out = new PrintWriter(new File("tree.out"));
        solve();
        out.close();
    }

    int x, n, d;
    int[] a, b;

    int getNextX() {
        x = (int) ((((long) x * 37) + 10007) % 1000000007);
        return x;
    }

    void initAB() {
        for (int i = 0; i < n; ++i) {
            a[i] = i + 1;
        }
        for (int i = 0; i < n; ++i) {
            int pos = getNextX() % (i + 1);
            int t = a[i];
            a[i] = a[pos];
            a[pos] = t;
        }
        for (int i = 0; i < n; ++i) {
            --a[i];
        }
        for (int i = 0; i < n; ++i) {
            if (i < d) b[i] = 1;
            else b[i] = 0;
        }
        for (int i = 0; i < n; ++i) {
            int pos = getNextX() % (i + 1);
            int t = b[i];
            b[i] = b[pos];
            b[pos] = t;
        }
    }

    void solve() {
        n = nextInt();
        d = nextInt();
        x = nextInt();
        a = new int[n];
        b = new int[n];
        initAB();
        /*
        for (int i = 0; i < n; ++i) {
            System.err.print(a[i] + " ");
        }
        System.err.println();
        for (int i = 0; i < n; ++i) {
            System.err.print(b[i] + " ");
        }
        System.err.println();
        */
        ArrayList<Integer> mas = new ArrayList<Integer>();
        for (int i = 0; i < n; ++i) {
            if (b[i] == 1) mas.add(i);
        }
        int[] c = new int[n];
        for (int i = 0; i < n; ++i) c[i] = -1;
        int sq = (int) (Math.sqrt(n + 0.0) + 7);
        if (d <= sq) {
            for (int i = 0; i < n; ++i) {
                for (int j : mas) {
                    if (i + j < n) c[i + j] = Math.max(c[i + j], a[i]);
                    else break;
                }
            }
        } else {
            int[] pos = new int[n];
            for (int i = 0; i < n; ++i) {
                pos[a[i]] = i;
            }
            int p = 0;
            while (b[p] == 0) ++p;
            for (int i = p; i < n; ++i) {
                for (int k = n - 1; k >= 0; --k) {
                    if (pos[k] > i) continue;
                    if (b[i - pos[k]] == 1) {
                        c[i] = k;
                        break;
                    }
                }
            }
        }
        for (int i = 0; i < n; ++i) {
            out.println(c[i] + 1);
        }
    }

    StringTokenizer tok;
    BufferedReader in;
    PrintWriter out;

    String next() {
        if (tok == null || !tok.hasMoreElements()) {
            try {
                tok = new StringTokenizer(in.readLine());
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tok.nextToken();
    }

    int nextInt() {
        return Integer.parseInt(next());
    }

    long nextLong() {
        return Long.parseLong(next());
    }

    double nextDouble() {
        return Double.parseDouble(next());
    }

    BigInteger nextBigInteger() {
        return new BigInteger(next());
    }
}

import java.io.BufferedWriter;
import java.util.InputMismatchException;
import java.util.NoSuchElementException;
import java.math.BigInteger;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.io.Writer;
import java.io.IOException;
import java.util.Arrays;
import java.io.InputStream;
import java.io.OutputStreamWriter;
import java.util.Comparator;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 * @author Egor Kulikov (egor@egork.net)
 */
public class Main {
	public static void main(String[] args) {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		OutputWriter out = new OutputWriter(outputStream);
		TaskB solver = new TaskB();
		solver.solve(1, in, out);
		out.close();
	}
}

class TaskB {
	long x;

	public void solve(int testNumber, InputReader in, OutputWriter out) {
		int count = in.readInt();
		int ones = in.readInt();
		x = in.readLong();
		int[] a = new int[count];
		for (int i = 0; i < count; i++) {
			a[i] = i + 1;
		}
		shuffle(count, a);
		int[] b = new int[count];
		Arrays.fill(b, 0, ones, 1);
		shuffle(count, b);
		int[] answer = new int[count];
		int size = (count + 31) >> 5;
		int[] ready = new int[size];
		int[] mask = new int[size];
		for (int i = 0; i < size; i++) {
			for (int j = i * 32; j < (i + 1) * 32 && j < count; j++) {
				if (b[j] == 1) {
					mask[i] += 1 << (j - i * 32);
				}
			}
		}
		int[][] upMasks = new int[32][size];
		int[][] downMasks = new int[32][size];
		for (int i = 0; i < 32; i++) {
			int filter;
			if (i == 0) {
				filter = -1;
			} else {
				filter = (1 << (32 - i)) - 1;
			}
			int otherShift = 32 - i;
			for (int j = 0; j < size; j++) {
				upMasks[i][j] = mask[j] & filter;
				downMasks[i][j] = mask[j] >> otherShift;
			}
		}
		int[] order = ArrayUtils.order(a);
		ArrayUtils.reverse(order);
		for (int i : order) {
			int value = a[i];
			int shift = i & 31;
			int otherShift = 32 - shift;
			int filter;
			if (shift == 0) {
				filter = -1;
			} else {
				filter = (1 << (32 - shift)) - 1;
			}
			int start = i >> 5;
			int upTo = size - start - 1;
			int otherFilter = (1 << shift) - 1;
			if (otherFilter == -1) {
				otherFilter = 0;
			}
			for (int j = 0; j < upTo; j++) {
				if ((ready[j + start] >> shift & upMasks[shift][j]) != upMasks[shift][j]) {
					for (int k = (j + start) * 32 + shift; k < (j + start + 1) * 32 && k < count; k++) {
						if (b[k - i] == 1 && answer[k] == 0) {
							answer[k] = value;
							ready[k >> 5] += 1 << (k & 31);
						}
					}
				}
				if ((ready[j + start + 1] & downMasks[shift][j]) != downMasks[shift][j]) {
					for (int k = (j + start + 1) * 32; k < (j + start + 1) * 32 + shift && k < count; k++) {
						if (b[k - i] == 1 && answer[k] == 0) {
							answer[k] = value;
							ready[k >> 5] += 1 << (k & 31);
						}
					}
				}
			}
			if ((ready[upTo + start] >> shift & upMasks[shift][upTo]) != upMasks[shift][upTo]) {
				for (int k = (upTo + start) * 32 + shift; k < (upTo + start + 1) * 32 && k < count; k++) {
					if (b[k - i] == 1 && answer[k] == 0) {
						answer[k] = value;
						ready[k >> 5] += 1 << (k & 31);
					}
				}
			}
		}
		out.printLine(answer);
	}

	protected void shuffle(int count, int[] a) {
		for (int i = 0; i < count; i++) {
			int index = next() % (i + 1);
			int temp = a[i];
			a[i] = a[index];
			a[index] = temp;
		}
	}

	private int next() {
		x = (x * 37 + 10007) % 1000000007;
		return (int) x;
	}
}

class InputReader {

	private InputStream stream;
	private byte[] buf = new byte[1024];
	private int curChar;
	private int numChars;
	private SpaceCharFilter filter;

	public InputReader(InputStream stream) {
		this.stream = stream;
	}

	public int read() {
		if (numChars == -1)
			throw new InputMismatchException();
		if (curChar >= numChars) {
			curChar = 0;
			try {
				numChars = stream.read(buf);
			} catch (IOException e) {
				throw new InputMismatchException();
			}
			if (numChars <= 0)
				return -1;
		}
		return buf[curChar++];
	}

	public int readInt() {
		int c = read();
		while (isSpaceChar(c))
			c = read();
		int sgn = 1;
		if (c == '-') {
			sgn = -1;
			c = read();
		}
		int res = 0;
		do {
			if (c < '0' || c > '9')
				throw new InputMismatchException();
			res *= 10;
			res += c - '0';
			c = read();
		} while (!isSpaceChar(c));
		return res * sgn;
	}

	public long readLong() {
		int c = read();
		while (isSpaceChar(c))
			c = read();
		int sgn = 1;
		if (c == '-') {
			sgn = -1;
			c = read();
		}
		long res = 0;
		do {
			if (c < '0' || c > '9')
				throw new InputMismatchException();
			res *= 10;
			res += c - '0';
			c = read();
		} while (!isSpaceChar(c));
		return res * sgn;
	}

	public boolean isSpaceChar(int c) {
		if (filter != null)
			return filter.isSpaceChar(c);
		return isWhitespace(c);
	}

	public static boolean isWhitespace(int c) {
		return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
	}

	public interface SpaceCharFilter {
		public boolean isSpaceChar(int ch);
	}
}

class OutputWriter {
	private final PrintWriter writer;

	public OutputWriter(OutputStream outputStream) {
		writer = new PrintWriter(new BufferedWriter(new OutputStreamWriter(outputStream)));
	}

	public OutputWriter(Writer writer) {
		this.writer = new PrintWriter(writer);
	}

	public void print(int[] array) {
        for (int i = 0; i < array.length; i++) {
            if (i != 0)
                writer.print(' ');
            writer.print(array[i]);
        }
    }

	public void printLine(int[] array) {
        print(array);
        writer.println();
    }

	public void close() {
		writer.close();
	}

}

class ArrayUtils {

	public static int[] createOrder(int size) {
		int[] order = new int[size];
		for (int i = 0; i < size; i++)
			order[i] = i;
		return order;
	}

	public static int[] sort(int[] array, IntComparator comparator) {
		return sort(array, 0, array.length, comparator);
	}

	public static int[] sort(int[] array, int from, int to, IntComparator comparator) {
		if (from == 0 && to == array.length)
			new IntArray(array).inPlaceSort(comparator);
		else
			new IntArray(array).subList(from, to).inPlaceSort(comparator);
		return array;
	}

	public static int[] order(final int[] array) {
		return sort(createOrder(array.length), new IntComparator() {
			public int compare(int first, int second) {
				if (array[first] < array[second])
					return -1;
				if (array[first] > array[second])
					return 1;
				return 0;
			}
		});
	}

	public static void reverse(int[] array) {
		for (int i = 0, j = array.length - 1; i < j; i++, j--) {
			int temp = array[i];
			array[i] = array[j];
			array[j] = temp;
		}
	}

}

abstract class IntCollection {
	public abstract IntIterator iterator();
	public abstract int size();

}

interface IntIterator {
	public int value() throws NoSuchElementException;
	/*
	 * @throws NoSuchElementException only if iterator already invalid
	 */
	public void advance() throws NoSuchElementException;
	public boolean isValid();
}

interface IntComparator {
    public static final IntComparator DEFAULT = new IntComparator() {
        public int compare(int first, int second) {
            if (first < second)
                return -1;
            if (first > second)
                return 1;
            return 0;
        }
    };

	public int compare(int first, int second);
}

abstract class IntList extends IntCollection implements Comparable<IntList> {
	private static final int INSERTION_THRESHOLD = 16;

	public abstract int get(int index);
	public abstract void set(int index, int value);

	public IntIterator iterator() {
		return new IntIterator() {
			private int size = size();
			private int index = 0;

			public int value() throws NoSuchElementException {
				if (!isValid())
					throw new NoSuchElementException();
				return get(index);
			}

			public void advance() throws NoSuchElementException {
				if (!isValid())
					throw new NoSuchElementException();
				index++;
			}

			public boolean isValid() {
				return index < size;
			}
		};
	}

	public IntList subList(final int from, final int to) {
		return new SubList(from, to);
	}

	private void swap(int first, int second) {
		if (first == second)
			return;
		int temp = get(first);
		set(first, get(second));
		set(second, temp);
	}

	public IntSortedList inPlaceSort(IntComparator comparator) {
		quickSort(0, size() - 1, (Integer.bitCount(Integer.highestOneBit(size()) - 1) * 5) >> 1, comparator);
		return new IntSortedArray(this, comparator);
	}

	private void quickSort(int from, int to, int remaining, IntComparator comparator) {
		if (to - from < INSERTION_THRESHOLD) {
			insertionSort(from, to, comparator);
			return;
		}
		if (remaining == 0) {
			heapSort(from, to, comparator);
			return;
		}
		remaining--;
		int pivotIndex = (from + to) >> 1;
		int pivot = get(pivotIndex);
		swap(pivotIndex, to);
		int storeIndex = from;
		int equalIndex = to;
		for (int i = from; i < equalIndex; i++) {
			int value = comparator.compare(get(i), pivot);
			if (value < 0)
				swap(storeIndex++, i);
			else if (value == 0)
				swap(--equalIndex, i--);
		}
		quickSort(from, storeIndex - 1, remaining, comparator);
		for (int i = equalIndex; i <= to; i++)
			swap(storeIndex++, i);
		quickSort(storeIndex, to, remaining, comparator);
	}

	private void heapSort(int from, int to, IntComparator comparator) {
		for (int i = (to + from - 1) >> 1; i >= from; i--)
			siftDown(i, to, comparator, from);
		for (int i = to; i > from; i--) {
			swap(from, i);
			siftDown(from, i - 1, comparator, from);
		}
	}

	private void siftDown(int start, int end, IntComparator comparator, int delta) {
		int value = get(start);
		while (true) {
			int child = ((start - delta) << 1) + 1 + delta;
			if (child > end)
				return;
			int childValue = get(child);
			if (child + 1 <= end) {
				int otherValue = get(child + 1);
				if (comparator.compare(otherValue, childValue) > 0) {
					child++;
					childValue = otherValue;
				}
			}
			if (comparator.compare(value, childValue) >= 0)
				return;
			swap(start, child);
			start = child;
		}
	}

	private void insertionSort(int from, int to, IntComparator comparator) {
		for (int i = from + 1; i <= to; i++) {
			int value = get(i);
			for (int j = i - 1; j >= from; j--) {
				if (comparator.compare(get(j), value) <= 0)
					break;
				swap(j, j + 1);
			}
		}
	}

	public int hashCode() {
		int hashCode = 1;
		for (IntIterator i = iterator(); i.isValid(); i.advance())
			hashCode = 31 * hashCode + i.value();
		return hashCode;
	}

	public boolean equals(Object obj) {
		if (!(obj instanceof IntList))
			return false;
		IntList list = (IntList)obj;
		if (list.size() != size())
			return false;
		IntIterator i = iterator();
		IntIterator j = list.iterator();
		while (i.isValid()) {
			if (i.value() != j.value())
				return false;
			i.advance();
			j.advance();
		}
		return true;
	}

	public int compareTo(IntList o) {
		IntIterator i = iterator();
		IntIterator j = o.iterator();
		while (true) {
			if (i.isValid()) {
				if (j.isValid()) {
					if (i.value() != j.value()) {
						if (i.value() < j.value())
							return -1;
						else
							return 1;
					}
				} else
					return 1;
			} else {
				if (j.isValid())
					return -1;
				else
					return 0;
			}
			i.advance();
			j.advance();
		}
	}

	private class SubList extends IntList {
        private final int to;
        private final int from;
        private int size;

        public SubList(int from, int to) {
            this.to = to;
            this.from = from;
            size = to - from;
        }

        public int get(int index) {
            if (index < 0 || index >= size)
                throw new IndexOutOfBoundsException();
            return IntList.this.get(index + from);
        }

        public void set(int index, int value) {
            if (index < 0 || index >= size)
                throw new IndexOutOfBoundsException();
            IntList.this.set(index + from, value);
        }

        public int size() {
            return size;
        }

	}
}

abstract class IntSortedList extends IntList {
	protected final IntComparator comparator;

	protected IntSortedList(IntComparator comparator) {
		this.comparator = comparator;
	}

	public void set(int index, int value) {
		throw new UnsupportedOperationException();
	}

	public IntSortedList inPlaceSort(IntComparator comparator) {
		if (comparator == this.comparator)
			return this;
		throw new UnsupportedOperationException();
	}

	protected void ensureSorted() {
		int size = size();
		if (size == 0)
			return;
		int last = get(0);
		for (int i = 1; i < size; i++) {
			int current = get(i);
			if (comparator.compare(last, current) > 0)
				throw new IllegalArgumentException();
			last = current;
		}
	}

	public IntSortedList subList(final int from, final int to) {
		return new IntSortedList(comparator) {
			private int size = to - from;

			@Override
			public int get(int index) {
				if (index < 0 || index >= size)
					throw new IndexOutOfBoundsException();
				return IntSortedList.this.get(index + from);
			}

			@Override
			public int size() {
				return size;
			}
		};
	}
}

class IntArray extends IntList {
	private final int[] array;

	public IntArray(int[] array) {
		this.array = array;
	}

	public IntArray(IntCollection collection) {
		array = new int[collection.size()];
		int i = 0;
		for (IntIterator iterator = collection.iterator(); iterator.isValid(); iterator.advance())
			array[i++] = iterator.value();
	}

	public int get(int index) {
		return array[index];
	}

	public void set(int index, int value) {
		array[index] = value;
	}

	public int size() {
		return array.length;
	}

}

class IntSortedArray extends IntSortedList {
	private final int[] array;

	public IntSortedArray(int[] array) {
		this(array, IntComparator.DEFAULT);
	}

	public IntSortedArray(IntCollection collection) {
		this(collection, IntComparator.DEFAULT);
	}

	public IntSortedArray(int[] array, IntComparator comparator) {
		super(comparator);
		this.array = array;
		ensureSorted();
	}

	public IntSortedArray(IntCollection collection, IntComparator comparator) {
		super(comparator);
		array = new int[collection.size()];
		int i = 0;
		for (IntIterator iterator = collection.iterator(); iterator.isValid(); iterator.advance())
			array[i++] = iterator.value();
		ensureSorted();
	}

	public int get(int index) {
		return array[index];
	}

	public int size() {
		return array.length;
	}
}

import java.util.*;
import java.io.*;

public class DZY_Loves_FFT {
    public static void main(String[] args) {
        Scanner cin = new Scanner(System.in);
        PrintWriter out = new PrintWriter(new BufferedWriter(
                new OutputStreamWriter(System.out)));
        int n = cin.nextInt();
        int d = cin.nextInt();
        long x = cin.nextInt();

        int[] a = new int[n];
        for (int i = 0; i < n; i++) {
            a[i] = i + 1;
        }
        for (int i = 0; i < n; i++) {
            x = (x * 37 + 10007) % 1000000007;
            swap(a, i, (int) x % (i + 1));
        }
        int[] b = new int[n];
        Arrays.fill(b, 0, d, 1);
        for (int i = 0; i < n; i++) {
            x = (x * 37 + 10007) % 1000000007;
            swap(b, i, (int) x % (i + 1));
        }

        if (d < 1000) {
            int _k = 0;
            int[] arr = new int[d];
            for (int i = 0; i < n; i++) {
                if (b[i] == 1) {
                    arr[_k++] = i;
                }
            }
            for (int i = 0; i < n; i++) {
                int max = 0;
                for (int k = 0; k < d && arr[k] <= i; k++) {
                    int j = arr[k];
                    max = Math.max(max, a[i - j]);
                }
                out.println(max);
            }
        } else {
            int[] arr = new int[n + 1];
            for (int i = 0; i < n; i++) {
                arr[a[i]] = i;
            }
            TreeSet<Integer> set = new TreeSet<Integer>();
            label: for (int i = 0; i < n; i++) {
                set.add(-a[i]);
                for (int k : set) {
                    int j = arr[-k];
                    if (b[i - j] == 1) {
                        out.println(-k);
                        continue label;
                    }
                }
                out.println(0);
            }
        }
        out.flush();
    }

    static void swap(int[] a, int i, int j) {
        int tmp = a[i];
        a[i] = a[j];
        a[j] = tmp;
    }
}

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Collection;
import java.util.Locale;
import java.util.StringTokenizer;

public class Main {
	public static void main(String[] args) throws IOException {
		new Thread(null, new Runnable() {
			public void run() {
				try {
					long prevTime = System.currentTimeMillis();
					new Main().run();
					System.err.println("Total time: "
							+ (System.currentTimeMillis() - prevTime) + " ms");
					System.err.println("Memory status: " + memoryStatus());
				} catch (IOException e) {
					e.printStackTrace();
				}
			}
		}, "1", 1L << 24).start();
	}

	void run() throws IOException {
		in = new BufferedReader(new InputStreamReader(System.in));
		out = new PrintWriter(System.out);
		Object o = solve();
		if (o != null)
			out.println(o);
		out.close();
		in.close();
	}

	// x is 64-bit variable;
	int n;
	long x;
	int d;

	int[] a;
	int[] b;

	long getNextX() {
		x = (x * 37 + 10007) % 1000000007;
		return x;
	}

	void initAB() {
		a = new int[n];
		for (int i = 0; i < n; i++) {
			a[i] = i + 1;
		}
		for (int i = 0; i < n; i++) {
			swap(a, i, (int) (getNextX() % (i + 1)));
		}

		b = new int[n];
		for (int i = 0; i < n; i++) {
			if (i < d)
				b[i] = 1;
			else
				b[i] = 0;
		}
		for (int i = 0; i < n; i++) {
			swap(b, i, (int) (getNextX() % (i + 1)));
		}
	}

	private void swap(int[] a, int i, int j) {
		int t = a[i];
		a[i] = a[j];
		a[j] = t;
	}

	private Object solve() throws IOException {
		n = ni();
		d = ni();
		x = ni();
		initAB();

		int[] ret = new int[n];
		int[] getIndex = new int[n + 1];
		for (int i = 0; i < n; i++)
			getIndex[a[i]] = i;

		boolean[] ok = new boolean[n];
		Arrays.fill(ok, true);
		IteratorUF free = new IteratorUF(ok);

		int[] next = new int[n];
		next[n-1]= n;
		for(int i =n-2;i>=0;i--)
			if(b[i+1]==1){
				next[i]= i+1;
			}else{
				next[i] = next[i+1];
			}

		for (int i = n; i >= 1; i--) {
			int index = getIndex[i];

			int ii =(b[0]==1? 0 : next[0]);
			while(index+ii<n){
				int check = free.next(index + ii);
				if(check==index+ii){
					ret[check]=i;
					free.kill(check);
					ii = next[ii];
				}else{
					if(check==n)
						break;
					int dif = check- index;
					if(b[dif]==1){
						ii= dif;
					}else{
						ii= next[dif];
					}
				}

			}

		}
		for (int elem : ret)
			pln(elem);
		return null;
	}

	public class IteratorUF {
		boolean[] alive;
		int[] next;
		int n;

		public IteratorUF(boolean[] bs) {
			this.n = bs.length;
			this.alive = new boolean[n + 1];
			System.arraycopy(bs, 0, alive, 0, n);
			alive[n] = true;

			this.next = new int[bs.length];
			for (int i = 0; i < next.length; i++)
				next[i] = i + 1;
		}

		// no matar n
		public void kill(int index) {
			alive[index] = false;
		}

		public boolean isAlive(int index) {
			return alive[index];
		}

		// devuelve proxima posicion o n si no hay siguiente.
		// si pregunto por n da n, por algo mayor da exception

		public int next(int index) {
			if (alive[index])
				return index;

			return next[index] = next(next[index]);
		}

	}

	BufferedReader in;
	PrintWriter out;
	StringTokenizer strTok = new StringTokenizer("");

	String nextToken() throws IOException {
		while (!strTok.hasMoreTokens())
			strTok = new StringTokenizer(in.readLine());
		return strTok.nextToken();
	}

	int ni() throws IOException {
		return Integer.parseInt(nextToken());
	}

	long nl() throws IOException {
		return Long.parseLong(nextToken());
	}

	double nd() throws IOException {
		return Double.parseDouble(nextToken());
	}

	int[] nia(int size) throws IOException {
		int[] ret = new int[size];
		for (int i = 0; i < size; i++)
			ret[i] = ni();
		return ret;
	}

	long[] nla(int size) throws IOException {
		long[] ret = new long[size];
		for (int i = 0; i < size; i++)
			ret[i] = nl();
		return ret;
	}

	double[] nda(int size) throws IOException {
		double[] ret = new double[size];
		for (int i = 0; i < size; i++)
			ret[i] = nd();
		return ret;
	}

	String nextLine() throws IOException {
		strTok = new StringTokenizer("");
		return in.readLine();
	}

	boolean EOF() throws IOException {
		while (!strTok.hasMoreTokens()) {
			String s = in.readLine();
			if (s == null)
				return true;
			strTok = new StringTokenizer(s);
		}
		return false;
	}

	void printRepeat(String s, int count) {
		for (int i = 0; i < count; i++)
			out.print(s);
	}

	void printArray(int[] array) {
		for (int i = 0; i < array.length; i++) {
			if (i > 0)
				out.print(' ');
			out.print(array[i]);
		}
		out.println();
	}

	void printArray(long[] array) {
		for (int i = 0; i < array.length; i++) {
			if (i > 0)
				out.print(' ');
			out.print(array[i]);
		}
		out.println();
	}

	void printArray(double[] array) {
		for (int i = 0; i < array.length; i++) {
			if (i > 0)
				out.print(' ');
			out.print(array[i]);
		}
		out.println();
	}

	void printArray(double[] array, String spec) {
		for (int i = 0; i < array.length; i++) {
			if (i > 0)
				out.print(' ');
			out.printf(Locale.US, spec, array[i]);
		}
		out.println();
	}

	void printArray(Object[] array) {
		boolean blank = false;
		for (Object x : array) {
			if (blank)
				out.print(' ');
			else
				blank = true;
			out.print(x);
		}
		out.println();
	}

	@SuppressWarnings("rawtypes")
	void printCollection(Collection collection) {
		boolean blank = false;
		for (Object x : collection) {
			if (blank)
				out.print(' ');
			else
				blank = true;
			out.print(x);
		}
		out.println();
	}

	static String memoryStatus() {
		return (Runtime.getRuntime().totalMemory()
				- Runtime.getRuntime().freeMemory() >> 20)
				+ "/" + (Runtime.getRuntime().totalMemory() >> 20) + " MB";
	}

	public void pln() {
		out.println();
	}

	public void pln(int arg) {
		out.println(arg);
	}

	public void pln(long arg) {
		out.println(arg);
	}

	public void pln(double arg) {
		out.println(arg);
	}

	public void pln(String arg) {
		out.println(arg);
	}

	public void pln(boolean arg) {
		out.println(arg);
	}

	public void pln(char arg) {
		out.println(arg);
	}

	public void pln(float arg) {
		out.println(arg);
	}

	public void pln(Object arg) {
		out.println(arg);
	}

	public void p(int arg) {
		out.print(arg);
	}

	public void p(long arg) {
		out.print(arg);
	}

	public void p(double arg) {
		out.print(arg);
	}

	public void p(String arg) {
		out.print(arg);
	}

	public void p(boolean arg) {
		out.print(arg);
	}

	public void p(char arg) {
		out.print(arg);
	}

	public void p(float arg) {
		out.print(arg);
	}

	public void p(Object arg) {
		out.print(arg);
	}

}

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Scanner;
import java.util.StringTokenizer;

public class a {
	static int z = 500;
	public static void main(String[] args) throws IOException {
		FastScanner in = new FastScanner(System.in);
		PrintWriter out = new PrintWriter(System.out);
		n = in.nextInt();
		d = in.nextInt();
		x = in.nextLong();
		a = new int[n];
		b = new int[n];
		initAB();
		int[] map = new int[n];
		for(int i=0;i<n;i++)
			map[a[i]-1] = i;
		ArrayList<Integer> bs = new ArrayList<>();
		for(int i=0;i<n;i++) {
			if(b[i] == 1)
				bs.add(i);
		}
		outer: for(int i=0;i<n;i++) {
			for(int k=n-1;k>=n-z && k >= 0;k--) {
				int aidx = map[k];
				int bidx = i - aidx;
				if(bidx >= 0 && b[bidx] == 1) {
					out.println(k+1);
					continue outer;
				}
			}
			int max = 0;
			for(int b : bs) {
				int ai = i - b;
				if(ai < 0) continue;
				max = Math.max(max, a[ai]);
			}
			out.println(max);
		}
		out.close();
	}
	static long getNextX() {
	    x = (x * 37 + 10007) % 1000000007;
	    return x;
	}
	static int[] a,b;
	static int n, d;
	static long x;
	static void initAB() {
	    for(int i = 0; i < n; i = i + 1){
	        a[i] = i + 1;
	    }
	    for(int i = 0; i < n; i = i + 1){
	    	int tmp = a[i];
	    	int idx = (int) (getNextX() % (i + 1));
	    	a[i] = a[idx];
	    	a[idx] = tmp;
	    }
	    for(int i = 0; i < n; i = i + 1){
	        if (i < d)
	            b[i] = 1;
	        else
	            b[i] = 0;
	    }
	    for(int i = 0; i < n; i = i + 1){
	    	int tmp = b[i];
	    	int idx = (int) (getNextX() % (i + 1));
	    	b[i] = b[idx];
	    	b[idx] = tmp;
	    }
	}

	static class FastScanner {
		BufferedReader br;
		StringTokenizer st;

		public FastScanner(InputStream i) {
			br = new BufferedReader(new InputStreamReader(i));
			st = null;
		}

		public String next() throws IOException {
			while (st == null || !st.hasMoreTokens())
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}

		public String nextLine() throws IOException {
			if (st == null) {
				st = new StringTokenizer(br.readLine());
			}
			String line = st.nextToken("\n");
			st = null;
			return line;
		}

		public int nextInt() throws IOException {
			return Integer.parseInt(next());
		}

		public long nextLong() throws IOException {
			return Long.parseLong(next());
		}

		public double nextDouble() throws IOException {
			return Double.parseDouble(next());
		}
	}
}

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Scanner;
import java.util.StringTokenizer;

public class a {
	static int z = 7000;
	public static void main(String[] args) throws IOException {
		FastScanner in = new FastScanner(System.in);
		PrintWriter out = new PrintWriter(System.out);
		n = in.nextInt();
		d = in.nextInt();
		x = in.nextLong();
		a = new int[n];
		b = new int[n];
		initAB();
		int[] map = new int[n];
		for(int i=0;i<n;i++)
			map[a[i]-1] = i;
		ArrayList<Integer> bs = new ArrayList<>();
		for(int i=0;i<n;i++) {
			if(b[i] == 1)
				bs.add(i);
		}
		outer: for(int i=0;i<n;i++) {
			if(d < 300) {
				int max = 0;
				for(int b : bs) {
					int ai = i - b;
					if(ai < 0) continue;
					max = Math.max(max, a[ai]);
				}
				out.println(max);
				continue;
			}
			for(int k=n-1;k>=n-z && k >= 0;k--) {
				int aidx = map[k];
				int bidx = i - aidx;
				if(bidx >= 0 && b[bidx] == 1) {
					out.println(k+1);
					continue outer;
				}
			}
			int max = 0;
			for(int ai=0, bi=i;bi>=0;ai++, bi--) {
				max = Math.max(max, a[ai] * b[bi]);
			}
			out.println(max);
		}
		out.close();
	}
	static long getNextX() {
	    x = (x * 37 + 10007) % 1000000007;
	    return x;
	}
	static int[] a,b;
	static int n, d;
	static long x;
	static void initAB() {
	    for(int i = 0; i < n; i = i + 1){
	        a[i] = i + 1;
	    }
	    for(int i = 0; i < n; i = i + 1){
	    	int tmp = a[i];
	    	int idx = (int) (getNextX() % (i + 1));
	    	a[i] = a[idx];
	    	a[idx] = tmp;
	    }
	    for(int i = 0; i < n; i = i + 1){
	        if (i < d)
	            b[i] = 1;
	        else
	            b[i] = 0;
	    }
	    for(int i = 0; i < n; i = i + 1){
	    	int tmp = b[i];
	    	int idx = (int) (getNextX() % (i + 1));
	    	b[i] = b[idx];
	    	b[idx] = tmp;
	    }
	}

	static class FastScanner {
		BufferedReader br;
		StringTokenizer st;

		public FastScanner(InputStream i) {
			br = new BufferedReader(new InputStreamReader(i));
			st = null;
		}

		public String next() throws IOException {
			while (st == null || !st.hasMoreTokens())
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}

		public String nextLine() throws IOException {
			if (st == null) {
				st = new StringTokenizer(br.readLine());
			}
			String line = st.nextToken("\n");
			st = null;
			return line;
		}

		public int nextInt() throws IOException {
			return Integer.parseInt(next());
		}

		public long nextLong() throws IOException {
			return Long.parseLong(next());
		}

		public double nextDouble() throws IOException {
			return Double.parseDouble(next());
		}
	}
}

import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.BitSet;
import java.util.Calendar;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.PriorityQueue;
import java.util.SortedSet;
import java.util.Stack;
import java.util.StringTokenizer;
import java.util.TreeMap;
import java.util.TreeSet;

/**
 * #
 *
 * @author pttrung
 */
public class B_Round_254_Div1 {

	public static long MOD = 1000000007;
	static long x;

	public static void main(String[] args) throws FileNotFoundException {
		// PrintWriter out = new PrintWriter(new FileOutputStream(new File(
		// "output.txt")));
		PrintWriter out = new PrintWriter(System.out);
		Scanner in = new Scanner();
		int n = in.nextInt();
		int d = in.nextInt();
		x = in.nextLong();
		int[] a = new int[n];
		int[] b = new int[n];
		initAB(a, b, d, n);
		TreeSet<Integer> list = new TreeSet();
		for (int i = 0; i < n; i++) {
			if (b[i] == 1) {
				list.add(i);
			}
		}

		int[] result = new int[n];

		if (!list.isEmpty()) {
			if (d > 1000) {
				TreeSet<Integer> set = new TreeSet();
				Point[] data = new Point[n];
				for (int i = 0; i < n; i++) {
					set.add(i);
					data[i] = new Point(a[i], i);
				}
				Arrays.sort(data);
				int index = n - 1;
				while (!set.isEmpty() && index >= 0) {
					int first = data[index].y;

					for (Iterator<Integer> it = set.tailSet(first).iterator(); it.hasNext();) {
						// System.out.println(i + " " + first + " " +
						// data[index].x);
						Integer i = it.next();
						if (b[i.intValue() - first] == 1) {
							result[i] = data[index].x;
							it.remove();
						}
					}

					index--;
				}
			} else {
				int first = list.pollFirst();
				Point[]data = new Point[n - first];
				for(int i = first; i < n; i++){
					data[i - first] = new Point(a[i - first], i);
					result[i] = a[i - first];
				}
				for(int i : list){
					for(Point p : data){
						p.y += i - first;
						if(p.y < n){
							result[p.y] = Math.max(result[p.y], p.x);
						}
					}
					first = i;
				}
			}

		}
		for (int i : result) {
			out.println(i);
		}
		out.close();
	}

	static long getNextX() {
		x = (x * 37 + 10007) % 1000000007;
		return x;
	}

	static void initAB(int[] a, int[] b, int d, int n) {
		for (int i = 0; i < n; i = i + 1) {
			a[i] = i + 1;
		}
		for (int i = 0; i < n; i = i + 1) {
			swap(a, i, (int) (getNextX() % (i + 1)));
		}
		for (int i = 0; i < n; i = i + 1) {
			if (i < d)
				b[i] = 1;
			else
				b[i] = 0;
		}
		for (int i = 0; i < n; i = i + 1) {
			swap(b, i, (int) (getNextX() % (i + 1)));
		}
	}

	static void swap(int[] data, int a, int b) {
		int tmp = data[a];
		data[a] = data[b];
		data[b] = tmp;
	}

	public static int[] KMP(String val) {
		int i = 0;
		int j = -1;
		int[] result = new int[val.length() + 1];
		result[0] = -1;
		while (i < val.length()) {
			while (j >= 0 && val.charAt(j) != val.charAt(i)) {
				j = result[j];
			}
			j++;
			i++;
			result[i] = j;
		}
		return result;

	}

	public static boolean nextPer(int[] data) {
		int i = data.length - 1;
		while (i > 0 && data[i] < data[i - 1]) {
			i--;
		}
		if (i == 0) {
			return false;
		}
		int j = data.length - 1;
		while (data[j] < data[i - 1]) {
			j--;
		}
		int temp = data[i - 1];
		data[i - 1] = data[j];
		data[j] = temp;
		Arrays.sort(data, i, data.length);
		return true;
	}

	public static int digit(long n) {
		int result = 0;
		while (n > 0) {
			n /= 10;
			result++;
		}
		return result;
	}

	public static double dist(long a, long b, long x, long y) {
		double val = (b - a) * (b - a) + (x - y) * (x - y);
		val = Math.sqrt(val);
		double other = x * x + a * a;
		other = Math.sqrt(other);
		return val + other;

	}

	public static class Point implements Comparable<Point> {

		int x, y;

		public Point(int start, int end) {
			this.x = start;
			this.y = end;
		}

		@Override
		public int hashCode() {
			int hash = 5;
			hash = 47 * hash + this.x;
			hash = 47 * hash + this.y;
			return hash;
		}

		@Override
		public boolean equals(Object obj) {
			if (obj == null) {
				return false;
			}
			if (getClass() != obj.getClass()) {
				return false;
			}
			final Point other = (Point) obj;
			if (this.x != other.x) {
				return false;
			}
			if (this.y != other.y) {
				return false;
			}
			return true;
		}

		@Override
		public int compareTo(Point o) {
			return x - o.x;
		}
	}

	public static class FT {

		long[] data;

		FT(int n) {
			data = new long[n];
		}

		public void update(int index, long value) {
			while (index < data.length) {
				data[index] += value;
				index += (index & (-index));
			}
		}

		public long get(int index) {
			long result = 0;
			while (index > 0) {
				result += data[index];
				index -= (index & (-index));
			}
			return result;

		}
	}

	public static long gcd(long a, long b) {
		if (b == 0) {
			return a;
		}
		return gcd(b, a % b);
	}

	public static long pow(long a, long b) {
		if (b == 0) {
			return 1;
		}
		if (b == 1) {
			return a;
		}
		long val = pow(a, b / 2);
		if (b % 2 == 0) {
			return val * val % MOD;
		} else {
			return val * (val * a % MOD) % MOD;

		}
	}

	static class Scanner {

		BufferedReader br;
		StringTokenizer st;

		public Scanner() throws FileNotFoundException {
			// System.setOut(new PrintStream(new
			// BufferedOutputStream(System.out), true));
			br = new BufferedReader(new InputStreamReader(System.in));
			// br = new BufferedReader(new InputStreamReader(new
			// FileInputStream(new File("input.txt"))));
		}

		public String next() {

			while (st == null || !st.hasMoreTokens()) {
				try {
					st = new StringTokenizer(br.readLine());
				} catch (Exception e) {
					throw new RuntimeException();
				}
			}
			return st.nextToken();
		}

		public long nextLong() {
			return Long.parseLong(next());
		}

		public int nextInt() {
			return Integer.parseInt(next());
		}

		public double nextDouble() {
			return Double.parseDouble(next());
		}

		public String nextLine() {
			st = null;
			try {
				return br.readLine();
			} catch (Exception e) {
				throw new RuntimeException();
			}
		}

		public boolean endLine() {
			try {
				String next = br.readLine();
				while (next != null && next.trim().isEmpty()) {
					next = br.readLine();
				}
				if (next == null) {
					return true;
				}
				st = new StringTokenizer(next);
				return st.hasMoreTokens();
			} catch (Exception e) {
				throw new RuntimeException();
			}
		}
	}
}

//package round254;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.InputMismatchException;

public class B {
	InputStream is;
	PrintWriter out;
	String INPUT = "";
	long x;

	void solve()
	{
		int n = ni(), d = ni(), x = ni();
		this.x = x;
		int[] a = new int[n];
		int[] b = new int[n];
		int[] ia = new int[n+1];
	    for(int i = 0; i < n; i = i + 1){
	        a[i] = i + 1;
	        ia[i+1] = i;
	    }
	    ia[0] = -1;
	    for(int i = 0; i < n; i = i + 1){
	    	int L = i;
	    	int R = (int)(getNextX() % (i + 1));
	    	int dd = ia[a[L]]; ia[a[L]] = ia[a[R]]; ia[a[R]] = dd;
	    	int dum = a[L]; a[L] = a[R]; a[R] = dum;
	    }
	    for(int i = 0; i < n; i = i + 1){
	        if (i < d)
	            b[i] = 1;
	        else
	            b[i] = 0;
	    }
	    for(int i = 0; i < n; i = i + 1){
	    	int L = i;
	    	int R = (int)(getNextX() % (i + 1));
	    	int dum = b[L]; b[L] = b[R]; b[R] = dum;
	    }

	    int[] bx = new int[d];
	    int z = 0;
	    for(int i = 0;i < n;i++){
	    	if(b[i] == 1)bx[z++] = i;
	    }

//	    tr(a);
//	    tr(ia);
//	    tr(b);
//	    tr(bx);

	    int[] v = new int[n+1];
	    Arrays.fill(v, 1);
	    int[] ft = buildFenwick(v);

	    int[] ret = new int[n];
	    for(int val = n;val >= 1;val--){
	    	int y = ia[val];

	    	if(y+bx[0] < n && v[y+bx[0]] == 1){
	    		v[y+bx[0]] = 0;
	    		addFenwick(ft, y+bx[0], -1);
	    		ret[y+bx[0]] = val;
	    	}
	    	int ind = 0;
	    	while(ind+1 < d && y+bx[ind] < n){
		    	int aft = after(ft, y+bx[ind]);
		    	int pos = y+bx[ind+1];
		    	if(aft == -1 || aft >= n)break;
		    	if(pos >= n)break;
		    	if(pos >= aft){
			    	if(v[pos] == 1){
			    		v[pos] = 0;
			    		addFenwick(ft, pos, -1);
			    		ret[pos] = val;
			    	}
			    	ind++;
		    	}else{
		    		int u = Arrays.binarySearch(bx, aft-y);
		    		if(u < 0)u = -u-1;
		    		ind = u-1;
		    	}
	    	}
//	    	tr(restoreFenwick(ft));
	    }
	    for(int i = 0;i < n;i++){
	    	out.println(ret[i]);
	    }
	}

	public static int sumFenwick(int[] ft, int i)
	{
		int sum = 0;
		for(i++;i > 0;i -= i&-i)sum += ft[i];
		return sum;
	}

	public static void addFenwick(int[] ft, int i, int v)
	{
		if(v == 0 || i < 0)return;
		int n = ft.length;
		for(i++;i < n;i += i&-i)ft[i] += v;
	}

	public static int findGFenwick(int[] ft, int v)
	{
		int i = 0;
		int n = ft.length;
		for(int b = Integer.highestOneBit(n);b != 0 && i < n;b >>= 1){
			if(i + b < n){
				int t = i + b;
				if(v >= ft[t]){
					i = t;
					v -= ft[t];
				}
			}
		}
		return v != 0 ? -(i+1) : i-1;
	}

	public static int valFenwick(int[] ft, int i)
	{
		return sumFenwick(ft, i) - sumFenwick(ft, i-1);
	}

	public static int[] restoreFenwick(int[] ft)
	{
		int n = ft.length-1;
		int[] ret = new int[n];
		for(int i = 0;i < n;i++)ret[i] = sumFenwick(ft, i);
		for(int i = n-1;i >= 1;i--)ret[i] -= ret[i-1];
		return ret;
	}

	public static int before(int[] ft, int x)
	{
		int u = sumFenwick(ft, x-1);
		if(u == 0)return -1;
		return findGFenwick(ft, u-1)+1;
	}

	public static int after(int[] ft, int x)
	{
		int u = sumFenwick(ft, x);
		int f = findGFenwick(ft, u);
		if(f+1 >= ft.length-1)return -1;
		return f+1;
	}

	public static int[] buildFenwick(int[] a)
	{
		int n = a.length;
		int[] ft = new int[n+1];
		System.arraycopy(a, 0, ft, 1, n);
		for(int k = 2, h = 1;k <= n;k*=2, h*=2){
			for(int i = k;i <= n;i+=k){
				ft[i] += ft[i-h];
			}
		}
		return ft;
	}

	long getNextX() {
	    x = (x * 37 + 10007) % 1000000007;
	    return x;
	}

	void run() throws Exception
	{
		is = oj ? System.in : new ByteArrayInputStream(INPUT.getBytes());
		out = new PrintWriter(System.out);

		long s = System.currentTimeMillis();
		solve();
		out.flush();
		tr(System.currentTimeMillis()-s+"ms");
	}

	public static void main(String[] args) throws Exception { new B().run(); }

	private byte[] inbuf = new byte[1024];
	private int lenbuf = 0, ptrbuf = 0;

	private int readByte()
	{
		if(lenbuf == -1)throw new InputMismatchException();
		if(ptrbuf >= lenbuf){
			ptrbuf = 0;
			try { lenbuf = is.read(inbuf); } catch (IOException e) { throw new InputMismatchException(); }
			if(lenbuf <= 0)return -1;
		}
		return inbuf[ptrbuf++];
	}

	private boolean isSpaceChar(int c) { return !(c >= 33 && c <= 126); }
	private int skip() { int b; while((b = readByte()) != -1 && isSpaceChar(b)); return b; }

	private double nd() { return Double.parseDouble(ns()); }
	private char nc() { return (char)skip(); }

	private String ns()
	{
		int b = skip();
		StringBuilder sb = new StringBuilder();
		while(!(isSpaceChar(b))){ // when nextLine, (isSpaceChar(b) && b != ' ')
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}

	private char[] ns(int n)
	{
		char[] buf = new char[n];
		int b = skip(), p = 0;
		while(p < n && !(isSpaceChar(b))){
			buf[p++] = (char)b;
			b = readByte();
		}
		return n == p ? buf : Arrays.copyOf(buf, p);
	}

	private char[][] nm(int n, int m)
	{
		char[][] map = new char[n][];
		for(int i = 0;i < n;i++)map[i] = ns(m);
		return map;
	}

	private int[] na(int n)
	{
		int[] a = new int[n];
		for(int i = 0;i < n;i++)a[i] = ni();
		return a;
	}

	private int ni()
	{
		int num = 0, b;
		boolean minus = false;
		while((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-'));
		if(b == '-'){
			minus = true;
			b = readByte();
		}

		while(true){
			if(b >= '0' && b <= '9'){
				num = num * 10 + (b - '0');
			}else{
				return minus ? -num : num;
			}
			b = readByte();
		}
	}

	private long nl()
	{
		long num = 0;
		int b;
		boolean minus = false;
		while((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-'));
		if(b == '-'){
			minus = true;
			b = readByte();
		}

		while(true){
			if(b >= '0' && b <= '9'){
				num = num * 10 + (b - '0');
			}else{
				return minus ? -num : num;
			}
			b = readByte();
		}
	}

	private boolean oj = System.getProperty("ONLINE_JUDGE") != null;
	private void tr(Object... o) { if(!oj)System.out.println(Arrays.deepToString(o)); }
}

import java.io.IOException;
import java.util.InputMismatchException;
import java.util.ArrayList;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 * @author George Marcus
 */
public class Main {
	public static void main(String[] args) {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		TaskB solver = new TaskB();
		solver.solve(1, in, out);
		out.close();
	}
}

class TaskB {
    long x;

    public void solve(int testNumber, InputReader in, PrintWriter out) {
        int N = in.nextInt();
        int d = in.nextInt();
        x = in.nextInt();

        int[] A = new int[N];
        for (int i = 0; i < N; i++) {
            A[i] = i + 1;
        }
        for (int i = 0; i < N; i++) {
            long cx = getNextX();
            int pos = (int) (cx % (i + 1));
            int aux = A[i];
            A[i] = A[pos];
            A[pos] = aux;
        }
        int[] B = new int[N];
        for (int i = 0; i < N; i++) {
            if (i < d) {
                B[i] = 1;
            } else {
                B[i] = 0;
            }
        }
        for (int i = 0; i < N; i++) {
            long cx = getNextX();
            int pos = (int) (cx % (i + 1));
            int aux = B[i];
            B[i] = B[pos];
            B[pos] = aux;
        }

        int[] P = new int[N + 1];
        for (int i = 0; i < N; i++) {
            P[ A[i] ] = i;
        }

        ArrayList<Integer> C = new ArrayList<Integer>();
        for (int i = 0; i < N; i++) {
            if (B[i] == 1) {
                C.add(i);
            }
        }

        int s = Math.min(N, 100);
        for (int i = 0; i < N; i++) {
            int crt = -1;
            for (int j = N; j > N - s && crt == -1; j--) {
                int p = P[j];
                if (p <= i && B[i - p] == 1) {
                    crt = j;
                }
            }

            if (crt == -1) {
                crt = 0;
                for (int j = 0; j < C.size() && C.get(j) <= i; j++) {
                    int p = C.get(j);
                    crt = Math.max(crt, A[i - p]);
                }
            }

            out.println(crt);
        }
    }

    public long getNextX() {
        x = (x * 37 + 10007) % 1000000007;
        return x;
    }
}

class InputReader {
    private InputStream stream;
    private byte[] buf = new byte[1024];
    private int curChar;
    private int numChars;

    public InputReader(InputStream stream) {
        this.stream = stream;
    }

    public int read() {
        if (numChars == -1)
            throw new InputMismatchException();
        if (curChar >= numChars) {
            curChar = 0;
            try {
                numChars = stream.read(buf);
            } catch (IOException e) {
                throw new InputMismatchException();
            }
            if (numChars <= 0)
                return -1;
        }
        return buf[curChar++];
    }

    public int nextInt() {
        return Integer.parseInt(nextString());
    }

    public String nextString() {
        int c = read();
        while (isSpaceChar(c))
            c = read();
        StringBuffer res = new StringBuffer();
        do {
            res.appendCodePoint(c);
            c = read();
        } while (!isSpaceChar(c));

        return res.toString();
    }

    private boolean isSpaceChar(int c) {
        return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
    }

}

import java.io.*;
import java.util.*;

public class R254qBDZYLovesFFT {

	static long x;

	public static void main(String args[]) {
		InputReader in = new InputReader(System.in);
		PrintWriter w = new PrintWriter(System.out);

		int i;
		int n = in.nextInt();
		int d = in.nextInt();
		x = in.nextLong();

		int a[] = new int[n];
		for(i = 0; i < n; i = i + 1)
	        a[i] = i + 1;

	    for(i = 0; i < n; i = i + 1){
	    	int t = a[i];
	    	int j = (int)(getNextX() % (i + 1));
	    	a[i] = a[j];
	    	a[j] = t;
	    }

	    int b[] = new int[n + 1];
	    for(i = 0; i < n; i = i + 1){
	        if (i < d)
	            b[i] = 1;
	        else
	            b[i] = 0;
	    }

	    for(i = 0; i < n; i = i + 1){
	    	int t = b[i];
	    	int j = (int)(getNextX() % (i + 1));
	    	b[i] = b[j];
	    	b[j] = t;
	    }

	    int pos[] = new int[d];
	    int lol = 0;
	    for(i=0;i<n;i++)
	    	if(b[i] == 1)
	    		pos[lol++] = i;

	    int rev[] = new int[n + 1];
	    for(i=0;i<n;i++)
	    	rev[a[i]] = i;

	    final int s = Math.min(234, n);
	    final int limit = n - s;

	    for(i=0;i<n;i++){
	    	int ans = 0;
	    	for(int j=n;j>limit;j--){
	    		if(rev[j] <= i && b[i - rev[j]] == 1){
	    			ans = j;
	    			break;
	    		}
	    	}
	    	if(ans == 0)
	    		for(int j=0;j<d && pos[j]<=i;j++)
	    			ans = Math.max(ans, a[i - pos[j]]);
	    	w.println(ans);
	    }

		w.close();
	}

	static long getNextX() {
	    x = (x * 37 + 10007) % 1000000007;
	    return x;
	}

	static class InputReader {

		private InputStream stream;
		private byte[] buf = new byte[8192];
		private int curChar;
		private int snumChars;
		private SpaceCharFilter filter;

		public InputReader(InputStream stream) {
			this.stream = stream;
		}

		public int snext() {
			if (snumChars == -1)
				throw new InputMismatchException();
			if (curChar >= snumChars) {
				curChar = 0;
				try {
					snumChars = stream.read(buf);
				} catch (IOException e) {
					throw new InputMismatchException();
				}
				if (snumChars <= 0)
					return -1;
			}
			return buf[curChar++];
		}

		public int nextInt() {
			int c = snext();
			while (isSpaceChar(c))
				c = snext();
			int sgn = 1;
			if (c == '-') {
				sgn = -1;
				c = snext();
			}

			int res = 0;

			do {
				if (c < '0' || c > '9')
					throw new InputMismatchException();
				res *= 10;
				res += c - '0';
				c = snext();
			} while (!isSpaceChar(c));

			return res * sgn;
		}

		public long nextLong() {
			int c = snext();
			while (isSpaceChar(c))
				c = snext();
			int sgn = 1;
			if (c == '-') {
				sgn = -1;
				c = snext();
			}

			long res = 0;

			do {
				if (c < '0' || c > '9')
					throw new InputMismatchException();
				res *= 10;
				res += c - '0';
				c = snext();
			} while (!isSpaceChar(c));

			return res * sgn;
		}

		public String readString() {
			int c = snext();
			while (isSpaceChar(c))
				c = snext();
			StringBuilder res = new StringBuilder();
			do {
				res.appendCodePoint(c);
				c = snext();
			} while (!isSpaceChar(c));
			return res.toString();
		}

		public boolean isSpaceChar(int c) {
			if (filter != null)
				return filter.isSpaceChar(c);
			return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
		}

		public interface SpaceCharFilter {
			public boolean isSpaceChar(int ch);
		}
	}
}

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;
import java.util.PriorityQueue;

public class B {

    private static final long MOD = 1000000007;

    public int[] solve(int n, int d, int x) {
        this.x = x;
        initAB(n, d);
        List<Integer> list = new ArrayList<>();
        for (int i=0; i<n; i++)
            if (b[i]==1)
                list.add(i);
        int[] res = new int[n];
        PriorityQueue<Location> que = new PriorityQueue<Location>();
        for (int i=0; i<n; i++)
            que.add(new Location(a[i], i));
        int rest = n;
        int checkNum = 100;
        while (que.size()>0 && rest>0 && checkNum-->0) {
            Location loc = que.poll();
            for (int idx : list) {
                if (loc.idx+idx>=n)
                    break;
                if (res[loc.idx+idx]==0) {
                    res[loc.idx+idx] = loc.a;
                    rest--;
                }
            }
        }
        for (int i=0; i<n; i++) {
            if (res[i]>0)
                continue;
            for (int idx : list) {
                if (idx>i)
                    break;
                res[i] = Math.max(res[i], a[i-idx]);
            }
        }
        return res;
    }

    private class Location implements Comparable<Location> {
        private int a, idx;
        private Location(int a, int idx) {
            this.a = a;
            this.idx = idx;
        }
        public int compareTo(Location loc) {
            return loc.a-this.a;
        }
    }

    private long x = 0;
    private int[] a, b;

    private long getNextX() {
        x = (x*37 + 10007)%MOD;
        return x;
    }

    private void initAB(int n, int d) {
        a = new int[n];
        b = new int[n];
        for (int i=0; i<n; i++)
            a[i] = i+1;
        for (int i=0; i<n; i++) {
            int j = (int)(getNextX()%(i+1));
            int tmp = a[i];
            a[i] = a[j];
            a[j] = tmp;
        }
        for (int i=0; i<n; i++)
            if (i<d)
                b[i] = 1;
            else
                b[i] = 0;
        for (int i=0; i<n; i++) {
            int j = (int)(getNextX()%(i+1));
            int tmp = b[i];
            b[i] = b[j];
            b[j] = tmp;
        }
    }

    public static void main(String args[]) throws IOException {
        BufferedReader br = null;
        try {
            br = new BufferedReader(new InputStreamReader(System.in));
            String line = br.readLine();
            String[] split = line.split(" ");
            int n = Integer.parseInt(split[0]);
            int d = Integer.parseInt(split[1]);
            int x = Integer.parseInt(split[2]);
            int[] res = new B().solve(n, d, x);
            for (int i=0; i<n; i++)
                System.out.println(res[i]);
        } finally {
            if (br!=null)
                br.close();
        }
    }
}

import java.io.BufferedWriter;
import java.util.InputMismatchException;
import java.util.NoSuchElementException;
import java.math.BigInteger;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.io.Writer;
import java.io.IOException;
import java.util.Arrays;
import java.io.InputStream;
import java.io.OutputStreamWriter;
import java.util.Comparator;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        OutputWriter out = new OutputWriter(outputStream);
        TaskB solver = new TaskB();
        solver.solve(1, in, out);
        out.close();
    }
}

class TaskB {

    int n, d,sqrt;
    long x;
    int[] A, ret, rev, arr;
    boolean[] B;
    IntList list;

    public void solve(int testNumber, InputReader in, OutputWriter out) {
        n=in.readInt();
        d=in.readInt();
        x=in.readLong();
        sqrt=(int)Math.round(Math.sqrt(d));
        initAB();
        rev=ArrayUtils.reversePermutation(A);
        list=new IntArrayList();
        for (int i=0; i<n; i++) if (B[i]) list.add(i);
        arr=list.toArray();
        ret=new int[n];
        for (int i=0; i<n; i++) ret[i]=C(i)+1;
        for (int i: ret) out.printLine(i);
    }

    int C(int pos) {
        for (int i=0; i<sqrt; i++) {
            int x=n-i-1, p=rev[x];
            if (p<=pos && B[pos-p]) return x;
        }
        int max=-1;
        for (int i: arr) if (i<=pos && A[pos-i]>max) max=A[pos-i];
        return max;
    }

    long getNextX() {
        return x=(x*37+10007)%1000000007;
    }

    void initAB() {
        A= ArrayUtils.createOrder(n);
        for (int i=0; i<n; i++) {
            int j=(int)getNextX()%(i+1), aux=A[i];
            A[i]=A[j];
            A[j]=aux;
        }
        B=new boolean[n];
        for (int i=0; i<n; i++) B[i]=i<d;
        for (int i=0; i<n; i++) {
            int j=(int)getNextX()%(i+1);
            boolean aux=B[i];
            B[i]=B[j];
            B[j]=aux;
        }
    }
}

abstract class IntList extends IntCollection implements Comparable<IntList> {

    public abstract int get(int index);

    public IntIterator iterator() {
        return new IntIterator() {
            private int size = size();
            private int index = 0;

            public int value() throws NoSuchElementException {
                if (!isValid())
                    throw new NoSuchElementException();
                return get(index);
            }

            public void advance() throws NoSuchElementException {
                if (!isValid())
                    throw new NoSuchElementException();
                index++;
            }

            public boolean isValid() {
                return index < size;
            }
        };
    }

    public int hashCode() {
        int hashCode = 1;
        for (IntIterator i = iterator(); i.isValid(); i.advance())
            hashCode = 31 * hashCode + i.value();
        return hashCode;
    }

    public boolean equals(Object obj) {
        if (!(obj instanceof IntList))
            return false;
        IntList list = (IntList)obj;
        if (list.size() != size())
            return false;
        IntIterator i = iterator();
        IntIterator j = list.iterator();
        while (i.isValid()) {
            if (i.value() != j.value())
                return false;
            i.advance();
            j.advance();
        }
        return true;
    }

    public int compareTo(IntList o) {
        IntIterator i = iterator();
        IntIterator j = o.iterator();
        while (true) {
            if (i.isValid()) {
                if (j.isValid()) {
                    if (i.value() != j.value()) {
                        if (i.value() < j.value())
                            return -1;
                        else
                            return 1;
                    }
                } else
                    return 1;
            } else {
                if (j.isValid())
                    return -1;
                else
                    return 0;
            }
            i.advance();
            j.advance();
        }
    }

}

class InputReader {

    private InputStream stream;
    private byte[] buf = new byte[1024];
    private int curChar;
    private int numChars;
    private SpaceCharFilter filter;

    public InputReader(InputStream stream) {
        this.stream = stream;
    }

    public int read() {
        if (numChars == -1)
            throw new InputMismatchException();
        if (curChar >= numChars) {
            curChar = 0;
            try {
                numChars = stream.read(buf);
            } catch (IOException e) {
                throw new InputMismatchException();
            }
            if (numChars <= 0)
                return -1;
        }
        return buf[curChar++];
    }

    public int readInt() {
        int c = read();
        while (isSpaceChar(c))
            c = read();
        int sgn = 1;
        if (c == '-') {
            sgn = -1;
            c = read();
        }
        int res = 0;
        do {
            if (c < '0' || c > '9')
                throw new InputMismatchException();
            res *= 10;
            res += c - '0';
            c = read();
        } while (!isSpaceChar(c));
        return res * sgn;
    }

    public long readLong() {
        int c = read();
        while (isSpaceChar(c))
            c = read();
        int sgn = 1;
        if (c == '-') {
            sgn = -1;
            c = read();
        }
        long res = 0;
        do {
            if (c < '0' || c > '9')
                throw new InputMismatchException();
            res *= 10;
            res += c - '0';
            c = read();
        } while (!isSpaceChar(c));
        return res * sgn;
    }

    public boolean isSpaceChar(int c) {
        if (filter != null)
            return filter.isSpaceChar(c);
        return isWhitespace(c);
    }

    public static boolean isWhitespace(int c) {
        return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
    }

    public interface SpaceCharFilter {
        public boolean isSpaceChar(int ch);
    }
}

class OutputWriter {
    private final PrintWriter writer;

    public OutputWriter(OutputStream outputStream) {
        writer = new PrintWriter(new BufferedWriter(new OutputStreamWriter(outputStream)));
    }

    public void close() {
        writer.close();
    }

    public void printLine(int i) {
        writer.println(i);
    }
}

class ArrayUtils {

    public static int[] createOrder(int size) {
        int[] order = new int[size];
        for (int i = 0; i < size; i++)
            order[i] = i;
        return order;
    }

    public static int[] reversePermutation(int[] permutation) {
        int[] result = new int[permutation.length];
        for (int i = 0; i < permutation.length; i++)
            result[permutation[i]] = i;
        return result;
    }

}

class IntArrayList extends IntList {
    private int[] array;
    private int size;

    public IntArrayList() {
        this(10);
    }

    public IntArrayList(int capacity) {
        array = new int[capacity];
    }

    public int get(int index) {
        if (index >= size)
            throw new IndexOutOfBoundsException();
        return array[index];
    }

    public int size() {
        return size;
    }

    public void add(int value) {
        ensureCapacity(size + 1);
        array[size++] = value;
    }

    public void ensureCapacity(int newCapacity) {
        if (newCapacity > array.length) {
            int[] newArray = new int[Math.max(newCapacity, array.length << 1)];
            System.arraycopy(array, 0, newArray, 0, size);
            array = newArray;
        }
    }

    public int[] toArray() {
        int[] array = new int[size];
        System.arraycopy(this.array, 0, array, 0, size);
        return array;
    }

}

abstract class IntCollection {
    public abstract IntIterator iterator();
    public abstract int size();
    public abstract void add(int value);

    public int[] toArray() {
        int size = size();
        int[] array = new int[size];
        int i = 0;
        for (IntIterator iterator = iterator(); iterator.isValid(); iterator.advance())
            array[i++] = iterator.value();
        return array;
    }

}

interface IntIterator {
    public int value() throws NoSuchElementException;
    /*
     * @throws NoSuchElementException only if iterator already invalid
     */
    public void advance() throws NoSuchElementException;
    public boolean isValid();
}

import java.util.ArrayList;
import java.io.InputStream;
import java.util.List;
import java.util.AbstractQueue;
import java.util.Scanner;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.Collections;
import java.util.Comparator;
import java.util.PriorityQueue;
import java.io.IOException;
import java.util.AbstractCollection;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
	public static void main(String[] args) {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		Scanner in = new Scanner(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		TaskD solver = new TaskD();
		solver.solve(1, in, out);
		out.close();
	}
}

class TaskD {
    int n, d;
    long x;
    //x is 64-bit variable;
    private long getNextX() {
        x = (x * 37 + 10007) % 1000000007;
        return x;
    }

    private void initAB(int[] a, int[] b) {
        for (int i = 0; i < n; i = i + 1)
            a[i] = i + 1;
        for (int i = 0; i < n; i = i + 1) {
            int tmp = a[i];
            int j = (int)(getNextX() % (i + 1));
            a[i] = a[j];
            a[j] = tmp;
        }
        for (int i = 0; i < n; i = i + 1) {
            if (i < d)
                b[i] = 1;
            else
                b[i] = 0;
        }
        for (int i = 0; i < n; i = i + 1) {
            int tmp = b[i];
            int j = (int)(getNextX() % (i + 1));
            b[i] = b[j];
            b[j] = tmp;
        }
    }
    public void solve(int testNumber, Scanner in, PrintWriter out) {
        n = in.nextInt();
        d = in.nextInt();
        x = in.nextLong();

        int[] a = new int[n];
        int[] b = new int[n];
        initAB(a, b);

        final int threshold = 5000;
        if (d < threshold)
            solveSmallD(out, a, b);
        else
            solveLargeD(out, a, b);
    }

    private void solveSmallD(PrintWriter out, int[] a, int[] b) {
        int[] c = new int[n];
        for (int i = 0; i < n; i++) {
            if (b[i] == 1) {
                for (int j = i; j < n; j++) {
                    if (a[j - i] > c[j]) c[j] = a[j - i];
                }
            }
        }
        for (int i = 0; i < n; i++)
            out.println(c[i]);
    }

    private void solveLargeD(PrintWriter out, int[] a, int[] b) {
        int[] ai = new int[n + 1];
        for (int i = 0; i < n; i++)
            ai[a[i]] = i;

        int[] c = new int[n];
        PriorityQueue<Integer> pq = new PriorityQueue<>(n, Collections.reverseOrder());
        for (int i = 0; i < n; i++) {
            pq.add(a[i]);
            List<Integer> l = new ArrayList<>();
            while (!pq.isEmpty()) {
                int v = pq.remove();
                l.add(v);
                if (b[i - ai[v]] == 1) {
                    c[i] = v;
                    break;
                }
            }
            for (int v : l) pq.add(v);
        }
        for (int i = 0; i < n; i++)
            out.println(c[i]);
    }
}

import java.io.*;
import java.util.*;
import java.math.BigInteger;
import java.util.Collections.*;
import static java.lang.Math.*;
import static java.lang.Math.max;
import static java.lang.Math.min;
import static java.util.Arrays.*;
import static java.math.BigInteger.*;

public class Main{

    void run(){
        Locale.setDefault(Locale.US);
        boolean my;
        try {
            my = System.getProperty("MY_LOCAL") != null;
        } catch (Exception e) {
            my = false;

        }
        try{
            err = System.err;
            if( my ){
                sc  = new FastScanner(new BufferedReader(new FileReader("input.txt")));
//                sc  = new FastScanner(new BufferedReader(new FileReader("C:\\myTest.txt")));
                out = new PrintWriter   (new FileWriter("output.txt"));
            }
            else {
                sc = new FastScanner(new BufferedReader(new InputStreamReader(System.in)));
                out = new PrintWriter(new OutputStreamWriter(System.out));
            }
//            out = new PrintWriter(new OutputStreamWriter(System.out));
        }catch(Exception e){
            MLE();
        }
        if( my )
            tBeg = System.currentTimeMillis();
        solve();
        if( my )
            err.println( "TIME: " + (System.currentTimeMillis() - tBeg ) / 1e3 );
        exit(0);
    }

    void exit( int val ){
        err.flush();
        out.flush();
        System.exit(val);
    }

    double tBeg;
    FastScanner sc;
    PrintWriter out;
    PrintStream err;

    class FastScanner{

        StringTokenizer st;
        BufferedReader br;

        FastScanner( BufferedReader _br ){
            br = _br;
        }

        String readLine(){
            try {
                return br.readLine();
            } catch (IOException e) {
                return null;
            }
        }

        String next(){
            while( st==null || !st.hasMoreElements() )
                st = new StringTokenizer(readLine());
            return st.nextToken();
        }

        int nextInt(){ return Integer.parseInt(next()); }
        long nextLong(){ return Long.parseLong(next()); }
        double nextDouble(){ return Double.parseDouble(next()); }
    }

    void MLE(){
        int[][] arr = new int[1024*1024][]; for( int i = 0; i < 1024*1024; ++i ) arr[i] = new int[1024*1024];
    }

    void MLE( boolean doNotMLE ){ if( !doNotMLE ) MLE(); }

    void TLE(){
        for(;;);
    }

    public static void main(String[] args) {
        new Main().run();
//        new Thread( null, new Runnable() {
//            @Override
//            public void run() {
//                new Main().run();
//            }
//        }, "Lolka", 256_000_000L ).run();
    }

    ////////////////////////////////////////////////////////////////

    final int ZALUPA = (int)1e3;
    int n;
    int d;
    long x;
    int[] a, b;
    int[] pos, posOne;

    int getNextX() {
        x = (x * 37 + 10007) % 1000000007;
        return (int)x;
    }

    void initAB() {
        int i;
        for(i = 0; i < n; i = i + 1){
            a[i] = i + 1;
        }
        for(i = 0; i < n; i = i + 1){
            int j = getNextX() % (i + 1);
            int t = a[i];
            a[i] = a[j];
            a[j] = t;
        }
        for(i = 0; i < n; i = i + 1){
            if (i < d)
                b[i] = 1;
            else
                b[i] = 0;
        }
        for(i = 0; i < n; i = i + 1){
            int j = getNextX() % (i + 1);
            int t = b[i];
            b[i] = b[j];
            b[j] = t;
        }

        pos = new int[n+1];
        for ( i = 0; i < n; i++) {
            pos[a[i]] = i;
        }

        posOne = new int[d]; fill( posOne, -1 );
        int sz = 0;
        for (i= 0; i < n; ++i) {
            if( b[i] == 1 ){
                posOne[sz++] = i;
            }
        }
        if( posOne.length != sz ) MLE();
    }

    void solve(){
//        for( int i = 0; i < 1e4; ++i ) err.printf("%10d\n", getNextX());
        n = sc.nextInt();
        d = sc.nextInt();
        x = sc.nextInt();
        a = new int[n];
        b = new int[n];
        initAB();

        for (int i = 0; i < n; i++) {
            int ci = 0;
            for (int val = n, low = max(0, n - ZALUPA + 1); low <= val; val--) {
                if( pos[val] <= i && b[i-pos[val]] == 1 ){
                    ci = val;
                    break;
                }
            }
            if( ci == 0 ){
                for (int j : posOne) {
                    if( i < j ) break;
                    ci = max( ci, a[i-j] );
                }
            }
            out.println(ci);
        }
    }

}

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

/**
 * @author Don Li
 */
public class DZYLovesFFT {

    int n, d, x;
    int[] a, b;

    void solve() {
        n = in.nextInt();
        d = in.nextInt();
        x = in.nextInt();
        a = new int[n];
        b = new int[n];

        initAB();

        int[] inv = new int[n + 1];
        for (int i = 0; i < n; i++) inv[a[i]] = i;

        int[] pos = new int[d];
        for (int i = 0, j = 0; i < n; i++) if (b[i] > 0) pos[j++] = i;

        int s = 30;

        for (int i = 0; i < n; i++) {
            int ans = 0;
            for (int v = n; v >= n - s; v--) {
                if (v > 0 && inv[v] <= i && b[i - inv[v]] > 0) {
                    ans = v;
                    break;
                }
            }
            if (ans == 0) {
                for (int j = 0; j < d && pos[j] <= i; j++) {
                    ans = Math.max(ans, a[i - pos[j]]);
                }
            }
            out.println(ans);
        }
    }

    int getNextX() {
        x = (int) ((x * 37L + 10007) % 1000000007);
        return x;
    }

    void initAB() {
        for (int i = 0; i < n; i = i + 1) {
            a[i] = i + 1;
        }
        for (int i = 0; i < n; i = i + 1) {
            swap(a, i, getNextX() % (i + 1));
        }
        for (int i = 0; i < n; i = i + 1) {
            if (i < d)
                b[i] = 1;
            else
                b[i] = 0;
        }
        for (int i = 0; i < n; i = i + 1) {
            swap(b, i, getNextX() % (i + 1));
        }
    }

    void swap(int[] a, int i, int j) {
        int tmp = a[i];
        a[i] = a[j];
        a[j] = tmp;
    }

    public static void main(String[] args) {
        in = new FastScanner(new BufferedReader(new InputStreamReader(System.in)));
        out = new PrintWriter(System.out);
        new DZYLovesFFT().solve();
        out.close();
    }

    static FastScanner in;
    static PrintWriter out;

    static class FastScanner {
        BufferedReader in;
        StringTokenizer st;

        public FastScanner(BufferedReader in) {
            this.in = in;
        }

        public String nextToken() {
            while (st == null || !st.hasMoreTokens()) {
                try {
                    st = new StringTokenizer(in.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(nextToken());
        }

        public long nextLong() {
            return Long.parseLong(nextToken());
        }

        public double nextDouble() {
            return Double.parseDouble(nextToken());
        }
    }
}

// practice with rainboy
import java.io.*;
import java.util.*;

public class CF445D {
	static int x;
	static int getNextX() {
		x = (int) ((x * 37L + 10007) % 1000000007);
		return x;
	}
	static int[] aa, bb;
	static void initAB(int n, int d) {
		aa = new int[n];
		bb = new int[n];
		for (int i = 0; i < n; i++)
			aa[i] = i + 1;
		for (int i = 0; i < n; i++) {
			int j = getNextX() % (i + 1);
			int tmp = aa[i]; aa[i] = aa[j]; aa[j] = tmp;
		}
		for (int i = 0; i < n; i++)
			bb[i] = i < d ? 1 : 0;
		for (int i = 0; i < n; i++) {
			int j = getNextX() % (i + 1);
			int tmp = bb[i]; bb[i] = bb[j]; bb[j] = tmp;
		}
	}
	static final int S = 20;
	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		PrintWriter pw = new PrintWriter(System.out);
		StringTokenizer st = new StringTokenizer(br.readLine());
		int n = Integer.parseInt(st.nextToken());
		int d = Integer.parseInt(st.nextToken());
		x = Integer.parseInt(st.nextToken());
		initAB(n, d);
		int[] ii = new int[S + 1];
		int[] jj = new int[n];
		int k = 0;
		for (int i = 0; i < n; i++) {
			int h = i < S ? i : S;
			while (h > 0 && aa[ii[h - 1]] < aa[i]) {
				ii[h] = ii[h - 1];
				h--;
			}
			ii[h] = i;
			if (bb[i] == 1)
				jj[k++] = i;
			int c = 0;
			for (h = 0; h <= i && h < S; h++)
				if (bb[i - ii[h]] == 1) {
					c = aa[ii[h]];
					break;
				}
			if (c == 0)
				for (h = 0; h < k; h++)
					c = Math.max(c, aa[i - jj[h]]);
			pw.println(c);
		}
		pw.close();
	}
}

import java.io.BufferedWriter;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.Scanner;
import java.util.TreeSet;

/**
 *
 * @author Darkhan
 */
public class task4 {
    static int[] a, b, ar;
    static int n, d;
    static long x;
    static ArrayList<Integer> bset = new ArrayList<>();
    static TreeSet<Integer> aset = new TreeSet<>();
    public static void main (String[] args){
        Scanner in = new Scanner(System.in);
        PrintWriter out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));
        n = in.nextInt();
        d = in.nextInt();
        x = in.nextLong();
        a = new int[n];
        b = new int[n];
        ar = new int[n+1];
        initAB();
        Iterator<Integer> it;
        long t;
        if (d < 3000){
            for (int i=0;i<n;i++){
                if (b[i] == 1) bset.add(i);
                t = 0;
                for (Integer bset1 : bset) {
                    t = Math.max(t, a[i - bset1]);
                }
                out.println(t);
            }
        }
        else{
            int val;
            for (int i=0;i<n;i++){
                t = 0;
                aset.add(a[i]);
                it = aset.descendingIterator();
                while(it.hasNext()){
                    val = it.next();
                    if (b[i-ar[val]] == 0) continue;
                    t = val;
                    break;
                }
                out.println(t);
            }
        }
        out.close();
    }
    public static long getNextX() {
        x = (x * 37 + 10007) % 1000000007;
        return x;
    }
    public static void initAB() {
        for(int i = 0; i < n; i = i + 1){
            a[i] = i + 1;
            ar[i+1] = i;
        }
        for(int i = 0; i < n; i = i + 1){
            int t = (int)(getNextX() % (i + 1));
            ar[a[i]] = t;
            ar[a[t]] = i;
            swap(a, i, t);
        }
        for(int i = 0; i < n; i = i + 1){
            if (i < d)
                b[i] = 1;
            else
                b[i] = 0;
        }
        for(int i = 0; i < n; i = i + 1){
            swap(b, i, (int)(getNextX() % (i + 1)));
        }
    }
    public static void swap(int[] a, int i, int j){
        int t = a[i];
        a[i] = a[j];
        a[j] = t;
    }
}

import java.io.InputStreamReader;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 * @author Rubanenko
 */
public class Main {
	public static void main(String[] args) {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		TaskB solver = new TaskB();
		solver.solve(1, in, out);
		out.close();
	}
}

class TaskB {

    long x;
    int n, d;
    int[] a, b, p, c;
    int getNext() {
        x = (x * 37 + 10007) % 1000000007;
        return (int) x;
    }

    void initAB() {
        int i, j, tmp;
        for(i = 0; i < n; i = i + 1){
            a[i] = i + 1;
        }
        for(i = 0; i < n; i = i + 1){
            j = getNext() % (i + 1);
            tmp = a[i];
            a[i] = a[j];
            a[j] = tmp;
        }
        for (i = 0; i < n; i++) {
            p[a[i]] = i;
        }
        for(i = 0; i < n; i = i + 1){
            if (i < d)
                b[i] = 1;
            else
                b[i] = 0;
        }
        for(i = 0; i < n; i = i + 1){
            j = getNext() % (i + 1);
            tmp = b[i];
            b[i] = b[j];
            b[j] = tmp;
        }
    }

    public void solve(int testNumber, InputReader in, PrintWriter out) {
        n = in.nextInt();
        d = in.nextInt();
        x = in.nextLong();
        c = new int[n];
        a = new int[n];
        b = new int[n];
        p = new int[n + 1];
        initAB();
        if (d < 1000) {
            for (int u = 0; u < n; u++) {
                if (b[u] == 1) {
                    for (int i = u; i < n; i++) {
                        if (a[i - u] > c[i]) c[i] = a[i - u];
                    }
                }
            }
            for (int i = 0; i < n; i++) {
                out.println(c[i]);
            }
            return;
        }
        int mn = 0;
        int cnt = n;
        for (int i = n; i > 0 && cnt > 0; i--) {
            int j = p[i];
            for (int u = j; u < n; u++) {
                //System.out.println(u - j + " " + u);
                if (b[u - j] == 1 && c[u] == 0) {
                    c[u] = i;
                    cnt--;
                }
            }
            if (cnt < 1000) break;
        }
        for (int i = 0; i < n; i++) {
            if (c[i] > 0) {
                continue;
            }
            for (int j = 0; j <= i; j++) {
                if (b[i - j] == 1 && a[j] > c[i]) {
                    c[i] = a[j];
                }
            }
        }
        for (int i = 0; i < n; i++) {
            out.println(c[i]);
        }
    }
}

class InputReader {
    private BufferedReader reader;
    private StringTokenizer tokenizer;

    public InputReader(InputStream inputStream) {
        reader = new BufferedReader(new InputStreamReader(inputStream));
    }

    public String nextLine() {
        String line = null;
        try {
            line = reader.readLine();
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
        return line;
    }

    public String next() {
        while (tokenizer == null || !tokenizer.hasMoreTokens())
            tokenizer = new StringTokenizer(nextLine());
        return tokenizer.nextToken();
    }

    public int nextInt() {
        return Integer.parseInt(next());
    }
    public long nextLong() {
        return Long.parseLong(next());
    }
}

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.StringTokenizer;
import java.util.function.BiFunction;
import java.util.function.Function;
import java.util.stream.Collectors;
import java.util.stream.IntStream;
import java.util.stream.Stream;

public class Solution {
    static int n, d, x;
    static int[] a, b;

    static int getNextX() {
        x = (int)((37L * x + 10007) % (1000 * 1000 * 1000 + 7));
        return x;
    }

    static void swap(int[] array) {
        for (int i = 0; i < n; i++) {
            int j = getNextX() % (i + 1);
            int t = array[i];
            array[i] = array[j];
            array[j] = t;
        }
    }

    static void initAB() {
        a = new int[n];
        b = new int[n];
        for (int i = 0; i < n; i++) {
            a[i] = i + 1;
        }
        for (int i = 0; i < n; i++) {
            b[i] = i < d ? 1 : 0;
        }
        swap(a);
        swap(b);
    }

    public static void main(String[] args) throws IOException {
        try (BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
             PrintWriter writer = new PrintWriter(System.out)) {
            n = nextInt(reader);
            d = nextInt(reader);
            x = nextInt(reader);
            initAB();
            int[] inverseA = new int[n + 1];
            for (int i = 0; i < n; i++) {
                inverseA[a[i]] = i;
            }
            List<Integer> nonZeroPositionsInB = new ArrayList<>(n);
            for (int i = 0; i < n; i++) {
                if (b[i] == 1) {
                    nonZeroPositionsInB.add(i);
                }
            }
            int[] nzpib = nonZeroPositionsInB.stream().mapToInt(x -> x).toArray();
            int[] c = new int[n];
            int iterations = Math.min(n, 100 * 1000 * 1000 / nzpib.length);
            for (int i = 0; i < iterations; i++) {
                int aValue = n - iterations + i + 1;
                int ai = inverseA[aValue];
                for (int bi : nzpib) {
                    if (ai + bi >= n) break;
                    c[ai + bi] = aValue;
                }
            }
            for (int i = 0; i < n; i++) {
                if (c[i] == 0) {
                    for (int bi : nzpib) {
                        if (bi > i) break;
                        c[i] = Math.max(c[i], a[i - bi]);
                    }
                }
            }
            IntStream.of(c).forEach(writer::println);
        }
    }

    private static StringTokenizer stringTokenizer;

    private static String next(BufferedReader reader) throws IOException {
        if (stringTokenizer == null || !stringTokenizer.hasMoreTokens()) {
            stringTokenizer = new StringTokenizer(reader.readLine());
        }
        return stringTokenizer.nextToken();
    }

    private static int nextInt(BufferedReader reader) throws IOException {
        return Integer.parseInt(next(reader));
    }

    private static long nextLong(BufferedReader reader) throws IOException {
        return Long.parseLong(next(reader));
    }
}

import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.*;

/**
 * Created by hama_du on 15/08/03.
 */
public class B {
    public static void main(String[] args) {
        InputReader in = new InputReader(System.in);
        PrintWriter out = new PrintWriter(System.out);

        int n = in.nextInt();
        int d = in.nextInt();
        int x = in.nextInt();
        a = new int[n];
        b = new int[n];
        initAB(n, d, x);

        int[] imosB = new int[n+1];
        for (int i = 0; i < n ; i++) {
            imosB[i+1] = imosB[i] + b[i];
        }
        int[] ones = new int[n];
        int oi = 0;
        for (int i = 0; i < n ; i++) {
            if (b[i] == 1) {
                ones[oi++] = i;
            }
        }

        int[][] ord = new int[n][2];
        for (int i = 0; i < n ; i++) {
            ord[i][0] = a[i];
            ord[i][1] = i;
        }
        Arrays.sort(ord, new Comparator<int[]>() {
            @Override
            public int compare(int[] o1, int[] o2) {
                return o2[0] - o1[0];
            }
        });

        int[] ans = new int[n];

        TreeSet<Integer> left = new TreeSet<>();
        for (int i = 0; i < n ; i++) {
            left.add(i);
        }

        int[] mark = new int[n];
        int mi = 0;

        for (int i = 0; i < n; i++) {
            int idx = ord[i][1];
            int cnt = n - idx;
            if (imosB[cnt] <= 320) {
                int oneI = 0;
                while (oneI < oi && ones[oneI] < cnt) {
                    int ai = idx+ones[oneI];
                    if (ans[ai] == 0) {
                        ans[ai] = ord[i][0];
                        left.remove(ai);
                    }
                    oneI++;
                }
            } else {
                mi = 0;
                for (int ai : left.tailSet(idx, true)) {
                    if (b[ai-idx] == 1) {
                        mark[mi++] = ai;
                        ans[ai] = ord[i][0];
                    }
                }
                for (int j = 0; j < mi ; j++) {
                    left.remove(mark[j]);
                }
            }
        }

        for (int i = 0; i < n ; i++) {
            out.println(ans[i]);
        }
        out.flush();
    }

    static long getNextX(long x) {
        x = (x * 37 + 10007) % 1000000007;
        return x;
    }

    static int[] a;
    static int[] b;

    static void swap(int[] a, int i1, int i2) {
        int tmp = a[i1];
        a[i1] = a[i2];
        a[i2] = tmp;
    }

    static void initAB(int n, int d, long x) {
        for (int i = 0; i < n ; i++){
            a[i] = i + 1;
        }
        for(int i = 0; i < n; i++) {
            x = getNextX(x);
            swap(a, i, (int)(x % (i + 1)));
        }
        for(int i = 0; i < n; i++){
            if (i < d) {
                b[i] = 1;
            } else {
                b[i] = 0;
            }
        }
        for(int i = 0; i < n; i++){
            x = getNextX(x);
            swap(b, i, (int)(x % (i + 1)));
        }
    }

    static class InputReader {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;

        public InputReader(InputStream stream) {
            this.stream = stream;
        }

        private int next() {
            if (numChars == -1)
                throw new InputMismatchException();
            if (curChar >= numChars) {
                curChar = 0;
                try {
                    numChars = stream.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
                if (numChars <= 0)
                    return -1;
            }
            return buf[curChar++];
        }

        public char nextChar() {
            int c = next();
            while (isSpaceChar(c))
                c = next();
            if ('a' <= c && c <= 'z') {
                return (char) c;
            }
            if ('A' <= c && c <= 'Z') {
                return (char) c;
            }
            throw new InputMismatchException();
        }

        public String nextToken() {
            int c = next();
            while (isSpaceChar(c))
                c = next();
            StringBuilder res = new StringBuilder();
            do {
                res.append((char) c);
                c = next();
            } while (!isSpaceChar(c));
            return res.toString();
        }

        public int nextInt() {
            int c = next();
            while (isSpaceChar(c))
                c = next();
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = next();
            }
            int res = 0;
            do {
                if (c < '0' || c > '9')
                    throw new InputMismatchException();
                res *= 10;
                res += c - '0';
                c = next();
            } while (!isSpaceChar(c));
            return res * sgn;
        }

        public long nextLong() {
            int c = next();
            while (isSpaceChar(c))
                c = next();
            long sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = next();
            }
            long res = 0;
            do {
                if (c < '0' || c > '9')
                    throw new InputMismatchException();
                res *= 10;
                res += c - '0';
                c = next();
            } while (!isSpaceChar(c));
            return res * sgn;
        }

        public boolean isSpaceChar(int c) {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        public interface SpaceCharFilter {
            public boolean isSpaceChar(int ch);
        }
    }

    static void debug(Object... o) {
        System.err.println(Arrays.deepToString(o));
    }
}

import java.util.List;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.PriorityQueue;
import java.util.ArrayList;
import java.io.BufferedReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.AbstractCollection;
import java.util.StringTokenizer;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
	public static void main(String[] args) {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		FastScanner in = new FastScanner(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		TaskB solver = new TaskB();
		solver.solve(1, in, out);
		out.close();
	}
}

class TaskB {
	public void solve(int testNumber, FastScanner in, PrintWriter out) {
		n = in.nextInt();
		d = in.nextInt();
		x = in.nextLong();
		initAB();
		int[] c = new int[n];
		if (d < 5000) {
			int[] pos = new int[n + 1];
			for (int i = 0; i < n; i++) {
				pos[a[i]] = i;
			}
			int[] x = new int[d];
			d = 0;
			for (int i = 0; i < n; i++) {
				if (b[i] == 1) {
					x[d++] = i;
				}
			}
			int left = n;
			for (int val = n; val >= 1; val--) {
				int i = pos[val];
				for (int j = 0; j < d; j++) {
					int k = x[j] + i;
					if (k >= n) {
						break;
					}
					if (c[k] == 0) {
						--left;
						c[k] = val;
					}
					if (left == 0) {
						break;
					}
				}
				if (left == 0) {
					break;
				}
			}
		} else {
			PriorityQueue<Item> pq = new PriorityQueue<Item>();
			for (int i = 0; i < n; i++) {
				pq.offer(new Item(a[i], i));
				List<Item> list = new ArrayList<Item>();
				while (!pq.isEmpty()) {
					Item it = pq.poll();
					list.add(it);
					if (b[i - it.pos] == 1) {
						c[i] = it.val;
						break;
					}
				}
				for (Item it : list) {
					pq.offer(it);
				}
			}
		}
		for (int i = 0; i < n; i++) {
			out.println(c[i]);
		}
	}

	int n, d;
	long x;
	int[] a, b;

	long getNextX() {
		x = (x * 37 + 10007) % 1000000007;
		return x;
	}

	void initAB() {
		a = new int[n];
		b = new int[n];
		for (int i = 0; i < n; i++) {
			a[i] = i + 1;
		}
		for (int i = 0; i < n; i++) {
			int j = (int)(getNextX() % (i + 1));
			int t = a[i];
			a[i] = a[j];
			a[j] = t;
		}
		for (int i = 0; i < n; i++) {
			if (i < d) {
				b[i] = 1;
			} else {
				b[i] = 0;
			}
		}
		for (int i = 0; i < n; i++) {
			int j = (int)(getNextX() % (i + 1));
			int t = b[i];
			b[i] = b[j];
			b[j] = t;
		}
	}

	class Item implements Comparable<Item> {
		int val;
		int pos;
		Item(int val, int pos) {
			this.val = val;
			this.pos = pos;
		}
		public int compareTo(Item o) {
			return o.val - val;
		}
	}
}

class FastScanner {

	private BufferedReader in;
	private StringTokenizer st;

	public FastScanner(InputStream stream) {
		in = new BufferedReader(new InputStreamReader(stream));
	}

	public String next() {
		while (st == null || !st.hasMoreTokens()) {
			try {
				st = new StringTokenizer(in.readLine());
			} catch (IOException e) {
				throw new RuntimeException(e);
			}
		}
		return st.nextToken();
	}

	public int nextInt() {
		return Integer.parseInt(next());
	}

	public long nextLong() {
		return Long.parseLong(next());
	}

}

import java.io.*;
import java.util.*;

public class B {

	BufferedReader br;
	PrintWriter out;
	StringTokenizer st;
	boolean eof;

	long x;

	long getNextX() {
		x = (x * 37 + 10007) % 1000000007;
		return x;
	}

	void solve() throws IOException {
		int n = nextInt();
		int d = nextInt();
		x = nextLong();

		int[] a = new int[n];
		int[] b = new int[n];

		for (int i = 0; i < n; i++) {
			a[i] = i;
		}
		for (int i = 0; i < n; i = i + 1) {
			int j = (int) (getNextX() % (i + 1));
			int tmp = a[i];
			a[i] = a[j];
			a[j] = tmp;
		}
		for (int i = 0; i < n; i++) {
			if (i < d)
				b[i] = 1;
			else
				b[i] = 0;
		}
		for (int i = 0; i < n; i = i + 1) {
			int j = (int) (getNextX() % (i + 1));
			int tmp = b[i];
			b[i] = b[j];
			b[j] = tmp;
		}

		int[] inv = new int[n];
		for (int i = 0; i < n; i++) {
			inv[a[i]] = i;
		}

		int[] ans = new int[n];
		Arrays.fill(ans, -1);
		int[] put = new int[d];
		for (int i = 0, j = 0; i < n; i++) {
			if (b[i] == 1) {
				put[j++] = i;
			}
		}
		TreeSet<Integer> left = new TreeSet<>();
		for (int i = 0; i < n; i++) {
			left.add(i);
		}

		List<Integer> rem = new ArrayList<Integer>(n);

		for (int val = n - 1; val >= 0; val--) {
			int pos = inv[val];
			int szPut = Arrays.binarySearch(put, n - pos);
			if (szPut < 0) {
				szPut = -szPut - 2;
			}
			if (szPut < left.size()) {
				for (int i = 0; i < d; i++) {
					if (pos + put[i] >= n) {
						break;
					}
					if (ans[pos + put[i]] == -1) {
						ans[pos + put[i]] = val;
						left.remove(pos + put[i]);
					}
				}
			} else {
				rem.clear();
				for (Integer p : left.tailSet(pos)) {
					if (b[p - pos] == 1) {
						rem.add(p);
						ans[p] = val;
					}
				}
				for (Integer x : rem) {
					left.remove(x);
				}
			}
		}

		for (int i = 0; i < n; i++) {
			out.println(ans[i] + 1);
		}
	}

	B() throws IOException {
		br = new BufferedReader(new InputStreamReader(System.in));
		out = new PrintWriter(System.out);
		solve();
		out.close();
	}

	public static void main(String[] args) throws IOException {
		new B();
	}

	String nextToken() {
		while (st == null || !st.hasMoreTokens()) {
			try {
				st = new StringTokenizer(br.readLine());
			} catch (Exception e) {
				eof = true;
				return null;
			}
		}
		return st.nextToken();
	}

	String nextString() {
		try {
			return br.readLine();
		} catch (IOException e) {
			eof = true;
			return null;
		}
	}

	int nextInt() throws IOException {
		return Integer.parseInt(nextToken());
	}

	long nextLong() throws IOException {
		return Long.parseLong(nextToken());
	}

	double nextDouble() throws IOException {
		return Double.parseDouble(nextToken());
	}
}

import java.io.BufferedWriter;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;
import java.util.TreeSet;

public class Snippet {
    static long x;
    static int n, d;
    static int[] a;
    static int[] b;
    static long  getNextX() {
        x = (x * 37 + 10007) % 1000000007;
        return x;
    }
    static void  initAB() {
        int i;
        for(i = 0; i < n; i = i + 1){
            a[i] = i+1;
        }
        for(i = 0; i < n; i = i + 1){
            swap(a, i,  (int)getNextX() % (i + 1) );
        }
        for(i = 0; i < n; i = i + 1){
            if (i < d)
                b[i] = 1;
            else
                b[i] = 0;
        }
        for(i = 0; i < n; i = i + 1){
            swap(b, i,  (int)getNextX() % (i + 1) );
        }
    }
    static void  swap(int[] arr, int i, int j) {
        int tmp = arr[i];
        arr[i] = arr[j];
        arr[j] = tmp;
    }
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        PrintWriter out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));
        n = sc.nextInt();
        d = sc.nextInt();
        x = sc.nextLong();

        a = new int[n];
        b = new int[n];
        initAB();

        List<Integer> b1 = new ArrayList<Integer>();
        if (d < 1000) {
            for (int i =0; i < n; ++i) {
                int c = 0;
                if (b[i] == 1) b1.add(i);
                for (int j = 0;  j < b1.size(); ++j) {
                    c = Math.max(c, a[i - b1.get(j)]);
                }
                out.println(c);
            }
        } else {
            int[] arr = new int[n + 1];
            for (int i = 0; i < n; ++i) arr[a[i]] = i;
            TreeSet<Integer> set = new TreeSet<Integer>();
            label:
                for (int i = 0; i < n; ++i) {
                    set.add(-a[i]);
                    for (int k : set) {
                        int j = arr[-k];
                        if (b[i - j] == 1) {
                            out.println(-k);
                            continue label;
                        }
                    }
                    out.println(0);
                }
        }
        out.flush();

    }
    public static void debug(Object... o) {
        System.out.println(Arrays.deepToString(o));
    }
}

import java.io.*;
import java.util.*;

public class DZYLovesFFT {
    static long x;
    static int n, d;
    static int[] a;
    static int[] b;

    static long getNextX() {
        x = (x * 37 + 10007) % 1000000007;
        return x;
    }

    static void initAB() {
        int i;
        for (i = 0; i < n; i = i + 1) {
            a[i] = i + 1;
        }
        for (i = 0; i < n; i = i + 1) {
            swap(a, i, (int) getNextX() % (i + 1));
        }
        for (i = 0; i < n; i = i + 1) {
            if (i < d)
                b[i] = 1;
            else
                b[i] = 0;
        }
        for (i = 0; i < n; i = i + 1) {
            swap(b, i, (int) getNextX() % (i + 1));
        }
    }

    static void swap(int[] arr, int i, int j) {
        int tmp = arr[i];
        arr[i] = arr[j];
        arr[j] = tmp;
    }

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        PrintWriter out = new PrintWriter(new BufferedWriter(
                new OutputStreamWriter(System.out)));
        n = sc.nextInt();
        d = sc.nextInt();
        x = sc.nextLong();
        a = new int[n];
        b = new int[n];
        initAB();
        List<Integer> b1 = new ArrayList<Integer>();
        if (d < 1000) {
            for (int i = 0; i < n; ++i) {
                int c = 0;
                if (b[i] == 1)
                    b1.add(i);
                for (int j = 0; j < b1.size(); ++j) {
                    c = Math.max(c, a[i - b1.get(j)]);
                }
                out.println(c);
            }
        } else {
            int[] arr = new int[n + 1];
            for (int i = 0; i < n; ++i)
                arr[a[i]] = i;
            TreeSet<Integer> set = new TreeSet<Integer>();
            label: for (int i = 0; i < n; ++i) {
                set.add(-a[i]);
                for (int k : set) {
                    int j = arr[-k];
                    if (b[i - j] == 1) {
                        out.println(-k);
                        continue label;
                    }
                }
                out.println(0);
            }
        }
        out.flush();
    }

    public static void debug(Object... o) {
        System.out.println(Arrays.deepToString(o));
    }
}

import java.io.*;
import java.util.*;

public class Main {

	public static class pair implements Comparable<pair>
	{
		int a;
		int b;
		public pair(int pa, int pb)
		{
			a = pa; b= pb;
		}
		@Override
		public int compareTo(pair o) {
			if(this.a < o.a)
				return -1;
			if(this.a > o.a)
				return 1;
			return Integer.compare(o.b, this.b);
		}
	}

	//int n = Integer.parseInt(in.readLine());
	//String[] spl = in.readLine().split(" ");

	public static long x;
	public static int n,d;
	public static int[] a, b;

	public static long getNextX() {
		x = (x * 37 + 10007) % 1000000007;
		return x;
	}
	public static void initAB() {
		for(int i = 0; i < n; i = i + 1){
			a[i] = i + 1;
		}
		for(int i = 0; i < n; i = i + 1){
			int nxt = (int)(getNextX() % (i + 1));
			int tmp = a[i];
			a[i] = a[nxt];
			a[nxt] = tmp;
		}
		for(int i = 0; i < n; i = i + 1){
			if (i < d)
				b[i] = 1;
			else
				b[i] = 0;
		}
		for(int i = 0; i < n; i = i + 1){
			int nxt = (int)(getNextX() % (i + 1));
			int tmp = b[i];
			b[i] = b[nxt];
			b[nxt] = tmp;
		}
	}

	public static void main (String[] args) throws Exception
	{
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		String[] spl = in.readLine().split(" ");
		n = Integer.parseInt(spl[0]);
		d = Integer.parseInt(spl[1]);
		x = Integer.parseInt(spl[2]);
		a = new int[n];
		b = new int[n];
		initAB();
		int s = 100;
		int[] pos = new int[n+5];
		int[] bb = new int[n+5];
		for (int i = 0; i < n; i++) {
			pos[a[i]] = i;
		}
		int idx = 0;
		for (int i = 0; i < n; i++) {
			if(b[i]==1)
				bb[idx++] = i;
		}
		a: for (int i = 0; i < n; i++) {
			for (int j = n; j >= n-s && j>=0; j--) {
				if(pos[j] <= i && b[i-pos[j]]==1)
				{
					System.out.println(j);
					continue a;
				}
			}
			int max = 0;
			int j = 0;
			while(bb[j] <=i && j<idx)
			{
				max = Math.max(max, a[i-bb[j]]);
				j++;
			}
			System.out.println(max);
		}
	}
}

import java.util.*;
import java.io.*;

public class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		PrintWriter out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));
		int n = in.nextInt();
		int d = in.nextInt();
		long x = in.nextInt();

		int[] a = new int[n];
		for (int i = 0; i < n; i++) {
			a[i] = i + 1;
		}
		for (int i = 0; i < n; i++) {
			x = (x * 37 + 10007) % 1000000007;
			swap(a, i, (int)x % (i + 1));
		}
		int[] b = new int[n];
		Arrays.fill(b, 0, d, 1);
		for (int i = 0; i < n; i++) {
			x = (x * 37 + 10007) % 1000000007;
			swap(b, i, (int)x % (i + 1));
		}

		if (d < 1000) {
			int _k = 0;
			int[] arr = new int[d];
			for (int i = 0; i < n; i++) {
				if (b[i] == 1) {
					arr[_k++] = i;
				}
			}
			for (int i = 0; i < n; i++) {
				int max = 0;
				for (int k = 0; k < d && arr[k] <= i; k++) {
					int j = arr[k];
					max = Math.max(max, a[i - j]);
				}
				out.println(max);
			}
		}
		else {
			int[] arr = new int[n + 1];
			for (int i = 0; i < n; i++) {
				arr[a[i]] = i;
			}
			TreeSet<Integer> set = new TreeSet<Integer>();
			label:
			for (int i = 0; i < n; i++) {
				set.add(-a[i]);
				for (int k: set) {
					int j = arr[-k];
					if (b[i - j] == 1) {
						out.println(-k);
						continue label;
					}
				}
				out.println(0);
			}
		}
		out.flush();
	}

	static void swap(int[] a, int i, int j) {
		int tmp = a[i];
		a[i] = a[j];
		a[j] = tmp;
	}
}

import java.io.*;
import java.util.*;

public class CF {
	FastScanner in;
	PrintWriter out;

	long x;

	final int LOG = 6;
	final int DIV = 1 << LOG;
	final int DIVM1 = DIV - 1;

	long getNextX() {
		x = (x * 37 + 10007) % 1000000007;
		return x;
	}

	int n;
	int[] a;
	int[] b;
	int d;

	void swap(int[] a, int p1, int p2) {
		int v1 = a[p1];
		a[p1] = a[p2];
		a[p2] = v1;
	}

	void initAB() {
		for (int i = 0; i < n; i = i + 1) {
			a[i] = i + 1;
		}
		for (int i = 0; i < n; i = i + 1) {
			swap(a, i, (int) (getNextX() % (i + 1)));
		}
		for (int i = 0; i < n; i = i + 1) {
			if (i < d)
				b[i] = 1;
			else
				b[i] = 0;
		}
		for (int i = 0; i < n; i = i + 1) {
			swap(b, i, (int) (getNextX() % (i + 1)));
		}
	}

	class MBitSet {
		long[] vals;
		int n;

		MBitSet(int[] a, int shift) {
			n = 1 + a.length / DIV + 1;
			vals = new long[n];
			for (int i = 0; i < a.length; i++)
				if (a[i] == 1) {
					int pos = i + shift;
					vals[pos >> LOG] |= 1L << (pos & DIVM1);
				}
		}

		MBitSet(MBitSet an) {
			this.n = an.n;
			this.vals = new long[this.n];
			for (int i = 0; i < n; i++) {
				vals[i] = an.vals[i];
			}
		}

		void shift(int f) {
			for (int i = n - 1; i >= 0; i--) {
				if (i - f >= 0) {
					vals[i] = vals[i - f];
				} else {
					vals[i] = 0;
				}
			}
		}

		MBitSet(int n) {
			this.n = 1 + n / 64 + 1;
			vals = new long[this.n];
		}

		void set(int pos) {
			vals[pos >> LOG] ^= 1L << (pos & DIVM1);
		}

	}

	void solve() {
		long st = System.currentTimeMillis();
		n = in.nextInt();
		d = in.nextInt();
		x = in.nextInt();
		int[] c = new int[n];
		a = new int[n];
		b = new int[n];
		initAB();
		int[] pos = new int[n];
		for (int i = 0; i < n; i++) {
			pos[a[i] - 1] = i;
		}
		MBitSet[] bs = new MBitSet[64];
		for (int i = 0; i < DIV; i++)
			bs[i] = new MBitSet(b, i);
		MBitSet curNotSet = new MBitSet(n);
		for (int i = 0; i < n; i++)
			curNotSet.set(i);
		for (int i = n - 1; i >= 0; i--) {
			int p = pos[i];
			int start = p / DIV;
			int xx = p & DIVM1;
			for (int j = start; j < curNotSet.n; j++) {
				long tt = curNotSet.vals[j] & (bs[xx].vals[j - start]);
				while (tt != 0) {
					int v = Long.numberOfTrailingZeros(tt);
					int posit = j * DIV + v;
					c[posit] = i + 1;
					curNotSet.set(posit);
					tt ^= 1L << v;
				}
			}

		}
		for (int i = 0; i < n; i++) {
			 out.println(c[i]);
		}
		System.err.println(System.currentTimeMillis() - st);
//		System.err.println(z);
	}

	void run() {
		try {
			in = new FastScanner(new File("CF.in"));
			out = new PrintWriter(new File("CF.out"));

			solve();

			out.close();
		} catch (FileNotFoundException e) {
			e.printStackTrace();
		}
	}

	void runIO() {

		in = new FastScanner(System.in);
		out = new PrintWriter(System.out);

		solve();

		out.close();
	}

	class FastScanner {
		BufferedReader br;
		StringTokenizer st;

		public FastScanner(File f) {
			try {
				br = new BufferedReader(new FileReader(f));
			} catch (FileNotFoundException e) {
				e.printStackTrace();
			}
		}

		public FastScanner(InputStream f) {
			br = new BufferedReader(new InputStreamReader(f));
		}

		String next() {
			while (st == null || !st.hasMoreTokens()) {
				String s = null;
				try {
					s = br.readLine();
				} catch (IOException e) {
					e.printStackTrace();
				}
				if (s == null)
					return null;
				st = new StringTokenizer(s);
			}
			return st.nextToken();
		}

		boolean hasMoreTokens() {
			while (st == null || !st.hasMoreTokens()) {
				String s = null;
				try {
					s = br.readLine();
				} catch (IOException e) {
					e.printStackTrace();
				}
				if (s == null)
					return false;
				st = new StringTokenizer(s);
			}
			return true;
		}

		int nextInt() {
			return Integer.parseInt(next());
		}

		long nextLong() {
			return Long.parseLong(next());
		}

		double nextDouble() {
			return Double.parseDouble(next());
		}
	}

	public static void main(String[] args) {
		new CF().runIO();
	}
}

import java.io.BufferedWriter;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;
import java.util.TreeSet;

public class Snippet {
    static long x;
    static int n, d;
    static int[] a;
    static int[] b;
    static long  getNextX() {
        x = (x * 37 + 10007) % 1000000007;
        return x;
    }
    static void  initAB() {
        int i;
        for(i = 0; i < n; i = i + 1){
            a[i] = i+1;
        }
        for(i = 0; i < n; i = i + 1){
            swap(a, i,  (int)getNextX() % (i + 1) );
        }
        for(i = 0; i < n; i = i + 1){
            if (i < d)
                b[i] = 1;
            else
                b[i] = 0;
        }
        for(i = 0; i < n; i = i + 1){
            swap(b, i,  (int)getNextX() % (i + 1) );
        }
    }
    static void  swap(int[] arr, int i, int j) {
        int tmp = arr[i];
        arr[i] = arr[j];
        arr[j] = tmp;
    }
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        PrintWriter out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));
        n = sc.nextInt();
        d = sc.nextInt();
        x = sc.nextLong();

        a = new int[n];
        b = new int[n];
        initAB();

        List<Integer> b1 = new ArrayList<Integer>();
        if (d < 1000) {
            for (int i =0; i < n; ++i) {
                int c = 0;
                if (b[i] == 1) b1.add(i);
                for (int j = 0;  j < b1.size(); ++j) {
                    c = Math.max(c, a[i - b1.get(j)]);
                }
                out.println(c);
            }
        } else {
            int[] arr = new int[n + 1];
            for (int i = 0; i < n; ++i) arr[a[i]] = i;
            TreeSet<Integer> set = new TreeSet<Integer>();
            label:
                for (int i = 0; i < n; ++i) {
                    set.add(-a[i]);
                    for (int k : set) {
                        int j = arr[-k];
                        if (b[i - j] == 1) {
                            out.println(-k);
                            continue label;
                        }
                    }
                    out.println(0);
                }
        }

    }
    public static void debug(Object... o) {
        System.out.println(Arrays.deepToString(o));
    }
}

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

import java.io.BufferedWriter;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.Scanner;
import java.util.TreeSet;

/**
 *
 * @author Darkhan
 */
public class task4 {
    static int[] a, b, ar;
    static int n, d;
    static long x;
    static ArrayList<Integer> bset = new ArrayList<>();
    static TreeSet<Integer> aset = new TreeSet<>();
    public static void main (String[] args){
        Scanner in = new Scanner(System.in);
        PrintWriter out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));
        n = in.nextInt();
        d = in.nextInt();
        x = in.nextLong();
        a = new int[n];
        b = new int[n];
        ar = new int[n+1];
        initAB();
        Iterator<Integer> it;
        long t;
        if (d < 3000){
            for (int i=0;i<n;i++){
                if (b[i] == 1) bset.add(i);
                t = 0;
                for (Integer bset1 : bset) {
                    t = Math.max(t, a[i - bset1]);
                }
                out.println(t);
            }
        }
        else{
            int val;
            for (int i=0;i<n;i++){
                t = 0;
                aset.add(a[i]);
                it = aset.descendingIterator();
                while(it.hasNext()){
                    val = it.next();
                    if (b[i-ar[val]] == 0) continue;
                    t = val;
                    break;
                }
                out.println(t);
            }
        }
    }
    public static long getNextX() {
        x = (x * 37 + 10007) % 1000000007;
        return x;
    }
    public static void initAB() {
        for(int i = 0; i < n; i = i + 1){
            a[i] = i + 1;
            ar[i+1] = i;
        }
        for(int i = 0; i < n; i = i + 1){
            int t = (int)(getNextX() % (i + 1));
            ar[a[i]] = t;
            ar[a[t]] = i;
            swap(a, i, t);
        }
        for(int i = 0; i < n; i = i + 1){
            if (i < d)
                b[i] = 1;
            else
                b[i] = 0;
        }
        for(int i = 0; i < n; i = i + 1){
            swap(b, i, (int)(getNextX() % (i + 1)));
        }
    }
    public static void swap(int[] a, int i, int j){
        int t = a[i];
        a[i] = a[j];
        a[j] = t;
    }
}

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

import java.util.Scanner;

/**
 *
 * @author Darkhan
 */
public class task4 {
    static int[] a, b, br = new int[100000];
    static int n, d;
    static long x;
    public static void main (String[] args){
        Scanner in = new Scanner(System.in);
        n = in.nextInt();
        d = in.nextInt();
        x = in.nextLong();
        a = new int[n];
        b = new int[n];
        initAB();
        long t;
        for (int i=0;i<n;i++){
            t = 0;
            for (int j=1;j<=br[0];j++){
                if (br[j] > i) break;
                t = Math.max(t, a[i-br[j]]);
            }
            System.out.println(t);
        }
    }
    public static long getNextX() {
        x = (x * 37 + 10007) % 1000000007;
        return x;
    }
    public static void initAB() {
        for(int i = 0; i < n; i = i + 1){
            a[i] = i + 1;
        }
        for(int i = 0; i < n; i = i + 1){
            swap(a, i, (int)(getNextX() % (i + 1)));
        }
        for(int i = 0; i < n; i = i + 1){
            if (i < d){
                b[i] = 1;
                br[++br[0]] = i;
            }
            else
                b[i] = 0;
        }
        for(int i = 0; i < n; i = i + 1){
            swap(b, i, (int)(getNextX() % (i + 1)));
        }
    }
    public static void swap(int[] a, int i, int j){
        int t = a[i];
        a[i] = a[j];
        a[j] = t;
    }
}

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

import java.util.Scanner;

/**
 *
 * @author Darkhan
 */
public class task4 {
    static int[] a, b, ar = new int[100001], br = new int[100001];
    static int n, d;
    static long x;
    public static void main (String[] args){
        Scanner in = new Scanner(System.in);
        n = in.nextInt();
        d = in.nextInt();
        x = in.nextLong();
        a = new int[n];
        b = new int[n];
        initAB();
        long t;
        int j;
        boolean bo;
//        System.out.println("\nA:");
//        for (int i=0;i<n;i++)
//            System.out.print(a[i]+" ");
//        System.out.println("\nAR:");
//        for (int i=0;i<=n;i++)
//            System.out.print(ar[i]+" ");
//        System.out.println("\nB:");
//        for (int i=0;i<n;i++)
//            System.out.print(b[i]+" ");
//        System.out.println("\nBR:");
//        for (int i=0;i<=n;i++)
//            System.out.print(br[i]+" ");
//        System.out.println("");
        for (int i=0;i<n;i++){
            bo = false;
            for (j=n;j>=n-30 && j>0 && n-30>0;j--){
                if (ar[j] <= i && br[i-ar[j]] == 1){
                    System.out.println(j);
                    bo = true;
                    break;
                }
            }
            if (bo) continue;
            t = 0;
            for (j=1;j<=br[0];j++){
                if (br[j] > i) break;
                t = Math.max(t, a[i-br[j]]);
            }
            System.out.println(t);
        }
    }
    public static long getNextX() {
        x = (x * 37 + 10007) % 1000000007;
        return x;
    }
    public static void initAB() {
        for(int i = 0; i < n; i = i + 1){
            a[i] = i + 1;
            ar[i+1] = i;
        }
        for(int i = 0; i < n; i = i + 1){
            int t = (int)(getNextX() % (i + 1));
            ar[a[i]] = t;
            ar[a[t]] = i;
            swap(a, i, t);
        }
        for(int i = 0; i < n; i = i + 1){
            if (i < d)
                b[i] = 1;
            else
                b[i] = 0;
        }
        for(int i = 0; i < n; i = i + 1){
            swap(b, i, (int)(getNextX() % (i + 1)));
        }
        for(int i = 0; i < n; i = i + 1){
            if (b[i] == 1)  br[++br[0]] = i;
        }
    }
    public static void swap(int[] a, int i, int j){
        int t = a[i];
        a[i] = a[j];
        a[j] = t;
    }
}

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Scanner;
import java.util.StringTokenizer;

public class a {
	static int z = 7000;
	public static void main(String[] args) throws IOException {
		FastScanner in = new FastScanner(System.in);
		PrintWriter out = new PrintWriter(System.out);
		n = in.nextInt();
		d = in.nextInt();
		x = in.nextLong();
		a = new int[n];
		b = new int[n];
		initAB();
		int[] map = new int[n];
		for(int i=0;i<n;i++)
			map[a[i]-1] = i;
		ArrayList<Integer> bs = new ArrayList<>();
		for(int i=0;i<n;i++) {
			if(b[i] == 1)
				bs.add(i);
		}
		outer: for(int i=0;i<n;i++) {
			if(d < 300) {
				int max = 0;
				for(int b : bs) {
					int ai = i - b;
					if(ai < 0) continue;
					max = Math.max(max, a[ai]);
				}
				out.println(max);
			}
			for(int k=n-1;k>=n-z && k >= 0;k--) {
				int aidx = map[k];
				int bidx = i - aidx;
				if(bidx >= 0 && b[bidx] == 1) {
					out.println(k+1);
					continue outer;
				}
			}
			int max = 0;
			for(int ai=0, bi=i;bi>=0;ai++, bi--) {
				max = Math.max(max, a[ai] * b[bi]);
			}
			out.println(max);
		}
		out.close();
	}
	static long getNextX() {
	    x = (x * 37 + 10007) % 1000000007;
	    return x;
	}
	static int[] a,b;
	static int n, d;
	static long x;
	static void initAB() {
	    for(int i = 0; i < n; i = i + 1){
	        a[i] = i + 1;
	    }
	    for(int i = 0; i < n; i = i + 1){
	    	int tmp = a[i];
	    	int idx = (int) (getNextX() % (i + 1));
	    	a[i] = a[idx];
	    	a[idx] = tmp;
	    }
	    for(int i = 0; i < n; i = i + 1){
	        if (i < d)
	            b[i] = 1;
	        else
	            b[i] = 0;
	    }
	    for(int i = 0; i < n; i = i + 1){
	    	int tmp = b[i];
	    	int idx = (int) (getNextX() % (i + 1));
	    	b[i] = b[idx];
	    	b[idx] = tmp;
	    }
	}

	static class FastScanner {
		BufferedReader br;
		StringTokenizer st;

		public FastScanner(InputStream i) {
			br = new BufferedReader(new InputStreamReader(i));
			st = null;
		}

		public String next() throws IOException {
			while (st == null || !st.hasMoreTokens())
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}

		public String nextLine() throws IOException {
			if (st == null) {
				st = new StringTokenizer(br.readLine());
			}
			String line = st.nextToken("\n");
			st = null;
			return line;
		}

		public int nextInt() throws IOException {
			return Integer.parseInt(next());
		}

		public long nextLong() throws IOException {
			return Long.parseLong(next());
		}

		public double nextDouble() throws IOException {
			return Double.parseDouble(next());
		}
	}
}

import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        BDZYLovesFFT solver = new BDZYLovesFFT();
        solver.solve(1, in, out);
        out.close();
    }

    static class BDZYLovesFFT {
        int n;
        int d;
        long x;
        int[] a;
        int[] b;

        public void solve(int testNumber, InputReader in, PrintWriter out) {
            n = in.readInt();
            d = in.readInt();
            x = in.readLong();
            a = new int[n];
            b = new int[n];
            initAB();
            int s = 50;
            int[] idx = new int[n + 1];
            for (int i = 0; i < n; i++) idx[a[i]] = i;

            int[] q = new int[n];
            int t = 0;
            for (int i = 0; i < n; i++) if (b[i] == 1) q[t++] = i;

            int[] c = new int[n];
            Arrays.fill(c, -1);
            c[0] = a[0] * b[0];
            for (int i = 1; i < n; i++) {
                for (int j = 0; j < s; j++) {
                    if (n - j >= 0 && idx[n - j] <= i && b[i - idx[n - j]] == 1) {
                        c[i] = n - j;
                        break;
                    }
                }
                if (c[i] < 0) {
                    c[i] = 0;
                    for (int j = 0; j < t && q[j] <= i; j++) {
                        c[i] = Math.max(c[i], a[q[j]] * b[i - q[j]]);
                    }
                }
            }
            for (int i : c) out.println(i);

        }

        int getNextX() {
            x = (x * 37 + 10007) % 1000000007;
            return (int) x;
        }

        void initAB() {
            for (int i = 0; i < n; i = i + 1) {
                a[i] = i + 1;
            }
            for (int i = 0; i < n; i = i + 1) {
                int t = a[i];
                int v = getNextX() % (i + 1);
                a[i] = a[v];
                a[v] = t;
            }
            for (int i = 0; i < n; i = i + 1) {
                if (i < d)
                    b[i] = 1;
                else
                    b[i] = 0;
            }
            for (int i = 0; i < n; i = i + 1) {
                int v = getNextX() % (i + 1);
                int t = b[i];
                b[i] = b[v];
                b[v] = t;
            }
        }

    }

    static class InputReader {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;
        private InputReader.SpaceCharFilter filter;

        public InputReader(InputStream stream) {
            this.stream = stream;
        }

        public int read() {
            if (numChars == -1)
                throw new InputMismatchException();
            if (curChar >= numChars) {
                curChar = 0;
                try {
                    numChars = stream.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
                if (numChars <= 0)
                    return -1;
            }
            return buf[curChar++];
        }

        public int readInt() {
            int c = read();
            while (isSpaceChar(c))
                c = read();
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = read();
            }
            int res = 0;
            do {
                if (c < '0' || c > '9')
                    throw new InputMismatchException();
                res *= 10;
                res += c - '0';
                c = read();
            } while (!isSpaceChar(c));
            return res * sgn;
        }

        public long readLong() {
            int c = read();
            while (isSpaceChar(c))
                c = read();
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = read();
            }
            long res = 0;
            do {
                if (c < '0' || c > '9')
                    throw new InputMismatchException();
                res *= 10;
                res += c - '0';
                c = read();
            } while (!isSpaceChar(c));
            return res * sgn;
        }

        public boolean isSpaceChar(int c) {
            if (filter != null)
                return filter.isSpaceChar(c);
            return isWhitespace(c);
        }

        public static boolean isWhitespace(int c) {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        public interface SpaceCharFilter {
            public boolean isSpaceChar(int ch);

        }

    }
}

import java.util.List;
import java.util.LinkedList;
import java.util.Scanner;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.io.IOException;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
	public static void main(String[] args) {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		Scanner in = new Scanner(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		TaskD solver = new TaskD();
		solver.solve(1, in, out);
		out.close();
	}
}

class TaskD {
    int n, d;
    long x;
    //x is 64-bit variable;
    private long getNextX() {
        x = (x * 37 + 10007) % 1000000007;
        return x;
    }

    private void initAB(int[] a, int[] b) {
        for (int i = 0; i < n; i = i + 1) {
            a[i] = i + 1;
        }
        for (int i = 0; i < n; i = i + 1) {
            int tmp = a[i];
            int j = (int)(getNextX() % (i + 1));
            a[i] = a[j];
            a[j] = tmp;
        }
        for (int i = 0; i < n; i = i + 1) {
            if (i < d)
                b[i] = 1;
            else
                b[i] = 0;
        }
        for (int i = 0; i < n; i = i + 1) {
            int tmp = b[i];
            int j = (int)(getNextX() % (i + 1));
            b[i] = b[j];
            b[j] = tmp;
        }
    }
    public void solve(int testNumber, Scanner in, PrintWriter out) {
        n = in.nextInt();
        d = in.nextInt();
        x = in.nextLong();

        int[] a = new int[n];
        int[] b = new int[n];
        initAB(a, b);

        final int threshold = 1000;
        if (d < threshold)
            solveSmallD(out, a, b);
        else
            solveLargeD(out, a, b, threshold);

    }

    private void solveSmallD(PrintWriter out, int[] a, int[] b) {
        List<Integer> bi = new LinkedList<>();
        for (int i = 0; i < n; i++)
            if (b[i] == 1)
                bi.add(i);

        for (int i = 0; i < n; i++) {
            int res = 0;
            for (int j = 0; j < bi.size(); j++)
                if (bi.get(j) <= i)
                    res = Math.max(res, a[i - bi.get(j)]);
            out.write(res + "\n");
        }
    }

    private void solveLargeD(PrintWriter out, int[] a, int[] b, int threshold) {
        int[] ai = new int[n + 1];
        for (int i = 0; i < n; i++)
            ai[a[i]] = i;

        for (int i = 0; i < n; i++) {
            boolean ok = false;
            for (int v = n; v >= n - threshold; v--) {
                if (ai[v] <= i && b[i - ai[v]] == 1) {
                    out.write(v + "\n");
                    ok = true;
                    break;
                }
            }
            if (!ok) assert false;
        }
    }
}

import java.io.InputStreamReader;
import java.io.IOException;
import java.util.PriorityQueue;
import java.io.BufferedReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
	public static void main(String[] args) {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		FastScanner in = new FastScanner(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		TaskB solver = new TaskB();
		solver.solve(1, in, out);
		out.close();
	}
}

class TaskB {
	public void solve(int testNumber, FastScanner in, PrintWriter out) {
		n = in.nextInt();
		d = in.nextInt();
		x = in.nextLong();
		initAB();
		int[] pos = new int[n + 1];
		for (int i = 0; i < n; i++) {
			pos[a[i]] = i;
		}
		int[] x = new int[d];
		d = 0;
		for (int i = 0; i < n; i++) {
			if (b[i] == 1) {
				x[d++] = i;
			}
		}
		int sq = 1;
		while (sq*sq <= n) {
			++sq;
		}
		int[] c = new int[n];
		if (d < sq) {
			int left = n;
			for (int val = n; val >= 1; val--) {
				int i = pos[val];
				for (int j = 0; j < d; j++) {
					int k = x[j] + i;
					if (k >= n) {
						break;
					}
					if (c[k] == 0) {
						--left;
						c[k] = val;
					}
					if (left == 0) {
						break;
					}
				}
				if (left == 0) {
					break;
				}
			}
		} else {
			PriorityQueue<Item> pq = new PriorityQueue<Item>();
			for (int i = 0; i < n; i++) {
				pq.offer(new Item(a[i], i));
				for (Item it : pq) {
					if (b[i - it.pos] == 1) {
						c[i] = it.val;
						break;
					}
				}
			}
		}
		for (int i = 0; i < n; i++) {
			out.println(c[i]);
		}
	}

	int n, d;
	long x;
	int[] a, b;

	long getNextX() {
		x = (x * 37 + 10007) % 1000000007;
		return x;
	}

	void initAB() {
		a = new int[n];
		b = new int[n];
		for (int i = 0; i < n; i++) {
			a[i] = i + 1;
		}
		for (int i = 0; i < n; i++) {
			int j = (int)(getNextX() % (i + 1));
			int t = a[i];
			a[i] = a[j];
			a[j] = t;
		}
		for (int i = 0; i < n; i++) {
			if (i < d) {
				b[i] = 1;
			} else {
				b[i] = 0;
			}
		}
		for (int i = 0; i < n; i++) {
			int j = (int)(getNextX() % (i + 1));
			int t = b[i];
			b[i] = b[j];
			b[j] = t;
		}
	}

	class Item implements Comparable<Item> {
		int val;
		int pos;
		Item(int val, int pos) {
			this.val = val;
			this.pos = pos;
		}
		public int compareTo(Item o) {
			return o.val - val;
		}
	}
}

class FastScanner {

	private BufferedReader in;
	private StringTokenizer st;

	public FastScanner(InputStream stream) {
		in = new BufferedReader(new InputStreamReader(stream));
	}

	public String next() {
		while (st == null || !st.hasMoreTokens()) {
			try {
				st = new StringTokenizer(in.readLine());
			} catch (IOException e) {
				throw new RuntimeException(e);
			}
		}
		return st.nextToken();
	}

	public int nextInt() {
		return Integer.parseInt(next());
	}

	public long nextLong() {
		return Long.parseLong(next());
	}

}

import java.util.List;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.PriorityQueue;
import java.util.ArrayList;
import java.io.PrintStream;
import java.io.BufferedReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.util.AbstractCollection;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
	public static void main(String[] args) {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		FastScanner in = new FastScanner(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		TaskB solver = new TaskB();
		solver.solve(1, in, out);
		out.close();
	}
}

class TaskB {
	public void solve(int testNumber, FastScanner in, PrintWriter out) {
		n = in.nextInt();
		d = in.nextInt();
		x = in.nextLong();
		initAB();
		int sq = 1;
		while (sq*sq <= n) {
			++sq;
		}
		int[] c = new int[n];
		if (d < sq) {
			int[] pos = new int[n + 1];
			for (int i = 0; i < n; i++) {
				pos[a[i]] = i;
			}
			int[] x = new int[d];
			d = 0;
			for (int i = 0; i < n; i++) {
				if (b[i] == 1) {
					x[d++] = i;
				}
			}
			int left = n;
			for (int val = n; val >= 1; val--) {
				int i = pos[val];
				for (int j = 0; j < d; j++) {
					int k = x[j] + i;
					if (k >= n) {
						break;
					}
					if (c[k] == 0) {
						--left;
						c[k] = val;
					}
					if (left == 0) {
						break;
					}
				}
				if (left == 0) {
					break;
				}
			}
		} else {
			PriorityQueue<Item> pq = new PriorityQueue<Item>();
			System.out.println(Arrays.toString(a));
			for (int i = 0; i < n; i++) {
				pq.offer(new Item(a[i], i));
				List<Item> list = new ArrayList<Item>();
				while (!pq.isEmpty()) {
					Item it = pq.poll();
					list.add(it);
					if (b[i - it.pos] == 1) {
						c[i] = it.val;
						break;
					}
				}
				for (Item it : list) {
					pq.offer(it);
				}
			}
		}
		for (int i = 0; i < n; i++) {
			out.println(c[i]);
		}
	}

	int n, d;
	long x;
	int[] a, b;

	long getNextX() {
		x = (x * 37 + 10007) % 1000000007;
		return x;
	}

	void initAB() {
		a = new int[n];
		b = new int[n];
		for (int i = 0; i < n; i++) {
			a[i] = i + 1;
		}
		for (int i = 0; i < n; i++) {
			int j = (int)(getNextX() % (i + 1));
			int t = a[i];
			a[i] = a[j];
			a[j] = t;
		}
		for (int i = 0; i < n; i++) {
			if (i < d) {
				b[i] = 1;
			} else {
				b[i] = 0;
			}
		}
		for (int i = 0; i < n; i++) {
			int j = (int)(getNextX() % (i + 1));
			int t = b[i];
			b[i] = b[j];
			b[j] = t;
		}
	}

	class Item implements Comparable<Item> {
		int val;
		int pos;
		Item(int val, int pos) {
			this.val = val;
			this.pos = pos;
		}
		public int compareTo(Item o) {
			return o.val - val;
		}
	}
}

class FastScanner {

	private BufferedReader in;
	private StringTokenizer st;

	public FastScanner(InputStream stream) {
		in = new BufferedReader(new InputStreamReader(stream));
	}

	public String next() {
		while (st == null || !st.hasMoreTokens()) {
			try {
				st = new StringTokenizer(in.readLine());
			} catch (IOException e) {
				throw new RuntimeException(e);
			}
		}
		return st.nextToken();
	}

	public int nextInt() {
		return Integer.parseInt(next());
	}

	public long nextLong() {
		return Long.parseLong(next());
	}

}

import java.io.*;
import java.util.*;

public class CF {
	FastScanner in;
	PrintWriter out;

	long x;

	long getNextX() {
		x = (x * 37 + 10007) % 1000000007;
		return x;
	}

	int n;
	int[] a;
	int[] b;
	int d;

	void swap(int[] a, int p1, int p2) {
		int v1 = a[p1];
		a[p1] = a[p2];
		a[p2] = v1;
	}

	void initAB() {
		for (int i = 0; i < n; i = i + 1) {
			a[i] = i + 1;
		}
		for (int i = 0; i < n; i = i + 1) {
			swap(a, i, (int) (getNextX() % (i + 1)));
		}
		for (int i = 0; i < n; i = i + 1) {
			if (i < d)
				b[i] = 1;
			else
				b[i] = 0;
		}
		for (int i = 0; i < n; i = i + 1) {
			swap(b, i, (int) (getNextX() % (i + 1)));
		}
	}

	class MBitSet {
		long[] vals;
		int n;

		MBitSet(int[] a, int go) {
			n = 1 + a.length / 64 + 1;
			vals = new long[n];
			for (int i = 0; i < a.length; i++)
				if (a[i] == 1) {
					int pos = i + go;
					vals[pos >> 6] |= 1 << (pos & 63);
				}
		}

		MBitSet(MBitSet an) {
			this.n = an.n;
			this.vals = new long[this.n];
			for (int i = 0; i < n; i++) {
				vals[i] = an.vals[i];
			}
		}

		void shift(int f) {
			for (int i = n - 1; i >= 0; i--) {
				if (i - f >= 0) {
					vals[i] = vals[i - f];
				} else {
					vals[i] = 0;
				}
			}
		}

		void update(MBitSet x) {
			for (int i = 0; i < x.n; i++) {
				vals[i] = x.vals[i];
			}
		}

		MBitSet(int n) {
			this.n = 1 + n / 64 + 1;
			vals = new long[this.n];
		}

		void and(MBitSet another) {
			for (int i = 0; i < Math.min(n, another.n); i++) {
				vals[i] &= another.vals[i];
			}
		}

		void set(int pos) {
			vals[pos >> 6] ^= 1 << (pos & 63);
		}

	}

	void solve() {
		long st = System.currentTimeMillis();
		n = in.nextInt();
		d = in.nextInt();
		x = in.nextInt();
		int[] c = new int[n];
		a = new int[n];
		b = new int[n];
		initAB();
		int[] pos = new int[n];
		for (int i = 0; i < n; i++) {
			pos[a[i] - 1] = i;
		}
		MBitSet[] bs = new MBitSet[64];
		for (int i = 0; i < 64; i++)
			bs[i] = new MBitSet(b, i);
		MBitSet curNotSet = new MBitSet(n);
		for (int i = 0; i < n; i++)
			curNotSet.set(i);
		for (int i = n - 1; i >= 0; i--) {
			int p = pos[i];
			int start = p / 64;
			int xx = p & 63;
			for (int j = start; j < curNotSet.n; j++) {
				long tt = curNotSet.vals[j] & (bs[xx].vals[j - start]);

				while (tt != 0) {
					int v = Long.numberOfTrailingZeros(tt);
					int posit = j * 64 + v;
					c[posit] = i + 1;
					curNotSet.set(posit);
					tt ^= 1 << v;
				}
			}

		}
		for (int i = 0; i < n; i++) {
			 out.println(c[i]);
		}
		System.err.println(System.currentTimeMillis() - st);
//		System.err.println(z);
	}

	void run() {
		try {
			in = new FastScanner(new File("CF.in"));
			out = new PrintWriter(new File("CF.out"));

			solve();

			out.close();
		} catch (FileNotFoundException e) {
			e.printStackTrace();
		}
	}

	void runIO() {

		in = new FastScanner(System.in);
		out = new PrintWriter(System.out);

		solve();

		out.close();
	}

	class FastScanner {
		BufferedReader br;
		StringTokenizer st;

		public FastScanner(File f) {
			try {
				br = new BufferedReader(new FileReader(f));
			} catch (FileNotFoundException e) {
				e.printStackTrace();
			}
		}

		public FastScanner(InputStream f) {
			br = new BufferedReader(new InputStreamReader(f));
		}

		String next() {
			while (st == null || !st.hasMoreTokens()) {
				String s = null;
				try {
					s = br.readLine();
				} catch (IOException e) {
					e.printStackTrace();
				}
				if (s == null)
					return null;
				st = new StringTokenizer(s);
			}
			return st.nextToken();
		}

		boolean hasMoreTokens() {
			while (st == null || !st.hasMoreTokens()) {
				String s = null;
				try {
					s = br.readLine();
				} catch (IOException e) {
					e.printStackTrace();
				}
				if (s == null)
					return false;
				st = new StringTokenizer(s);
			}
			return true;
		}

		int nextInt() {
			return Integer.parseInt(next());
		}

		long nextLong() {
			return Long.parseLong(next());
		}

		double nextDouble() {
			return Double.parseDouble(next());
		}
	}

	public static void main(String[] args) {
		new CF().runIO();
	}
}

import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Collections;
import java.util.StringTokenizer;

public class B {

    static StringTokenizer st;
    static BufferedReader br;
    static PrintWriter pw;
    static long x;
    public static void main(String[] args) throws IOException {
        br = new BufferedReader(new InputStreamReader(System.in));
        pw = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));
        int n = nextInt();
        int d = nextInt();
        x = nextInt();
        long[]a = new long[n], b = new long[n];
        for (int i = 0; i < n; i++) {
            a[i] = i+1;
        }
        for (int i = 0; i < n; i++) {
            int id = (int) (getNext() % (i+1));
            long t = a[i];
            a[i] = a[id];
            a[id] = t;
        }
        for(int i = 0; i < n; i++){
            if (i < d)
                b[i] = 1;
            else
                b[i] = 0;
        }
        for (int i = 0; i < n; i++) {
            int id = (int) (getNext() % (i+1));
            long t = b[i];
            b[i] = b[id];
            b[id] = t;
        }
        ArrayList<Integer> B = new ArrayList<>();
        for (int i = 0; i < n; i++) {
            if (b[i]==1)
                B.add(i);
        }
        int[]ans = new int[n];
        int[]id = new int[n+1];
        for (int i = 0; i < n; i++) {
            id[(int) a[i]] = i;
        }
        int max = 0;
        for (int i = n; i >= 1; i--) {
            int pos = id[i];
            for (int j : B) {
                if (pos+j >= n || ans[pos+j] != 0)
                    break;
                ans[pos+j] = i;
                if (pos+j > max)
                    max = pos+j;
            }
            int ind = Collections.binarySearch(B, max-pos+1);
            if (ind < 0)
                ind = Math.abs(ind)-1;
            for (int j = ind; j < B.size(); j++) {
                int jj = B.get(j);
                if (pos+jj >= n || ans[pos+jj] != 0)
                    break;
                ans[pos+jj] = i;
                if (pos+jj > max)
                    max = pos+jj;
            }
        }
        for (int i = 0; i < n; i++) {
            pw.println(ans[i]);
        }
        pw.close();
    }
    private static long getNext() {
        x = (x * 37 + 10007) % 1000000007;
        return x;
    }
    private static int nextInt() throws IOException {
        return Integer.parseInt(next());
    }
    private static long nextLong() throws IOException {
        return Long.parseLong(next());
    }
    private static double nextDouble() throws IOException {
        return Double.parseDouble(next());
    }
    private static String next() throws IOException {
        while (st==null || !st.hasMoreTokens())
            st = new StringTokenizer(br.readLine());
        return st.nextToken();
    }
}

import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Collections;
import java.util.StringTokenizer;

public class B {

    static StringTokenizer st;
    static BufferedReader br;
    static PrintWriter pw;
    static long x;
    public static void main(String[] args) throws IOException {
        br = new BufferedReader(new InputStreamReader(System.in));
        pw = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));
        int n = nextInt();
        int d = nextInt();
        x = nextInt();
        long[]a = new long[n], b = new long[n];
        for (int i = 0; i < n; i++) {
            a[i] = i+1;
        }
        for (int i = 0; i < n; i++) {
            int id = (int) (getNext() % (i+1));
            long t = a[i];
            a[i] = a[id];
            a[id] = t;
        }
        for(int i = 0; i < n; i++){
            if (i < d)
                b[i] = 1;
            else
                b[i] = 0;
        }
        for (int i = 0; i < n; i++) {
            int id = (int) (getNext() % (i+1));
            long t = b[i];
            b[i] = b[id];
            b[id] = t;
        }
        ArrayList<Integer> B = new ArrayList<>();
        for (int i = 0; i < n; i++) {
            if (b[i]==1)
                B.add(i);
        }
        int[]ans = new int[n];
        int[]id = new int[n+1];
        for (int i = 0; i < n; i++) {
            id[(int) a[i]] = i;
        }
        int max = -1;
        for (int i = n; i >= 1; i--) {
            int pos = id[i];
            for (int j : B) {
                if (pos+j >= n || ans[pos+j] != 0)
                    break;
                ans[pos+j] = i;
            }
            int ind = Collections.binarySearch(B, max-pos+1);
            if (ind < 0)
                ind = Math.abs(ind)-1;
            for (int j = ind; j < B.size(); j++) {
                int jj = B.get(j);
                if (pos+jj >= n || ans[pos+jj] != 0)
                    break;
                ans[pos+jj] = i;
                if (pos+j > max)
                    max = pos+j;
            }
        }
        for (int i = 0; i < n; i++) {
            pw.println(ans[i]);
        }
        pw.close();
    }
    private static long getNext() {
        x = (x * 37 + 10007) % 1000000007;
        return x;
    }
    private static int nextInt() throws IOException {
        return Integer.parseInt(next());
    }
    private static long nextLong() throws IOException {
        return Long.parseLong(next());
    }
    private static double nextDouble() throws IOException {
        return Double.parseDouble(next());
    }
    private static String next() throws IOException {
        while (st==null || !st.hasMoreTokens())
            st = new StringTokenizer(br.readLine());
        return st.nextToken();
    }
}

import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Collections;
import java.util.StringTokenizer;

public class B {

    static StringTokenizer st;
    static BufferedReader br;
    static PrintWriter pw;
    static long x;
    public static void main(String[] args) throws IOException {
        br = new BufferedReader(new InputStreamReader(System.in));
        pw = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));
        int n = nextInt();
        int d = nextInt();
        x = nextInt();
        long[]a = new long[n], b = new long[n];
        for (int i = 0; i < n; i++) {
            a[i] = i+1;
        }
        for (int i = 0; i < n; i++) {
            int id = (int) (getNext() % (i+1));
            long t = a[i];
            a[i] = a[id];
            a[id] = t;
        }
        for(int i = 0; i < n; i++){
            if (i < d)
                b[i] = 1;
            else
                b[i] = 0;
        }
        for (int i = 0; i < n; i++) {
            int id = (int) (getNext() % (i+1));
            long t = b[i];
            b[i] = b[id];
            b[id] = t;
        }
        ArrayList<Integer> B = new ArrayList<>();
        for (int i = 0; i < n; i++) {
            if (b[i]==1)
                B.add(i);
        }
        int[]ans = new int[n];
        int[]id = new int[n+1];
        for (int i = 0; i < n; i++) {
            id[(int) a[i]] = i;
        }
        int max = -1;
        for (int i = n; i >= 1; i--) {
            int pos = id[i];
            for (int j : B) {
                if (pos+j >= n || ans[pos+j] != 0)
                    break;
                ans[pos+j] = i;
                if (pos+j > max)
                    max = pos+j;
            }
            int ind = Collections.binarySearch(B, max-pos+1);
            if (ind < 0)
                ind = Math.abs(ind)-1;
            for (int j = ind; j < B.size(); j++) {
                int jj = B.get(j);
                if (pos+jj >= n || ans[pos+jj] != 0)
                    break;
                ans[pos+jj] = i;
                if (pos+jj > max)
                    max = pos+jj;
            }
        }
        for (int i = 0; i < n; i++) {
            pw.println(ans[i]);
        }
        pw.close();
    }
    private static long getNext() {
        x = (x * 37 + 10007) % 1000000007;
        return x;
    }
    private static int nextInt() throws IOException {
        return Integer.parseInt(next());
    }
    private static long nextLong() throws IOException {
        return Long.parseLong(next());
    }
    private static double nextDouble() throws IOException {
        return Double.parseDouble(next());
    }
    private static String next() throws IOException {
        while (st==null || !st.hasMoreTokens())
            st = new StringTokenizer(br.readLine());
        return st.nextToken();
    }
}

import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Collections;
import java.util.StringTokenizer;

public class B {

    static StringTokenizer st;
    static BufferedReader br;
    static PrintWriter pw;
    static long x;
    public static void main(String[] args) throws IOException {
        br = new BufferedReader(new InputStreamReader(System.in));
        pw = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));
        int n = nextInt();
        int d = nextInt();
        x = nextInt();
        long[]a = new long[n], b = new long[n];
        for (int i = 0; i < n; i++) {
            a[i] = i+1;
        }
        for (int i = 0; i < n; i++) {
            int id = (int) (getNext() % (i+1));
            long t = a[i];
            a[i] = a[id];
            a[id] = t;
        }
        for(int i = 0; i < n; i++){
            if (i < d)
                b[i] = 1;
            else
                b[i] = 0;
        }
        for (int i = 0; i < n; i++) {
            int id = (int) (getNext() % (i+1));
            long t = b[i];
            b[i] = b[id];
            b[id] = t;
        }
        ArrayList<Integer> B = new ArrayList<>();
        for (int i = 0; i < n; i++) {
            if (b[i]==1)
                B.add(i);
        }
        int[]ans = new int[n];
        int[]id = new int[n+1];
        for (int i = 0; i < n; i++) {
            id[(int) a[i]] = i;
        }
        int max = -1;
        for (int i = n; i >= 1; i--) {
            int pos = id[i];
            for (int j : B) {
                if (pos+j >= n || ans[pos+j] != 0)
                    break;
                ans[pos+j] = i;
                if (pos+j > max)
                    max = pos+j;
            }
            int ind = Collections.binarySearch(B, max-pos+1);
            if (ind < 0)
                ind = Math.abs(ind)-1;
            for (int j = ind; j < B.size(); j++) {
                int jj = B.get(j);
                if (pos+jj >= n || ans[pos+jj] != 0)
                    break;
                ans[pos+jj] = i;
            }
        }
        for (int i = 0; i < n; i++) {
            pw.println(ans[i]);
        }
        pw.close();
    }
    private static long getNext() {
        x = (x * 37 + 10007) % 1000000007;
        return x;
    }
    private static int nextInt() throws IOException {
        return Integer.parseInt(next());
    }
    private static long nextLong() throws IOException {
        return Long.parseLong(next());
    }
    private static double nextDouble() throws IOException {
        return Double.parseDouble(next());
    }
    private static String next() throws IOException {
        while (st==null || !st.hasMoreTokens())
            st = new StringTokenizer(br.readLine());
        return st.nextToken();
    }
}

import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Collections;
import java.util.StringTokenizer;

public class B {

    static StringTokenizer st;
    static BufferedReader br;
    static PrintWriter pw;
    static long x;
    public static void main(String[] args) throws IOException {
        br = new BufferedReader(new InputStreamReader(System.in));
        pw = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));
        int n = nextInt();
        int d = nextInt();
        x = nextInt();
        long[]a = new long[n], b = new long[n];
        for (int i = 0; i < n; i++) {
            a[i] = i+1;
        }
        for (int i = 0; i < n; i++) {
            int id = (int) (getNext() % (i+1));
            long t = a[i];
            a[i] = a[id];
            a[id] = t;
        }
        for(int i = 0; i < n; i++){
            if (i < d)
                b[i] = 1;
            else
                b[i] = 0;
        }
        for (int i = 0; i < n; i++) {
            int id = (int) (getNext() % (i+1));
            long t = b[i];
            b[i] = b[id];
            b[id] = t;
        }
        ArrayList<Integer> B = new ArrayList<>();
        for (int i = 0; i < n; i++) {
            if (b[i]==1)
                B.add(i);
        }
        int[]ans = new int[n];
        int[]id = new int[n+1];
        for (int i = 0; i < n; i++) {
            id[(int) a[i]] = i;
        }
        int max = -1;
        for (int i = n; i >= 1; i--) {
            int pos = id[i];
            for (int j : B) {
                if (pos+j >= n || ans[pos+j] != 0)
                    break;
                ans[pos+j] = i;
            }
            int ind = Collections.binarySearch(B, max-pos+1);
            if (ind < 0)
                ind = Math.abs(ind)-1;
            for (int j = ind; j < B.size(); j++) {
                int jj = B.get(j);
                if (pos+jj >= n)
                    break;
                if (ans[pos+jj] != 0) {
                    ans[pos+jj] = i;
                    if (pos+jj > max)
                        max = pos+jj;
                }
            }
        }
        for (int i = 0; i < n; i++) {
            pw.println(ans[i]);
        }
        pw.close();
    }
    private static long getNext() {
        x = (x * 37 + 10007) % 1000000007;
        return x;
    }
    private static int nextInt() throws IOException {
        return Integer.parseInt(next());
    }
    private static long nextLong() throws IOException {
        return Long.parseLong(next());
    }
    private static double nextDouble() throws IOException {
        return Double.parseDouble(next());
    }
    private static String next() throws IOException {
        while (st==null || !st.hasMoreTokens())
            st = new StringTokenizer(br.readLine());
        return st.nextToken();
    }
}

import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Collections;
import java.util.StringTokenizer;

public class B {

    static StringTokenizer st;
    static BufferedReader br;
    static PrintWriter pw;
    static long x;
    public static void main(String[] args) throws IOException {
        br = new BufferedReader(new InputStreamReader(System.in));
        pw = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));
        int n = nextInt();
        int d = nextInt();
        x = nextInt();
        long[]a = new long[n], b = new long[n];
        for (int i = 0; i < n; i++) {
            a[i] = i+1;
        }
        for (int i = 0; i < n; i++) {
            int id = (int) (getNext() % (i+1));
            long t = a[i];
            a[i] = a[id];
            a[id] = t;
        }
        for(int i = 0; i < n; i++){
            if (i < d)
                b[i] = 1;
            else
                b[i] = 0;
        }
        for (int i = 0; i < n; i++) {
            int id = (int) (getNext() % (i+1));
            long t = b[i];
            b[i] = b[id];
            b[id] = t;
        }
        ArrayList<Integer> B = new ArrayList<>();
        for (int i = 0; i < n; i++) {
            if (b[i]==1)
                B.add(i);
        }
        int[]ans = new int[n];
        int[]id = new int[n+1];
        for (int i = 0; i < n; i++) {
            id[(int) a[i]] = i;
        }
        int max = -1;
        for (int i = n; i >= 1; i--) {
            int pos = id[i];
            for (int j : B) {
                if (pos+j >= n || ans[pos+j] != 0)
                    break;
                ans[pos+j] = i;
            }
            int ind = Collections.binarySearch(B, max-pos+1);
            if (ind < 0)
                ind = Math.abs(ind)-1;
            for (int j = ind; j < B.size(); j++) {
                int jj = B.get(j);
                if (pos+jj >= n)
                    break;
                if (ans[pos+jj] != 0) {
                    ans[pos+jj] = i;
                    if (pos+j > max)
                        max = pos+j;
                }
            }
        }
        for (int i = 0; i < n; i++) {
            pw.println(ans[i]);
        }
        pw.close();
    }
    private static long getNext() {
        x = (x * 37 + 10007) % 1000000007;
        return x;
    }
    private static int nextInt() throws IOException {
        return Integer.parseInt(next());
    }
    private static long nextLong() throws IOException {
        return Long.parseLong(next());
    }
    private static double nextDouble() throws IOException {
        return Double.parseDouble(next());
    }
    private static String next() throws IOException {
        while (st==null || !st.hasMoreTokens())
            st = new StringTokenizer(br.readLine());
        return st.nextToken();
    }
}

import java.util.Map;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.TreeMap;
import java.util.Set;
import java.io.PrintStream;
import java.io.BufferedReader;
import java.util.Comparator;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.io.Reader;
import java.util.TreeSet;
import java.util.Collections;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 * @author Vadim
 */
public class Main {
	public static void main(String[] args) {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		TaskD solver = new TaskD();
		solver.solve(1, in, out);
		out.close();
	}
}

class TaskD {
    long x;
    long getNextX() {
        x = (x * 37 + 10007) % 1000000007;
        return x;
    }
    void swap (int[] a, int i, int j) {
        int t = a[i];
        a[i] = a[j];
        a[j] = t;
    }
    void initAB(int a[], int b[], int d, int n) {
        for(int i = 0; i < n; i = i + 1){
            a[i] = i + 1;
        }
        for(int i = 0; i < n; i = i + 1){
            swap(a, i, (int)(getNextX() % (i + 1)));
        }
        for(int i = 0; i < n; i = i + 1){
            if (i < d)
                b[i] = 1;
            else
                b[i] = 0;
        }
        for(int i = 0; i < n; i = i + 1){
            swap(b, i, (int)(getNextX() % (i + 1)));
        }
    }
    public void solve(int testNumber, InputReader in, PrintWriter out) {
        int n = in.ni();
        int d = in.ni();
        x = in.nl();
        int [] a = new int[n];
        int [] b = new int[n];

        initAB(a, b, d, n);
        System.out.println(Arrays.toString(a));
        System.out.println(Arrays.toString(b));
        TreeMap<Integer, Integer> maxValues = new TreeMap<Integer, Integer>(Collections.reverseOrder());
        TreeSet<Integer> ones = new TreeSet<Integer>();
        for (int i = 0; i < n; i++) {
            if(b[i] == 1) {
                ones.add(i);
            }
            maxValues.put(a[i], i);
            int ans = 0;
            if(i < 200 || ones.size() > 100) {
                for (Map.Entry<Integer, Integer> entry : maxValues.entrySet()) {
                    if(b[i-entry.getValue()] == 1) {
                        ans = entry.getKey();
                        break;
                    }
                }
            } else {
                for (Integer index : ones) {
                    if(index > i) {
                        break;
                    }
                    ans = Math.max(ans, a[i-index]);
                }
            }
            out.println(ans);
        }
    }
}

class InputReader  extends BufferedReader {
    public InputReader(InputStream st) {
        super(new InputStreamReader(st));
    }

    public int nextInt() {
        try {
            int c = read();

            while (isWhiteSpace(c)) {
                c = read();
            }
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = read();
            }
            int ret = 0;
            while (c >= 0 && !isWhiteSpace(c)) {
                if (c < '0' || c > '9') {
                    throw new RuntimeException();
                }
                ret = ret * 10 + c - '0';
                c = read();
            }
            return ret * sgn;
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }

    public long nextLong() {
        try {
            int c = read();

            while (isWhiteSpace(c)) {
                c = read();
            }
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = read();
            }
            long ret = 0;
            while (c >= 0 && !isWhiteSpace(c)) {
                if (c < '0' || c > '9') {
                    throw new RuntimeException();
                }
                ret = ret * 10 + c - '0';
                c = read();
            }
            return ret * sgn;
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }

    public int ni() {
        return nextInt();
    }

    public long nl() {
        return nextLong();
    }

    public String readLine() {
        try {
            return super.readLine();
        } catch (IOException e) {
            return null;
        }
    }

    static boolean isWhiteSpace(int c) {
        return c >= 0 && c <= 32;
    }

}

import java.lang.*;
import java.io.*;
import java.util.*;
import java.math.*;

public class Main {
    public static void main(String[] args) {
        new Solver().run();
    }
}

class Solver {

    void run() {
        in = new BufferedReader(new InputStreamReader(System.in));
        out = new PrintWriter(System.out);
        //in = new BufferedReader(new FileReader("tree.in"));
        //out = new PrintWriter(new File("tree.out"));
        solve();
        out.close();
    }

    int x, n, d;
    int[] a, b;

    int getNextX() {
        x = (int) ((((long) x * 37) + 10007) % 1000000007);
        return x;
    }

    void initAB() {
        for (int i = 0; i < n; ++i) {
            a[i] = i + 1;
        }
        for (int i = 0; i < n; ++i) {
            int pos = getNextX() % (i + 1);
            int t = a[i];
            a[i] = a[pos];
            a[pos] = t;
        }
        for (int i = 0; i < n; ++i) {
            --a[i];
        }
        for (int i = 0; i < n; ++i) {
            if (i < d) b[i] = 1;
            else b[i] = 0;
        }
        for (int i = 0; i < n; ++i) {
            int pos = getNextX() % (i + 1);
            int t = b[i];
            b[i] = b[pos];
            b[pos] = t;
        }
    }

    void solve() {
        n = nextInt();
        d = nextInt();
        x = nextInt();
        a = new int[n];
        b = new int[n];
        initAB();
        /*
        for (int i = 0; i < n; ++i) {
            System.err.print(a[i] + " ");
        }
        System.err.println();
        for (int i = 0; i < n; ++i) {
            System.err.print(b[i] + " ");
        }
        System.err.println();
        */
        ArrayList<Integer> mas = new ArrayList<Integer>();
        for (int i = 0; i < n; ++i) {
            if (b[i] == 1) mas.add(i);
        }
        int[] c = new int[n];
        int sq = (int) (Math.sqrt(n + 0.0) + 7);
        if (d <= sq) {
            for (int i = 0; i < n; ++i) {
                for (int j : mas) {
                    if (i + j < n) c[i + j] = Math.max(c[i + j], a[i]);
                    else break;
                }
            }
        } else {
            int[] pos = new int[n];
            for (int i = 0; i < n; ++i) {
                pos[a[i]] = i;
            }
            boolean[] used = new boolean[n];
            int usedCount = 0;
            for (int k = n - 1; k >= 0 && usedCount < n; --k) {
                int i = pos[k];
                for (int j : mas) {
                    if (i + j < n) {
                        if (!used[i + j]) {
                            c[i + j] = k;
                            used[i + j] = true;
                            usedCount++;
                        }
                    } else break;
                }
            }
        }
        for (int i = 0; i < n; ++i) {
            out.println(c[i] + 1);
        }
    }

    StringTokenizer tok;
    BufferedReader in;
    PrintWriter out;

    String next() {
        if (tok == null || !tok.hasMoreElements()) {
            try {
                tok = new StringTokenizer(in.readLine());
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tok.nextToken();
    }

    int nextInt() {
        return Integer.parseInt(next());
    }

    long nextLong() {
        return Long.parseLong(next());
    }

    double nextDouble() {
        return Double.parseDouble(next());
    }

    BigInteger nextBigInteger() {
        return new BigInteger(next());
    }
}

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Collection;
import java.util.Locale;
import java.util.StringTokenizer;

public class Main {
	public static void main(String[] args) throws IOException {
		new Thread(null, new Runnable() {
			public void run() {
				try {
					long prevTime = System.currentTimeMillis();
					new Main().run();
					System.err.println("Total time: "
							+ (System.currentTimeMillis() - prevTime) + " ms");
					System.err.println("Memory status: " + memoryStatus());
				} catch (IOException e) {
					e.printStackTrace();
				}
			}
		}, "1", 1L << 24).start();
	}

	void run() throws IOException {
		in = new BufferedReader(new InputStreamReader(System.in));
		out = new PrintWriter(System.out);
		Object o = solve();
		if (o != null)
			out.println(o);
		out.close();
		in.close();
	}

	// x is 64-bit variable;
	int n;
	long x;
	int d;

	int[] a;
	int[] b;

	long getNextX() {
		x = (x * 37 + 10007) % 1000000007;
		return x;
	}

	void initAB() {
		a = new int[n];
		for (int i = 0; i < n; i++) {
			a[i] = i + 1;
		}
		for (int i = 0; i < n; i++) {
			swap(a, i, (int) (getNextX() % (i + 1)));
		}

		b = new int[n];
		for (int i = 0; i < n; i++) {
			if (i < d)
				b[i] = 1;
			else
				b[i] = 0;
		}
		for (int i = 0; i < n; i++) {
			swap(b, i, (int) (getNextX() % (i + 1)));
		}
	}

	private void swap(int[] a, int i, int j) {
		int t = a[i];
		a[i] = a[j];
		a[j] = t;
	}

	private Object solve() throws IOException {
		n = ni();
		d = ni();
		x = ni();
		initAB();

		int[] ret = new int[n];
		int[] getIndex = new int[n + 1];
		for (int i = 0; i < n; i++)
			getIndex[a[i]] = i;

		boolean[] ok = new boolean[n];
		Arrays.fill(ok, true);
		IteratorUF free = new IteratorUF(ok);

		int[] next = new int[n];
		next[n-1]= n;
		for(int i =n-2;i>=0;i--)
			if(b[i+1]==1){
				next[i]= i+1;
			}else{
				next[i] = next[i+1];
			}

		for (int i = n; i >= 1; i--) {
			int index = getIndex[i];

			int ii =(b[0]==1? 0 : next[0]);
			while(index+ii<n){
				int check = free.next(index + ii);
				if(check==index+ii){
					ret[check]=i;
					free.kill(check);
					ii = next[ii];
				}else{
					if(check==n)
						break;
					int dif = check- index;
					if(b[ii+dif]==1){
						ii= ii+dif;
					}else{
						ii= next[ii+dif];
					}
				}

			}

		}
		for (int elem : ret)
			pln(elem);
		return null;
	}

	public class IteratorUF {
		boolean[] alive;
		int[] next;
		int n;

		public IteratorUF(boolean[] bs) {
			this.n = bs.length;
			this.alive = new boolean[n + 1];
			System.arraycopy(bs, 0, alive, 0, n);
			alive[n] = true;

			this.next = new int[bs.length];
			for (int i = 0; i < next.length; i++)
				next[i] = i + 1;
		}

		// no matar n
		public void kill(int index) {
			alive[index] = false;
		}

		public boolean isAlive(int index) {
			return alive[index];
		}

		// devuelve proxima posicion o n si no hay siguiente.
		// si pregunto por n da n, por algo mayor da exception

		public int next(int index) {
			if (alive[index])
				return index;

			return next[index] = next(next[index]);
		}

	}

	BufferedReader in;
	PrintWriter out;
	StringTokenizer strTok = new StringTokenizer("");

	String nextToken() throws IOException {
		while (!strTok.hasMoreTokens())
			strTok = new StringTokenizer(in.readLine());
		return strTok.nextToken();
	}

	int ni() throws IOException {
		return Integer.parseInt(nextToken());
	}

	long nl() throws IOException {
		return Long.parseLong(nextToken());
	}

	double nd() throws IOException {
		return Double.parseDouble(nextToken());
	}

	int[] nia(int size) throws IOException {
		int[] ret = new int[size];
		for (int i = 0; i < size; i++)
			ret[i] = ni();
		return ret;
	}

	long[] nla(int size) throws IOException {
		long[] ret = new long[size];
		for (int i = 0; i < size; i++)
			ret[i] = nl();
		return ret;
	}

	double[] nda(int size) throws IOException {
		double[] ret = new double[size];
		for (int i = 0; i < size; i++)
			ret[i] = nd();
		return ret;
	}

	String nextLine() throws IOException {
		strTok = new StringTokenizer("");
		return in.readLine();
	}

	boolean EOF() throws IOException {
		while (!strTok.hasMoreTokens()) {
			String s = in.readLine();
			if (s == null)
				return true;
			strTok = new StringTokenizer(s);
		}
		return false;
	}

	void printRepeat(String s, int count) {
		for (int i = 0; i < count; i++)
			out.print(s);
	}

	void printArray(int[] array) {
		for (int i = 0; i < array.length; i++) {
			if (i > 0)
				out.print(' ');
			out.print(array[i]);
		}
		out.println();
	}

	void printArray(long[] array) {
		for (int i = 0; i < array.length; i++) {
			if (i > 0)
				out.print(' ');
			out.print(array[i]);
		}
		out.println();
	}

	void printArray(double[] array) {
		for (int i = 0; i < array.length; i++) {
			if (i > 0)
				out.print(' ');
			out.print(array[i]);
		}
		out.println();
	}

	void printArray(double[] array, String spec) {
		for (int i = 0; i < array.length; i++) {
			if (i > 0)
				out.print(' ');
			out.printf(Locale.US, spec, array[i]);
		}
		out.println();
	}

	void printArray(Object[] array) {
		boolean blank = false;
		for (Object x : array) {
			if (blank)
				out.print(' ');
			else
				blank = true;
			out.print(x);
		}
		out.println();
	}

	@SuppressWarnings("rawtypes")
	void printCollection(Collection collection) {
		boolean blank = false;
		for (Object x : collection) {
			if (blank)
				out.print(' ');
			else
				blank = true;
			out.print(x);
		}
		out.println();
	}

	static String memoryStatus() {
		return (Runtime.getRuntime().totalMemory()
				- Runtime.getRuntime().freeMemory() >> 20)
				+ "/" + (Runtime.getRuntime().totalMemory() >> 20) + " MB";
	}

	public void pln() {
		out.println();
	}

	public void pln(int arg) {
		out.println(arg);
	}

	public void pln(long arg) {
		out.println(arg);
	}

	public void pln(double arg) {
		out.println(arg);
	}

	public void pln(String arg) {
		out.println(arg);
	}

	public void pln(boolean arg) {
		out.println(arg);
	}

	public void pln(char arg) {
		out.println(arg);
	}

	public void pln(float arg) {
		out.println(arg);
	}

	public void pln(Object arg) {
		out.println(arg);
	}

	public void p(int arg) {
		out.print(arg);
	}

	public void p(long arg) {
		out.print(arg);
	}

	public void p(double arg) {
		out.print(arg);
	}

	public void p(String arg) {
		out.print(arg);
	}

	public void p(boolean arg) {
		out.print(arg);
	}

	public void p(char arg) {
		out.print(arg);
	}

	public void p(float arg) {
		out.print(arg);
	}

	public void p(Object arg) {
		out.print(arg);
	}

}