the output matches the required result but not accepted.
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));
ArrayList<String> list = new ArrayList<String>();
ArrayList<String> result = new ArrayList<String>();
int n, m;
n = Integer.parseInt(reader.readLine());
m = Integer.parseInt(reader.readLine());
int count = n;
while(count > 0){
list.add(reader.readLine());
count--;
}
count = 0;
while(count != m){
list.add(list.get(count++));
}
//write your code here
for(int i = m; i < list.size(); i++){
result.add(list.get(i));
}
for(int i = 0; i < result.size(); i++){
System.out.println(result.get(i));
}
}
}