Please help me what's wrong in my code?
package com.codegym.task.task07.task0720;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
/*
Shuffled just in time
*/
public class Solution {
public static void main(String[] args) throws IOException {
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
//write your code here
ArrayList<String> list = new ArrayList<String>();
int N = Integer.parseInt(reader.readLine());
int M = Integer.parseInt(reader.readLine());
String[] array = new String[M];
for(int i=0; i<N; i++){
list.add(i, reader.readLine());
}
for(int k=0; k<M; k++){
array[k] = list.get(k);
list.remove(k);
}
for(int j=N; j<M+N; j++){
for(int l=0; l<M; l++){
list.add(j, array[l]);
}
}
}
}