class A:
    def __init__(self, txt: str):
        self.s: A = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.x: B = None
        self.txt = txt

class C:
    def __init__(self, txt: str):
        self.v: C = None
        self.txt = txt

b = A("b")
n = B("n")
m = C("m")
j = B("j")
d = C("d")
i = C("i")
f = C("f")
l = A("l")
k = A("k")
e = A("e")

b.s = k
n.x = j
m.v = d
j.x = n
d.v = m
i.v = m
f.v = d
l.s = e
k.s = e
e.s = b
assert k.s.s.s.s.s.s.s.txt == "
class A:
    def __init__(self, txt: str):
        self.s: A = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.x: B = None
        self.txt = txt

class C:
    def __init__(self, txt: str):
        self.v: C = None
        self.txt = txt

b = A("b")
n = B("n")
m = C("m")
j = B("j")
d = C("d")
i = C("i")
f = C("f")
l = A("l")
k = A("k")
e = A("e")

b.s = k
n.x = j
m.v = d
j.x = n
d.v = m
i.v = m
f.v = d
l.s = e
k.s = e
e.s = b
assert k.s.s.s.s.s.s.s.txt == "e"