#include <bits/stdc++.h>
 
using namespace std;
#define ll long long
#define M 1000000007
#define pb push_back
#define bg begin
#define pob pop_back
#define sz size
#define SUM accumulate
#define SPACE " "
#define vr std::vector
#define que queue
#define dqu deque
#define stk stack
#define pqu priority_queue
#define mst multiset
#define pf push_front
#define pof pop_front




void solve(){
  string str,s;
  cin >> str;
  reverse(str.bg(),str.end());
  for (int i = 0; i < str.sz(); ++i)
  {
    if (str[i] == '0')
    {
      s.pb('0');
      /* code */
    }
    else if (str[i] == '1')
    {
      s.pb('1');
      /* code */
    }
    else if (str[i] == '6')
    {
      s.pb('9');
      /* code */
    }
    else if (str[i] == '9')
    {
      s.pb('6');
      /* code */
    }
    else
    {
      s.pb('8');
    }

    /* code */
  }
  cout << s <<endl;


  

} 
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  // freopen("input.txt", "r", stdin);
  // freopen("output.txt", "w", stdout);
  int tt= 1;
  // cin >> tt;
  while (tt--) {
    solve();
    
    
  }
  return 0;
}
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define pi 3.141592653589793238
#define int long long
#define ll long long
#define ld long double
using namespace __gnu_pbds;
using namespace std;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;


long long powm(long long a, long long b,long long mod) {
    long long res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a %mod;
        a = a * a %mod;
        b >>= 1;
    }
    return res;
}


int gcd(int a, int b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);     
}





signed main()
{

ios_base::sync_with_stdio(false); 
cin.tie(NULL);  
cout.tie(0);   

#ifndef ONLINE_JUDGE
    if(fopen("INPUT.txt","r"))
    {
        freopen("INPUT.txt","r",stdin);
        freopen("OUTPUT.txt","w",stdout);
    }
#endif          

    int n;
    cin>>n;
    map<string,int>mm1;
    map<string,int>mm2;
    string str;
    for(int i=0;i<n;i++)
    {
        cin>>str;
        if(str[0]=='!')
        {
            int len=str.length();
            if(len>1)
                mm1[str.substr(1,len-1)]++;
        }
        else
        {
            mm2[str]++;
        }
    }

    for(auto i:mm1)
    {
        if(mm2[i.first]>0)
        {
            cout<<i.first;
            return 0;
        }
    }
    cout<<"satisfiable";

}    
