#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#define rep(i,N) for(int i=0;i<(int)N;i++)
static inline int Asc(const void *a,const void *b){return strcmp((char*)a,(char*)b);}
static inline int IN(void)
{
  int x=0,f=0,c=getchar();while(c<48||c>57){f^=(c==45),c=getchar();}
  while(c>47&&c<58){x=x*10+c-48,c=getchar();}return f?-x:x;
}
int main(void)
{
  int N=IN(),check=0,len=0,sizeS=0,sizeT=0,idxS=0,idxT=0;char S[N][11],T[N][11],temp[11];
  rep(i,N)
  {
    if(!scanf("%s",temp)){exit(EXIT_FAILURE);}
    len=(int)strlen(temp);
    if(temp[0]=='!'){len--;rep(j,len){T[sizeT][j]=temp[j+1];}if(len<10){T[sizeT][len]=0;}sizeT++;}
    else{rep(j,len){S[sizeS][j]=temp[j];}if(len<10){S[sizeS][len]=0;}sizeS++;}
  }
  qsort(S,sizeS,11,Asc);qsort(T,sizeT,11,Asc);
  while(idxS<sizeS&&idxT<sizeT)
  {
    check=strcmp(S[idxS],T[idxT]);
    if(!check){return !puts(S[idxS]);}
    else if(check<0){idxS++;}else{idxT++;}
  }
  return !puts("satisfiable");
}
#include <bits/stdc++.h>
using namespace std;

int main() {
  string S;
  cin >> S;
  int N = (int) S.size();
  for (int i = 0; i < N; i++) {
    if (S.at(i) == '6') {
      S.at(i) = '9';
    }
    else if (S.at(i) == '9') {
      S.at(i) = '6';
    }
  }
  for (int i = N - 1; i >= 0; i--) {
    cout << S.at(i);
  }
  cout << endl;
  return 0;
}