#pragma GCC optimize("O3")
#pragma GCC target("avx2")
#include <algorithm>
#include <iostream>
#include <bitset>
#include <vector>
#include <array>
using namespace std;
#define f(x,y,z) for(int x=y;x<=z;++x)
vector<int> v[200001];
int n, a, b, it;
array<int, 200001> jr, dlm, nmr;
bitset<200001> sdh;
void jrk(int x) {
    for(int &i:v[x]) if(!jr[i]) {
        jr[i] = jr[x]+1, jrk(i);
    }
}
void trn(int x) {
    sdh[x] = true;
    for(int &i:v[x]) if(!sdh[i]) {
        trn(i), dlm[x] = max(dlm[x], dlm[i]+1);
    }
}
void isi(int x) {
    sdh[x] = true, nmr[x] = a;
    vector<pair<int, int>> mn;
    for(int &i:v[x]) if(!sdh[i]) mn.push_back({dlm[i], i});
    sort(mn.begin(), mn.end());
    for(auto &i:mn) ++a, isi(i.second), ++a;
}
int main() {
    ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
    cin >> n;
    f(i,2,n) {
        cin >> a >> b;
        v[a].push_back(b);
        v[b].push_back(a);
    }
    jr[1] = a = 1, jrk(1);
    it = max_element(jr.begin()+1, jr.begin()+n+1)-jr.begin();
    trn(it), sdh.reset(), isi(it);
    f(i,1,n) cout << nmr[i] << ' ';
}
#include <bits/stdc++.h>
using namespace std;

#define REP(i,a,b) for(int i=a;i<=b;i++)

const int Nmax=2e5+9;
int N;
string S[Nmax];
map <string,int> M;

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    cin>>N;
    REP(i,1,N) cin>>S[i];
    REP(i,1,N) {
        if (S[i][0]!='!') M[S[i]]=1;
    }
    REP(i,1,N) {
        if (S[i][0]!='!') continue;
        S[i].erase(S[i].begin());
        if (M[S[i]]==1) {
            cout<<S[i];     return 0;
        }
    }
    cout<<"satisfiable";
    return 0;
}
