Collections.deque()

  • + 0 comments
    from collections import deque
     
    if __name__ == "__main__":
        n = int(input())
        d = deque()
        for i in range(n):
            temp =  input().split()
            if len(temp)>1:
                getattr(d,temp[0])(temp[1])
            else:
                getattr(d,temp[0])()
        print(' '.join(d))