public class Solution {
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
ArrayList<String> s= new ArrayList<String>();
int N=Integer.parseInt(br.readLine());
int M=Integer.parseInt(br.readLine());
int x=s.size()+M;
for(int i=0;i<N;i++){
s.add(br.readLine());
}
for(int i=s.size();i<x;i++)
{
s.add(br.readLine());
}
for(int i=0;i<s.size();i++)
{
System.out.println(s.get(i));
}
//write your code here
}
}
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
Use the keyboard to enter 2 numbers N and M.
Enter N strings and put them in a list.
Move the first M strings to the end of the list.
Display the list, each value on a new line.
*/
public class Solution {
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
ArrayList<String> s= new ArrayList<String>();
int N=Integer.parseInt(br.readLine());
int M=Integer.parseInt(br.readLine());
int x=s.size()+M;
for(int i=0;i<N;i++){
s.add(br.readLine());
}
for(int i=s.size();i<x;i++)
{
s.add(br.readLine());
}
for(int i=0;i<s.size();i++)
{
System.out.println(s.get(i));
}
//write your code here
}
}