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

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

c = A("c")
l = B("l")
m = A("m")
e = B("e")
d = B("d")
k = A("k")
i = B("i")
h = A("h")

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

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

c = A("c")
l = B("l")
m = A("m")
e = B("e")
d = B("d")
k = A("k")
i = B("i")
h = A("h")

c.v = m
l.x = i
l.w = i
m.v = k
e.x = d
e.w = l
d.x = i
d.w = i
k.v = h
i.x = d
i.w = d
h.v = m
assert c.v.v.v.v.v.txt == "k"