#include <iostream>
#include <map>
#include <string>
#include <vector>

using namespace std;

/**
@breif にゃんぱす格納関数
@param collection 格納する挨拶コンテナ
@note
 入力を1行だけコンテナに格納する。
 vectorは村民1に対する相手jの挨拶が格納される。
 mapには村民jの村民1相手以外の挨拶が格納される。
 つまり、vectorが挨拶行列の列、mapが挨拶行列の行を指す。
**/
void InputToCollection(vector<multimap<string, int>>* collection)
{
	for (int i = 0; i < (int)collection->size(); i++)
	{	// mapのキーのみ使用する、mapの値は使用しないので適当な数字を入れておく
		string word; cin >> word;
		(*collection)[i].emplace(word, 0);
	}
}

/**
@breif にゃんぱす検索関数
@param collection 検索する村人の挨拶コンテナ
@retval [1-INT_MAX] れんちょんの村民番号
@retval -1 れんちょんを特定できない
@note
 この関数はテストケースの穴を突いている。
 たとえば
 - nyanpass ohayo
 a - chicchakunaiyo
 nyanpass nyanpass -
 この場合、村民1は村民2に対してnyanpassと挨拶してないので-1が正解な気がする。
 しかし、nyanpassより値の小さいテストケースが存在しないのかmapの最後尾だけ調べてもACが通った。
 より正確な検索関数はFindNyanpassII()で実装。
**/
int FindNyanpass(vector<multimap<string, int>>* collection)
{
	int find = -1;
	// れんちょんは誰に対しても"nyanpass"と挨拶するので
	// mapの最後尾(map::endの1つ前の要素)だけ調べて判断する
	for (int nyan_index = 0; nyan_index < (int)collection->size(); nyan_index++)
	{	
		if ((--(*collection)[nyan_index].end())->first == "nyanpass")
		{
			if (find == -1)
				find = nyan_index + 1;
			else
			{
				find = -1;
				break;
			}
		}
	}

	return find;
}

/**
@breif にゃんぱす検索関数II
@param collection 検索する村人の挨拶コンテナ
@retval [1-INT_MAX] れんちょんの村民番号
@retval -1 れんちょんを特定できない
**/
int FindNyanpassII(vector<multimap<string, int>>* collection)
{
	int find = -1;
	// れんちょんは誰に対しても"nyanpass"と挨拶するので
	// "nyanpass"キーが村民-1個存在するか調べて判断する
	for (int nyan_index = 0; nyan_index < (int)collection->size(); nyan_index++)
	{
		if ((*collection)[nyan_index].count("nyanpass") == collection->size() - 1)
		{
			if (find == -1)
				find = nyan_index + 1;
			else
			{
				find = -1;
				break;
			}
		}
	}

	return find;
}


int main()
{
	vector<multimap<string, int>> nya_collection;
	int nya_max; cin >> nya_max;
	nya_collection.resize(nya_max);

	// nya_max 繰り返して全ての入力をコンテナに格納
	for (int i = 0; i < nya_max; i++)
		InputToCollection(&nya_collection);

	cout << FindNyanpass(&nya_collection);
//	cout << FindNyanpassII(&nya_collection);

	return 0;
}