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

class B:
    def __init__(self, txt: str):
        self.w: A = None
        self.v: B = None
        self.txt = txt

b = A("b")
m = B("m")
n = A("n")
l = A("l")
a = A("a")
k = A("k")
e = A("e")
c = B("c")
i = B("i")
h = A("h")

b.x = h
m.w = n
m.v = i
n.x = a
l.x = h
a.x = n
k.x = n
e.x = n
c.w = h
c.v = i
i.w = l
i.v = m
h.x = n
assert b.x.x.x.x.x.txt == "
class A:
    def __init__(self, txt: str):
        self.x: A = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.w: A = None
        self.v: B = None
        self.txt = txt

b = A("b")
m = B("m")
n = A("n")
l = A("l")
a = A("a")
k = A("k")
e = A("e")
c = B("c")
i = B("i")
h = A("h")

b.x = h
m.w = n
m.v = i
n.x = a
l.x = h
a.x = n
k.x = n
e.x = n
c.w = h
c.v = i
i.w = l
i.v = m
h.x = n
assert b.x.x.x.x.x.txt == "a"