#include <bits/stdc++.h>
using namespace std;
struct node
{
int num;
string name;
}p[1001];//用结构体存储人名
queue<node>q;//注意如何定义
bool judge(int x)
{
if(x%7==0)
return 1;//7的倍数
while(x)
{
if(x%10==7)
return 1;
x=x/10;//处理含有7
}
return 0;
}
int main()
{
int n,m,t;
string name;
cin>>n>>m>>t;
for(int i=1;i<=n;i++)
{
cin>>p[i].name;
p[i].num=i;//人名配上顺序
}
for(int i=1;i<=n;i++)
q.push(p[i]);//第一遍入队
for(int i=1;i<=m-1;i++)//从m开始重新入队出队
{
q.push(p[i]);
q.pop();
}
t--;
while(q.size()>1)
{
t++;
node tmp=q.front();
q.pop();
if(!judge(t))//判断数字,同例2
q.push(tmp);
}
printf("%s\n",q.front().name.c_str());//输出
return 0;
}