#define _CRT_SECURE_NO_WARNINGS
#pragma comment(linker, "/STACK:500000000") 
#include <functional>
#include <algorithm>
#include <iostream> 
#include <string.h> 
#include <stdlib.h>
#include <complex>
#include <sstream> 
#include <numeric>
#include <ctype.h> 
#include <stdio.h> 
#include <bitset>
#include <vector> 
#include <string> 
#include <math.h> 
#include <time.h> 
#include <queue> 
#include <stack> 
#include <list>
#include <map> 
#include <set> 
#define Int long long 
#define INF 0x3F3F3F3F 
#define eps 1e-9
using namespace std;


#pragma comment(linker, "/STACK:500000000") 
#include <functional>
#include <algorithm> 
#include <iostream> 
#include <string.h> 
#include <stdlib.h>
#include <limits.h>
#include <numeric>
#include <sstream> 
#include <fstream>
#include <ctype.h> 
#include <stdio.h> 
#include <bitset>
#include <vector> 
#include <string> 
#include <math.h> 
#include <time.h> 
#include <queue> 
#include <stack> 
#include <list>
#include <map> 
#include <set> 
#define Int long long 
#define eps 1e-9
using namespace std;
typedef pair<int, int> pii;

#define MAXN 11111

int N;
string mark[MAXN];
int used[MAXN], nex[MAXN];
map<string, int> M;
vector<int> ans;

void read(int cur)
{
	while (!used[cur])
	{
		ans.push_back(cur);
		used[cur] = 1;
		if (nex[cur] == -1)
			break;
		cur = nex[cur];
	}
}

int main()
{
	while (cin >> N && N)
	{
		for (int i = 0; i < N; i++)
			cin >> mark[i];
		fill(used, used + 10010, 0);
		fill(nex, nex + 10010, -1);
		M.clear();
		ans.clear();

		for (int i = 0; i < N; i++)
		{
			if (mark[i] == "-")
				read(i);
			else if (mark[i] == "v")
				nex[i + 1] = i;
			else
			{
				string type;
				int number = 0;
				int x = 0;
				while (islower(mark[i][x]))
				{
					type += mark[i][x];
					x++;
				}
				while (x<mark[i].size() && isdigit(mark[i][x]))
				{
					number = number * 10 + mark[i][x] - '0';
					x++;
				}
				if (M.find(type) != M.end())
					nex[i] = M[type];
				
				if (number > 1)
					M[type] = i;
				else 
					M.erase(type);

				if (x < mark[i].size())
					nex[i + 1] = i;
				else if (number == 1)
					read(i);
			}
		}
		for (int i = 0; i < N; i++)
			cout << ans[i] + 1 << endl;
	}
}