Harryxun/stf_run huggingface dataset:
i = 1
while True:
    input = input()
    if input == '0': break
    print("Case {}: {}".format(i, input))
    i += 1

### FIXED CODE ###

import sys, itertools
  
for count, input in zip(itertools.count(1), sys.stdin):
    if int(input) == 0: break
    print('Case {0}: {1}'.format(count, input), end='')
# from math import sqrt
# from heapq import heappush, heappop
# from collections import deque
from operator import mul
from functools import reduce
# a, b = [int(v) for v in input().split()]


def main():

    mod = 1000000007

    def modcmb(n, r, mod):
        if r < 0 or r > n:
            return 0
        r = min(r, n - r)
        over = reduce(lambda v1, v2: (v1 * v2) % mod, range(n, n-r, -1))
        under = reduce(lambda v1, v2: (v1 * v2) % mod, range(1, r+1))
        return over * pow(under, mod - 2, mod) % mod

    n, a, b = map(int, input().split())

    count = pow(2, n, mod) - 1
    count -= modcmb(n, a, mod)
    count -= modcmb(n, b, mod)

    if count < 0:
        count += mod * (-count // mod + 1)
    print(count % mod)


main()


### FIXED CODE ###

# from math import sqrt
# from heapq import heappush, heappop
# from collections import deque
from operator import mul
from functools import reduce
# a, b = [int(v) for v in input().split()]


def main():

    def modcmb(n, r, mod):
        if r < 0 or r > n:
            return 0
        r = min(r, n - r)
        over = 1
        under = 1
        for i in range(r):
            over = over * (n - i) % mod
            under = under * (i + 1) % mod

#        over = reduce(lambda v1, v2: (v1 * v2) % mod, range(n, n-r, -1))
#        under = reduce(lambda v1, v2: (v1 * v2) % mod, range(1, r+1))
        return (over * pow(under, mod - 2, mod)) % mod

    mod = 1000000007
    n, a, b = map(int, input().split())

    count = pow(2, n, mod) - 1
    count -= modcmb(n, a, mod)
    count -= modcmb(n, b, mod)

    while count < 0:
        count += mod
    print(count % mod)


main()
# @author 

import sys

class SDigitSum:
    def solve(self):
        MOD = 10 ** 9 + 7

        k = input()
        d = int(input())

        s = len(k)
        dp = [[0] * d for _ in range(s + 1)]
        dp[0][0] = 1
        for i in range(10):
            dp[1][i % d] += 1

        # pre = [[0] * (d + 1) for _ in range(s + 1)]
        # for i in range(d):
        #     pre[1][i] = pre[1][i - 1] + dp[1][i]
        for l in range(2, s):
            # cur is sum(dp[l - 1][(-lm + r) % d] for lm in range(1, 10)
            # cur = sum(dp[l - 1][(-lm + 0) % d] for lm in range(1, 10))
            for r in range(d):
                dp[l][r] = (dp[l - 1][r] + sum(dp[l - 1][(-lm + r) % d] for lm in range(1, 10))) % MOD
                # dp[l][r] = (dp[l - 1][r] + cur) % MOD
                # cur -= dp[l - 1][(r - 9) % d]
                # cur += dp[l - 1][(r + 1 - 1) % d]


        ans = dp[s - 1][0]
        done = 0
        for i in range(s):
            lm = int(k[i])
            ans = (ans + sum(dp[s - 1 - i][(-done - (lm - v)) % d] for v in range(1, lm + 1 * (i != 0)))) % MOD
            done += lm

        if (sum(int(x) for x in k)) % d == 0:
            ans = (ans + 1) % MOD

        print((ans - 1) % MOD)

solver = SDigitSum()
input = sys.stdin.readline

solver.solve()


### FIXED CODE ###

# @author 

import sys

class SDigitSum:
    def solve(self):
        MOD = 10 ** 9 + 7

        k = input().strip()
        d = int(input())

        s = len(k)
        dp = [[0] * d for _ in range(s + 1)]
        dp[0][0] = 1
        for i in range(10):
            dp[1][i % d] += 1

        pre = [[0] * (d + 1) for _ in range(s + 1)]
        for i in range(d):
            pre[1][i] = pre[1][i - 1] + dp[1][i]
        for l in range(2, s):
            # cur is sum(dp[l - 1][(-lm + r) % d] for lm in range(1, 10)
            cur = sum(dp[l - 1][(-lm + 0) % d] for lm in range(1, 10))
            for r in range(d):
                # dp[l][r] = (dp[l - 1][r] + sum(dp[l - 1][(-lm + r) % d] for lm in range(1, 10))) % MOD
                dp[l][r] = (dp[l - 1][r] + cur) % MOD
                cur -= dp[l - 1][(r - 9) % d]
                cur += dp[l - 1][(r + 1 - 1) % d]


        ans = dp[s - 1][0]
        done = 0
        for i in range(s):
            lm = int(k[i])
            ans = (ans + sum(dp[s - 1 - i][(-done - (lm - v)) % d] for v in range(1, lm + 1 * (i != 0)))) % MOD
            done += lm

        if (sum(int(x) for x in k)) % d == 0:
            ans = (ans + 1) % MOD

        print((ans - 1) % MOD)

solver = SDigitSum()
input = sys.stdin.readline

solver.solve()
N = int(input())
v = [int(_) for _ in input().split()]

import numpy as np

# v = [8, 3, 3, 4, 10]
# N = len(v)

A = np.zeros((N, N))
for i in range(N):
    A[(i - 1) % N][i] = 1 / 2
    A[i][i] = 1 / 2

ans = np.dot(np.linalg.inv(A), v)
ans = [int(x) for x in ans]
print(ans)

### FIXED CODE ###

import sys
import numpy as np
def input():
    return sys.stdin.readline().rstrip()
def main():
    n = int(input())
    a = [int(e) for e in input().split()]

    x = [0 for _ in range(n)]
    x[0] = sum(a) - (sum(a[1:n:2]) * 2)
    for i in range(2, n, 2):
        x[i] = x[i-2] + ((a[i-1] - a[i-2]) * 2)
    x[1] = sum(a) - (sum(a[2:n:2]) * 2)
    for i in range(3, n, 2):
        x[i] = x[i-2] + ((a[i-1] - a[i-2]) * 2)
    print(*x)
main()
# -*- coding: utf-8 -*-

import sys
import os
import math

for s in sys.stdin:
    n = int(s)

    T = [0] * 2001
    for a in range(1001):
        for b in range(1001):
            T[a+b] += 1

    sum_n_num = 0
    for a_b_sum in range(0, n+1):
        c_d_sum = n - a_b_sum
        sum_n_num += T[a_b_sum] * T[c_d_sum]

    print(sum_n_num)

### FIXED CODE ###

# -*- coding: utf-8 -*-

import sys
import os
import math

T = [0] * 2001
for a in range(1001):
    for b in range(1001):
        T[a + b] += 1

for s in sys.stdin:
    n = int(s)

    sum_n_num = 0
    for a_b_sum in range(0, n+1):
        c_d_sum = n - a_b_sum
        if a_b_sum <= 2000 and c_d_sum <= 2000:
            sum_n_num += T[a_b_sum] * T[c_d_sum]

    print(sum_n_num)
N = int(input())
A = list(map(int,input().split()))
i = 0
while i<N:
    print(A.count(i+1))
    i+=1

### FIXED CODE ###

r = int(input())
print(2*r*3.141)
n=int(input())

l=list(map(int,input().split()))
l1=[]
l2=[]

for i in range(n):
	if i%2==0:
		l1.append(l[i])
	else:
		l2.append(l[i])

count1=[]
count2=[]

for i in range(100000):
	count1.append(0)
	count2.append(0)

for i in range(n//2):
	count1[l1[i]-1]+=1
	count2[l2[i]-1]+=1

max1=0
max2=0

maxc1=[]
maxc2=[]

for i in range(100000):
	if count1[i]>=max1:
		max1=count1[i]
		maxc1.append(i)

	if count2[i]>=max2:
		max2=count2[i]
		maxc2.append(i)

# print('maxc1',maxc1)
# print('maxc2',maxc2)
# print('max1',max1)
# print('max2',max2)

# if len(maxc2)+len(maxc1)>2 or (len(maxc2)+len(maxc1)==2 and maxc1[0]!=maxc2[0]):
# 	final=max1+max2

# else :
max3=0
max4=0
for i in range(100000):
	if i!=maxc1[0]:
		if count1[i]>=max3:
			max3=count1[i]
			maxc1.append(i)

	if i!=maxc2[0]:
		if count2[i]>=max4:
			max4=count2[i]
			maxc2.append(i)

final=max(max1+max4,max2+max3)

print(n-final)


### FIXED CODE ###

n=input()
l=[]

for i in n:
	if i=='9':
		l.append('1')
	elif i=='1':
		l.append('9')
	else:
		l.append(i)

print(''.join(l))
def pbox(n,a):
    count = 0
    result = []
    for i in xrange(n):
        total = 0
        b = [a[j] for j in xrange(i,n,i+1)]
        total = sum(b)
        if total % 2 == 1 and a[i] == 1:
            result.append(i+1)
        else:
            pass

    print len(result)
    print ' '.join(map(str,result))

if __name__ == '__main__':
    n = int(raw_input())
    a = map(int,raw_input().split())

    pbox(n,a)
~

### FIXED CODE ###

import copy
def calcmax(a,b,fst,scd,n):
    for i in xrange(n):
        if fst == a[i]:
            count = i

    for i in xrange(n):
        if count == i:
            print scd
        else:
            print fst

if __name__ == '__main__':
    n = int(raw_input())
    a = [int(raw_input()) for i in xrange(n)]
    print("")

    fst = max(a)

    b = copy.deepcopy(a)
    b.remove(fst)

    scd = max(b)

    calcmax(a,b,fst,scd,n)
t=input()
n=len(t)
a=[0]*n
for i in range(n):
    a[i]=t[i]

for i in range(n):
    if a[i]=="?":
        if a[i-1]="D" and a[i+1]=="?":
            a[i]=="p"
        elif a[i-1]=="P" and a[i+1]=="?":
            s[i]=="D"
        elif a[i-1]="P":
            a[i]=="D"
        else:
            a[i]=="D"
    #print(a)

s=''.join(a)
print(s)


### FIXED CODE ###

t=input()
n=len(t)
a=[0]*n
for i in range(n):
    a[i]=t[i]

for i in range(n):
    if a[i]=="?":
        if i!=n-1:
            if a[i-1]=="D" and a[i+1]=="?":
                a[i]="P"
            elif a[i-1]=="P" and a[i+1]=="?":
                a[i]="D"
            elif a[i-1]=="D" and a[i+1]=="D":
                a[i]="P"
            else:
                a[i]="D"
        else:
            a[i]="D"
    #print(a)

s=''.join(a)
print(s)
n = int(input())
t = int(input())
ans = 1234567
for i in range(n):
    c = int(input())
    if int(input) <= t:
        ans = max(ans,c)

if ans == 1234567:
    print("LTE")
else:
    print(ans)
        

### FIXED CODE ###

n,t = map(int,input().split())

ans = 1234567
for i in range(n):
    c,tt = map(int,input().split())
    if tt <= t:
        ans = min(ans,c)

if ans == 1234567:
    print("TLE")
else:
    print(ans)
ans = 0
for i in range(int(input())):
  for j in range(int(input())):
    for l in range(int(input())):
      try:
        money = int(input())
      except:
        pass
      if (500 * i + 100 * j + 50 * l) == money:
        ans += 1
print(ans)

### FIXED CODE ###

ans = 0
fhun = int(input())
hun = int(input())
fif = int(input())
money = int(input())
for i in range(fhun + 1):
  for j in range(hun + 1):
    for l in range(fif + 1):
      if (500 * i + 100 * j + 50 * l) == money:
        ans += 1
print(ans)
def f(k):
  global N,h,update
  if k==N:
    return -1
  if h[k]==0:
    return k
  else:
    h[k]-=1
    update=True
    f(k+1)


update=False
N=int(input())
h=list(map(int,input().split(" ")))
r=0
s=0
while True:
  if h[s]!=0:
    break
  s+=1

while True:
  f(s)
  if update:
    r+=1
    while s!=N-1 and h[s]==0:
      s+=1
    update=False
  else:
    break

print(r)

### FIXED CODE ###

import sys

def f(k):
  global N,h,update
  if k==N:
    return -1
  if h[k]==0:
    return k
  else:
    h[k]-=1
    update=True
    f(k+1)


update=False
N=int(input())
h=list(map(int,input().split(" ")))
r=0
s=0

try:
  while True:
    if h[s]!=0:
      break
    s+=1
except Exception:
  print(0)
  sys.exit(0)

while True:
  f(s)
  if update:
    r+=1
    while s!=N-1 and h[s]==0:
      s+=1
    update=False
  else:
    break

print(r)
#c
n=int(input())
import math
nn=int(math.sqrt(n))+1
a=[0]*(8*n)
for x in range(1,nn+1):
    for y in range(1,nn+1):
        for z in range(1,nn+1):
            a[(x+y+z)**2-x*y-x*z-y*z]+=1
for i in range(1,n+1):
    print(a[i])

### FIXED CODE ###

n=int(input())
import math
nn=int(math.sqrt(n))+1
a=[0]*(100*n)
for x in range(1,nn+1):
    for y in range(1,nn+1):
        for z in range(1,nn+1):
            a[(x+y+z)**2-x*y-x*z-y*z]+=1
for i in range(1,n+1):
    print(a[i])
fruits=input()
prices=input()
list=prices.split()
i=len(list)-1
j=i-1
k=i-2
min=int(list[0])+int(list[1])+int(list[2])
while i>=2:
    while j>=1:
        while k>=0:
            sum=int(list[i])+int(list[j])+int(list[k])
            if sum<min:
                min=sum
            k=k-1
        j=j-1
        k=j-1
    i=i-1
    j=i-1
    k=i-2
print(min)


### FIXED CODE ###

n, k = map(int,input().split())
li = list(map(int, input().split()))[:n]
count = 0
li.sort()
for i in range(k):
    count+=li[i]

print(count)
import sys
input = lambda:sys.stdin.readline().rstrip()
sys.setrecursionlimit(10**7)

def solve(k, cnt, Ans):
    S = str(bin(k)).count("1") 
    L = k % S
    if L < len(Ans)-1:
        return Ans[L]
    elif L == 0:
        return 1
    cnt += solve(L,cnt)
    return cnt 

N = int(input())
P = input()
I = P.count("1")
Df = int(P,2)
Ans = [1]

for i in range(1, I+1):
    cnt = 1
    Ans.append(solve(i, cnt, Ans)+1)
#print(Ans)

for i in range(N-1):
    if P[i] == "1":
        tmp = Df - 2**(N-i-1)
        cur = I-1
    else:
        tmp = Df + 2**(N-i-1)
        cur = I + 1 
    print(Ans[tmp%cur])
    #print(solve(tmp,cnt))

if P[N-1] == "1":
    tmp = Df - 1
else:
    tmp = Df + 1
cur = str(bin(tmp)).count("1")
print(Ans[tmp%cur])
#print(solve(N,cnt))

### FIXED CODE ###

N = int(input())
x = input()

cnt_x = x.count("1")
px10 = 0
nx10 = 0
ans = [0] * (N+1)

for i in range(1, N+1): #Nまで先に出しておく
    popcnt = format(i,"b").count("1")
    fx = i % popcnt
    ans[i] = ans[fx] + 1

for i in range(N):
    px10 += (int(x[i]) * pow(2,N-1-i, cnt_x+1)) % (cnt_x+1)#0⇒1となった場合の合計
    if cnt_x != 0 and cnt_x != 1:
        nx10 += int(x[i])*pow(2,N-1-i,cnt_x-1) % (cnt_x-1)#1⇒0となった場合の合計
#print(px10)
#print(nx10)
for i in range(N):
    if x[i] == "0":
        xi10 = (px10+pow(2,N-1-i,cnt_x+1))%(cnt_x+1)
        print(ans[xi10]+1)
    else:
        if cnt_x != 1:
            xi10 = (nx10-pow(2,N-1-i,cnt_x-1))%(cnt_x-1)
            print(ans[xi10]+1)
        else:
            print(0)
N = int(input())

A = list(map(int, input().split()))

buff = [0 for i in range(10)]

for i in range(N):
    buff[A[i]] += 1


ans = 0
# print(buff)
for i in range(N-2):
    ans = max(ans,buff[i]+buff[i+1]+buff[i+2])

print(ans)

### FIXED CODE ###

N = int(input())

A = list(map(int, input().split()))

buff = [0 for i in range(10**5)]

for i in range(N):
    buff[A[i]] += 1


ans = 0
# print(buff)
for i in range(N-2):
    ans = max(ans,buff[i]+buff[i+1]+buff[i+2])

ans = max(ans, buff[N-2])
ans = max(ans, buff[N-1])
print(ans)
S1=int(input())
S2=int(input())
if S1 == S2[2]+S2[1]+S2[0]:
  print('YES')
else:
  print('NO')

### FIXED CODE ###

S1=str(input())
S2=str(input())
if S1 == S2[2]+S2[1]+S2[0]:
  print('YES')
else:
  print('NO')
n = int(input())
a = list(map(int, input().split()))

inf = int(1e9)

dp = [inf]*(n+3)
dp[0] = 0

for i in range(n):
  dp[i+1] = min(dp[i+1], dp[i] + abs(a[i+1] - a[i]))
  dp[i+2] = min(dp[i+2], dp[i] + abs(a[i+2] - a[i]))

print(dp[n-1])

### FIXED CODE ###

N = int(input())
H = list(map(int, input().split()))

DP = [0] * N
DP[0] = 0
DP[1] = abs(H[1] - H[0])
##
for i in range(2, N):
    DP[i] = min( DP[i-1] + abs(H[i]-H[i-1]), DP[i-2] + abs(H[i]-H[i-2]) )
##
print(DP[N-1])
n=int(input())
l=list(input())
m=int(input())
for i in range(len(l)):
	if l[i]!=l[m-1]:
    	l[i]="*"
print("".join(l))
	

### FIXED CODE ###

n=int(input())
l=list(input())
m=int(input())
for i in range(len(l)):
  if l[i]!=l[m-1]:
    l[i]="*"
print("".join(l))
A_1 = list(map(int, input().split()))
A_2 = list(map(int, input().split()))
A_3 = list(map(int, input().split()))
N = int(input())
b = [list(map(int, input().split()))for _ in range(N)]
for i in range(3):
    for j in range(N):
        if A_1[i] == b[j][0]:
            A_1[i] = "*"
        elif A_2[i] == b[j][0]:
            A_2[i] = "*"
        elif A_3[i] == b[j][0]:
            A_3[i] = "*"
        else:
            pass
if A_1[0] == A_1[1] == A_1[2] or A_2[0] == A_2[1] == A_2[2] or A_3[0] == A_3[1] == A_3[2] or A_1[0] == A_2[0] == A_3[0] or A_1[1] == A_2[1] == A_3[1] or A_1[2] == A_2[2] == A_3[3] or A_1[0] == A_2[1] == A_3[2] or A_1[2] == A_2[1] == A_3[0]:
    print("Yes")
else:
    print("No")


### FIXED CODE ###

A_1 = list(map(int, input().split()))
A_2 = list(map(int, input().split()))
A_3 = list(map(int, input().split()))
N = int(input())
b = [(int(input())) for _ in range(N)]
for i in range(3):
    for j in range(N):
        if A_1[i] == b[j]:
            A_1[i] = 1
        elif A_2[i] == b[j]:
            A_2[i] = 1
        elif A_3[i] == b[j]:
            A_3[i] = 1


if A_1[0] == A_1[1] == A_1[2]:
    print("Yes")
elif A_2[0] == A_2[1] == A_2[2]:
    print("Yes")
elif A_3[0] == A_3[1] == A_3[2]:
    print("Yes")
elif A_1[0] == A_2[0] == A_3[0]:
    print("Yes")
elif A_1[1] == A_2[1] == A_3[1]:
    print("Yes")
elif A_1[2] == A_2[2] == A_3[2]:
    print("Yes")
elif A_1[0] == A_2[1] == A_3[2]:
    print("Yes")
elif A_1[2] == A_2[1] == A_3[0]:
    print("Yes")
else:
    print("No")
a,b=map(int,input().split())
price=10*b
c=[]  
while(price<=10*b+10):
  if int(price*0.08)==a:
    c.append(a)
    price=price+1
  else:
    price=price+1
if c=[]:
  print(-1)
else:
  print(min(c))

### FIXED CODE ###

a,b=map(int,input().split())
price=10*b
c=[]  
while(price<10*b+10):
  if int(price*0.08)==a:
    c.append(price)
    price=price+1
  else:
    price=price+1
if c==[]:
  print(-1)
else:
  print(min(c))
s = input()
if S[2]==S[3] and S[4]==S[5]:
    print("Yes")
else:
    print("No")


### FIXED CODE ###

S = input()
if S[2]==S[3] and S[4]==S[5]:
    print("Yes")
else:
    print("No")
S = input()
W = input()
S *= 2

T = [-1] * len(W)

ii = 2
jj = 0

T[0] = -1
T[1] = 0

while ii < len(W):
    if W[ii - 1] == W[jj]:
        T[ii] = jj + 1
        ii += 1
        jj += 1
    elif jj > 0:
        jj = T[jj]
    else:
        T[ii] = 0
        ii += 1

def KMP(i0):
    ret = -1
    
    m = 0
    i = 0

    while m + i < len(S) - i0:
        if W[i] == S[m + i + i0]:
            i += 1
            if i == len(W):
                return m
        else:
            m = m + i - T[i]
            if i > 0:
                i = T[i]
    return len(S) - i0

i = 0
c = 0
cmax = 0
while i < len(S):
    k = KMP(i)
    if k == len(S):
        break
    elif k == 0:
        c += 1
    else:
        c = 1
    cmax = max(cmax, c)
    i += k + len(W)
if cmax * len(W) * 2 > len(S):
    print(-1)
else:
    print(cmax)

### FIXED CODE ###

S = input()
W = input()
M = len(S)
S *= 3 * (len(W)//len(S)+1)


N = len(W)
def primeFactor(N):
    i, n, ret, d, sq = 2, N, {}, 2, 99
    while i <= sq:
        k = 0
        while n % i == 0: n, k, ret[i] = n//i, k+1, k+1
        if k > 0 or i == 97: sq = int(n**(1/2)+0.5)
        if i < 4: i = i * 2 - 1
        else: i, d = i+d, d^6
    if n > 1: ret[n] = 1
    return ret

def divisors(N):
    pf = primeFactor(N)
    ret = [1]
    for p in pf:
        ret_prev = ret
        ret = []
        for i in range(pf[p]+1):
            for r in ret_prev:
                ret.append(r * (p ** i))
    return sorted(ret)

D = divisors(N)
p = 1
for d in D:
    if W[:-d] == W[d:]:
        W = W[:d]
        p = N//d
        N = d
        break

W = W[:d]

T = [-1] * (len(W)+1)

ii = 2
jj = 0

T[0] = -1
T[1] = 0

while ii < len(W) + 1:
    if W[ii - 1] == W[jj]:
        T[ii] = jj + 1
        ii += 1
        jj += 1
    elif jj > 0:
        jj = T[jj]
    else:
        T[ii] = 0
        ii += 1
m = 0
def KMP(i0):
    global m, i
    ret = -1

    while m + i < len(S):
        if W[i] == S[m + i]:
            i += 1
            if i == len(W):
                t = m
                m = m + i - T[i]
                if i > 0:
                    i = T[i]
                return t
        else:
            m = m + i - T[i]
            if i > 0:
                i = T[i]
    return len(S)

i = 0
j = -10**9
c = 0
cmax = 0
f = 0
while m < len(S)-N:
    k = KMP(0)
    if k == len(S):
        break
    elif k == N + j:
        c += 1
    else:
        c = 1
        f += 1
    cmax = max(cmax, c)
    j = k
if f == 1:
    print(-1)
else:
    print(cmax//p)
import numpy as np
import scipy.sparse
from itertools import combinations
N,M,K = (int(x) for x in input().split())
AB = [list(map(int, input().split())) for _ in range(M)]
CD = [list(map(int, input().split())) for _ in range(K)]
lil = scipy.sparse.lil_matrix((N, N), dtype = int)
for i in range(M):
    lil[AB[i][0]-1, AB[i][1]-1] = 1
    lil[AB[i][1]-1, AB[i][0]-1] = 1
lil2 = scipy.sparse.csgraph.dijkstra(lil, directed = False).astype(int)
block = np.zeros((N, N))
for i in range(K):
    block[CD[i][0]-1, CD[i][1]-1] = -100000
    block[CD[i][1]-1, CD[i][0]-1] = -100000
sug = lil2 + block
ans = [np.count_nonzero(sug[i] > 1) for i in range(N)]
print(*ans)

### FIXED CODE ###

from collections import deque
N,M,K = (int(x) for x in input().split())
AB = [list(map(int, input().split())) for _ in range(M)]
CD = [list(map(int, input().split())) for _ in range(K)]
friends = [set() for _ in range(N)]
blocks = [set() for _ in range(N)]
searched = [0] * N
ans = [0] * N
d = deque()
for x, y in AB:
    friends[x-1].add(y-1)
    friends[y-1].add(x-1)
for x, y in CD:
    blocks[x-1].add(y-1)
    blocks[y-1].add(x-1)
for i in range(N):
    if searched[i]:
        continue
    trace = set()
    d.append(i)
    trace.add(i)
    searched[i] = 1
    while d:
        temp = d.popleft()
        for x in friends[temp]:
            if searched[x] == 0:
                d.append(x)
                trace.add(x)
                searched[x] = 1
    chain = len(trace)
    for j in trace:
        ans[j] = chain - 1 - len(trace&friends[j]) - len(trace&blocks[j])
print(*ans)
import sys
sys.setrecursionlimit(11000)

mod = int(1e9+7)

def dfs(i,dp,bad):
    if i == 0:
      return 1
    if i in dp:
      return dp[i]
    dp[i] = 0
    for d in (1,2):
      x = i-d;
      if 0 <= x and x not in bad:
        dp[i] += dfs(x,dp,bad)
        dp[i] %= mod
    return dp[i]

n,m = [int(a) for a in input().split()]
bad = set()
for _ in range(m):
  a = int(input())
  bad.add(a)
print(dfs(n,dict(),bad))


### FIXED CODE ###

import sys
sys.setrecursionlimit(200000)

mod = int(1e9+7)

def dfs(i,dp,bad):
    if i == 0:
      return 1
    if i in dp:
      return dp[i]
    dp[i] = 0
    for d in (1,2):
      x = i-d;
      if 0 <= x and x not in bad:
        dp[i] += dfs(x,dp,bad)
        dp[i] %= mod
    return dp[i]

n,m = [int(a) for a in input().split()]
bad = set()
for _ in range(m):
  a = int(input())
  bad.add(a)
print(dfs(n,dict(),bad))
# encoding: utf-8

import sys
from collections import deque


class Solution:
    @staticmethod
    def doubly_linked_list():
        # write your code here
        array_length = int(input())
        _input = sys.stdin.readlines()
        task_list = list(map(lambda x: dict(action=x.split()[0], value=int(x.split()[-1])), _input))
        task_deque = deque()
        for task in task_list:
            if task.get('action')=='insert':
                task_deque.appendleft(task.get('value'))
            else:
                task_deque.remove(task.get('value'))

        print(" ".join(map(str, task_deque)))
        assert len(task_deque) <= array_length

if __name__ == '__main__':
    solution = Solution()
    solution.doubly_linked_list()

### FIXED CODE ###

# encoding: utf-8

import sys
from collections import deque


class Solution:
    @staticmethod
    def doubly_linked_list():
        # write your code here
        array_length = int(input())
        task_deque = deque()
        _input = sys.stdin.readlines()

        for i in range(array_length):
            l_arg = _input[i].split()
            action = l_arg[0]
            if len(l_arg) > 1:
                value = l_arg[-1]
            # print(action, 'v', value)

            if action == 'insert':
                task_deque.appendleft(value)
            elif action == 'deleteFirst':
                task_deque.popleft()
            elif action == 'deleteLast':
                task_deque.pop()
            else:
                try:
                    task_deque.remove(value)
                except Exception as e:
                    pass
        print(" ".join(task_deque))


if __name__ == '__main__':
    solution = Solution()
    solution.doubly_linked_list()