using System.Text;
string s1;
while ((s1 = System.Console.ReadLine()) != null)
{
var arr = s1.Split(" ");
int n = arr.Length;
List<int> team1 = new List<int>();
List<int> team2 = new List<int>();
List<int> current = team2;
for (int i = 0; i < n; i++)
{
var tmp = arr[i].Split('/');
if (tmp[1] == "N")
{
if (current == team1) current = team2;
else if (current == team2) current = team1;
}
current.Add(int.Parse(tmp[0]));
}