use std::io::{self,BufRead};fn p<'a>(t:&mut std::str::SplitWhitespace<'a>)->&'a str{let mut w=t.next().unwrap();if"if"==w{let c=p(t);t.next();let x=p(t);t.next();w=p(t);if"true"==c{w=x}}&w}fn main(){let i=io::stdin();for x in i.lock().lines(){println!("{}",p(&mut x.unwrap().split_whitespace()));}}