What i did wrong?
package com.javarush.task.task07.task0720;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Scanner;
/*
Перестановочка подоспела
*/
public class Solution {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
int numberN = scanner.nextInt();
int numberM = scanner.nextInt();
ArrayList<String> words = new ArrayList<>();
for(int i =0; i<=numberN; i++){
words.add(scanner.nextLine());
}
int count = 0;
for(int i=0; i<=numberM;i++){
String g = words.get(i);
words.add(g);
}
for(int j =0;j<=numberM; j++){
words.remove(j);
j--;
count ++;
if(count == numberM) {
break;
}
for(String s:words){
System.out.println(s);
}
}
}
}