#include<stdio.h>
#include<string.h>

int main()
{
    char s[21];
    scanf("%s",s);

    int n,i;
    scanf("%d",&n);
    char a[n][21];

    // reading the valid animals from input
    for(i=0;i<n;i++)
        scanf("%s",a[i]);

    int f=0;

    // Assume that value of f indicates the following:
    // 0 ---> No animal found
    // 1 ---> Animal found and can eliminate next player
    // 2 ---> Animal found and there is a chance that next player can also chose the valid animal

    //checking if any animal exists starting with the letter(ending letter of prevoius player's animal)

    for(i=0;i<n;i++){
        if(s[strlen(s)-1]==a[i][0]){
            strcpy(s,a[i]); // copying the found animal into s
            strcpy(a[i]," "); //making the found animal empty (to remove it from the valid animals list)
            f=1;
            break;
        }
    }

    // if there exists an animal that we can use now
    //checking if the next player can win or gets eliminated

    if(f==1){
        for(i=0;i<n;i++){
            if(s[strlen(s)-1]==a[i][0]){ // if the animal is found
                f=2;
                break;
            }
        }
    }

    if(f==0)
        printf("?");
    else if(f==1)
        printf("%s!",s);
    else
        printf("%s",s);

    return 0;
}
