#include
using namespace std;
class Node {
public:
int DataContainer;
Node *next;
Node(int d)
{
DataContainer=d;
next=NULL;
}
};
void Insertion(int d, Node *&head)
{
if (head == NULL)
{
head=new Node(d);
return;
}
Node *n = head;
while (n->next!=NULL)
{
n=n->next;
}
n->next=new Node(d);
}
Node *input(){
int d;
cin>>d;
Node*head=NULL;
while (d!=-1)
{
Insertion(d,head);
cin>>d;
}
return head;
}
void kNode(int k,Node *head)
{
Node *fast=head;
Node *slow=head;
for (int i = 0; i < k; i++)
{
fast=fast->next;
}
while (fast!=NULL)
{
slow=slow->next;
}
cout<<endl;
cout<DataContainer;
}
void print(Node *head)
{
while (head!= NULL)
{
cout<DataContainer<<" ";
head=head->next;
}
}
int main()
{
int k;
int d;
Node *head=input();
cin>>k;
kNode(k,head);
}