import java.io.*;
import java.util.*;
public class Solution implements Runnable {
Scanner in;
PrintWriter out;
public void run() {
try {
in = new Scanner(new FileReader("input.txt"));
out = new PrintWriter(System.out);
int n, m, i;
String str;
while (in.hasNextInt()) {
n = in.nextInt();
m = in.nextInt();
//out.println(n + " and " + m);
in.nextLine();
for (i = 0; i < m; i++) {
str = in.nextLine();
if (i == (n - 1) % m) out.println(str);
}
}
in.close();
out.close();
}
catch (Exception ex) {
ex.printStackTrace();
System.exit(-1);
}
}
public static void main(String args[]) {
new Thread(new Solution()).start();
}
}