I think my code works, but it doesn't let the user to introduce the word 0, automatically fills it with an empty string "". I have realised that if I removed the scan class from reading n and m and hardcode the values n=6, m=2. Then the code works as expected. Anyvbody knows why?
package com.codegym.task.task07.task0720;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.Scanner;

/*
Shuffled just in time

*/

public class Solution {
    public static void main(String[] args) throws IOException {
        Scanner sc = new Scanner(System.in);

        //write your code here

        int n = sc.nextInt();
        int m = sc.nextInt();

        ArrayList<String> sensei = new ArrayList<String>();

        System.out.println("Write vector:");
        for (int i = 0; i < n; i++) {
            System.out.println("Write word: " + i);
            sensei.add(sc.nextLine());
        }

        for (int i = 0; i < m; i++) {
            sensei.add(sensei.get(i));
        }

        for (int i = 0; i < m; i++) {
            sensei.remove(0);
        }

        for (int i = 0; i < sensei.size(); i++) {
            System.out.println(sensei.get(i));
        }

    }
}