RT
#include <bits/stdc++.h>
using namespace std;
inline int read(){
int s = 0 , t = 1;
char c = getchar();
while(c < '0' || c > '9'){
if(c == '-') t = -1;
c = getchar();
}
while(c >= '0' && c <= '9'){
s = (s << 1) + (s << 3) + (c ^ 48);
c = getchar();
}
return s * t;
}
inline void print(int x){
if(x <= 9){
putchar(x + '0');
return ;
}
print(x / 10);
putchar(x % 10 + '0');
}
int honest[100005] , contradiction , whosays[100005] , zuifan , cnt , notrue;
string name[100005] , content[100005] , today[8] = {"" , "today is sunday." , "today is monday." , "today is tuesday." , "today is wednesday." , "today is thursday." , "today is friday." , "today is saturday."};
inline void work(int ren , int f){
if(honest[ren] != 0 && honest[ren] != f){
contradiction = 1;
return;
}
honest[ren] = f;
}
int main(){
int n , m , p;
cin >> m >> n >> p;
for(int i = 1;i <= m;i++) cin >> name[i];
string names;
for(int i = 1;i <= p;i++){
cin >> names;
names.erase(names.end() - 1);
for(int j = 1;j <= m;j++){
if(name[j] == names){
whosays[i] = j;
break;
}
}
getline(cin , content[i]);
content[i].erase(content[i].begin());
content[i].erase(content[i].end() - 1);
}
for(int day = 1;day <= 7;day++){
for(int i = 1;i <= m;i++){
contradiction = 0;
memset(honest , 0 , sizeof(honest));
for(int j = 1;j <= p;j++){
if(content[j] == "I am guilty."){
if(i == whosays[j]) work(whosays[j] , 1);
else work(whosays[j] , -1);
}
if(content[j] == "I am not guilty."){
if(i != whosays[j]) work(whosays[j] , 1);
else work(whosays[j] , -1);
}
for(int days = 1;days <= 7;days++){
string tmpp = content[j];
for(int i = 0;i < tmpp.size();i++){
if(tmpp[i] >= 'A' && tmpp[i] <= 'Z') tmpp[i] += 'a' - 'A';
}
if(tmpp == today[days]){
if(days == day) work(whosays[j] , 1);
else work(whosays[j] , -1);
}
}
for(int k = 1;k <= m;k++){
if(content[j] == name[k] + " is guilty.") work(whosays[k] , k == zuifan ? 1 : -1);
if(content[j] == name[k] + " is not guilty.") work(whosays[k] , k != zuifan ? 1 : -1);
}
}
cnt = 0;
notrue = 0;
for(int j = 1;j <= m;j++){
if(honest[j] == 0) notrue++;
else if(honest[j] == -1) cnt++;
}
if(!contradiction && cnt <= n && cnt + notrue >= n ){
if(zuifan && zuifan != i){
cout << "Cannot Determine";
return 0;
}
zuifan = i;
}
}
}
if(!zuifan) cout << "Impossible";
else cout << name[zuifan];
return 0;
}