#include <bits/stdc++.h>
#define int long long
#define INF 9223372036854775806
#define cignore cin.ignore(numeric_limits<streamsize>::max(), '\n');
using namespace std;

signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);

    int n;
    cin >> n;
    string s[n];
    for(int i = 0; i < n; ++i)
        cin >> s[i];
    unordered_set<string> ust (s, s+n);
    for(string ss: s)
    {
        if(ust.count('!'+ss))
        {
            cout << ss << '\n';
            return 0;
        }
    }
    cout << "satisfiable\n";
    return 0;
}

#include<bits/stdc++.h>
#define y1 y3647
#define earse erase
#define INF 1000000000
#define LL long long
using namespace std;
inline void read(int &x)
{
	x=0;int f=1;
	char ch=getchar();
	while(ch!=45&&(ch>'9'||ch<'0'))ch=getchar();
	if(ch==45){f=-1,ch=getchar();}
	while(ch<='9'&&ch>='0'){x=x*10+ch-48;ch=getchar();}
	x*=f;
}
/*



*/
const int N=2e5+10; 
int i,j,k,n,s,t,m;
char ch[N];
signed main()
{
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	//freopen(".ans","w",sdtout);
	read(n);
	scanf("%s",ch+1);
	if(ch[1]!=ch[n])
	{
		printf("1\n");
		return 0;
	}
	for(i=2;i<n;i++)
	if(ch[i]!=ch[1]&&ch[i+1]!=ch[n])
	{
		printf("2\n");
		return 0;
	}
	printf("-1\n");
	return 0;
}
