public static void main(String[] args) throws IOException {
Scanner sc1 = new Scanner(System.in);
ArrayList<String> list = new ArrayList<>();
int N = Integer.parseInt(sc1.nextLine());
int M = Integer.parseInt(sc1.nextLine());
for(int x = 0; x<N; x++) {
String w = sc1.nextLine();
list.add(w);
}
for(int x = 0; x<M; x++) {
list.add(list.get(0));
list.remove(0);
}
for (int k = 0; k < M; k++) {
list.remove(0);
}
}
}
package com.codegym.task.task07.task0720;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Scanner;
import java.util.ArrayList;
/*
Shuffled just in time
*/
public class Solution {
public static void main(String[] args) throws IOException {
Scanner sc1 = new Scanner(System.in);
ArrayList<String> list = new ArrayList<>();
int N = Integer.parseInt(sc1.nextLine());
int M = Integer.parseInt(sc1.nextLine());
for(int x = 0; x<N; x++) {
String w = sc1.nextLine();
list.add(w);
}
for(int x = 0; x<M; x++) {
list.add(list.get(0));
list.remove(0);
}
for (int k = 0; k < M; k++) {
list.remove(0);
}
}
}