import java.util.LinkedList ;
import java.util.Queue ;

public class GLCMethod01 {

    public static long updateSoma(Queue<Integer> lista , int factors[]){
        if (lista.size() != factors.length){
            System.out.println("The sum was not performed!") ;
            return 0 ;
        }

        // this transforms the queue into an array
        // to see the reference and full explanation:
        // https://stackoverflow.com/questions/960431/how-to-convert-listinteger-to-int-in-java
        int[] tmp = lista.stream().mapToInt(i->i).toArray() ;

        long soma = 0 ;

        for (int i = 0 ; i < factors.length ; i++)
            soma += factors[i] * tmp[i] ;

        return soma ;
    }

    public static void main(String[] args){

        // the number of points in the sequence
        int seqlen = Integer.parseInt(args[0]) ;
        // The number of number that we will generate.
        int npts = Integer.parseInt(args[1]) ;

        // These are the constants for the algorithm.
        int M = (int)(Math.pow(2,31) - 1) ;
        int A = (int)(Math.pow(7,5)) ;
        int C = 0 ;

        // first we fill the queue
        Queue<Integer> sequence = new LinkedList<>() ;
        int[] Afact = new int[seqlen] ;

        int state = 1 ;
        long soma = 0 ;

        for (int i = 0 ; i < seqlen ; i++){
            state = Math.floorMod(A * state , M) ;
            sequence.add(state) ;
            Afact[i] = (int)(10 * Math.random()) + 1 ;
            soma += state * Afact[i] ;
        }


        /* now the queue is filled with seqlen number of points.  all
           that we have to do now is to generate a new state, remove the
           top of the queue and add the new value to the bottom.
         */


        int[] randseq = new int[npts] ;

        for (int i = 0 ; i < npts ; i++){
            state = Math.floorMod(soma , M) ;
            // removes the head of the queue
            sequence.remove() ;
            sequence.add(state) ;
            soma = updateSoma(sequence, Afact) ;
            randseq[i] = state ;
            System.out.println(randseq[i]) ;
        }

    }

}
