t =int(input())
a =[]for _ inrange(t):
s =input().split()if s[0]=='insert':
x, y =int(s[1]),int(s[2])if x in a:
a.insert(a.index(x), y)else:
a.append(y)elif s[0]=='delete':
x =int(s[1])if x in a:
a.remove(x)print(' '.join(map(str, a))if a else'NULL')
from collections import deque
q = deque()
t = int(input())
for _ in range(t):
s = input().split()
if s[0] == 'push':
q.appendleft(int(s[1]))
elif s[0] == 'pop':
if q:
print(q.pop())
else:
print('error')
elif s[0] == 'front':
if q:
print(q[-1])
else:
print('error')
n,m =map(int,input().split())
p =[ _ for _ inrange(n +1)]
sz =[1]*(n +1)deffind(x):if x == p[x]:return x
p[x]= find(p[x])return p[x]defunion(x, y):
x = find(x)
y = find(y)if x == y:returnif sz[x]< sz[y]:
x, y = y, x
p[y]= x
sz[x]+= sz[y]for _ inrange(m):
a,b =map(int,input().split())
union(a,b)for i inrange(1, n +1):
find(i)print(len(set(p))-1,max(sz))