o=[];[o.insert(0, a[1])if bool(int(a[0])) else o.append(a[1])for a in[list(input().split())for _ in range(int(input()))]];print(''.join(o))